File size: 711 Bytes
942ab48
 
1a3265c
1bf3e82
a794105
942ab48
12fdc2a
9aebf92
aaed869
5d557b7
 
93d756b
942ab48
 
93d756b
 
c5c548b
f6a549c
942ab48
9aebf92
942ab48
12fdc2a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import streamlit as st
from transformers import pipeline
from PIL import Image 

question = pipeline("visual-question-answering" , model="JBDef/finetuned_yelp")
def main():
    st.title("Visual Question Answering")

    with st.form("text_field"):
        file = st.file_uploader("Upload image", type=["jpg", "png"] )
        text_input = st.text_input("Enter some question :")
        
        # clicked==True only when the button is clicked
        clicked = st.form_submit_button("Submit")
        if clicked:        
          img = Image.open(file)
          image = st.image(img)
          results = question(dict(image) , str(text_input))
          st.json(results)

if __name__ == "__main__":
    main()