Spaces:
Running
Running
Fix indentation
Browse files
app.py
CHANGED
@@ -12,11 +12,11 @@ def answer_question(image, text):
|
|
12 |
with torch.no_grad():
|
13 |
outputs = model(**encoding)
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
|
19 |
-
|
20 |
|
21 |
image = gr.inputs.Image(type="pil")
|
22 |
question = gr.inputs.Textbox(label="Question")
|
|
|
12 |
with torch.no_grad():
|
13 |
outputs = model(**encoding)
|
14 |
|
15 |
+
logits = outputs.logits
|
16 |
+
idx = logits.argmax(-1).item()
|
17 |
+
predicted_answer = model.config.id2label[idx])
|
18 |
|
19 |
+
return predicted_answer
|
20 |
|
21 |
image = gr.inputs.Image(type="pil")
|
22 |
question = gr.inputs.Textbox(label="Question")
|