Update app.py
Browse files
app.py
CHANGED
|
@@ -38,6 +38,10 @@ def parse_input(image, sketchpad, state):
|
|
| 38 |
def tabs_select(e: gr.SelectData, _state):
|
| 39 |
_state["tab_index"] = e.index
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
with gr.Blocks() as iface:
|
| 42 |
gr.HTML("""<p align="center"><img src="https://cdn-icons-png.flaticon.com/512/5853/5853758.png" style="height: 60px"/><p>""")
|
| 43 |
gr.HTML("""<center><font size=8>Image Captioning Demo</center>""")
|
|
@@ -54,10 +58,9 @@ with gr.Blocks() as iface:
|
|
| 54 |
input_sketchpad = gr.Sketchpad(type="pil", label="Sketch", layers=False)
|
| 55 |
input_tabs.select(fn=tabs_select, inputs=[state])
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
return example_img
|
| 61 |
|
| 62 |
with gr.Row():
|
| 63 |
with gr.Column():
|
|
@@ -69,7 +72,7 @@ with gr.Blocks() as iface:
|
|
| 69 |
fn=parse_input,
|
| 70 |
inputs=[input_image, input_sketchpad, state],
|
| 71 |
outputs= gr.Textbox(label = "Result"))
|
| 72 |
-
|
| 73 |
# Launch the interface
|
| 74 |
if __name__ == "__main__":
|
| 75 |
iface.launch()
|
|
|
|
| 38 |
def tabs_select(e: gr.SelectData, _state):
|
| 39 |
_state["tab_index"] = e.index
|
| 40 |
|
| 41 |
+
example_img_path = "https://sl.bing.net/i3YznO6vkiW"
|
| 42 |
+
def use_example_img():
|
| 43 |
+
return example_img_path
|
| 44 |
+
|
| 45 |
with gr.Blocks() as iface:
|
| 46 |
gr.HTML("""<p align="center"><img src="https://cdn-icons-png.flaticon.com/512/5853/5853758.png" style="height: 60px"/><p>""")
|
| 47 |
gr.HTML("""<center><font size=8>Image Captioning Demo</center>""")
|
|
|
|
| 58 |
input_sketchpad = gr.Sketchpad(type="pil", label="Sketch", layers=False)
|
| 59 |
input_tabs.select(fn=tabs_select, inputs=[state])
|
| 60 |
|
| 61 |
+
|
| 62 |
+
example_img = gr.Image(value = example_img_path, label="Example image", interactive =True)
|
| 63 |
+
|
|
|
|
| 64 |
|
| 65 |
with gr.Row():
|
| 66 |
with gr.Column():
|
|
|
|
| 72 |
fn=parse_input,
|
| 73 |
inputs=[input_image, input_sketchpad, state],
|
| 74 |
outputs= gr.Textbox(label = "Result"))
|
| 75 |
+
example_img.click(use_example_img, outputs = input_image)
|
| 76 |
# Launch the interface
|
| 77 |
if __name__ == "__main__":
|
| 78 |
iface.launch()
|