From 4cec2db9a3b94700e1277c9e2a3361a9ecacb3e9 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sat, 12 Jul 2025 09:44:42 -0400 Subject: [PATCH] allow resize non-pil Signed-off-by: Vladimir Mandic --- CHANGELOG.md | 7 ++++--- TODO.md | 8 ++++---- modules/images_resize.py | 18 +++++++++++++++++- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10fe8c1ff..dc35b66df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # Change Log for SD.Next -## Update for 2025-07-11 +## Update for 2025-07-12 -### Highlights for 2025-07-11 +### Highlights for 2025-07-12 In this release we finally break with legacy with the removal of the original [A1111](https://github.com/AUTOMATIC1111/stable-diffusion-webui/) codebase which has not been maintained for a while now This plus major cleanup of codebase and external dependencies resulted in ~53k LoC (*lines-of-code*) reduction and spread over [~720 files](https://github.com/vladmandic/sdnext/pull/4017)! @@ -23,7 +23,7 @@ Although upgrades and existing installations are tested and should work fine! [ReadMe](https://github.com/vladmandic/automatic/blob/master/README.md) | [ChangeLog](https://github.com/vladmandic/automatic/blob/master/CHANGELOG.md) | [Docs](https://vladmandic.github.io/sdnext-docs/) | [WiKi](https://github.com/vladmandic/automatic/wiki) | [Discord](https://discord.com/invite/sd-next-federal-batch-inspectors-1101998836328697867) -### Details for 2025-07-11 +### Details for 2025-07-12 - **License** - SD.Next [license](https://github.com/vladmandic/sdnext/blob/dev/LICENSE.txt) switched from **aGPL-v3.0** to **Apache-v2.0** @@ -87,6 +87,7 @@ Although upgrades and existing installations are tested and should work fine! - fix loading of manually downloaded diffuser models - fix api `/sdapi/v1/embeddings` endpoint - fix incorrect reporting of deleted and modified files + - allow upscaling with models that have implicit VAE processing - improve infotext param parsing - improve extensions ui search - improve model type autodetection diff --git a/TODO.md b/TODO.md index b30865bf2..3dbf728e8 100644 --- a/TODO.md +++ b/TODO.md @@ -6,12 +6,10 @@ Main ToDo list can be found at [GitHub projects](https://github.com/users/vladma ## Future Candidates +- Refactor: Sampler options - Feature: Common repo for `T5` and `CLiP` - Feature: LoRA add OMI format support for SD35/FLUX.1 -- Refactor: sampler options -- Video: API support -- Remove: CodeFormer -- Remove: GFPGAN +- Video: Generic API support - Video: LTX TeaCache and others - Video: LTX API - Video: LTX PromptEnhance @@ -35,6 +33,8 @@ Main ToDo list can be found at [GitHub projects](https://github.com/users/vladma - [Dream0 guidance](https://huggingface.co/ByteDance/DreamO) - [SUPIR upscaler](https://github.com/Fanghua-Yu/SUPIR) - Remove: Agent Scheduler +- Remove: CodeFormer +- Remove: GFPGAN - ModernUI: Lite vs Expert mode ### Future Considerations diff --git a/modules/images_resize.py b/modules/images_resize.py index 9e37d69cd..03646484e 100644 --- a/modules/images_resize.py +++ b/modules/images_resize.py @@ -10,6 +10,18 @@ from modules import shared, upscaler def resize_image(resize_mode: int, im: Union[Image.Image, torch.Tensor], width: int, height: int, upscaler_name: str=None, output_type: str='image', context: str=None): upscaler_name = upscaler_name or shared.opts.upscaler_for_img2img + def verify_image(image): + try: + if isinstance(image, torch.Tensor): + image = image.float().detach().cpu().numpy() + if isinstance(image, np.ndarray): + if np.issubdtype(image.dtype, np.floating): + image = (255.0 * image).astype(np.uint8) + image = Image.fromarray(image) + except Exception as e: + shared.log.error(f"Image verification failed: {e}") + return image + def latent(im, scale: float, selected_upscaler: upscaler.UpscalerData): if isinstance(im, torch.Tensor): im = selected_upscaler.scaler.upscale(im, scale, selected_upscaler.name) @@ -119,7 +131,11 @@ def resize_image(resize_mode: int, im: Union[Image.Image, torch.Tensor], width: if isinstance(im, torch.Tensor): # latent resize only supports fixed mode res = resize(im, width, height) return res - elif (resize_mode == 0) or (im.width == width and im.height == height) or (width == 0 and height == 0): # none + im = verify_image(im) + if not isinstance(im, Image.Image): + shared.log.error(f'Image resize: image={type(im)} invalid type') + return im + if (resize_mode == 0) or ((im.width == width) and (im.height == height)) or (width == 0 and height == 0): # none res = im.copy() elif resize_mode == 1: # fixed res = resize(im, width, height)