Spaces:
Sleeping
Sleeping
Eduardo Yáñez Parareda
commited on
Commit
•
a8ef8ed
1
Parent(s):
bd72581
app with pepper-classifier model
Browse files- app.py +22 -4
- pepper-classifier-model.pkl +3 -0
- pimiento-italiano-rojo.jpg +0 -0
- pimiento-italiano-verde.jpg +0 -0
- pimiento-morron-rojo.jpg +0 -0
- pimientos-del-padron.jpg +0 -0
app.py
CHANGED
@@ -1,8 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
8 |
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: pepper-classifier-app.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learner', 'pepper_types', 'image', 'label', 'examples', 'interface', 'predict']
|
5 |
+
|
6 |
+
# %% pepper-classifier-app.ipynb 0
|
7 |
+
from fastai.vision.all import *
|
8 |
import gradio as gr
|
9 |
|
10 |
+
# %% pepper-classifier-app.ipynb 1
|
11 |
+
learner = load_learner('pepper-classifier-model.pkl')
|
12 |
+
|
13 |
+
# %% pepper-classifier-app.ipynb 2
|
14 |
+
pepper_types = 'italian', 'morron', 'padron'
|
15 |
+
|
16 |
+
def predict(image):
|
17 |
+
type_of_pepper,_,probs = learner.predict(image)
|
18 |
+
return dict(zip(pepper_types, map(float, probs)))
|
19 |
|
20 |
+
# %% pepper-classifier-app.ipynb 7
|
21 |
+
image = gr.inputs.Image(shape=(224, 224))
|
22 |
+
label = gr.outputs.Label()
|
23 |
+
examples = ['pimiento-morron-rojo.jpg', 'pimiento-italiano-rojo.jpg', 'pimientos-del-padron.jpg', 'pimiento-italiano-verde.jpg']
|
24 |
|
25 |
+
interface = gr.Interface(fn=predict, inputs=image, outputs=label, examples=examples)
|
26 |
+
interface.launch(inline=False)
|
pepper-classifier-model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:773b1187fab781b0b48ee02c179a64fb3544e4e8eb5b63518385da8e3de4f902
|
3 |
+
size 46967509
|
pimiento-italiano-rojo.jpg
ADDED
pimiento-italiano-verde.jpg
ADDED
pimiento-morron-rojo.jpg
ADDED
pimientos-del-padron.jpg
ADDED