Spaces:
Runtime error
Runtime error
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() |