Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,25 @@
|
|
1 |
from fastai.vision.all import *
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
-
#
|
5 |
-
|
|
|
|
|
|
|
6 |
|
7 |
-
# Función de predicción
|
8 |
def predict(img):
|
9 |
pred_class, pred_idx, probs = learn.predict(img)
|
10 |
return dict(zip(learn.dls.vocab, map(float, probs)))
|
11 |
|
12 |
-
# Interfaz Gradio
|
13 |
demo = gr.Interface(
|
14 |
fn=predict,
|
15 |
inputs=gr.Image(type="pil"),
|
16 |
outputs=gr.Label(num_top_classes=3),
|
17 |
title="Clasificador de Ceguera",
|
18 |
description="Sube una imagen de retina para predecir el grado de ceguera.",
|
19 |
-
examples=["20068.jpg", "20084.jpg"]
|
20 |
)
|
21 |
|
22 |
-
# Lanzar la app
|
23 |
if __name__ == "__main__":
|
24 |
demo.launch()
|
|
|
1 |
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
+
from huggingface_hub import hf_hub_download
|
4 |
|
5 |
+
# Descargar el archivo desde Hugging Face al entorno local
|
6 |
+
model_path = hf_hub_download(repo_id="AdrianRevi/Practica1Blindness", filename="model.pkl")
|
7 |
+
|
8 |
+
# Cargar el modelo localmente
|
9 |
+
learn = load_learner(model_path)
|
10 |
|
|
|
11 |
def predict(img):
|
12 |
pred_class, pred_idx, probs = learn.predict(img)
|
13 |
return dict(zip(learn.dls.vocab, map(float, probs)))
|
14 |
|
|
|
15 |
demo = gr.Interface(
|
16 |
fn=predict,
|
17 |
inputs=gr.Image(type="pil"),
|
18 |
outputs=gr.Label(num_top_classes=3),
|
19 |
title="Clasificador de Ceguera",
|
20 |
description="Sube una imagen de retina para predecir el grado de ceguera.",
|
21 |
+
examples=["20068.jpg", "20084.jpg"]
|
22 |
)
|
23 |
|
|
|
24 |
if __name__ == "__main__":
|
25 |
demo.launch()
|