huckiyang commited on
Commit
a25014e
·
1 Parent(s): 35d0ee5

[data] fixing visual

Browse files
Files changed (2) hide show
  1. app.py +29 -59
  2. leaderboard_data.csv +2 -1
app.py CHANGED
@@ -16,12 +16,13 @@ from src.display.css_html_js import custom_css
16
  ### Space initialisation
17
 
18
 
19
- LEADERBOARD_DF = pd.read_csv("leaderboard_data.csv")
20
- # Ensure all data is treated as string initially for display consistency
21
- LEADERBOARD_DF = LEADERBOARD_DF.astype(str)
 
22
 
23
  BIAS_DF = pd.read_csv("bias_evaluation_data.csv")
24
- BIAS_DF = BIAS_DF.astype(str).fillna("-") # Fill NaN with '-' to be consistent with how it looks in the LaTeX table
25
 
26
 
27
  demo = gr.Blocks(css=custom_css)
@@ -32,68 +33,37 @@ with demo:
32
  with gr.Tabs(elem_classes="tab-buttons") as tabs:
33
  with gr.TabItem("🧠 Unified performance evaluation of VLM captioners", elem_id="llm-benchmark-tab-table", id=0):
34
  with gr.Column():
35
- # 1. Display the table first
36
- # Make DataFrame interactive for sorting
 
 
37
  table_output = gr.DataFrame(value=LEADERBOARD_DF, label="Leaderboard Results", interactive=True, wrap=True)
38
-
39
- gr.Markdown("---") # Visual separator
40
-
41
- # 2. Controls below the table
42
  gr.Markdown("### Display Options")
43
-
44
- all_columns_list = LEADERBOARD_DF.columns.tolist()
45
- column_selector = gr.CheckboxGroup(
46
- choices=all_columns_list,
47
- value=all_columns_list, # Initially, all columns are selected
48
- label="Select Columns to Display:"
49
- )
50
-
51
- # Assuming the first column is 'Model' for filtering
52
- # If leaderboard_data.csv might be empty or have no columns, add checks
53
- model_filter_col_name = ""
54
- model_filter_choices = []
55
- if not LEADERBOARD_DF.empty and LEADERBOARD_DF.columns.any():
56
- model_filter_col_name = LEADERBOARD_DF.columns[0]
57
- model_filter_choices = LEADERBOARD_DF[model_filter_col_name].astype(str).unique().tolist()
58
 
 
 
 
59
  model_selector = gr.CheckboxGroup(
60
  choices=model_filter_choices,
61
- value=model_filter_choices, # Initially, all models are selected
62
- label=f"Filter by {model_filter_col_name} types:" if model_filter_col_name else "Model Filter"
63
  )
64
 
65
- # Update function for the table
66
- def update_table(selected_cols, selected_models_from_filter):
67
- temp_df = LEADERBOARD_DF.copy()
68
-
69
- # Filter by selected models (from the first column)
70
- if model_filter_col_name and selected_models_from_filter:
71
- temp_df = temp_df[temp_df[model_filter_col_name].isin(selected_models_from_filter)]
72
- elif model_filter_col_name and not selected_models_from_filter: # No models selected, show empty
73
- temp_df = pd.DataFrame(columns=LEADERBOARD_DF.columns)
74
-
75
-
76
- # Select display columns
77
- # Ensure selected_cols are valid columns present in the temp_df after filtering
78
- valid_selected_cols = [col for col in selected_cols if col in temp_df.columns]
79
- if not valid_selected_cols and not temp_df.empty : # If all columns are deselected, but df is not empty, show all original columns of filtered
80
- final_df = temp_df
81
- elif not valid_selected_cols and temp_df.empty: # if all columns deselected and df is empty
82
- final_df = pd.DataFrame(columns=selected_cols) # empty df with original column names
83
  else:
84
- final_df = temp_df[valid_selected_cols]
85
-
86
- return gr.DataFrame.update(value=final_df)
87
 
88
- # Event listeners
89
- column_selector.change(
90
- fn=update_table,
91
- inputs=[column_selector, model_selector],
92
- outputs=[table_output]
93
- )
94
  model_selector.change(
95
  fn=update_table,
96
- inputs=[column_selector, model_selector],
97
  outputs=[table_output]
98
  )
99
 
@@ -122,7 +92,7 @@ with demo:
122
 
123
  # Filter by Model (for the bias table)
124
  bias_model_filter_choices = BIAS_DF["Model"].unique().tolist() if "Model" in BIAS_DF.columns else []
