Spaces:
Running
on
L4
Running
on
L4
avoid upscale for large img.
Browse files
app.py
CHANGED
|
@@ -115,10 +115,14 @@ def inference(image, background_enhance, face_upsample, upscale, codeformer_fide
|
|
| 115 |
print('\timage size:', img.shape)
|
| 116 |
|
| 117 |
upscale = int(upscale) # covert type to int
|
| 118 |
-
if upscale > 4:
|
| 119 |
-
upscale = 4
|
| 120 |
-
if upscale > 2 and max(img.shape[:2])>1000:
|
| 121 |
-
upscale = 2
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
face_helper = FaceRestoreHelper(
|
| 124 |
upscale,
|
|
@@ -132,7 +136,6 @@ def inference(image, background_enhance, face_upsample, upscale, codeformer_fide
|
|
| 132 |
bg_upsampler = upsampler if background_enhance else None
|
| 133 |
face_upsampler = upsampler if face_upsample else None
|
| 134 |
|
| 135 |
-
|
| 136 |
if has_aligned:
|
| 137 |
# the input faces are already cropped and aligned
|
| 138 |
img = cv2.resize(img, (512, 512), interpolation=cv2.INTER_LINEAR)
|
|
|
|
| 115 |
print('\timage size:', img.shape)
|
| 116 |
|
| 117 |
upscale = int(upscale) # covert type to int
|
| 118 |
+
if upscale > 4: # avoid momory exceeded due to too large upscale
|
| 119 |
+
upscale = 4
|
| 120 |
+
if upscale > 2 and max(img.shape[:2])>1000: # avoid momory exceeded due to too large img resolution
|
| 121 |
+
upscale = 2
|
| 122 |
+
if max(img.shape[:2]) > 1500: # avoid momory exceeded due to too large img resolution
|
| 123 |
+
upscale = 1
|
| 124 |
+
background_enhance = False
|
| 125 |
+
face_upsample = False
|
| 126 |
|
| 127 |
face_helper = FaceRestoreHelper(
|
| 128 |
upscale,
|
|
|
|
| 136 |
bg_upsampler = upsampler if background_enhance else None
|
| 137 |
face_upsampler = upsampler if face_upsample else None
|
| 138 |
|
|
|
|
| 139 |
if has_aligned:
|
| 140 |
# the input faces are already cropped and aligned
|
| 141 |
img = cv2.resize(img, (512, 512), interpolation=cv2.INTER_LINEAR)
|