Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,20 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from fastai.vision.all import load_learner, PILImage
|
| 3 |
-
|
| 4 |
-
# Cargar el modelo utilizando load_learner
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
labels = learn.dls.vocab
|
| 9 |
-
|
| 10 |
def predict(img):
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
img = PILImage.create(img)
|
| 13 |
-
|
| 14 |
-
pred, pred_idx, probs = learn.predict(img)
|
| 15 |
-
|
| 16 |
-
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 17 |
-
|
| 18 |
# Crear la interfaz con t铆tulo y descripci贸n
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
inputs=gr.Image(),
|
| 25 |
-
|
| 26 |
-
outputs=gr.Label(num_top_classes=3),
|
| 27 |
|
| 28 |
title="Brain and fruits classifier",
|
| 29 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from fastai.vision.all import load_learner, PILImage
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
# Cargar el modelo utilizando load_learner
|
| 5 |
+
learn = load_learner('model.pkl')
|
| 6 |
+
labels = learn.dls.vocab
|
| 7 |
|
|
|
|
|
|
|
| 8 |
def predict(img):
|
| 9 |
+
img = PILImage.create(img)
|
| 10 |
+
pred, pred_idx, probs = learn.predict(img)
|
| 11 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# Crear la interfaz con t铆tulo y descripci贸n
|
| 14 |
+
gr.Interface(
|
| 15 |
+
fn=predict,
|
| 16 |
+
inputs=gr.Image(),
|
| 17 |
+
outputs=gr.Label(num_top_classes=3),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
title="Brain and fruits classifier",
|
| 20 |
|