Spaces:
Sleeping
Sleeping
sagivphilipp
commited on
Commit
•
e9ffcde
1
Parent(s):
039be16
init files
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import pathlib
|
4 |
+
plt = platform.system()
|
5 |
+
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
|
6 |
+
learn = load_learner('model.pkl')
|
7 |
+
|
8 |
+
|
9 |
+
labels = learn.dls.vocab
|
10 |
+
def predict(img):
|
11 |
+
pred,pred_idx,probs = learn.predict(img)
|
12 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
13 |
+
|
14 |
+
title = "Shirt Neck Classifier"
|
15 |
+
description = "Find the shirt neck type"
|
16 |
+
article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
|
17 |
+
examples = ['demo1.jpg', 'demo2.jpg', 'demo3.jpg', 'demo4.jpg', 'demo5.jpg']
|
18 |
+
interpretation='default'
|
19 |
+
enable_queue=True
|
20 |
+
|
21 |
+
gr.Interface(fn=predict,
|
22 |
+
inputs=gr.inputs.Image(shape=(300, 300)),
|
23 |
+
outputs=gr.outputs.Label(num_top_classes=3),
|
24 |
+
title=title,
|
25 |
+
description=description,
|
26 |
+
article=article,
|
27 |
+
examples=examples,
|
28 |
+
interpretation=interpretation,
|
29 |
+
enable_queue=enable_queue).launch()
|
demo1.jpg
ADDED
demo2.jpg
ADDED
demo3.jpg
ADDED
demo4.jpg
ADDED
demo5.jpg
ADDED
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|