Howieeeee commited on
Commit
4c9bd23
·
verified ·
1 Parent(s): 771f1fe

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +66 -28
app.py CHANGED
@@ -124,6 +124,20 @@ block = gr.Blocks(css="""
124
  max-width: 80%;
125
  margin: auto;
126
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  """)
128
  with block:
129
  with gr.Column(elem_classes="container"):
@@ -133,53 +147,72 @@ with block:
133
  with gr.Tabs(elem_classes="tab-buttons") as tabs:
134
  # Table 0
135
  with gr.TabItem("🏅 WorldScore Benchmark", elem_id="worldscore-tab-table", id=0):
136
- with gr.Column():
137
- model_type_filter = gr.CheckboxGroup(
138
- choices=MODEL_TYPE,
139
- value=DEFAULT_MODEL_TYPE,
140
- label="Model Type",
141
- interactive=True
142
- )
143
- ability_filter = gr.CheckboxGroup(
144
- choices=ABILITY,
145
- value=DEFAULT_ABILITY,
146
- label="Ability",
147
- interactive=True
148
- )
 
 
 
 
 
 
 
 
149
 
150
  data_component = gr.components.Dataframe(
151
  value=get_baseline_df(),
152
  headers=COLUMN_NAMES,
153
- type="pandas",
154
  datatype=DATA_TITILE_TYPE,
155
  interactive=False,
156
  visible=True,
 
157
  )
158
 
159
- def on_filter_change(model_types, abilities):
160
  df = get_baseline_df()
161
  # Filter by selected model types
162
  df = df[df['Model Type'].isin(model_types)]
163
  # Filter by selected abilities
164
  df = df[df['Ability'].isin(abilities)]
 
 
 
165
  return gr.Dataframe(
166
  value=df,
167
  headers=COLUMN_NAMES,
168
  type="pandas",
169
  datatype=DATA_TITILE_TYPE,
170
  interactive=False,
171
- visible=True
 
172
  )
173
 
174
  model_type_filter.change(
175
  fn=on_filter_change,
176
- inputs=[model_type_filter, ability_filter],
177
  outputs=data_component
178
  )
179
 
180
  ability_filter.change(
181
  fn=on_filter_change,
182
- inputs=[model_type_filter, ability_filter],
 
 
 
 
 
 
183
  outputs=data_component
184
  )
185
 
@@ -255,17 +288,22 @@ with block:
255
  )
256
 
257
 
258
- def refresh_data():
259
- value = get_baseline_df()
260
- return value, DEFAULT_MODEL_TYPE, DEFAULT_ABILITY
 
 
 
261
 
262
- with gr.Row(elem_classes="container"):
263
- data_run = gr.Button("Refresh")
264
- data_run.click(
265
- refresh_data,
266
- inputs=[],
267
- outputs=[data_component, model_type_filter, ability_filter]
268
- )
 
 
269
 
270
 
271
  block.launch()
 
124
  max-width: 80%;
125
  margin: auto;
126
  }
127
+ /* 添加以下样式来控制表格列宽 */
128
+ .gradio-dataframe {
129
+ overflow-x: auto !important;
130
+ }
131
+ .gradio-dataframe table {
132
+ width: 100% !important;
133
+ white-space: nowrap !important;
134
+ }
135
+ .gradio-dataframe td, .gradio-dataframe th {
136
+ min-width: fit-content !important;
137
+ max-width: none !important;
138
+ white-space: pre-wrap !important;
139
+ padding: 8px !important;
140
+ }
141
  """)
142
  with block:
143
  with gr.Column(elem_classes="container"):
 
147
  with gr.Tabs(elem_classes="tab-buttons") as tabs:
148
  # Table 0
149
  with gr.TabItem("🏅 WorldScore Benchmark", elem_id="worldscore-tab-table", id=0):
150
+ with gr.Row():
151
+ with gr.Column(scale=0.3):
152
+ model_type_filter = gr.CheckboxGroup(
153
+ choices=MODEL_TYPE,
154
+ value=DEFAULT_MODEL_TYPE,
155
+ label="Model Type",
156
+ interactive=True
157
+ )
158
+ ability_filter = gr.CheckboxGroup(
159
+ choices=ABILITY,
160
+ value=DEFAULT_ABILITY,
161
+ label="Ability",
162
+ interactive=True
163
+ )
164
+ with gr.Column(scale=0.7):
165
+ sort_by_filter = gr.Radio(
166
+ choices=TASK_INFO,
167
+ value=DEFAULT_INFO[0],
168
+ label="Sort by",
169
+ interactive=True
170
+ )
171
 
172
  data_component = gr.components.Dataframe(
173
  value=get_baseline_df(),
174
  headers=COLUMN_NAMES,
175
+ type="pandas",
176
  datatype=DATA_TITILE_TYPE,
177
  interactive=False,
178
  visible=True,
179
+ wrap=True
180
  )
181
 
182
+ def on_filter_change(model_types, abilities, sort_by):
183
  df = get_baseline_df()
184
  # Filter by selected model types
185
  df = df[df['Model Type'].isin(model_types)]
186
  # Filter by selected abilities
187
  df = df[df['Ability'].isin(abilities)]
188
+ # Sort by selected sort by
189
+ df = df.sort_values(by=sort_by, ascending=False)
190
+
191
  return gr.Dataframe(
192
  value=df,
193
  headers=COLUMN_NAMES,
194
  type="pandas",
195
  datatype=DATA_TITILE_TYPE,
196
  interactive=False,
197
+ visible=True,
198
+ wrap=True
199
  )
200
 
201
  model_type_filter.change(
202
  fn=on_filter_change,
203
+ inputs=[model_type_filter, ability_filter, sort_by_filter],
204
  outputs=data_component
205
  )
206
 
207
  ability_filter.change(
208
  fn=on_filter_change,
209
+ inputs=[model_type_filter, ability_filter, sort_by_filter],
210
+ outputs=data_component
211
+ )
212
+
213
+ sort_by_filter.change(
214
+ fn=on_filter_change,
215
+ inputs=[model_type_filter, ability_filter, sort_by_filter],
216
  outputs=data_component
217
  )
218
 
 
288
  )
289
 
290
 
291
+ def refresh_data():
292
+ value = get_baseline_df()
293
+ data_component.value = value
294
+ model_type_filter.value = DEFAULT_MODEL_TYPE
295
+ ability_filter.value = DEFAULT_ABILITY
296
+ sort_by_filter.value = DEFAULT_INFO[0]
297
 
298
+ return data_component, model_type_filter, ability_filter, sort_by_filter
299
+
300
+ with gr.Row(elem_classes="container"):
301
+ data_run = gr.Button("Refresh")
302
+ data_run.click(
303
+ refresh_data,
304
+ inputs=[],
305
+ outputs=[data_component, model_type_filter, ability_filter, sort_by_filter]
306
+ )
307
 
308
 
309
  block.launch()