Spaces:
Runtime error
Runtime error
Commit
·
34705d2
1
Parent(s):
a339abc
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,34 +5,23 @@ import streamlit as st
|
|
| 5 |
from fastai.vision.all import *
|
| 6 |
st.markdown('<h1 style="color:black;">BDI Image classification model</h1>', unsafe_allow_html=True)
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
learn = load_learner('export (5).pkl')
|
| 11 |
-
categories = ('Dog Destroying Stuff','Neutral')
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
@st.cache(allow_output_mutation=True)
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
upload= st.file_uploader('Insert image for classification', type=['png','jpg'])
|
| 19 |
-
c1, c2= st.columns(2)
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
def get_base64_of_bin_file(bin_file):
|
| 24 |
with open(bin_file, 'rb') as f:
|
| 25 |
data = f.read()
|
| 26 |
return base64.b64encode(data).decode()
|
| 27 |
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
if upload is not None:
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
if pred == 'Dog Destroying Stuff':
|
| 38 |
-
sound()
|
|
|
|
| 5 |
from fastai.vision.all import *
|
| 6 |
st.markdown('<h1 style="color:black;">BDI Image classification model</h1>', unsafe_allow_html=True)
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
@st.cache(allow_output_mutation=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
def get_base64_of_bin_file(bin_file):
|
| 10 |
with open(bin_file, 'rb') as f:
|
| 11 |
data = f.read()
|
| 12 |
return base64.b64encode(data).decode()
|
| 13 |
|
| 14 |
|
| 15 |
+
learn = load_learner('export (5).pkl')
|
| 16 |
+
|
| 17 |
+
categories = ('Dog Destroying Stuff','Neutral')
|
| 18 |
+
upload= st.file_uploader('Insert image for classification', type=['png','jpg'])
|
| 19 |
+
c1, c2= st.columns(2)
|
| 20 |
if upload is not None:
|
| 21 |
+
im= Image.open(upload)
|
| 22 |
+
c1.header('Input Image')
|
| 23 |
+
c1.image(im)
|
| 24 |
+
pred, idx, probs = learn.predict(im)
|
| 25 |
+
c2.header('Output')
|
| 26 |
+
c2.subheader('Predicted class :')
|
| 27 |
+
c2.write(pred)
|
|
|
|
|
|