Phips commited on
Commit
c1951fb
1 Parent(s): b394b97

Add input examples which will be cached

Browse files
app.py CHANGED
@@ -173,7 +173,7 @@ def image_properties(img):
173
  def main():
174
  # Gradio Interface
175
  with gr.Blocks(title="Self-trained ESRGAN models demo", theme="dark") as demo:
176
-
177
  gr.Markdown(
178
  """# <div align="center"> Upscale image </div>
179
  Here I demo my self-trained models. The models with their corresponding infos can be found on [my github repo](https://github.com/phhofm/models).
@@ -187,15 +187,17 @@ def main():
187
  info="See model infos at the bottom of this page")
188
  face_enhance = gr.Checkbox(label="Face Enhancement using GFPGAN (Doesn't work for anime images)",value=False, show_label=True)
189
 
190
- with gr.Row():
191
- with gr.Group():
192
  input_image = gr.Image(label="Source Image", type="pil", image_mode="RGBA")
193
  input_image_properties = gr.Textbox(label="Image Properties - Demo will throw error if input image has either width or height > 1000. Output download is jpg for smaller size. Use models locally to circument these limits.", max_lines=1)
194
- output_image = gr.Image(label="Upscaled Image", image_mode="RGBA")
 
 
195
  with gr.Row():
196
  upscale_btn = gr.Button("Upscale")
197
  reset_btn = gr.Button("Reset")
198
  with gr.Group():
 
199
  gr.Markdown(
200
  """
201
  **Model infos**
@@ -230,6 +232,7 @@ def main():
230
 
231
  # Event listeners:
232
  input_image.change(fn=image_properties, inputs=input_image, outputs=input_image_properties)
 
233
  upscale_btn.click(fn=realesrgan, inputs=[input_image, model_name, face_enhance], outputs=output_image)
234
  reset_btn.click(fn=reset, inputs=[], outputs=[output_image, input_image])
235
 
 
173
  def main():
174
  # Gradio Interface
175
  with gr.Blocks(title="Self-trained ESRGAN models demo", theme="dark") as demo:
176
+
177
  gr.Markdown(
178
  """# <div align="center"> Upscale image </div>
179
  Here I demo my self-trained models. The models with their corresponding infos can be found on [my github repo](https://github.com/phhofm/models).
 
187
  info="See model infos at the bottom of this page")
188
  face_enhance = gr.Checkbox(label="Face Enhancement using GFPGAN (Doesn't work for anime images)",value=False, show_label=True)
189
 
190
+ with gr.Group():
 
191
  input_image = gr.Image(label="Source Image", type="pil", image_mode="RGBA")
192
  input_image_properties = gr.Textbox(label="Image Properties - Demo will throw error if input image has either width or height > 1000. Output download is jpg for smaller size. Use models locally to circument these limits.", max_lines=1)
193
+ with gr.Group():
194
+ output_image = gr.Image(label="Upscaled Image", type="pil", image_mode="RGBA", interactive=False)
195
+ output_image_properties = gr.Textbox(label="Image Properties", max_lines=1)
196
  with gr.Row():
197
  upscale_btn = gr.Button("Upscale")
198
  reset_btn = gr.Button("Reset")
199
  with gr.Group():
200
+ gr.Examples(examples="examples",inputs=[input_image, model_name, face_enhance],outputs=output_image,fn=realesrgan, cache_examples=True)
201
  gr.Markdown(
202
  """
203
  **Model infos**
 
232
 
233
  # Event listeners:
234
  input_image.change(fn=image_properties, inputs=input_image, outputs=input_image_properties)
235
+ output_image.change(fn=image_properties, inputs=output_image, outputs=output_image_properties)
236
  upscale_btn.click(fn=realesrgan, inputs=[input_image, model_name, face_enhance], outputs=output_image)
237
  reset_btn.click(fn=reset, inputs=[], outputs=[output_image, input_image])
238
 
examples/bibli.png ADDED
examples/buddy.jpg ADDED
examples/dearalice1.png ADDED
examples/jujutsukaisen.png ADDED
examples/log.csv ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ input_image,model_name,face_enhance
2
+ dearalice1.png,4xHFA2k,
3
+ dearalice1.png,4xNomos8kSC,
4
+ dearalice1.png,2xHFA2kCompact,
5
+ buddy.jpg,4xNomos8kSC,true
6
+ buddy.jpg,4xLSDIRplusC,true
7
+ buddy.jpg,4xLSDIRCompactC3,true
8
+ seeufer.jpg,4xNomos8kSC,
9
+ seeufer.jpg,4xLSDIR,
10
+ seeufer.jpg,4xLSDIRplusN,
11
+ bibli.png,4xLSDIR,
12
+ bibli.png,4xLSDIRplusN,
13
+ palme.jpg,4xNomos8kSC,
14
+ zimmer.jpg,4xNomos8kSC,
15
+ text.png,2xParimgCompact,
16
+ jujutsukaisen.png,4xHFA2k,
examples/palme.jpg ADDED
examples/seeufer.jpg ADDED
examples/text.png ADDED
examples/zimmer.jpg ADDED