sczhou commited on
Commit
9a8ec17
·
verified ·
1 Parent(s): 83881b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -145,11 +145,16 @@ def inference(image, face_align, background_enhance, face_upsample, upscale, cod
145
  upscale = 4
146
  if upscale > 2 and max(img.shape[:2])>1000: # avoid memory exceeded due to too large img resolution
147
  upscale = 2
148
- if max(img.shape[:2]) > 1500: # avoid memory exceeded due to too large img resolution
149
- upscale = 1
150
- background_enhance = False
151
- face_upsample = False
152
-
 
 
 
 
 
153
  face_helper = FaceRestoreHelper(
154
  upscale,
155
  face_size=512,
@@ -182,9 +187,10 @@ def inference(image, face_align, background_enhance, face_upsample, upscale, cod
182
  if min(img.shape[:2]) > 1000 and num_det_faces > 15:
183
  raise gr.Error(
184
  "Too many faces detected (>15) in a high-resolution image. "
185
- "To keep the demo responsive, this case is skipped. "
186
- "For such inputs, please deploy the demo locally without this limit."
187
  )
 
188
 
189
  # face restoration for each cropped face
190
  for idx, cropped_face in enumerate(face_helper.cropped_faces):
@@ -326,7 +332,7 @@ demo = gr.Interface(
326
  gr.Slider(0, 1, value=0.5, step=0.01, label='Codeformer_Fidelity (0 for better quality, 1 for better identity)')
327
  ], [
328
  gr.Image(type="filepath", label="Output"),
329
- gr.Markdown("Please download the output within 30 seconds.")
330
  ],
331
  title=title,
332
  description=description,
@@ -339,7 +345,7 @@ demo = gr.Interface(
339
  ['05.jpg', True, True, True, 2, 0.1],
340
  ['06.png', False, True, True, 1, 0.5]
341
  ],
342
- concurrency_limit=1
343
  )
344
 
345
  DEBUG = os.getenv('DEBUG') == '1'
 
145
  upscale = 4
146
  if upscale > 2 and max(img.shape[:2])>1000: # avoid memory exceeded due to too large img resolution
147
  upscale = 2
148
+ if min(img.shape[:2]) > 1100 or max(img.shape[:2]) > 1500: # avoid memory exceeded due to too large img resolution
149
+ # upscale = 1
150
+ # background_enhance = False
151
+ # face_upsample = False
152
+ raise gr.Error(
153
+ "Image resolution is too large (short side > 1100 or long side > 1500). "
154
+ "To keep the demo responsive and avoid long queue times, this case is skipped. "
155
+ "For such inputs, please deploy this demo locally and remove this limit."
156
+ )
157
+
158
  face_helper = FaceRestoreHelper(
159
  upscale,
160
  face_size=512,
 
187
  if min(img.shape[:2]) > 1000 and num_det_faces > 15:
188
  raise gr.Error(
189
  "Too many faces detected (>15) in a high-resolution image. "
190
+ "To keep the demo responsive and avoid long queue times, this case is skipped. "
191
+ "For such inputs, please deploy this demo locally and remove this limit."
192
  )
193
+
194
 
195
  # face restoration for each cropped face
196
  for idx, cropped_face in enumerate(face_helper.cropped_faces):
 
332
  gr.Slider(0, 1, value=0.5, step=0.01, label='Codeformer_Fidelity (0 for better quality, 1 for better identity)')
333
  ], [
334
  gr.Image(type="filepath", label="Output"),
335
+ gr.Markdown("**Please download the output within 30 seconds.**")
336
  ],
337
  title=title,
338
  description=description,
 
345
  ['05.jpg', True, True, True, 2, 0.1],
346
  ['06.png', False, True, True, 1, 0.5]
347
  ],
348
+ concurrency_limit=2
349
  )
350
 
351
  DEBUG = os.getenv('DEBUG') == '1'