Spaces:
Sleeping
Sleeping
update path
Browse files
app.py
CHANGED
|
@@ -1,15 +1,9 @@
|
|
| 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 |
-
import pathlib
|
| 10 |
-
plt = platform.system()
|
| 11 |
-
if plt == 'Windows': pathlib.WindowsPath = pathlib.PosixPath
|
| 12 |
-
|
| 13 |
header = st.container()
|
| 14 |
inference = st.container()
|
| 15 |
|
|
@@ -18,14 +12,17 @@ with header:
|
|
| 18 |
st.text("Is your food Italian, French, Chinese, Indian, or Japanese?")
|
| 19 |
|
| 20 |
with inference:
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
learn_inf = load_learner('export.pkl')
|
| 23 |
|
| 24 |
st.header('Show me your food pic!')
|
| 25 |
st.text("(I currently accept Italian, French, Chinese, Indian, or Japanese. Otherwise, I guesss wildly!)")
|
| 26 |
uploaded_file = st.file_uploader("Show me your food pic!")
|
| 27 |
if uploaded_file is not None:
|
| 28 |
img = load_image(uploaded_file)
|
|
|
|
| 29 |
pred, pred_idx, probs = learn_inf.predict(img)
|
| 30 |
prob_value = probs[pred_idx].item()
|
| 31 |
rounded_prob_percentage = round(prob_value * 100)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
|
|
|
| 3 |
from fastai import *
|
| 4 |
from fastai.vision.all import *
|
|
|
|
| 5 |
import pickle
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
header = st.container()
|
| 8 |
inference = st.container()
|
| 9 |
|
|
|
|
| 12 |
st.text("Is your food Italian, French, Chinese, Indian, or Japanese?")
|
| 13 |
|
| 14 |
with inference:
|
| 15 |
+
path = Path()
|
| 16 |
+
path.ls(file_exts='.pkl')
|
| 17 |
|
| 18 |
+
learn_inf = load_learner(path/'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 |
+
#img = PILImage.create(uploaded_file)
|
| 26 |
pred, pred_idx, probs = learn_inf.predict(img)
|
| 27 |
prob_value = probs[pred_idx].item()
|
| 28 |
rounded_prob_percentage = round(prob_value * 100)
|