root commited on
Commit
d44bf9b
1 Parent(s): b9e7cf7

add example

Browse files
Files changed (2) hide show
  1. app.py +9 -7
  2. forbidden_city.webp +0 -0
app.py CHANGED
@@ -120,7 +120,7 @@ def inference_caption(
120
 
121
 
122
  title = """<h1 align="center">BLIP-2</h1>"""
123
- description = """Gradio demo for BLIP-2, a multimodal chatbot from Salesforce Research. To use it, simply upload your image, or click one of the examples to load them. Please visit our <a href='https://github.com/salesforce/LAVIS/tree/main/projects/blip2' target='_blank'>project webpage</a>.</p>
124
  <p> <strong>Disclaimer</strong>: This is a research prototype and is not intended for production use. No data including but not restricted to text and images is collected. </p>"""
125
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2201.12086' target='_blank'>BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models</a>"
126
 
@@ -128,6 +128,7 @@ endpoint = Endpoint()
128
 
129
  examples = [
130
  ["house.png", "How could someone get out of the house?"],
 
131
  # [
132
  # "sunset.png",
133
  # "Write a romantic message that goes along this photo.",
@@ -156,17 +157,18 @@ with gr.Blocks() as iface:
156
  minimum=0.5,
157
  maximum=1.0,
158
  value=0.8,
 
159
  interactive=True,
160
- label="Temperature (set to 0 for greedy decoding with nucleus sampling)",
161
  )
162
 
163
  len_penalty = gr.Slider(
164
- minimum=-2.0,
165
  maximum=2.0,
166
  value=1.0,
167
- step=0.5,
168
  interactive=True,
169
- label="Length Penalty (larger value encourages longer sequence with beam search)",
170
  )
171
 
172
  rep_penalty = gr.Slider(
@@ -179,7 +181,7 @@ with gr.Blocks() as iface:
179
  )
180
 
181
  with gr.Row():
182
- caption_output = gr.Textbox(lines=2, label="Caption Output")
183
  caption_button = gr.Button(
184
  value="Caption it!", interactive=True, variant="primary"
185
  )
@@ -199,7 +201,7 @@ with gr.Blocks() as iface:
199
  chat_input = gr.Textbox(lines=2, label="Chat Input")
200
 
201
  with gr.Row():
202
- chatbot = gr.Chatbot()
203
  image_input.change(lambda: (None, "", "", []), [], [chatbot, chat_input, caption_output, state])
204
 
205
  with gr.Row():
 
120
 
121
 
122
  title = """<h1 align="center">BLIP-2</h1>"""
123
+ description = """Gradio demo for BLIP-2, image-to-text generation from Salesforce Research. To use it, simply upload your image, or click one of the examples to load them. Please visit our <a href='https://github.com/salesforce/LAVIS/tree/main/projects/blip2' target='_blank'>project webpage</a>.</p>
124
  <p> <strong>Disclaimer</strong>: This is a research prototype and is not intended for production use. No data including but not restricted to text and images is collected. </p>"""
125
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2201.12086' target='_blank'>BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models</a>"
126
 
 
128
 
129
  examples = [
130
  ["house.png", "How could someone get out of the house?"],
131
+ ["forbidden_city.webp", "In what dynasties was this place build?"],
132
  # [
133
  # "sunset.png",
134
  # "Write a romantic message that goes along this photo.",
 
157
  minimum=0.5,
158
  maximum=1.0,
159
  value=0.8,
160
+ step=0.1,
161
  interactive=True,
162
+ label="Temperature (used with nucleus sampling)",
163
  )
164
 
165
  len_penalty = gr.Slider(
166
+ minimum=-1.0,
167
  maximum=2.0,
168
  value=1.0,
169
+ step=0.2,
170
  interactive=True,
171
+ label="Length Penalty (set to larger for longer sequence, used with beam search)",
172
  )
173
 
174
  rep_penalty = gr.Slider(
 
181
  )
182
 
183
  with gr.Row():
184
+ caption_output = gr.Textbox(lines=2, label="Caption Output (from OPT)")
185
  caption_button = gr.Button(
186
  value="Caption it!", interactive=True, variant="primary"
187
  )
 
201
  chat_input = gr.Textbox(lines=2, label="Chat Input")
202
 
203
  with gr.Row():
204
+ chatbot = gr.Chatbot(label="Chat Output (from FlanT5)")
205
  image_input.change(lambda: (None, "", "", []), [], [chatbot, chat_input, caption_output, state])
206
 
207
  with gr.Row():
forbidden_city.webp ADDED