125
- bias_model_selector = gr.CheckboxGroup(
126
  choices=bias_model_filter_choices,
127
  value=bias_model_filter_choices,
128
  label="Filter by Model:"
@@ -157,9 +127,9 @@ with demo:
157
 
158
  return gr.DataFrame.update(value=final_df)
159
 
160
- bias_column_selector.change(fn=update_bias_table, inputs=[bias_column_selector, bias_type_selector, bias_model_selector], outputs=[bias_table_output])
161
- bias_type_selector.change(fn=update_bias_table, inputs=[bias_column_selector, bias_type_selector, bias_model_selector], outputs=[bias_table_output])
162
- bias_model_selector.change(fn=update_bias_table, inputs=[bias_column_selector, bias_type_selector, bias_model_selector], outputs=[bias_table_output])
163
 
164
  # The original gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text") is replaced by the table and its controls.
165
  # If you still want to show LLM_BENCHMARKS_TEXT, you can add it here, e.g.:
 
16
  ### Space initialisation
17
 
18
 
19
+ # Load with multi-header and set the first column ('Model') as index
20
+ LEADERBOARD_DF = pd.read_csv("leaderboard_data.csv", header=[0, 1], index_col=0)
21
+ # No need to astype(str) globally here, Gradio DataFrame handles it well.
22
+ # If specific styling or type issues arise, it can be done selectively.
23
 
24
  BIAS_DF = pd.read_csv("bias_evaluation_data.csv")
25
+ BIAS_DF = BIAS_DF.astype(str).fillna("-")
26
 
27
 
28
  demo = gr.Blocks(css=custom_css)
 
33
  with gr.Tabs(elem_classes="tab-buttons") as tabs:
34
  with gr.TabItem("🧠 Unified performance evaluation of VLM captioners", elem_id="llm-benchmark-tab-table", id=0):
35
  with gr.Column():
36
+ # Add the image display
37
+ gr.Image("table_snapshot.png", label="Original Table Snapshot", interactive=False)
38
+
39
+ # Display the table with multi-level header
40
  table_output = gr.DataFrame(value=LEADERBOARD_DF, label="Leaderboard Results", interactive=True, wrap=True)
41
+
42
+ gr.Markdown("---")
 
 
43
  gr.Markdown("### Display Options")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
+ # Removed column_selector
46
+
47
+ model_filter_choices = LEADERBOARD_DF.index.tolist()
48
  model_selector = gr.CheckboxGroup(
49
  choices=model_filter_choices,
50
+ value=model_filter_choices,
51
+ label="Filter by Model types:"
52
  )
53
 
54
+ def update_table(selected_models_from_filter):
55
+ # Filter based on index (Model names)
56
+ if selected_models_from_filter:
57
+ filtered_df = LEADERBOARD_DF.loc[LEADERBOARD_DF.index.isin(selected_models_from_filter)]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  else:
59
+ # If no models are selected, show an empty DataFrame with the same columns
60
+ filtered_df = pd.DataFrame(columns=LEADERBOARD_DF.columns)
61
+ return gr.DataFrame.update(value=filtered_df)
62
 
63
+ # Event listener (only model_selector now)
 
 
 
 
 
64
  model_selector.change(
65
  fn=update_table,
66
+ inputs=[model_selector],
67
  outputs=[table_output]
68
  )
69
 
 
92
 
93
  # Filter by Model (for the bias table)
94
  bias_model_filter_choices = BIAS_DF["Model"].unique().tolist() if "Model" in BIAS_DF.columns else []
95
+ bias_model_selector_for_bias_tab = gr.CheckboxGroup(
96
  choices=bias_model_filter_choices,
97
  value=bias_model_filter_choices,
98
  label="Filter by Model:"
 
127
 
128
  return gr.DataFrame.update(value=final_df)
129
 
130
+ bias_column_selector.change(fn=update_bias_table, inputs=[bias_column_selector, bias_type_selector, bias_model_selector_for_bias_tab], outputs=[bias_table_output])
131
+ bias_type_selector.change(fn=update_bias_table, inputs=[bias_column_selector, bias_type_selector, bias_model_selector_for_bias_tab], outputs=[bias_table_output])
132
+ bias_model_selector_for_bias_tab.change(fn=update_bias_table, inputs=[bias_column_selector, bias_type_selector, bias_model_selector_for_bias_tab], outputs=[bias_table_output])
133
 
134
  # The original gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text") is replaced by the table and its controls.
135
  # If you still want to show LLM_BENCHMARKS_TEXT, you can add it here, e.g.:
leaderboard_data.csv CHANGED
@@ -1,4 +1,5 @@
1
- Model,CLIP-S,CapS_S,CapS_A,N-avg_Alignment,Recall,Noun,Verb,N-avg_Descriptiveness,Syn,Sem,N-avg_Complexity,CH_s,FS,FS_s,Harm,N-avg_Side_effects
 
2
  MiniGPT-4,60.8,33.0,35.9,0.19,75.3,33.0,34.7,0.22,8.0,32.6,0.38,37.8,55.0,37.6,0.31,0.18
3
  InstructBLIP,59.9,36.0,35.5,0.18,82.1,34.2,34.7,0.40,7.7,46.0,0.41,58.5,62.4,43.3,0.10,0.66
4
  LLaVA-1.5,60.1,38.5,45.0,0.67,80.5,32.5,31.0,0.11,7.1,39.6,0.08,49.0,65.7,41.6,0.12,0.71
 
1
+ Model,Alignment,Alignment,Alignment,Alignment,Descriptiveness,Descriptiveness,Descriptiveness,Descriptiveness,Complexity,Complexity,Complexity,Side effects,Side effects,Side effects,Side effects,Side effects
2
+ Model,CLIP-S,CapS_S,CapS_A,N-avg,Recall,Noun,Verb,N-avg,Syn,Sem,N-avg,CHs↓,FS↑,FSs↑,Harm↓,N-avg↑
3
  MiniGPT-4,60.8,33.0,35.9,0.19,75.3,33.0,34.7,0.22,8.0,32.6,0.38,37.8,55.0,37.6,0.31,0.18
4
  InstructBLIP,59.9,36.0,35.5,0.18,82.1,34.2,34.7,0.40,7.7,46.0,0.41,58.5,62.4,43.3,0.10,0.66
5
  LLaVA-1.5,60.1,38.5,45.0,0.67,80.5,32.5,31.0,0.11,7.1,39.6,0.08,49.0,65.7,41.6,0.12,0.71