File size: 836 Bytes
440b4dc
e72f0b1
e7486b1
9dc172d
2ba91d1
9ebb258
e7486b1
2ba91d1
e7486b1
e0d86b8
2ba91d1
e72f0b1
440b4dc
e72f0b1
e0d86b8
2ba91d1
fdcbdd8
e0d86b8
fdcbdd8
 
e72f0b1
 
2ba91d1
fdcbdd8
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from fastai.vision.all import *
import gradio as gr
from huggingface_hub import hf_hub_download

# Descargar el modelo exportado desde el repositorio Hugging Face
model_path = hf_hub_download(repo_id="AdrianRevi/Practica1Blindness", filename="model.pkl")

# Cargar el modelo
learn = load_learner(model_path)

# Función de predicción
def predict(img):
    pred_class, pred_idx, probs = learn.predict(img)
    return dict(zip(learn.dls.vocab, map(float, probs)))

# Crear interfaz
demo = gr.Interface(
    fn=predict,
    inputs=gr.Image(type="pil"),
    outputs=gr.Label(num_top_classes=3),
    title="Clasificador de Ceguera",
    description="Sube una imagen de retina para predecir el grado de ceguera.",
    examples=["20068.jpg", "20084.jpg"]  # Asegúrate de subir estas imágenes
)

if __name__ == "__main__":
    demo.launch()