Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -30,9 +30,12 @@ def classify_images(img_ultrasound, img_oct, img_fundus, img_fluorescence):
|
|
30 |
# Convert images to PILImage and predict with each model
|
31 |
for img, key in zip(imgs, modality_keys):
|
32 |
pil_img = PILImage.create(img)
|
33 |
-
pred, _,
|
34 |
predictions.append(pred)
|
35 |
-
|
|
|
|
|
|
|
36 |
|
37 |
# Majority vote for final decision
|
38 |
final_decision = max(set(predictions), key=predictions.count)
|
@@ -41,11 +44,11 @@ def classify_images(img_ultrasound, img_oct, img_fundus, img_fluorescence):
|
|
41 |
|
42 |
return "\n".join(detailed_predictions) # Return detailed predictions as a single string
|
43 |
|
44 |
-
#
|
45 |
inputs = [gr.Image(label=f"{modality} Image") for modality in modality_keys]
|
46 |
-
output = gr.Text(label="
|
47 |
|
48 |
intf = gr.Interface(fn=classify_images, inputs=inputs, outputs=output,
|
49 |
title="ODD Detection from Multiple Imaging Modalities",
|
50 |
-
description="Upload images for each modality and receive a binary prediction for Optic Disk Drusen presence.")
|
51 |
-
intf.launch(share=True)
|
|
|
30 |
# Convert images to PILImage and predict with each model
|
31 |
for img, key in zip(imgs, modality_keys):
|
32 |
pil_img = PILImage.create(img)
|
33 |
+
pred, _, probs = models[key].predict(pil_img)
|
34 |
predictions.append(pred)
|
35 |
+
|
36 |
+
# Assuming binary classification, extract the probability for the predicted class
|
37 |
+
prob_pred = probs.max() # Get the highest probability score
|
38 |
+
detailed_predictions.append(f"{key}: {pred} ({prob_pred:.2f}%)") # Format prediction with percentage
|
39 |
|
40 |
# Majority vote for final decision
|
41 |
final_decision = max(set(predictions), key=predictions.count)
|
|
|
44 |
|
45 |
return "\n".join(detailed_predictions) # Return detailed predictions as a single string
|
46 |
|
47 |
+
# Define the Gradio interface inputs and outputs
|
48 |
inputs = [gr.Image(label=f"{modality} Image") for modality in modality_keys]
|
49 |
+
output = gr.Text(label="Predictions")
|
50 |
|
51 |
intf = gr.Interface(fn=classify_images, inputs=inputs, outputs=output,
|
52 |
title="ODD Detection from Multiple Imaging Modalities",
|
53 |
+
description="Upload images for each modality and receive individual predictions with percentages and a binary prediction for Optic Disk Drusen presence.")
|
54 |
+
intf.launch(share=True)
|