Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
inputs=["text", "slider"],
|
9 |
-
outputs=["text"],
|
10 |
-
)
|
11 |
|
12 |
-
|
|
|
13 |
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: . (unless otherwise specified).
|
2 |
+
|
3 |
+
__all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
|
4 |
+
|
5 |
+
from fastai.vision.all import *
|
6 |
import gradio as gr
|
7 |
+
import timm
|
8 |
+
|
9 |
+
# Upload your model
|
10 |
+
learn = load_learner('model.pkl')
|
11 |
+
|
12 |
+
categories = learn.dls.vocab
|
13 |
|
14 |
+
def classify_image(img):
|
15 |
+
pred,idx,probs = learn.predict(img)
|
16 |
+
return dict(zip(categories, map(float,probs)))
|
17 |
|
18 |
+
image = gr.Image()
|
19 |
+
label = gr.Label()
|
|
|
|
|
|
|
20 |
|
21 |
+
# Upload your own images and link them
|
22 |
+
examples = ['basset.jpg']
|
23 |
|
24 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
25 |
+
intf.launch()
|