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. 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) #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')