allow resize non-pil

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-07-12 09:44:42 -04:00
parent a1e186072a
commit 4cec2db9a3
3 changed files with 25 additions and 8 deletions
+4 -3
View File
@@ -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
+4 -4
View File
@@ -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
+17 -1
View File
@@ -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)