aboutsummaryrefslogtreecommitdiff
path: root/modules/upscaler.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2022-11-04 22:56:18 +0300
committerAUTOMATIC <16777216c@gmail.com>2022-11-04 22:56:18 +0300
commit30b1bcc64e67ad50c5d3af3a6fe1bd1e9553f34e (patch)
treeb01a4265c735dd4f3ad46df9c0665b316c2f6ce5 /modules/upscaler.py
parent822210bae5ee027938618dcec07be08573c597a6 (diff)
fix upscale loop erroneously applied multiple times
Diffstat (limited to 'modules/upscaler.py')
-rw-r--r--modules/upscaler.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/modules/upscaler.py b/modules/upscaler.py
index 83fde7ca..c4e6e6bd 100644
--- a/modules/upscaler.py
+++ b/modules/upscaler.py
@@ -57,10 +57,18 @@ class Upscaler:
self.scale = scale
dest_w = img.width * scale
dest_h = img.height * scale
+
for i in range(3):
- if img.width > dest_w and img.height > dest_h:
- break
+ shape = (img.width, img.height)
+
img = self.do_upscale(img, selected_model)
+
+ if shape == (img.width, img.height):
+ break
+
+ if img.width >= dest_w and img.height >= dest_h:
+ break
+
if img.width != dest_w or img.height != dest_h:
img = img.resize((int(dest_w), int(dest_h)), resample=LANCZOS)