RanjithkumarPanjabikesan commited on
Commit
c2e6d2c
·
verified ·
1 Parent(s): f8bab5c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from helper import image_to_base64_str, import base64_to_pil
2
+ #Build Image Caption and Generate Image Game App.
3
+ import gradio as gr
4
+ def caption_and_generate(image):
5
+ caption = captioner(image)
6
+ image = generate(caption)
7
+ return [caption, image]
8
+
9
+ with gr.Blocks() as demo:
10
+ gr.Markdown("# Caption Image-and-Generate game 🖍️")
11
+ image_upload = gr.Image(label="Your first image",type="pil")
12
+ btn_all = gr.Button("Caption and generate")
13
+ caption = gr.Textbox(label="Generated caption")
14
+ image_output = gr.Image(label="Generated Image")
15
+
16
+ btn_all.click(fn=caption_and_generate, inputs=[image_upload], outputs=[caption, image_output])
17
+
18
+ gr.close_all()
19
+ demo.launch(debug="True")