nielsr HF staff commited on
Commit
3a227f4
1 Parent(s): 38ab1e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -3,6 +3,7 @@ from transformers import AutoProcessor, AutoModelForCausalLM, BlipForConditional
3
  import torch
4
 
5
  torch.hub.download_url_to_file('http://images.cocodataset.org/val2017/000000039769.jpg', 'cats.jpg')
 
6
 
7
  git_processor = AutoProcessor.from_pretrained("microsoft/git-base-coco")
8
  git_model = AutoModelForCausalLM.from_pretrained("microsoft/git-base-coco")
@@ -33,7 +34,7 @@ def generate_captions(image):
33
  return caption_git, caption_blip
34
 
35
 
36
- examples = [["cats.jpg"]]
37
 
38
  title = "Interactive demo: comparing image captioning models"
39
  description = "Gradio Demo to compare GIT and BLIP, 2 state-of-the-art captioning models. To use it, simply upload your image and click 'submit', or click one of the examples to load them. Read more at the links below."
@@ -41,7 +42,7 @@ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2102.033
41
 
42
  interface = gr.Interface(fn=generate_captions,
43
  inputs=gr.inputs.Image(type="pil"),
44
- outputs=[gr.outputs.Textbox(label="Generated caption by GIT"), gr.outputs.Textbox(label="Generated caption by BLIP")],
45
  examples=examples,
46
  title=title,
47
  description=description,
 
3
  import torch
4
 
5
  torch.hub.download_url_to_file('http://images.cocodataset.org/val2017/000000039769.jpg', 'cats.jpg')
6
+ torch.hub.download_url_to_file('https://huggingface.co/datasets/nielsr/textcaps-sample/resolve/main/stop_sign.png', 'stop_sign.png')
7
 
8
  git_processor = AutoProcessor.from_pretrained("microsoft/git-base-coco")
9
  git_model = AutoModelForCausalLM.from_pretrained("microsoft/git-base-coco")
 
34
  return caption_git, caption_blip
35
 
36
 
37
+ examples = [["cats.jpg", "stop_sign.png"]]
38
 
39
  title = "Interactive demo: comparing image captioning models"
40
  description = "Gradio Demo to compare GIT and BLIP, 2 state-of-the-art captioning models. To use it, simply upload your image and click 'submit', or click one of the examples to load them. Read more at the links below."
 
42
 
43
  interface = gr.Interface(fn=generate_captions,
44
  inputs=gr.inputs.Image(type="pil"),
45
+ outputs=[gr.outputs.Textbox(label="Caption generated by GIT"), gr.outputs.Textbox(label="Caption generated by BLIP")],
46
  examples=examples,
47
  title=title,
48
  description=description,