Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -66,6 +66,7 @@ def vilt_vqa(image, question):
|
|
66 |
with torch.no_grad():
|
67 |
outputs = vilt_model(**inputs)
|
68 |
logits = outputs.logits
|
|
|
69 |
idx = logits.argmax(-1).item()
|
70 |
answer = vilt_model.config.id2label[idx]
|
71 |
logger.info("ViLT: " + answer)
|
@@ -126,12 +127,16 @@ Supported 107 Languages: Afrikaans, Albanian, Amharic, Arabic, Armenian, Azerbai
|
|
126 |
# Load example images
|
127 |
torch.hub.download_url_to_file('http://farm3.staticflickr.com/2710/4520550856_7a9f9ea59d_z.jpg', 'apple.jpg')
|
128 |
torch.hub.download_url_to_file('http://images.cocodataset.org/val2017/000000039769.jpg', 'cats.jpg')
|
|
|
129 |
|
130 |
# Define home page variables
|
131 |
image = gr.Image(type="pil")
|
132 |
question = gr.Textbox(label="Question")
|
133 |
answer = gr.Textbox(label="Predicted answer")
|
134 |
-
examples = [
|
|
|
|
|
|
|
135 |
|
136 |
demo = gr.Interface(fn=vqa_main,
|
137 |
inputs=[image, question],
|
|
|
66 |
with torch.no_grad():
|
67 |
outputs = vilt_model(**inputs)
|
68 |
logits = outputs.logits
|
69 |
+
logger.info("ViLT logits:" + logits)
|
70 |
idx = logits.argmax(-1).item()
|
71 |
answer = vilt_model.config.id2label[idx]
|
72 |
logger.info("ViLT: " + answer)
|
|
|
127 |
# Load example images
|
128 |
torch.hub.download_url_to_file('http://farm3.staticflickr.com/2710/4520550856_7a9f9ea59d_z.jpg', 'apple.jpg')
|
129 |
torch.hub.download_url_to_file('http://images.cocodataset.org/val2017/000000039769.jpg', 'cats.jpg')
|
130 |
+
torch.hub.download_url_to_file('https://media.istockphoto.com/id/1174602891/photo/two-monkeys-mom-and-cub-eat-bananas.jpg?s=612x612&w=0&k=20&c=r7VXi9d1wHhyq3iAk9D2Z3yTZiOJMlLNtjdVRBEjG7g=', 'monkey.jpg')
|
131 |
|
132 |
# Define home page variables
|
133 |
image = gr.Image(type="pil")
|
134 |
question = gr.Textbox(label="Question")
|
135 |
answer = gr.Textbox(label="Predicted answer")
|
136 |
+
examples = [
|
137 |
+
["monkey.jpg", "Tell me what is going on in Korean."]
|
138 |
+
["apple.jpg", "What color is this? Answer in Uyghur."],
|
139 |
+
["cats.jpg", "How many cats are here?"]]
|
140 |
|
141 |
demo = gr.Interface(fn=vqa_main,
|
142 |
inputs=[image, question],
|