Spaces:
Sleeping
Sleeping
Rob Learsch
commited on
Commit
·
8debd85
1
Parent(s):
ae061fb
added app
Browse files- app.py +22 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
learn = load_learner('20250123_squish_model.pkl')
|
| 4 |
+
|
| 5 |
+
labels = learn.dls.vocab
|
| 6 |
+
def predict(img):
|
| 7 |
+
img = PILImage.create(img)
|
| 8 |
+
pred,pred_idx,probs = learn.predict(img)
|
| 9 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 10 |
+
|
| 11 |
+
title = "Squishable Type Classifier"
|
| 12 |
+
description = "A squishable classifier trained with fastai. Do you have a standard Squish? Undercover? Comfort Food? Let's find out! <br> Created as a demo for Gradio and HuggingFace Spaces."
|
| 13 |
+
article="<p style='text-align: center'><a href='https://rlearsch.github.io/' target='_blank'>Blog post</a></p>"
|
| 14 |
+
|
| 15 |
+
gr.Interface(fn=predict,
|
| 16 |
+
inputs=gr.components.Image(height=214, width=214),
|
| 17 |
+
outputs=gr.components.Label(num_top_classes=3),
|
| 18 |
+
title=title,
|
| 19 |
+
description=description,
|
| 20 |
+
article=article,
|
| 21 |
+
).queue(max_size=3
|
| 22 |
+
).launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
fastai
|