Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ from transformers import ViltProcessor, ViltForVisualQuestionAnswering
|
|
| 3 |
import torch
|
| 4 |
|
| 5 |
torch.hub.download_url_to_file('http://images.cocodataset.org/val2017/000000039769.jpg', 'cats.jpg')
|
|
|
|
| 6 |
|
| 7 |
processor = ViltProcessor.from_pretrained("dandelin/vilt-b32-finetuned-vqa")
|
| 8 |
model = ViltForVisualQuestionAnswering.from_pretrained("dandelin/vilt-b32-finetuned-vqa")
|
|
@@ -23,24 +24,7 @@ def answer_question(image, text):
|
|
| 23 |
image = gr.inputs.Image(type="pil")
|
| 24 |
question = gr.inputs.Textbox(label="Question")
|
| 25 |
answer = gr.outputs.Textbox(label="Predicted answer")
|
| 26 |
-
examples = [["cats.jpg", "How many cats are there?"],
|
| 27 |
-
[
|
| 28 |
-
"https://s3.geograph.org.uk/geophotos/06/21/24/6212487_1cca7f3f_1024x1024.jpg",
|
| 29 |
-
"What is the color of the flower?",
|
| 30 |
-
],
|
| 31 |
-
[
|
| 32 |
-
"https://computing.ece.vt.edu/~harsh/visualAttention/ProjectWebpage/Figures/vqa_1.png",
|
| 33 |
-
"What is the mustache made of?",
|
| 34 |
-
],
|
| 35 |
-
[
|
| 36 |
-
"https://computing.ece.vt.edu/~harsh/visualAttention/ProjectWebpage/Figures/vqa_2.png",
|
| 37 |
-
"How many slices of pizza are there?",
|
| 38 |
-
],
|
| 39 |
-
[
|
| 40 |
-
"https://computing.ece.vt.edu/~harsh/visualAttention/ProjectWebpage/Figures/vqa_3.png",
|
| 41 |
-
"Does it appear to be rainy?",
|
| 42 |
-
],
|
| 43 |
-
]
|
| 44 |
|
| 45 |
interface = gr.Interface(fn=answer_question, inputs=[image, question], outputs=answer, examples=examples, enable_queue=True)
|
| 46 |
interface.launch(debug=True)
|
|
|
|
| 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://computing.ece.vt.edu/~harsh/visualAttention/ProjectWebpage/Figures/vqa_1.png', 'banana.png')
|
| 7 |
|
| 8 |
processor = ViltProcessor.from_pretrained("dandelin/vilt-b32-finetuned-vqa")
|
| 9 |
model = ViltForVisualQuestionAnswering.from_pretrained("dandelin/vilt-b32-finetuned-vqa")
|
|
|
|
| 24 |
image = gr.inputs.Image(type="pil")
|
| 25 |
question = gr.inputs.Textbox(label="Question")
|
| 26 |
answer = gr.outputs.Textbox(label="Predicted answer")
|
| 27 |
+
examples = [["cats.jpg", "How many cats are there?"], ["banana.png", "What is the mustache made of?"]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
interface = gr.Interface(fn=answer_question, inputs=[image, question], outputs=answer, examples=examples, enable_queue=True)
|
| 30 |
interface.launch(debug=True)
|