Spaces:
Sleeping
Sleeping
Try this
Browse files
app.py
CHANGED
@@ -1,10 +1,23 @@
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
5 |
|
6 |
-
|
|
|
7 |
|
8 |
-
|
9 |
-
|
10 |
|
|
|
|
|
|
1 |
+
__all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
|
2 |
+
|
3 |
+
from fastai.vision.all import *
|
4 |
import gradio as gr
|
5 |
+
import timm
|
6 |
+
|
7 |
+
# Upload your model
|
8 |
+
learn = load_learner('model (1).pkl')
|
9 |
+
|
10 |
+
categories = learn.dls.vocab
|
11 |
|
12 |
+
def classify_image(img):
|
13 |
+
pred,idx,probs = learn.predict(img)
|
14 |
+
return dict(zip(categories, map(float,probs)))
|
15 |
|
16 |
+
image = gr.Image()
|
17 |
+
label = gr.Label()
|
18 |
|
19 |
+
# Upload your own images and link them
|
20 |
+
examples = ['unicycle.jpeg', 'bicycle.jpeg', 'tricycle.png']
|
21 |
|
22 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
23 |
+
intf.launch()
|
model.pkl
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:289406d996c0060f0cc8ef26c42971bdb27cfa389938f0f928045e734b079ae0
|
3 |
-
size 47061355
|
|
|
|
|
|
|
|