Divyam Sharma commited on
Commit
0d14460
Β·
1 Parent(s): d8ff2c8

Caption and Img Sepa

Browse files
Files changed (1) hide show
  1. app.py +29 -29
app.py CHANGED
@@ -83,48 +83,48 @@ def generate(prompt):
83
  ### First attempt, just captioning
84
 
85
  import gradio as gr
86
- # with gr.Blocks() as demo:
87
- # gr.Markdown("# Describe-and-Generate game πŸ–οΈ")
88
- # image_upload = gr.Image(label="Your first image",type="pil")
89
- # btn_caption = gr.Button("Generate caption")
90
- # caption = gr.Textbox(label="Generated caption")
91
 
92
- # btn_caption.click(fn=captioner, inputs=[image_upload], outputs=[caption])
93
 
94
  # gr.close_all()
95
  # demo.launch(share=True)
96
 
97
  # ### Let's add generation
98
 
99
- # with gr.Blocks() as demo:
100
- # gr.Markdown("# Describe-and-Generate game πŸ–οΈ")
101
- # image_upload = gr.Image(label="Your first image",type="pil")
102
- # btn_caption = gr.Button("Generate caption")
103
- # caption = gr.Textbox(label="Generated caption")
104
- # btn_image = gr.Button("Generate image")
105
- # image_output = gr.Image(label="Generated Image")
106
- # btn_caption.click(fn=captioner, inputs=[image_upload], outputs=[caption])
107
- # btn_image.click(fn=generate, inputs=[caption], outputs=[image_output])
108
-
109
- # gr.close_all()
110
- # demo.launch(share=True)
111
-
112
- ### Doing it all at once
113
-
114
- def caption_and_generate(image):
115
- caption = captioner(image)
116
- image = generate(caption)
117
- return [caption, image]
118
-
119
  with gr.Blocks() as demo:
120
  gr.Markdown("# Describe-and-Generate game πŸ–οΈ")
121
  image_upload = gr.Image(label="Your first image",type="pil")
122
- btn_all = gr.Button("Caption and generate")
123
  caption = gr.Textbox(label="Generated caption")
 
124
  image_output = gr.Image(label="Generated Image")
125
- btn_all.click(fn=caption_and_generate, inputs=[image_upload], outputs=[caption, image_output])
 
126
 
127
  # gr.close_all()
128
  demo.launch(share=True)
129
 
130
- gr.close_all()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  ### First attempt, just captioning
84
 
85
  import gradio as gr
86
+ with gr.Blocks() as demo:
87
+ gr.Markdown("# Describe-and-Generate game πŸ–οΈ")
88
+ image_upload = gr.Image(label="Your first image",type="pil")
89
+ btn_caption = gr.Button("Generate caption")
90
+ caption = gr.Textbox(label="Generated caption")
91
 
92
+ btn_caption.click(fn=captioner, inputs=[image_upload], outputs=[caption])
93
 
94
  # gr.close_all()
95
  # demo.launch(share=True)
96
 
97
  # ### Let's add generation
98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  with gr.Blocks() as demo:
100
  gr.Markdown("# Describe-and-Generate game πŸ–οΈ")
101
  image_upload = gr.Image(label="Your first image",type="pil")
102
+ btn_caption = gr.Button("Generate caption")
103
  caption = gr.Textbox(label="Generated caption")
104
+ btn_image = gr.Button("Generate image")
105
  image_output = gr.Image(label="Generated Image")
106
+ btn_caption.click(fn=captioner, inputs=[image_upload], outputs=[caption])
107
+ btn_image.click(fn=generate, inputs=[caption], outputs=[image_output])
108
 
109
  # gr.close_all()
110
  demo.launch(share=True)
111
 
112
+ ### Doing it all at once
113
+
114
+ # def caption_and_generate(image):
115
+ # caption = captioner(image)
116
+ # image = generate(caption)
117
+ # return [caption, image]
118
+
119
+ # with gr.Blocks() as demo:
120
+ # gr.Markdown("# Describe-and-Generate game πŸ–οΈ")
121
+ # image_upload = gr.Image(label="Your first image",type="pil")
122
+ # btn_all = gr.Button("Caption and generate")
123
+ # caption = gr.Textbox(label="Generated caption")
124
+ # image_output = gr.Image(label="Generated Image")
125
+ # btn_all.click(fn=caption_and_generate, inputs=[image_upload], outputs=[caption, image_output])
126
+
127
+ # gr.close_all()
128
+ # demo.launch(share=True)
129
+
130
+ # gr.close_all()