|
import sys |
|
sys.path.append(".") |
|
|
|
import streamlit as st |
|
import pandas as pd |
|
|
|
from model_loader import * |
|
|
|
|
|
|
|
|
|
ds = load_dataset("HuggingFaceM4/VQAv2", split="validation", cache_dir="cache", streaming=False) |
|
|
|
|
|
model_name = st.sidebar.selectbox( |
|
"Select a model: ", |
|
('vilt', 'git', 'blip', 'vbert') |
|
) |
|
|
|
image_selector_unspecific = st.number_input( |
|
"Select an image id: ", |
|
0, len(ds) |
|
) |
|
|
|
|
|
sample = ds[image_selector_unspecific] |
|
image = sample['image'] |
|
image |
|
|
|
|
|
question = st.text_input(f"Ask the model a question related to the image: \n" |
|
f"(e.g. \"{sample['question']}\")") |
|
args = load_model(model_name) |
|
answer = get_answer(args, image, question, model_name) |
|
st.write("answer") |