File size: 730 Bytes
6cb5353
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sys
sys.path.append(".")

import streamlit as st
import pandas as pd

from vqa_demo.model_loader import *


# load dataset
ds = load_dataset("test")

# define selector
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)
)

# select and display
sample = ds[image_selector_unspecific]
image = sample['image']
image

# inference
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) # TODO: cache
answer = get_answer(args, image, question, model_name)
st.write("answer")