Spaces:
Sleeping
Sleeping
update to app
Browse files- .gitignore +1 -0
- app.py +14 -3
- tmp/German-shepherd.png +0 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
tmp/
|
app.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
from fastai.vision.all import *
|
|
|
|
|
3 |
|
4 |
def is_cat(x) : return x[0].isupper()
|
5 |
|
@@ -11,12 +13,19 @@ def classify_image(img):
|
|
11 |
return dict(zip(categories,map(float,probs)))
|
12 |
|
13 |
def save_uploaded_file(uploadedfile):
|
14 |
-
|
|
|
|
|
|
|
15 |
with open(path_name,"wb") as f:
|
16 |
f.write(uploadedfile.getbuffer())
|
17 |
-
st.success(f"Saved file :{uploadedfile.name} as {path_name}")
|
18 |
return path_name
|
19 |
|
|
|
|
|
|
|
|
|
|
|
20 |
upload_image = st.file_uploader("Choose a file")
|
21 |
|
22 |
if upload_image is not None:
|
@@ -25,4 +34,6 @@ if upload_image is not None:
|
|
25 |
st.image(image)
|
26 |
path_name = save_uploaded_file(upload_image)
|
27 |
st.write("Prediction Propabilities:")
|
28 |
-
st.write(classify_image(path_name))
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from fastai.vision.all import *
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
import pandas as pd
|
5 |
|
6 |
def is_cat(x) : return x[0].isupper()
|
7 |
|
|
|
13 |
return dict(zip(categories,map(float,probs)))
|
14 |
|
15 |
def save_uploaded_file(uploadedfile):
|
16 |
+
temp_folder = "tmp"
|
17 |
+
if not os.path.exists(temp_folder):
|
18 |
+
os.makedirs(temp_folder)
|
19 |
+
path_name = os.path.join(temp_folder,uploadedfile.name)
|
20 |
with open(path_name,"wb") as f:
|
21 |
f.write(uploadedfile.getbuffer())
|
|
|
22 |
return path_name
|
23 |
|
24 |
+
st.write("""
|
25 |
+
# Dog vs Cat Classifier
|
26 |
+
This is a application that classifies images of dogs vs cats
|
27 |
+
""")
|
28 |
+
|
29 |
upload_image = st.file_uploader("Choose a file")
|
30 |
|
31 |
if upload_image is not None:
|
|
|
34 |
st.image(image)
|
35 |
path_name = save_uploaded_file(upload_image)
|
36 |
st.write("Prediction Propabilities:")
|
37 |
+
st.write(classify_image(path_name))
|
38 |
+
preds = pd.DataFrame(classify_image(path_name), index=[0])
|
39 |
+
st.bar_chart(preds)
|
tmp/German-shepherd.png
DELETED
Binary file (46.3 kB)
|
|