manual upload
Browse files- app.py +26 -0
- coriander.jpg +0 -0
- parsley.jpg +0 -0
- plants.pkl +3 -0
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learner', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
|
5 |
+
|
6 |
+
# %% ../app.ipynb 2
|
7 |
+
from fastai.vision.all import *
|
8 |
+
import gradio as gr
|
9 |
+
|
10 |
+
|
11 |
+
# %% ../app.ipynb 4
|
12 |
+
learner = load_learner('plants.pkl')
|
13 |
+
|
14 |
+
# %% ../app.ipynb 8
|
15 |
+
categories = ('Coriander قزبر','Parsley معدنوس')
|
16 |
+
def classify_image(img):
|
17 |
+
pred, idx, probs = learner.predict(img)
|
18 |
+
return dict(zip(categories,map(float,probs)))
|
19 |
+
|
20 |
+
# %% ../app.ipynb 10
|
21 |
+
image = gr.inputs.Image(shape=(192,192))
|
22 |
+
label = gr.outputs.Label()
|
23 |
+
examples = ['coriander.jpg','parsley.jpg']
|
24 |
+
|
25 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
26 |
+
intf.launch(inline=False)
|
coriander.jpg
ADDED
parsley.jpg
ADDED
plants.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e961b80f00239356eef1431d31b04b990a0588e00ddb3cdd8688a97c73fe813b
|
3 |
+
size 46959183
|