sczhou commited on
Commit
7924167
·
verified ·
1 Parent(s): dd797d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -159,15 +159,15 @@ def inference(image, face_align, background_enhance, face_upsample, upscale, cod
159
  upscale = 4
160
  if upscale > 2 and max(img.shape[:2])>1000: # avoid memory exceeded due to too large img resolution
161
  upscale = 2
162
- if min(img.shape[:2]) > 1000 or max(img.shape[:2])>1500: # avoid memory exceeded due to too large img resolution
163
  upscale = 1
164
  background_enhance = False
165
- if min(img.shape[:2]) > 1200 or max(img.shape[:2]) > 2000: # avoid memory exceeded due to too large img resolution
166
- # upscale = 1
167
- # background_enhance = False
168
- # face_upsample = False
169
  raise gr.Error(
170
- "Image resolution is too large (short side > 1200 or long side > 2000). "
171
  "To keep the demo responsive and avoid long queue times, this case is skipped. "
172
  "For such inputs, please deploy this demo locally and remove this limit."
173
  )
 
159
  upscale = 4
160
  if upscale > 2 and max(img.shape[:2])>1000: # avoid memory exceeded due to too large img resolution
161
  upscale = 2
162
+ if min(img.shape[:2]) > 1100 or max(img.shape[:2])>1500: # avoid memory exceeded due to too large img resolution
163
  upscale = 1
164
  background_enhance = False
165
+ face_upsample = False
166
+
167
+ h, w = img.shape[:2]
168
+ if h * w > 4_000_000: # avoid memory exceeded due to too large img resolution
169
  raise gr.Error(
170
+ "Image resolution is too large (>4 megapixels). "
171
  "To keep the demo responsive and avoid long queue times, this case is skipped. "
172
  "For such inputs, please deploy this demo locally and remove this limit."
173
  )