Sadjad Alikhani commited on
Commit
c536685
·
verified ·
1 Parent(s): 9167024

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -25,7 +25,7 @@ def beam_prediction_task(data_percentage, task_complexity):
25
  raw_cm = compute_average_confusion_matrix(raw_folder)
26
  if raw_cm is not None:
27
  raw_cm_path = os.path.join(raw_folder, "confusion_matrix_raw.png")
28
- plot_confusion_matrix_beamPred(raw_cm, classes=np.arange(raw_cm.shape[0]), title=f"Raw Confusion Matrix ({data_percentage}% data, {task_complexity} beams)", save_path=raw_cm_path)
29
  raw_img = Image.open(raw_cm_path)
30
  else:
31
  raw_img = None
@@ -68,7 +68,7 @@ def plot_confusion_matrix_beamPred(cm, classes, title, save_path):
68
 
69
  # Set dark mode styling
70
  plt.style.use('dark_background')
71
- plt.figure(figsize=(5, 5))
72
 
73
  # Plot the confusion matrix with a dark-mode compatible colormap
74
  sns.heatmap(cm, cmap="magma", cbar=True, linecolor='white')
@@ -80,20 +80,17 @@ def plot_confusion_matrix_beamPred(cm, classes, title, save_path):
80
  plt.xticks(tick_marks, classes, color="white", fontsize=10) # White text for dark mode
81
  plt.yticks(tick_marks, classes, color="white", fontsize=10) # White text for dark mode
82
 
83
-
84
  plt.ylabel('True label', color="white", fontsize=12)
85
  plt.xlabel('Predicted label', color="white", fontsize=12)
86
  plt.tight_layout()
87
 
88
  # Save the plot as an image
89
- plt.savefig(save_path, transparent=True) # Use transparent to blend with the dark mode website
90
  plt.close()
91
 
92
  # Return the saved image
93
  return Image.open(save_path)
94
 
95
-
96
-
97
  def compute_average_confusion_matrix(folder):
98
  confusion_matrices = []
99
  max_num_labels = 0
 
25
  raw_cm = compute_average_confusion_matrix(raw_folder)
26
  if raw_cm is not None:
27
  raw_cm_path = os.path.join(raw_folder, "confusion_matrix_raw.png")
28
+ plot_confusion_matrix_beamPred(raw_cm, classes=np.arange(raw_cm.shape[0]), title=f"Raw Confusion Matrix\n({data_percentage}% data, {task_complexity} beams)", save_path=raw_cm_path)
29
  raw_img = Image.open(raw_cm_path)
30
  else:
31
  raw_img = None
 
68
 
69
  # Set dark mode styling
70
  plt.style.use('dark_background')
71
+ plt.figure(figsize=(7, 7), facecolor='#2f2f2f')
72
 
73
  # Plot the confusion matrix with a dark-mode compatible colormap
74
  sns.heatmap(cm, cmap="magma", cbar=True, linecolor='white')
 
80
  plt.xticks(tick_marks, classes, color="white", fontsize=10) # White text for dark mode
81
  plt.yticks(tick_marks, classes, color="white", fontsize=10) # White text for dark mode
82
 
 
83
  plt.ylabel('True label', color="white", fontsize=12)
84
  plt.xlabel('Predicted label', color="white", fontsize=12)
85
  plt.tight_layout()
86
 
87
  # Save the plot as an image
88
+ plt.savefig(save_path, facecolor='#2f2f2f', transparent=True) # Use transparent to blend with the dark mode website
89
  plt.close()
90
 
91
  # Return the saved image
92
  return Image.open(save_path)
93
 
 
 
94
  def compute_average_confusion_matrix(folder):
95
  confusion_matrices = []
96
  max_num_labels = 0