ydshieh HF staff commited on
Commit
9f18ecc
1 Parent(s): 442cdb5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -14
app.py CHANGED
@@ -170,7 +170,7 @@ def main():
170
  model = AutoModelForVision2Seq.from_pretrained(ckpt, trust_remote_code=True).to("cuda")
171
  processor = AutoProcessor.from_pretrained(ckpt, trust_remote_code=True)
172
 
173
- def generate_predictions(image_input, text_input, do_sample, sampling_topp, sampling_temperature):
174
 
175
  # Save the image and load it again to match the original Kosmos-2 demo.
176
  # (https://github.com/microsoft/unilm/blob/f4695ed0244a275201fff00bee495f76670fbe70/kosmos-2/demo/gradio_app.py#L345-L346)
@@ -252,10 +252,6 @@ def main():
252
  with gr.Column():
253
  image_input = gr.Image(type="pil", label="Test Image")
254
  text_input = gr.Radio(["Brief", "Detailed"], label="Description Type", value="Brief")
255
- do_sample = gr.Checkbox(label="Enable Sampling", info="(Please enable it before adjusting sampling parameters below)", value=False)
256
- with gr.Accordion("Sampling parameters", open=False) as sampling_parameters:
257
- sampling_topp = gr.Slider(minimum=0.1, maximum=1, step=0.01, value=0.9, label="Sampling: Top-P")
258
- sampling_temperature = gr.Slider(minimum=0.1, maximum=1, step=0.01, value=0.7, label="Sampling: Temperature")
259
 
260
  run_button = gr.Button(label="Run", visible=True)
261
 
@@ -270,16 +266,16 @@ def main():
270
  with gr.Row():
271
  with gr.Column():
272
  gr.Examples(examples=[
273
- ["images/two_dogs.jpg", "Detailed", False],
274
- ["images/snowman.png", "Brief", False],
275
- ["images/man_ball.png", "Detailed", False],
276
- ], inputs=[image_input, text_input, do_sample])
277
  with gr.Column():
278
  gr.Examples(examples=[
279
- ["images/six_planes.png", "Brief", False],
280
- ["images/quadrocopter.jpg", "Brief", False],
281
- ["images/carnaby_street.jpg", "Brief", False],
282
- ], inputs=[image_input, text_input, do_sample])
283
  gr.Markdown(term_of_use)
284
 
285
  # record which text span (label) is selected
@@ -304,7 +300,7 @@ def main():
304
  selected.change(update_output_image, [image_input, image_output, entity_output, selected], [image_output])
305
 
306
  run_button.click(fn=generate_predictions,
307
- inputs=[image_input, text_input, do_sample, sampling_topp, sampling_temperature],
308
  outputs=[image_output, text_output1, entity_output],
309
  show_progress=True, queue=True)
310
 
 
170
  model = AutoModelForVision2Seq.from_pretrained(ckpt, trust_remote_code=True).to("cuda")
171
  processor = AutoProcessor.from_pretrained(ckpt, trust_remote_code=True)
172
 
173
+ def generate_predictions(image_input, text_input):
174
 
175
  # Save the image and load it again to match the original Kosmos-2 demo.
176
  # (https://github.com/microsoft/unilm/blob/f4695ed0244a275201fff00bee495f76670fbe70/kosmos-2/demo/gradio_app.py#L345-L346)
 
252
  with gr.Column():
253
  image_input = gr.Image(type="pil", label="Test Image")
254
  text_input = gr.Radio(["Brief", "Detailed"], label="Description Type", value="Brief")
 
 
 
 
255
 
256
  run_button = gr.Button(label="Run", visible=True)
257
 
 
266
  with gr.Row():
267
  with gr.Column():
268
  gr.Examples(examples=[
269
+ ["images/two_dogs.jpg", "Detailed"],
270
+ ["images/snowman.png", "Brief"],
271
+ ["images/man_ball.png", "Detailed"],
272
+ ], inputs=[image_input, text_input])
273
  with gr.Column():
274
  gr.Examples(examples=[
275
+ ["images/six_planes.png", "Brief"],
276
+ ["images/quadrocopter.jpg", "Brief"],
277
+ ["images/carnaby_street.jpg", "Brief"],
278
+ ], inputs=[image_input, text_input])
279
  gr.Markdown(term_of_use)
280
 
281
  # record which text span (label) is selected
 
300
  selected.change(update_output_image, [image_input, image_output, entity_output, selected], [image_output])
301
 
302
  run_button.click(fn=generate_predictions,
303
+ inputs=[image_input, text_input],
304
  outputs=[image_output, text_output1, entity_output],
305
  show_progress=True, queue=True)
306