Spaces:
Runtime error
Runtime error
File size: 1,106 Bytes
8d9306e fd6cb9f 8d9306e f705683 8d9306e f705683 9a6a97f f705683 8d9306e 9a6a97f 8d9306e f705683 9a6a97f 8d9306e 686f21e 8d9306e 9a6a97f 686f21e 8d9306e 686f21e |
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 35 36 37 38 39 40 41 42 43 44 45 |
import streamlit as st
from PIL import Image
import numpy as np
# Designing the interface
st.title("French Image Caption App")
# For newline
st.write('\n')
#image = Image.open('samples/val_000000039769.jpg')
#show = st.image(image, use_column_width=True)
#show.image(image, 'Preloaded Image', use_column_width=True)
with st.spinner('Loading ViT-GPT2 model ...'):
from model import *
st.sidebar.write(f'Vit-GPT2 model loaded :)')
st.sidebar.title("Select a sample image")
sample_name = st.sidebar.selectbox(
"Please Choose the Model",
sample_fns
)
sample_name = f'COCO_val2014_{sample_name.replace('.jpg', '').zfill(12)}.jpg'
sample_path = os.path.join(sample_dir, sample_name)
image = Image.open(sample_path)
show = st.image(image, use_column_width=True)
show.image(image, 'Selected Image', use_column_width=True)
# For newline
st.sidebar.write('\n')
with st.spinner('Generating image caption ...'):
caption = predict_dummy(image)
image.close()
st.success(f'caption: {caption}')
st.sidebar.header("ViT-GPT2 predicts:")
st.sidebar.write(f"caption: {caption}", '\n')
|