Created
December 28, 2019 20:27
-
-
Save iamatulsingh/1e10d693dd24464df5774310e59549f8 to your computer and use it in GitHub Desktop.
imageNet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import glob | |
import streamlit as st | |
from main import predict | |
from PIL import Image | |
# all models list | |
models_list = [ | |
"vgg16", | |
"vgg19", | |
"inception", | |
"xception", | |
"resnet" | |
] | |
# all images in 'images' folder | |
images = [image.split("\\")[1] for image in glob.glob(os.path.join("images", "*.jpg"))] | |
st.sidebar.title("ImageNet") | |
selected_image = st.sidebar.selectbox("Pick an image.", images) | |
selected_model = st.sidebar.selectbox("Pick a model.", models_list) | |
st.write("Enjoy Machine Learning with Streamlit !!!") | |
if st.sidebar.button('Predict'): | |
showpred = 1 | |
prediction, prob = predict( | |
selected_model, | |
os.path.join("images", selected_image) | |
) | |
image = Image.open(os.path.join("images", selected_image)) | |
st.image(image, | |
caption=f"prediction: {prediction}, probability: {prob * 100}", | |
use_column_width=True | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment