Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,22 @@
|
|
1 |
-
pip install fastai
|
2 |
-
|
3 |
from fastai.vision.all import *
|
4 |
import gradio as gr
|
5 |
|
6 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
def classify_images(img_ultrasound, img_oct, img_fundus, img_fluorescence):
|
9 |
imgs = [img_ultrasound, img_oct, img_fundus, img_fluorescence]
|
10 |
-
modality_keys = ['Ultrasound', 'OCT', 'Fundus', 'Fluorescence']
|
11 |
predictions = []
|
12 |
|
13 |
-
# Predict with each model
|
14 |
for img, key in zip(imgs, modality_keys):
|
15 |
-
|
|
|
16 |
predictions.append(pred)
|
17 |
|
18 |
# Majority vote for final decision
|
@@ -27,4 +31,4 @@ output = gr.outputs.Text(label="Final Decision")
|
|
27 |
intf = gr.Interface(fn=classify_images, inputs=inputs, outputs=output,
|
28 |
title="ODD Detection from Multiple Imaging Modalities",
|
29 |
description="Upload images for each modality and receive a binary prediction for Optic Disk Drusen presence.")
|
30 |
-
intf.launch(
|
|
|
|
|
|
|
1 |
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
|
4 |
+
# Load your models here. Example:
|
5 |
+
# models = {'Ultrasound': load_learner('path_to_ultrasound_model.pkl'),
|
6 |
+
# 'OCT': load_learner('path_to_oct_model.pkl'),
|
7 |
+
# 'Fundus': load_learner('path_to_fundus_model.pkl'),
|
8 |
+
# 'Fluorescence': load_learner('path_to_fluorescence_model.pkl')}
|
9 |
+
|
10 |
+
modality_keys = ['Ultrasound', 'OCT', 'Fundus', 'Fluorescence']
|
11 |
|
12 |
def classify_images(img_ultrasound, img_oct, img_fundus, img_fluorescence):
|
13 |
imgs = [img_ultrasound, img_oct, img_fundus, img_fluorescence]
|
|
|
14 |
predictions = []
|
15 |
|
16 |
+
# Convert images to PILImage and Predict with each model
|
17 |
for img, key in zip(imgs, modality_keys):
|
18 |
+
pil_img = PILImage.create(img)
|
19 |
+
pred, _, _ = models[key].predict(pil_img)
|
20 |
predictions.append(pred)
|
21 |
|
22 |
# Majority vote for final decision
|
|
|
31 |
intf = gr.Interface(fn=classify_images, inputs=inputs, outputs=output,
|
32 |
title="ODD Detection from Multiple Imaging Modalities",
|
33 |
description="Upload images for each modality and receive a binary prediction for Optic Disk Drusen presence.")
|
34 |
+
intf.launch(share=True)
|