Skip to content

Commit 30b1bcc

Browse files
committed
fix upscale loop erroneously applied multiple times
1 parent 822210b commit 30b1bcc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

modules/upscaler.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,18 @@ def upscale(self, img: PIL.Image, scale: int, selected_model: str = None):
5757
self.scale = scale
5858
dest_w = img.width * scale
5959
dest_h = img.height * scale
60+
6061
for i in range(3):
61-
if img.width > dest_w and img.height > dest_h:
62-
break
62+
shape = (img.width, img.height)
63+
6364
img = self.do_upscale(img, selected_model)
65+
66+
if shape == (img.width, img.height):
67+
break
68+
69+
if img.width >= dest_w and img.height >= dest_h:
70+
break
71+
6472
if img.width != dest_w or img.height != dest_h:
6573
img = img.resize((int(dest_w), int(dest_h)), resample=LANCZOS)
6674

0 commit comments

Comments
 (0)