vicalloy commited on
Commit
77307a6
1 Parent(s): 6cb67f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -22
app.py CHANGED
@@ -134,7 +134,8 @@ title = "GFPGAN: Practical Face Restoration Algorithm"
134
  description = r"""Gradio demo for <a href='https://github.com/TencentARC/GFPGAN' target='_blank'><b>GFPGAN: Towards Real-World Blind Face Restoration with Generative Facial Prior</b></a>.<br>
135
  It can be used to restore your **old photos** or improve **AI-generated faces**.<br>
136
  To use it, simply upload your image.<br>
137
- If GFPGAN is helpful, please help to ⭐ the <a href='https://github.com/TencentARC/GFPGAN' target='_blank'>Github Repo</a> and recommend it to your friends 😊
 
138
  """
139
  article = r"""
140
 
@@ -147,26 +148,31 @@ If you have any question, please email 📧 `xintao.wang@outlook.com` or `xintao
147
  <center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>
148
  <center><img src='https://visitor-badge.glitch.me/badge?page_id=Gradio_Xintao_GFPGAN' alt='visitor badge'></center>
149
  """
150
- demo = gr.Interface(
151
- inference, [
152
- gr.inputs.Image(type="filepath", label="Input"),
153
- # gr.inputs.Radio(['v1.2', 'v1.3', 'v1.4', 'RestoreFormer', 'CodeFormer'], type="value", default='v1.4', label='version'),
154
- gr.inputs.Radio(['v1.2', 'v1.3', 'v1.4', 'RestoreFormer'], type="value", default='v1.4', label='version'),
155
- gr.inputs.Number(label="Rescaling factor", default=2),
156
- gr.inputs.Number(label="Blur face", default=25),
157
- # gr.Slider(0, 100, label='Weight, only for CodeFormer. 0 for better quality, 100 for better identity', default=50)
158
- ], [
159
- gr.outputs.Image(type="numpy", label="Output (The whole image)"),
160
- gr.outputs.File(label="Download the output image"),
161
- gr.Gallery(label="Input faces").style(grid=[2], height="auto"),
162
- gr.Gallery(label="Output faces").style(grid=[2], height="auto")
163
- ],
164
- title=title,
165
- description=description,
166
- article=article,
167
- # examples=[['AI-generate.jpg', 'v1.4', 2, 50], ['lincoln.jpg', 'v1.4', 2, 50], ['Blake_Lively.jpg', 'v1.4', 2, 50],
168
- # ['10045.png', 'v1.4', 2, 50]]).launch()
169
- examples=[['HanamichiSakuragi.jpg', 'v1.4', 2, 31], ['LiShiming.jpg', 'v1.4', 2, 3], ['QianLong.jpg', 'v1.4', 2, 3],
170
- ['10045.png', 'v1.4', 2, 0]])
 
 
 
 
 
171
  demo.queue(concurrency_count=4)
172
  demo.launch()
 
134
  description = r"""Gradio demo for <a href='https://github.com/TencentARC/GFPGAN' target='_blank'><b>GFPGAN: Towards Real-World Blind Face Restoration with Generative Facial Prior</b></a>.<br>
135
  It can be used to restore your **old photos** or improve **AI-generated faces**.<br>
136
  To use it, simply upload your image.<br>
137
+ If GFPGAN is helpful, please help to ⭐ the <a href='https://github.com/TencentARC/GFPGAN' target='_blank'>Github Repo</a> and recommend it to your friends 😊<br>
138
+ This demo was forked by [vicalloy](https://github.com/vicalloy), add `face blur` param to optimize painting face enhance.
139
  """
140
  article = r"""
141
 
 
148
  <center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>
149
  <center><img src='https://visitor-badge.glitch.me/badge?page_id=Gradio_Xintao_GFPGAN' alt='visitor badge'></center>
150
  """
151
+ with gr.Blocks() as demo:
152
+ gr.Markdown("<center><h1>%s</h1></center>" % title)
153
+ gr.Markdown(description)
154
+ with gr.Row(equal_height=False):
155
+ with gr.Column():
156
+ file_path = gr.components.Image(type="filepath", label="Input")
157
+ version = gr.components.Radio(['v1.2', 'v1.3', 'v1.4', 'RestoreFormer'], type="value", value='v1.4', label='version')
158
+ rescaling_factor = gr.components.Number(label="Rescaling factor", value=2)
159
+ blur_face = gr.components.Number(label="Blur face", value=25)
160
+ submit = gr.Button("Submit")
161
+ with gr.Column():
162
+ output_img = gr.components.Image(type="numpy", label="Output (The whole image)")
163
+ download = gr.components.File(label="Download the output image")
164
+ with gr.Row():
165
+ with gr.Column():
166
+ input_faces = gr.Gallery(label="Input faces").style(grid=[2], height="auto")
167
+ with gr.Column():
168
+ output_faces = gr.Gallery(label="Output faces").style(grid=[2], height="auto")
169
+ gr.Examples([['HanamichiSakuragi.jpg', 'v1.4', 2, 31], ['LiShiming.jpg', 'v1.4', 2, 3], ['QianLong.jpg', 'v1.4', 2, 3],
170
+ ['10045.png', 'v1.4', 2, 0]], [file_path, version, rescaling_factor, blur_face])
171
+ gr.Markdown(article)
172
+ submit.click(
173
+ inference,
174
+ inputs=[file_path, version, rescaling_factor, blur_face],
175
+ outputs=[output_img, download, input_faces, output_faces]
176
+ )
177
  demo.queue(concurrency_count=4)
178
  demo.launch()