Spaces:
Runtime error
Runtime error
| from fastai.vision.all import * | |
| import gradio as gr | |
| from huggingface_hub import hf_hub_download | |
| # Descargar el modelo exportado desde Hugging Face | |
| model_path = hf_hub_download(repo_id="AdrianRevi/Practica1Blindness", filename="model.pkl") | |
| # Cargar el modelo localmente | |
| 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 la interfaz de Gradio | |
| 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"] | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |