wi-lab commited on
Commit
6cafefe
·
verified ·
1 Parent(s): c82ad5f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -12
app.py CHANGED
@@ -59,7 +59,7 @@ def compute_f1_score(cm):
59
  f1 = np.nan_to_num(f1) # Replace NaN with 0
60
  return np.mean(f1) # Return the mean F1-score across all classes
61
 
62
- def plot_confusion_matrix_beamPred(cm, classes, title, save_path, user_mode="light"):
63
  # Compute the average F1-score
64
  avg_f1 = compute_f1_score(cm)
65
 
@@ -559,21 +559,12 @@ with gr.Blocks(css="""
559
  task_complexity_dropdown = gr.Dropdown(label="Task Complexity (Number of Beams)", choices=[16, 32, 64, 128, 256], value=16)
560
 
561
  with gr.Row():
562
-
563
- mode_input = gr.Textbox(visible=False) # Hidden input to capture user mode
564
- gr.Markdown("""
565
- <script>
566
- const userPrefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
567
- document.querySelector('input[name="mode_input"]').value = userPrefersDark ? 'dark' : 'light';
568
- </script>
569
- """)
570
-
571
  raw_img_bp = gr.Image(label="Raw Channels", type="pil", width=300, height=500)
572
  embeddings_img_bp = gr.Image(label="Embeddings", type="pil", width=300, height=500)
573
 
574
  # Update the confusion matrices whenever sliders change
575
- data_percentage_slider.change(fn=beam_prediction_task, inputs=[data_percentage_slider, task_complexity_dropdown, mode_input], outputs=[raw_img_bp, embeddings_img_bp])
576
- task_complexity_dropdown.change(fn=beam_prediction_task, inputs=[data_percentage_slider, task_complexity_dropdown, mode_input], outputs=[raw_img_bp, embeddings_img_bp])
577
 
578
  # Add a conclusion section at the bottom
579
  gr.Markdown("""
 
59
  f1 = np.nan_to_num(f1) # Replace NaN with 0
60
  return np.mean(f1) # Return the mean F1-score across all classes
61
 
62
+ def plot_confusion_matrix_beamPred(cm, classes, title, save_path, user_mode="dark"):
63
  # Compute the average F1-score
64
  avg_f1 = compute_f1_score(cm)
65
 
 
559
  task_complexity_dropdown = gr.Dropdown(label="Task Complexity (Number of Beams)", choices=[16, 32, 64, 128, 256], value=16)
560
 
561
  with gr.Row():
 
 
 
 
 
 
 
 
 
562
  raw_img_bp = gr.Image(label="Raw Channels", type="pil", width=300, height=500)
563
  embeddings_img_bp = gr.Image(label="Embeddings", type="pil", width=300, height=500)
564
 
565
  # Update the confusion matrices whenever sliders change
566
+ data_percentage_slider.change(fn=beam_prediction_task, inputs=[data_percentage_slider, task_complexity_dropdown], outputs=[raw_img_bp, embeddings_img_bp])
567
+ task_complexity_dropdown.change(fn=beam_prediction_task, inputs=[data_percentage_slider, task_complexity_dropdown], outputs=[raw_img_bp, embeddings_img_bp])
568
 
569
  # Add a conclusion section at the bottom
570
  gr.Markdown("""