AppleSwing commited on
Commit
7d7c6e1
·
verified ·
1 Parent(s): c723de5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -296,6 +296,7 @@ def load_from_dir(dir_path: str, selected_tasks=None, selected_frameworks=None,
296
  def auto_refresh_from_dir(dir_path, tasks, frameworks, types, precisions, search):
297
  return load_from_dir(dir_path, tasks, frameworks, types, precisions, search, force_refresh=True)
298
 
 
299
  def parse_and_generate_plot(df_data, indices_str):
300
  if not indices_str or not indices_str.strip():
301
  return generate_radar_plot([])
@@ -307,6 +308,13 @@ def parse_and_generate_plot(df_data, indices_str):
307
  return generate_radar_plot([])
308
 
309
 
 
 
 
 
 
 
 
310
  def build_app() -> gr.Blocks:
311
  # NUCLEAR CSS FIX: Overwrite all generic Gradio variables to force light mode
312
  row_css = """
@@ -490,8 +498,7 @@ def build_app() -> gr.Blocks:
490
  gr.Markdown("**How to use:** Look at the 'Row #' column in the table. Enter row numbers (e.g., 0,1,2) and click Generate.")
491
 
492
  with gr.Row():
493
- row_indices_input = gr.Textbox(label="Row Numbers", placeholder="0,1,2", scale=3)
494
- # Added elem_id="gen_btn" here for specific CSS targeting
495
  generate_btn = gr.Button("🎯 Generate", variant="primary", scale=1, elem_id="gen_btn")
496
 
497
  radar_plot = gr.Plot(value=generate_radar_plot([]), elem_classes="plot-container")
@@ -500,7 +507,9 @@ def build_app() -> gr.Blocks:
500
  df_data_state = gr.State([])
501
  inputs = [dir_path, task_filter, framework_filter, model_type_filter, precision_filter, search_input]
502
 
503
- demo.load(fn=auto_refresh_from_dir, inputs=inputs, outputs=[leaderboard_output, df_data_state])
 
 
504
  search_input.change(fn=load_from_dir, inputs=inputs, outputs=[leaderboard_output, df_data_state])
505
  task_filter.change(fn=load_from_dir, inputs=inputs, outputs=[leaderboard_output, df_data_state])
506
  framework_filter.change(fn=load_from_dir, inputs=inputs, outputs=[leaderboard_output, df_data_state])
 
296
  def auto_refresh_from_dir(dir_path, tasks, frameworks, types, precisions, search):
297
  return load_from_dir(dir_path, tasks, frameworks, types, precisions, search, force_refresh=True)
298
 
299
+
300
  def parse_and_generate_plot(df_data, indices_str):
301
  if not indices_str or not indices_str.strip():
302
  return generate_radar_plot([])
 
308
  return generate_radar_plot([])
309
 
310
 
311
+ def initial_load(dir_path, tasks, frameworks, types, precisions, search):
312
+ """Load data and generate initial radar plot with rows 0,1,2."""
313
+ table_html, df_data = auto_refresh_from_dir(dir_path, tasks, frameworks, types, precisions, search)
314
+ plot = parse_and_generate_plot(df_data, "0,1,2")
315
+ return table_html, df_data, plot
316
+
317
+
318
  def build_app() -> gr.Blocks:
319
  # NUCLEAR CSS FIX: Overwrite all generic Gradio variables to force light mode
320
  row_css = """
 
498
  gr.Markdown("**How to use:** Look at the 'Row #' column in the table. Enter row numbers (e.g., 0,1,2) and click Generate.")
499
 
500
  with gr.Row():
501
+ row_indices_input = gr.Textbox(label="Row Numbers", placeholder="0,1,2", value="0,1,2", scale=3)
 
502
  generate_btn = gr.Button("🎯 Generate", variant="primary", scale=1, elem_id="gen_btn")
503
 
504
  radar_plot = gr.Plot(value=generate_radar_plot([]), elem_classes="plot-container")
 
507
  df_data_state = gr.State([])
508
  inputs = [dir_path, task_filter, framework_filter, model_type_filter, precision_filter, search_input]
509
 
510
+ # Load data and generate initial plot on page load
511
+ demo.load(fn=initial_load, inputs=inputs, outputs=[leaderboard_output, df_data_state, radar_plot])
512
+
513
  search_input.change(fn=load_from_dir, inputs=inputs, outputs=[leaderboard_output, df_data_state])
514
  task_filter.change(fn=load_from_dir, inputs=inputs, outputs=[leaderboard_output, df_data_state])
515
  framework_filter.change(fn=load_from_dir, inputs=inputs, outputs=[leaderboard_output, df_data_state])