Spaces:
Sleeping
Sleeping
Added classifier model
Browse files- app.py +16 -4
- export.pkl +3 -0
- lion.jpg +0 -0
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,7 +1,19 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
5 |
|
6 |
-
iface = gr.Interface(fn=
|
7 |
-
iface.launch()
|
|
|
1 |
+
__all__ = ['learnafter', 'classify_images', 'categories', 'image', 'label', 'examples', 'iface']
|
2 |
+
|
3 |
import gradio as gr
|
4 |
+
from fastai.vision.all import *
|
5 |
+
|
6 |
+
learnafter = load_learner('export.pkl')
|
7 |
+
|
8 |
+
categories = ('cheetah','lion','tiger')
|
9 |
+
|
10 |
+
def classify_images(img):
|
11 |
+
pred, idx, probs = learnafter.predict(img)
|
12 |
+
return dict(zip(categories, map(float, probs)))
|
13 |
|
14 |
+
image = gr.inputs.Image(shape=(224, 224))
|
15 |
+
label = gr.outputs.Label()
|
16 |
+
examples = ['lion.jpg']
|
17 |
|
18 |
+
iface = gr.Interface(fn=classify_images, inputs=image, outputs=label)
|
19 |
+
iface.launch(inline=False)
|
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:15f87cefc0b933318832ddc7b96cd10e055dc5d022621a01b4d02ca422a2e29a
|
3 |
+
size 46970575
|
lion.jpg
ADDED
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai==2.7.12
|