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