Ryu-m0m commited on
Commit
5514c44
1 Parent(s): 9f24d9b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from io import StringIO
4
+ from fastai import *
5
+ from fastai.vision.all import *
6
+ import bz2file as bz2
7
+ import pickle
8
+
9
+ header = st.container()
10
+ inference = st.container()
11
+
12
+ with header:
13
+ st.title("Cuisine Classifier")
14
+ st.text("Is your food Italian, French, Chinese, Indian, or Japanese?")
15
+
16
+ with inference:
17
+
18
+ learn_inf = load_learner('export.pkl')
19
+
20
+ st.header('Show me your food pic!')
21
+ st.text("(I currently accept Italian, French, Chinese, Indian, or Japanese. Otherwise, I guesss wildly!)")
22
+ uploaded_file = st.file_uploader("Show me your food pic!")
23
+ if uploaded_file is not None:
24
+ img = load_image(uploaded_file)
25
+ pred, pred_idx, probs = learn_inf.predict(img)
26
+ prob_value = probs[pred_idx].item()
27
+ rounded_prob_percentage = round(prob_value * 100)
28
+ st.text(f"This is {pred}, isn't it? Believe me, I am {rounded_prob_percentage}% sure!")