-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
43 lines (38 loc) · 1.29 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from fastai.vision.all import *
from fastai.vision.widgets import *
#from IPython.display import Image
from ipywidgets import *
from PIL import Image
import streamlit as st
import urllib.request
import wget
#path = Path()
st.set_option('deprecation.showfileUploaderEncoding', False)
st.title("PlantAI")
st.write('''
---
## **Which Plant is This**?
This is simple Web application to classify four type of plants:
**Schefflera**,
**Epipremnum aureum**,
**Dieffenbachia**,
**Dracaena**.
'''
)
st.image('https://dl.dropboxusercontent.com/s/2873nwxz55lrozc/plants.jpg?dl=0', use_column_width=True)
st.write('''
### Please upload a picture for one of these plants!
''')
Uploaded = st.file_uploader('', type=['png','jpg','jpeg'])
with st.spinner('Loading your picture into memory'):
url = wget.download('https://dl.dropboxusercontent.com/s/uahengnua8m3hbu/export.pkl?dl=0')
model = load_learner(url)
time.sleep(1)
if Uploaded is not None:
img = Image.open(Uploaded)
img_fastai = PILImage.create(Uploaded)
st.image(img, caption='This is your uploaded picture', use_column_width=True)
st.write("")
st.write("Classifying...")
pred,pred_idx,probs = model.predict(img_fastai)
st.write("Prediction: ", pred, "; Probability: ", probs[pred_idx]*100,'% :sunglasses:')