mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-06-07 21:20:49 +00:00
prevent neural network resizing when it is not necessary #1109
This commit is contained in:
parent
98cc6c6e74
commit
980cd1697a
@ -213,17 +213,19 @@ def resize_image(resize_mode, im, width, height):
|
|||||||
if opts.upscaler_for_img2img is None or opts.upscaler_for_img2img == "None" or im.mode == 'L':
|
if opts.upscaler_for_img2img is None or opts.upscaler_for_img2img == "None" or im.mode == 'L':
|
||||||
return im.resize((w, h), resample=LANCZOS)
|
return im.resize((w, h), resample=LANCZOS)
|
||||||
|
|
||||||
upscalers = [x for x in shared.sd_upscalers if x.name == opts.upscaler_for_img2img]
|
|
||||||
assert len(upscalers) > 0, f"could not find upscaler named {opts.upscaler_for_img2img}"
|
|
||||||
|
|
||||||
upscaler = upscalers[0]
|
|
||||||
scale = max(w / im.width, h / im.height)
|
scale = max(w / im.width, h / im.height)
|
||||||
upscaled = upscaler.scaler.upscale(im, scale, upscaler.data_path)
|
|
||||||
|
|
||||||
if upscaled.width != w or upscaled.height != h:
|
if scale > 1.0:
|
||||||
upscaled = im.resize((w, h), resample=LANCZOS)
|
upscalers = [x for x in shared.sd_upscalers if x.name == opts.upscaler_for_img2img]
|
||||||
|
assert len(upscalers) > 0, f"could not find upscaler named {opts.upscaler_for_img2img}"
|
||||||
|
|
||||||
return upscaled
|
upscaler = upscalers[0]
|
||||||
|
im = upscaler.scaler.upscale(im, scale, upscaler.data_path)
|
||||||
|
|
||||||
|
if im.width != w or im.height != h:
|
||||||
|
im = im.resize((w, h), resample=LANCZOS)
|
||||||
|
|
||||||
|
return im
|
||||||
|
|
||||||
if resize_mode == 0:
|
if resize_mode == 0:
|
||||||
res = resize(im, width, height)
|
res = resize(im, width, height)
|
||||||
|
Loading…
Reference in New Issue
Block a user