File size: 701 Bytes
9dc172d
440b4dc
fdcbdd8
9dc172d
440b4dc
 
e0d86b8
fdcbdd8
440b4dc
 
552557d
e0d86b8
fdcbdd8
e0d86b8
fdcbdd8
 
bbd316d
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
import gradio as gr
from fastai.vision.all import *
from PIL import Image

# Cargar modelo exportado desde Hugging Face
learn = load_learner("https://huggingface.co/AdrianRevi/Practica1Blindness/model.pkl")

def predict(img: Image.Image):
    pred_class, pred_idx, probs = learn.predict(img)
    labels = learn.dls.vocab
    return {labels[i]: float(probs[i]) for i in range(len(labels))}

demo = gr.Interface(
    fn=predict,
    inputs=gr.Image(type="pil"),
    outputs=gr.Label(num_top_classes=3),
    examples=["20068.jpg", "20084.jpg"],
    title="Blindness Detection",
    description="Sube una imagen del ojo para detectar el grado de ceguera.",
)

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