wiusdy commited on
Commit
403ed9b
1 Parent(s): 382c081

simple VQA

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -12,11 +12,26 @@ def vqa(image, text):
12
  idx = logits.argmax(-1).item()
13
  return f"{text}: {model.config.id2label[idx]}"
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- dogs = os.path.join(os.path.dirname(__file__), "617.jpg")
17
  text = "What are the dogs riding?"
18
 
19
- demo = gr.Interface(vqa, gr.Image(type="pil", value=dogs), text, "text")
20
 
21
  if __name__ == "__main__":
22
  demo.launch()
 
12
  idx = logits.argmax(-1).item()
13
  return f"{text}: {model.config.id2label[idx]}"
14
 
15
+ with gr.Blocks() as demo:
16
+
17
+ txt = gr.Textbox(label="Insert a question..", lines=2)
18
+ txt_3 = gr.Textbox(value="", label="Your answer is here..")
19
+ btn = gr.Button(value="Submit")
20
+
21
+ dogs = os.path.join(os.path.dirname(__file__), "617.jpg")
22
+ image = gr.Image(type="pil", value=dogs)
23
+ btn.click(vqa, inputs=[image, txt], outputs=[txt_3])
24
+
25
+ btn = gr.Button(value="Submit")
26
+
27
+ if __name__ == "__main__":
28
+ demo.launch()
29
+
30
+
31
 
 
32
  text = "What are the dogs riding?"
33
 
34
+ demo = gr.Interface(vqa, , text, "text")
35
 
36
  if __name__ == "__main__":
37
  demo.launch()