Spaces:
Running
Running
added model and interface
Browse files- app.py +13 -3
- cactus.jpg +0 -0
- dog.jpg +0 -0
- lego.jpg +0 -0
- model.pkl +3 -0
- plushie.jpg +0 -0
app.py
CHANGED
@@ -1,7 +1,17 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
|
4 |
+
learn_inf = load_learner('model.pkl')
|
5 |
+
categories = learn_inf.dls.vocab
|
6 |
|
7 |
+
def classify_image(img):
|
8 |
+
pred,pred_idx,probs = learn_inf.predict(img)
|
9 |
+
return dict(zip(categories, map(float, probs)))
|
10 |
+
|
11 |
+
iface = gr.Interface(
|
12 |
+
fn=classify_image,
|
13 |
+
inputs=gr.inputs.Image(shape=(224,224)),
|
14 |
+
outputs=gr.outputs.Label(),
|
15 |
+
examples=['lego.jpg', 'dog.jpg', 'cactus.jpg', 'plushie.jpg']
|
16 |
+
)
|
17 |
iface.launch()
|
cactus.jpg
ADDED
dog.jpg
ADDED
lego.jpg
ADDED
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a72e6aed40f299c03e785a1d114e84dde2511b1d8e81e415945dec9e482a793e
|
3 |
+
size 46963557
|
plushie.jpg
ADDED