ptah23 commited on
Commit
2fd2a2e
·
1 Parent(s): e0aac53
Files changed (2) hide show
  1. app.py +25 -0
  2. model.pkl +3 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import streamlit as st
3
+ from fastai.vision.core import *
4
+ from fastai.vision.all import *
5
+ import pathlib
6
+ import platform
7
+
8
+ if platform.system() == 'Windows':
9
+ temp = pathlib.PosixPath
10
+ pathlib.PosixPath = pathlib.WindowsPath
11
+ def is_cat(x): return x[0].isupper()
12
+ if __name__=='__main__':
13
+ learn = load_learner(pathlib.Path()/'model.pkl')
14
+ uploaded_file = st.file_uploader("Choose an image of a dog or cat")
15
+ if uploaded_file is not None:
16
+ im = PILImage.create((uploaded_file))
17
+ st.image(im.to_thumb(500, 500), caption='Uploaded Image')
18
+ if st.button('Classify'):
19
+ pred, ix, probs = learn.predict(im.convert('RGB'))
20
+ data = dict(zip(('Dog', 'Cat'), map(float, probs)))
21
+ st.bar_chart(data=data)
22
+ else:
23
+ st.write(f'Click the button to classify')
24
+
25
+
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e87969a9ecd168698eef4a6edeb04e5c4f57768fb30d7a1d08d7d5f422587738
3
+ size 47061483