Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceAPI
|
3 |
|
4 |
-
|
5 |
-
|
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 |
-
|
14 |
-
|
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 -
|