Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- app.py +20 -0
- exemple_Sam.jpg +0 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
from huggingface_hub import from_pretrained_fastai
|
4 |
+
|
5 |
+
# Load your model from Hugging Face
|
6 |
+
learn = from_pretrained_fastai("Laiaromeu/totallyspies_classifier")
|
7 |
+
labels = learn.dls.vocab
|
8 |
+
|
9 |
+
# Prediction function
|
10 |
+
def predict(img):
|
11 |
+
img = PILImage.create(img)
|
12 |
+
pred, pred_idx, probs = learn.predict(img)
|
13 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
14 |
+
|
15 |
+
# Create the Gradio interface
|
16 |
+
gr.Interface(
|
17 |
+
fn=predict,
|
18 |
+
inputs=gr.Image(),
|
19 |
+
outputs=gr.Label(num_top_classes=2)
|
20 |
+
).launch()
|
exemple_Sam.jpg
ADDED
![]() |
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
timm
|
2 |
+
fastai
|
3 |
+
toml
|