SeyedAli commited on
Commit
83c5511
·
1 Parent(s): 1148ad6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -30,6 +30,9 @@ def run_en_fa_transaltion_model(input_string, **generator_args):
30
  VQA_processor = ViltProcessor.from_pretrained("dandelin/vilt-b32-finetuned-vqa")
31
  VQA_model = ViltForQuestionAnswering.from_pretrained("dandelin/vilt-b32-finetuned-vqa").to(device)
32
 
 
 
 
33
 
34
  def VQA(image,text):
35
  with tempfile.NamedTemporaryFile(suffix=".png") as temp_image_file:
@@ -45,5 +48,5 @@ def VQA(image,text):
45
  idx = logits.argmax(-1).item()
46
  return run_en_fa_transaltion_model(VQA_model.config.id2label[idx])[0]
47
 
48
- iface = gr.Interface(fn=VQA, inputs=["image","text"], outputs="text")
49
  iface.launch(share=False)
 
30
  VQA_processor = ViltProcessor.from_pretrained("dandelin/vilt-b32-finetuned-vqa")
31
  VQA_model = ViltForQuestionAnswering.from_pretrained("dandelin/vilt-b32-finetuned-vqa").to(device)
32
 
33
+ image_input =gr.Image(label="عکس ورودی")
34
+ text_input = gr.TextArea(label="سوال فارسی",text_align="right",rtl=True,type="text")
35
+ text_output = gr.TextArea(label="پاسخ",text_align="right",rtl=True,type="text")
36
 
37
  def VQA(image,text):
38
  with tempfile.NamedTemporaryFile(suffix=".png") as temp_image_file:
 
48
  idx = logits.argmax(-1).item()
49
  return run_en_fa_transaltion_model(VQA_model.config.id2label[idx])[0]
50
 
51
+ iface = gr.Interface(fn=VQA, inputs=[image_input,text_input], outputs="text")
52
  iface.launch(share=False)