Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,29 @@
|
|
| 1 |
|
| 2 |
-
|
|
|
|
| 3 |
from fastai.vision.all import *
|
|
|
|
| 4 |
|
| 5 |
-
from huggingface_hub import login, from_pretrained_fastai
|
| 6 |
|
| 7 |
-
# Cargar el modelo
|
| 8 |
learn = from_pretrained_fastai("AlejandrOSM1/Clasificador_de_camiones_Definitivo_Resnet18")
|
| 9 |
-
# Obtener etiquetas del modelo
|
| 10 |
labels = learn.dls.vocab
|
| 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 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
| 1 |
|
| 2 |
+
|
| 3 |
+
import gradio as gr
|
| 4 |
from fastai.vision.all import *
|
| 5 |
+
from huggingface_hub import from_pretrained_fastai
|
| 6 |
|
|
|
|
| 7 |
|
|
|
|
| 8 |
learn = from_pretrained_fastai("AlejandrOSM1/Clasificador_de_camiones_Definitivo_Resnet18")
|
|
|
|
| 9 |
labels = learn.dls.vocab
|
| 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 |
+
|
| 18 |
+
title = "Bad truck classifier"
|
| 19 |
+
description = "Just upload a truck"
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
gr.Interface(
|
| 23 |
+
fn=predict,
|
| 24 |
+
inputs=gr.Image(),
|
| 25 |
+
outputs=gr.Label(num_top_classes=10),
|
| 26 |
+
title=title,
|
| 27 |
+
description=description,
|
| 28 |
+
examples=examples,
|
| 29 |
+
).launch()
|