RyuMoro
First commit
9f24d9b
raw
history blame
932 Bytes
import streamlit as st
import pandas as pd
from io import StringIO
from fastai import *
from fastai.vision.all import *
import bz2file as bz2
import pickle
header = st.container()
inference = st.container()
with header:
st.title("Cuisine Classifier")
st.text("Is your food Italian, French, Chinese, Indian, or Japanese?")
with inference:
learn_inf = load_learner('export.pkl')
st.header('Show me your food pic!')
st.text("(I currently accept Italian, French, Chinese, Indian, or Japanese. Otherwise, I guesss wildly!)")
uploaded_file = st.file_uploader("Show me your food pic!")
if uploaded_file is not None:
img = load_image(uploaded_file)
pred, pred_idx, probs = learn_inf.predict(img)
prob_value = probs[pred_idx].item()
rounded_prob_percentage = round(prob_value * 100)
st.text(f"This is {pred}, isn't it? Believe me, I am {rounded_prob_percentage}% sure!")