Babyloncoder commited on
Commit
53195f4
1 Parent(s): 98a1770

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the VQA model
5
+ oracle = pipeline(model="dandelin/vilt-b32-finetuned-vqa")
6
+
7
+ # Define a function to use the model
8
+ def answer_question(image, question):
9
+ response = oracle(question=question, image=image)
10
+ return response[0]['answer']
11
+
12
+ # Import the specific input and output components directly
13
+ from gradio import Image, Textbox
14
+
15
+ # Create the Gradio interface
16
+ interface = gr.Interface(
17
+ fn=answer_question,
18
+ inputs=[Image(type="filepath"), Textbox()],
19
+ outputs=Textbox()
20
+ )
21
+
22
+ # Launch the app
23
+ interface.launch()