aya369 commited on
Commit
b13e42c
·
verified ·
1 Parent(s): 0d8afb9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from captioning.image_caption import caption_image
3
+ from captioning.url_caption import caption_from_url
4
+
5
+ with gr.Blocks() as demo:
6
+ with gr.Tab("Upload Image"):
7
+ gr.Markdown("### Upload an image and get its caption")
8
+ with gr.Row():
9
+ img_input = gr.Image()
10
+ img_output = gr.Textbox(label="Caption")
11
+ img_button = gr.Button("Generate Caption")
12
+ img_button.click(caption_image, inputs=img_input, outputs=img_output)
13
+
14
+ with gr.Tab("URL Image Captioning"):
15
+ gr.Markdown("### Enter a webpage URL to caption all images in it")
16
+ url_input = gr.Textbox(label="Page URL")
17
+ url_output = gr.Textbox(label="Captions", lines=20)
18
+ url_button = gr.Button("Generate Captions", scale=-3)
19
+ url_button.click(caption_from_url, inputs=url_input, outputs=url_output)
20
+
21
+ demo.launch()