elmadany commited on
Commit
c4e9096
·
verified ·
1 Parent(s): 0f09993

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -11
app.py CHANGED
@@ -433,35 +433,43 @@ with gr.Blocks(title="Sahara Benchmark Leaderboards", css=google_style_css) as d
433
  outputs=[model_title_component, model_table_component]
434
  )
435
  # --- NEW TAB TO COMPARE MODELS ---
436
- with gr.Tab("Compare Models", id="compare", elem_id="models_comparasion_table"):
437
  gr.HTML("<br><br><center><h2>Compare Two Models</h2></center><br>")
438
  with gr.Row():
439
  model_1_dd = gr.Dropdown(MODEL_NAME_LIST, label="Select Model 1", interactive=True)
440
  model_2_dd = gr.Dropdown(MODEL_NAME_LIST, label="Select Model 2", interactive=True)
441
  compare_btn = gr.Button("Compare")
442
- # --- NEW: Add explanatory note for the 'Difference' column ---
 
443
  explanation_note = """
444
  **Note on the 'Difference' Column:**
445
  * This value is calculated as: `(Score of Model 1) - (Score of Model 2)`.
446
  * A positive value in <span style='color:green; font-weight:bold;'>green</span> indicates that **Model 1** performed better on that task.
447
  * A negative value in <span style='color:red; font-weight:bold;'>red</span> indicates that **Model 2** performed better on that task.
448
  """
449
- gr.Markdown(explanation_note)
450
- comparison_output = gr.HTML("<p style='text-align:center;'>Select two models and click Compare to see the results.</p>")
451
-
 
 
 
 
 
452
  def update_comparison_table(m1, m2):
453
  if not m1 or not m2:
454
- # Use gr.Info for a non-blocking alert
455
  gr.Info("Please select both models before clicking Compare.")
456
- return "<p style='text-align:center;'>Please select two models to compare.</p>"
457
- # Call the new comparison function
 
458
  df = compare_models(m1, m2)
459
- return df_to_html(df)
460
-
 
 
461
  compare_btn.click(
462
  fn=update_comparison_table,
463
  inputs=[model_1_dd, model_2_dd],
464
- outputs=[comparison_output]
465
  )
466
  with gr.Group(elem_classes="content-card"):
467
  gr.Markdown("<br>")
 
433
  outputs=[model_title_component, model_table_component]
434
  )
435
  # --- NEW TAB TO COMPARE MODELS ---
436
+ with gr.Tab("Compare Models", id="compare"):
437
  gr.HTML("<br><br><center><h2>Compare Two Models</h2></center><br>")
438
  with gr.Row():
439
  model_1_dd = gr.Dropdown(MODEL_NAME_LIST, label="Select Model 1", interactive=True)
440
  model_2_dd = gr.Dropdown(MODEL_NAME_LIST, label="Select Model 2", interactive=True)
441
  compare_btn = gr.Button("Compare")
442
+
443
+ # Note for the 'Difference' column
444
  explanation_note = """
445
  **Note on the 'Difference' Column:**
446
  * This value is calculated as: `(Score of Model 1) - (Score of Model 2)`.
447
  * A positive value in <span style='color:green; font-weight:bold;'>green</span> indicates that **Model 1** performed better on that task.
448
  * A negative value in <span style='color:red; font-weight:bold;'>red</span> indicates that **Model 2** performed better on that task.
449
  """
450
+ # --- MODIFIED: Make the note invisible by default ---
451
+ explanation_note_md = gr.Markdown(explanation_note, visible=False)
452
+
453
+ # Create a container with a unique ID for the comparison table
454
+ with gr.Column(elem_id="models_comparasion_table"):
455
+ comparison_output = gr.HTML("<p style='text-align:center;'>Select two models and click Compare to see the results.</p>")
456
+
457
+ # --- MODIFIED: The function now returns TWO values (visibility and html) ---
458
  def update_comparison_table(m1, m2):
459
  if not m1 or not m2:
 
460
  gr.Info("Please select both models before clicking Compare.")
461
+ # Return an update to hide the note and the placeholder text
462
+ return gr.update(visible=False), "<p style='text-align:center;'>Please select two models to compare.</p>"
463
+
464
  df = compare_models(m1, m2)
465
+ # Return an update to SHOW the note and the results table
466
+ return gr.update(visible=True), df_to_html(df)
467
+
468
+ # --- MODIFIED: Update the outputs list to target both components ---
469
  compare_btn.click(
470
  fn=update_comparison_table,
471
  inputs=[model_1_dd, model_2_dd],
472
+ outputs=[explanation_note_md, comparison_output]
473
  )
474
  with gr.Group(elem_classes="content-card"):
475
  gr.Markdown("<br>")