jdelgado2002 commited on
Commit
c10710a
·
verified ·
1 Parent(s): ad35b91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -16
app.py CHANGED
@@ -1,24 +1,13 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceAPI
3
 
4
- # Specify the model name
5
- model_repo = "jdelgado2002/diabetic_retinopathy_detection"
6
-
7
- # Initialize the InferenceAPI client
8
- api = InferenceAPI(model_repo)
9
-
10
- labels = ["No DR", "Mild", "Moderate", "Severe", "Proliferative DR"]
11
 
12
  def predict(img):
13
- # Convert the image to a base64 string
14
- img_str = gr.inputs.Image.to_base64(img, ext="jpeg")
15
-
16
- # Perform inference
17
- inputs = {"inputs": img_str}
18
- result = api(inputs)
19
-
20
- # Convert the result to the expected format
21
- return {labels[i]: float(result[i]) for i in range(len(labels))}
22
 
23
  title = "Proliferative Retinopathy Detection"
24
  description = """Detects severity of diabetic retinopathy -
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceAPI
3
 
4
+ learn = load_learner('model.pkl')
5
+ labels = learn.dls.vocab
 
 
 
 
 
6
 
7
  def predict(img):
8
+ img = PILImage.create(img)
9
+ pred,pred_idx,probs = learn.predict(img)
10
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
 
 
 
 
 
 
11
 
12
  title = "Proliferative Retinopathy Detection"
13
  description = """Detects severity of diabetic retinopathy -