fix resize
Browse files
app.py
CHANGED
@@ -58,10 +58,6 @@ def inference(img, version, scale, weight):
|
|
58 |
else:
|
59 |
img_mode = None
|
60 |
|
61 |
-
h, w = img.shape[0:2]
|
62 |
-
if h < 300:
|
63 |
-
img = cv2.resize(img, (w * 2, h * 2), interpolation=cv2.INTER_LANCZOS4)
|
64 |
-
|
65 |
if version == 'v1.2':
|
66 |
face_enhancer = GFPGANer(
|
67 |
model_path='GFPGANv1.2.pth', upscale=2, arch='clean', channel_multiplier=2, bg_upsampler=upsampler)
|
@@ -84,10 +80,9 @@ def inference(img, version, scale, weight):
|
|
84 |
print('Error', error)
|
85 |
|
86 |
try:
|
87 |
-
if scale
|
88 |
-
|
89 |
-
|
90 |
-
output = cv2.resize(output, (int(w * scale), int(h * scale)), interpolation=interpolation)
|
91 |
except Exception as error:
|
92 |
print('wrong scale input.', error)
|
93 |
if img_mode == 'RGBA': # RGBA images should be saved in png format
|
|
|
58 |
else:
|
59 |
img_mode = None
|
60 |
|
|
|
|
|
|
|
|
|
61 |
if version == 'v1.2':
|
62 |
face_enhancer = GFPGANer(
|
63 |
model_path='GFPGANv1.2.pth', upscale=2, arch='clean', channel_multiplier=2, bg_upsampler=upsampler)
|
|
|
80 |
print('Error', error)
|
81 |
|
82 |
try:
|
83 |
+
interpolation = cv2.INTER_AREA if scale < 2 else cv2.INTER_LANCZOS4
|
84 |
+
h, w = img.shape[0:2]
|
85 |
+
output = cv2.resize(output, (int(w * scale), int(h * scale)), interpolation=interpolation)
|
|
|
86 |
except Exception as error:
|
87 |
print('wrong scale input.', error)
|
88 |
if img_mode == 'RGBA': # RGBA images should be saved in png format
|