Ethium commited on
Commit
388a9c4
1 Parent(s): 977fcae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -11,6 +11,7 @@ def get_x(row):
11
  def get_y(row):
12
  return row['Buried ODD']
13
 
 
14
  # Load the models into a dictionary
15
  models = {
16
  'Ultrasound': load_learner('ODDUltrasound.pkl'),
@@ -24,17 +25,21 @@ modality_keys = ['Ultrasound', 'OCT', 'Fundus', 'Fluorescence']
24
  def classify_images(img_ultrasound, img_oct, img_fundus, img_fluorescence):
25
  imgs = [img_ultrasound, img_oct, img_fundus, img_fluorescence]
26
  predictions = []
 
27
 
28
  # Convert images to PILImage and predict with each model
29
  for img, key in zip(imgs, modality_keys):
30
  pil_img = PILImage.create(img)
31
  pred, _, _ = models[key].predict(pil_img)
32
  predictions.append(pred)
 
33
 
34
  # Majority vote for final decision
35
  final_decision = max(set(predictions), key=predictions.count)
36
 
37
- return f"ODD Detection: {final_decision}"
 
 
38
 
39
  # Adjust the Gradio interface definition by removing 'shape' argument
40
  inputs = [gr.Image(label=f"{modality} Image") for modality in modality_keys]
 
11
  def get_y(row):
12
  return row['Buried ODD']
13
 
14
+
15
  # Load the models into a dictionary
16
  models = {
17
  'Ultrasound': load_learner('ODDUltrasound.pkl'),
 
25
  def classify_images(img_ultrasound, img_oct, img_fundus, img_fluorescence):
26
  imgs = [img_ultrasound, img_oct, img_fundus, img_fluorescence]
27
  predictions = []
28
+ detailed_predictions = [] # To store detailed predictions for each modality
29
 
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, _, _ = models[key].predict(pil_img)
34
  predictions.append(pred)
35
+ detailed_predictions.append(f"{key}: {pred}") # Add the prediction with the modality name
36
 
37
  # Majority vote for final decision
38
  final_decision = max(set(predictions), key=predictions.count)
39
 
40
+ detailed_predictions.append(f"Final Decision: {final_decision}") # Add the final decision
41
+
42
+ return "\n".join(detailed_predictions) # Return detailed predictions as a single string
43
 
44
  # Adjust the Gradio interface definition by removing 'shape' argument
45
  inputs = [gr.Image(label=f"{modality} Image") for modality in modality_keys]