Spaces:
Sleeping
Sleeping
File size: 1,302 Bytes
5514c44 f29298a 5514c44 7b203a5 5514c44 f29298a 705cef1 f29298a be0aedc 5514c44 be0aedc 5514c44 29b2a86 5514c44 be0aedc 5514c44 7b203a5 |
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 |
import streamlit as st
import pandas as pd
from fastai import *
from fastai.vision.all import *
import pickle
import pathlib
header = st.container()
inference = st.container()
image_viewer = st.container()
with header:
st.title("Cuisine Classifier")
st.text("Is your food Italian, French, Chinese, Indian, or Japanese?")
with inference:
plt = platform.system()
if plt == 'Linux':
pathlib.WindowsPath = pathlib.PosixPath
if plt == 'Windows':
pathlib.PosixPath = pathlib.WindowsPath
path = Path()
path.ls(file_exts='.pkl')
learn_inf = load_learner(path/'export.pkl')
st.header('Show me your food pic!')
st.text("(I currently accept Italian, French, Chinese, Indian, or Japanese.)")
uploaded_file = st.file_uploader("Show me your food pic!")
if uploaded_file is not None:
img = load_image(uploaded_file)
#img = PILImage.create(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!")
with image_viewer:
st.header(f"Your food pic")
st.image(image=img, caption='your pic will be shown here') |