Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -3,9 +3,7 @@ import gradio as gr
|
|
3 |
from transformers import AutoProcessor, AutoTokenizer, AutoImageProcessor, AutoModelForCausalLM, BlipForConditionalGeneration, VisionEncoderDecoderModel
|
4 |
import torch
|
5 |
|
6 |
-
|
7 |
-
torch.hub.download_url_to_file('https://huggingface.co/datasets/nielsr/textcaps-sample/resolve/main/stop_sign.png', 'stop_sign.png')
|
8 |
-
torch.hub.download_url_to_file('https://cdn.openai.com/dall-e-2/demos/text2im/astronaut/horse/photo/0.jpg', 'astronaut.jpg')
|
9 |
|
10 |
git_processor_base = AutoProcessor.from_pretrained("microsoft/git-base-coco")
|
11 |
git_model_base = AutoModelForCausalLM.from_pretrained("microsoft/git-base-coco")
|
@@ -61,14 +59,14 @@ def generate_captions(image):
|
|
61 |
examples = [["cat.jpg"], ["dog.jpg"], ["horse.jpg"]]
|
62 |
outputs = [gr.outputs.Textbox(label="Caption generated by GIT-base"), gr.outputs.Textbox(label="Caption generated by GIT-large"), gr.outputs.Textbox(label="Caption generated by BLIP-base"), gr.outputs.Textbox(label="Caption generated by BLIP-large"), gr.outputs.Textbox(label="Caption generated by ViT+GPT-2")]
|
63 |
|
64 |
-
title = "
|
65 |
description = "Gradio Demo to compare GIT, BLIP and ViT+GPT2, 3 state-of-the-art vision+language 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."
|
66 |
article = "<p style='text-align: center'><a href='https://huggingface.co/docs/transformers/main/model_doc/blip' target='_blank'>BLIP docs</a> | <a href='https://huggingface.co/docs/transformers/main/model_doc/git' target='_blank'>GIT docs</a></p>"
|
67 |
|
68 |
iface = gr.Interface(fn=generate_captions,
|
69 |
inputs=gr.inputs.Image(type="pil"),
|
70 |
outputs=outputs,
|
71 |
-
|
72 |
title=title,
|
73 |
description=description,
|
74 |
article=article,
|
|
|
3 |
from transformers import AutoProcessor, AutoTokenizer, AutoImageProcessor, AutoModelForCausalLM, BlipForConditionalGeneration, VisionEncoderDecoderModel
|
4 |
import torch
|
5 |
|
6 |
+
|
|
|
|
|
7 |
|
8 |
git_processor_base = AutoProcessor.from_pretrained("microsoft/git-base-coco")
|
9 |
git_model_base = AutoModelForCausalLM.from_pretrained("microsoft/git-base-coco")
|
|
|
59 |
examples = [["cat.jpg"], ["dog.jpg"], ["horse.jpg"]]
|
60 |
outputs = [gr.outputs.Textbox(label="Caption generated by GIT-base"), gr.outputs.Textbox(label="Caption generated by GIT-large"), gr.outputs.Textbox(label="Caption generated by BLIP-base"), gr.outputs.Textbox(label="Caption generated by BLIP-large"), gr.outputs.Textbox(label="Caption generated by ViT+GPT-2")]
|
61 |
|
62 |
+
title = "Image to Text : Multiple Models"
|
63 |
description = "Gradio Demo to compare GIT, BLIP and ViT+GPT2, 3 state-of-the-art vision+language 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."
|
64 |
article = "<p style='text-align: center'><a href='https://huggingface.co/docs/transformers/main/model_doc/blip' target='_blank'>BLIP docs</a> | <a href='https://huggingface.co/docs/transformers/main/model_doc/git' target='_blank'>GIT docs</a></p>"
|
65 |
|
66 |
iface = gr.Interface(fn=generate_captions,
|
67 |
inputs=gr.inputs.Image(type="pil"),
|
68 |
outputs=outputs,
|
69 |
+
examples=examples,
|
70 |
title=title,
|
71 |
description=description,
|
72 |
article=article,
|