Skip to content

Commit

Permalink
fix upscale loop erroneously applied multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
AUTOMATIC1111 committed Nov 4, 2022
1 parent 822210b commit 30b1bcc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions modules/upscaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,18 @@ def upscale(self, img: PIL.Image, scale: int, selected_model: str = None):
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)

Expand Down

0 comments on commit 30b1bcc

Please sign in to comment.