AdrianRevi commited on
Commit
2ba91d1
·
verified ·
1 Parent(s): 10a9d9e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -2,23 +2,25 @@ 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__":
 
2
  import gradio as gr
3
  from huggingface_hub import hf_hub_download
4
 
5
+ # Descargar el modelo exportado desde el repositorio Hugging Face
6
+ model_path = hf_hub_download(repo_id="AdrianRevi/Practica1Blindness", filename="export.pkl")
7
 
8
+ # Cargar el modelo
9
  learn = load_learner(model_path)
10
 
11
+ # Función de predicción
12
  def predict(img):
13
  pred_class, pred_idx, probs = learn.predict(img)
14
  return dict(zip(learn.dls.vocab, map(float, probs)))
15
 
16
+ # Crear interfaz
17
  demo = gr.Interface(
18
  fn=predict,
19
  inputs=gr.Image(type="pil"),
20
  outputs=gr.Label(num_top_classes=3),
21
  title="Clasificador de Ceguera",
22
  description="Sube una imagen de retina para predecir el grado de ceguera.",
23
+ examples=["20068.jpg", "20084.jpg"] # Asegúrate de subir estas imágenes
24
  )
25
 
26
  if __name__ == "__main__":