Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
|
4 |
+
learn = load_learner("hs_classifier.pkl")
|
5 |
+
|
6 |
+
categories = "handbag", "shoe"
|
7 |
+
|
8 |
+
def classify_image(img):
|
9 |
+
_,_,probs = learn.predict(img)
|
10 |
+
return dict(
|
11 |
+
zip(categories, map(float, probs))
|
12 |
+
)
|
13 |
+
|
14 |
+
image = gr.Image()
|
15 |
+
label = gr.Label()
|
16 |
+
|
17 |
+
interface =gr.Interface(fn = classify_image,
|
18 |
+
inputs=image,
|
19 |
+
outputs=label)
|
20 |
+
|
21 |
+
interface.launch()
|