Ethium commited on
Commit
0325a51
1 Parent(s): 0345dbf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+ # Assuming models are loaded into a dictionary named `models` as before
5
+
6
+ def classify_images(img_ultrasound, img_oct, img_fundus, img_fluorescence):
7
+ imgs = [img_ultrasound, img_oct, img_fundus, img_fluorescence]
8
+ modality_keys = ['Ultrasound', 'OCT', 'Fundus', 'Fluorescence']
9
+ predictions = []
10
+
11
+ # Predict with each model
12
+ for img, key in zip(imgs, modality_keys):
13
+ pred, _, _ = models[key].predict(img)
14
+ predictions.append(pred)
15
+
16
+ # Majority vote for final decision
17
+ final_decision = max(set(predictions), key=predictions.count)
18
+
19
+ return f"ODD Detection: {final_decision}"
20
+
21
+ # Define the Gradio interface
22
+ inputs = [gr.inputs.Image(shape=(192, 192), label=f"{modality} Image") for modality in modality_keys]
23
+ output = gr.outputs.Text(label="Final Decision")
24
+
25
+ intf = gr.Interface(fn=classify_images, inputs=inputs, outputs=output,
26
+ title="ODD Detection from Multiple Imaging Modalities",
27
+ description="Upload images for each modality and receive a binary prediction for Optic Disk Drusen presence.")
28
+ intf.launch(inline=False)