aboutsummaryrefslogtreecommitdiffstats
path: root/modules/images.py
diff options
context:
space:
mode:
authord8ahazard <d8ahazard@gmail.com>2022-09-30 17:51:57 +0000
committerd8ahazard <d8ahazard@gmail.com>2022-09-30 17:51:57 +0000
commit3665551b120d86a11d7eefa0dc33ecce812a2c94 (patch)
tree7adb84216a59ca46622d1422553ec961c8f7ad3c /modules/images.py
parent8f1d412e7bcd279c3c49b0153def0e3d6d941e5a (diff)
parent2162be514a5af4af56118e744c33de363e7bd97e (diff)
downloadstable-diffusion-webui-gfx803-3665551b120d86a11d7eefa0dc33ecce812a2c94.tar.gz
stable-diffusion-webui-gfx803-3665551b120d86a11d7eefa0dc33ecce812a2c94.tar.bz2
stable-diffusion-webui-gfx803-3665551b120d86a11d7eefa0dc33ecce812a2c94.zip
Merge branch 'master' of https://github.com/d8ahazard/stable-diffusion-webui
Diffstat (limited to 'modules/images.py')
-rw-r--r--modules/images.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/modules/images.py b/modules/images.py
index 169e19e6..f1aed5d6 100644
--- a/modules/images.py
+++ b/modules/images.py
@@ -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':
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)
- upscaled = upscaler.scaler.upscale(im, scale, upscaler.data_path)
- if upscaled.width != w or upscaled.height != h:
- upscaled = im.resize((w, h), resample=LANCZOS)
+ if scale > 1.0:
+ 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]
+ 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 upscaled
+ return im
if resize_mode == 0:
res = resize(im, width, height)