Spaces:
Sleeping
Sleeping
Rob Learsch commited on
Commit ·
a8258e1
1
Parent(s): 8debd85
Update app.py
Browse filesMade the labels cuter
app.py
CHANGED
|
@@ -2,14 +2,20 @@ 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
|
| 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,
|
|
|
|
| 2 |
from fastai.vision.all import *
|
| 3 |
learn = load_learner('20250123_squish_model.pkl')
|
| 4 |
|
| 5 |
+
#labels = learn.dls.vocab
|
| 6 |
+
labels=['Comfort Food Squishable',
|
| 7 |
+
'Plague-related Squishable',
|
| 8 |
+
'Standard Squish',
|
| 9 |
+
'Undercover Squishable!'
|
| 10 |
+
]
|
| 11 |
+
|
| 12 |
def predict(img):
|
| 13 |
img = PILImage.create(img)
|
| 14 |
pred,pred_idx,probs = learn.predict(img)
|
| 15 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 16 |
|
| 17 |
title = "Squishable Type Classifier"
|
| 18 |
+
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."
|
| 19 |
article="<p style='text-align: center'><a href='https://rlearsch.github.io/' target='_blank'>Blog post</a></p>"
|
| 20 |
|
| 21 |
gr.Interface(fn=predict,
|