sczhou commited on
Commit
509a22f
·
verified ·
1 Parent(s): 8d18c11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -21
app.py CHANGED
@@ -339,22 +339,27 @@ td {
339
  <center><img src='https://api.infinitescript.com/badgen/count?name=sczhou/CodeFormer&ltext=Visitors&color=6dc9aa' alt='visitors'></center>
340
  """
341
 
342
- demo = gr.Interface(
343
- inference, [
344
- gr.Image(type="filepath", label="Input"),
345
- gr.Checkbox(value=True, label="Pre_Face_Align"),
346
- gr.Checkbox(value=True, label="Background_Enhance"),
347
- gr.Checkbox(value=True, label="Face_Upsample"),
348
- gr.Number(value=2, label="Rescaling_Factor (up to 4)"),
349
- gr.Slider(0, 1, value=0.5, step=0.01, label='Codeformer_Fidelity (0 for better quality, 1 for better identity)')
350
- ], [
351
- gr.Image(type="filepath", label="Output"),
352
- gr.Markdown("**Please download the output within 30 seconds.**")
353
- ],
354
- title=title,
355
- description=description,
356
- article=article,
357
- examples=[
 
 
 
 
 
358
  ['01.png', True, True, True, 2, 0.7],
359
  ['02.jpg', True, True, True, 2, 0.7],
360
  ['03.jpg', True, True, True, 2, 0.7],
@@ -362,9 +367,11 @@ demo = gr.Interface(
362
  ['05.jpg', True, True, True, 2, 0.1],
363
  ['06.png', False, True, True, 1, 0.5]
364
  ],
365
- concurrency_limit=2
366
- )
367
-
 
 
368
  DEBUG = os.getenv('DEBUG') == '1'
369
- # demo.launch(debug=DEBUG)
370
- demo.launch(debug=DEBUG, share=True, cache_examples=False)
 
339
  <center><img src='https://api.infinitescript.com/badgen/count?name=sczhou/CodeFormer&ltext=Visitors&color=6dc9aa' alt='visitors'></center>
340
  """
341
 
342
+ with gr.Blocks() as demo:
343
+ gr.Markdown(title)
344
+ gr.Markdown(description)
345
+ with gr.Box():
346
+ with gr.Column():
347
+ input_img = gr.Image(type="filepath", label="Input")
348
+ face_align = gr.Checkbox(value=True, label="Pre_Face_Align")
349
+ background_enhance = gr.Checkbox(value=True, label="Background_Enhance")
350
+ face_enhance = gr.Checkbox(value=True, label="Face_Upsample")
351
+ upscale_factor = gr.Number(value=2, label="Rescaling_Factor (up to 4)")
352
+ codeformer_fidelity = gr.Slider(0, 1, value=0.5, step=0.01, label='Codeformer_Fidelity (0 for better quality, 1 for better identity)')
353
+ submit = gr.Button('Enhance Image')
354
+ with gr.Column():
355
+ output_img = gr.Image(type="filepath", label="Output").style(height='auto')
356
+ note = gr.Markdown("**Please download the output within 30 seconds.**")
357
+
358
+ inps = [input_img, face_align, background_enhance, face_enhance, upscale_factor, codeformer_fidelity]
359
+ outs = [output_img, note]
360
+ submit.click(fn=inference, inputs=inps, outputs=outs)
361
+
362
+ ex = gr.Examples([
363
  ['01.png', True, True, True, 2, 0.7],
364
  ['02.jpg', True, True, True, 2, 0.7],
365
  ['03.jpg', True, True, True, 2, 0.7],
 
367
  ['05.jpg', True, True, True, 2, 0.1],
368
  ['06.png', False, True, True, 1, 0.5]
369
  ],
370
+ inputs=inps,
371
+ cache_examples=False)
372
+
373
+ gr.Markdown(article)
374
+
375
  DEBUG = os.getenv('DEBUG') == '1'
376
+ demo.queue(api_open=False, concurrency_count=2, max_size=10)
377
+ demo.launch(debug=DEBUG)