Spaces:
Runtime error
Runtime error
dudko
commited on
Commit
·
caa851b
1
Parent(s):
dea9be7
update .gitattributes so git lfs will track .pkl files
Browse files- app.py +18 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
learn = load_learner('thumbs_vs_heart_model.pkl')
|
5 |
+
|
6 |
+
labels = learn.dls.vocab
|
7 |
+
def predict(img):
|
8 |
+
img = PILImage.create(img)
|
9 |
+
pred,pred_idx,probs = learn.predict(img)
|
10 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
11 |
+
|
12 |
+
|
13 |
+
title = "Hand Gesture Classifier"
|
14 |
+
description = "A hand gesture classifier trained for two classes thumbs up and heart gesture. Created as a demo for Gradio and HuggingFace Spaces."
|
15 |
+
|
16 |
+
examples = ['boy_thumbs_up.jpg', 'girl_thumbs_up.jpg', 'man_heart.jpg', 'heart.jpg']
|
17 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=2), title=title, description=description, examples=examples,
|
18 |
+
interpretation='default').launch(share=True)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|