|
import streamlit as st |
|
from PIL import Image |
|
import numpy as np |
|
|
|
|
|
|
|
st.title("WIT: Image -> Caption App") |
|
|
|
st.write('\n') |
|
|
|
image = Image.open('images/image.png') |
|
show = st.image(image, use_column_width=True) |
|
|
|
from model import * |
|
|
|
st.sidebar.title("Upload Image") |
|
|
|
|
|
st.set_option('deprecation.showfileUploaderEncoding', False) |
|
|
|
uploaded_file = st.sidebar.file_uploader(" ", type=['png', 'jpg', 'jpeg']) |
|
|
|
if uploaded_file is not None: |
|
|
|
image = Image.open(uploaded_file) |
|
show.image(image, 'Uploaded Image', use_column_width=True) |
|
|
|
|
|
|
|
st.sidebar.write('\n') |
|
|
|
if st.sidebar.button("Click here to get image caption"): |
|
|
|
if uploaded_file is None: |
|
|
|
st.sidebar.write("Please upload an Image to Classify") |
|
|
|
else: |
|
|
|
with st.spinner('Generating image caption ...'): |
|
|
|
caption = 'dummy caption' |
|
st.success(f'caption: {caption}') |
|
|
|
st.sidebar.header("ViT-GPT2 predicts:") |
|
st.sidebar.write(f"caption: {caption}", '\n') |
|
|