Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
feat: add control buttons for metric display in each category
Browse files- Add "Select All", "Clear All", and "Show AVG Only" buttons for each category
- Modify initial display to show only AVG metrics
- Update checkbox group to handle new button actions
This change improves the user experience by:
- Making it easier to switch between different metric views
- Showing simpler initial view with only AVG metrics
- Providing quick access to commonly needed display settings
app.py
CHANGED
@@ -291,30 +291,67 @@ with gr.Blocks() as demo_leaderboard:
|
|
291 |
else:
|
292 |
label = task_type.value
|
293 |
with gr.Accordion(label, open=True, elem_classes="accordion"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
with gr.Row(height=110):
|
295 |
shown_column = gr.CheckboxGroup(
|
296 |
show_label=False,
|
|
|
297 |
choices=[
|
298 |
c.name
|
299 |
for c in fields(AutoEvalColumn)
|
300 |
if not c.hidden and not c.never_hidden and not c.dummy and c.task_type == task_type
|
301 |
-
# and not c.average
|
302 |
-
# or (task_type == TaskType.AVG and c.average)
|
303 |
],
|
|
|
304 |
value=[
|
305 |
c.name
|
306 |
for c in fields(AutoEvalColumn)
|
307 |
-
if c.
|
308 |
-
and not c.hidden
|
309 |
-
and not c.never_hidden
|
310 |
and c.task_type == task_type
|
311 |
-
|
312 |
-
|
|
|
|
|
313 |
],
|
314 |
elem_id="column-select",
|
315 |
container=False,
|
316 |
)
|
317 |
shown_columns_dict[task_type.name] = shown_column
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
with gr.Row():
|
319 |
filter_columns_type = gr.CheckboxGroup(
|
320 |
label="Model types",
|
@@ -412,6 +449,27 @@ with gr.Blocks() as demo_leaderboard:
|
|
412 |
# Check query parameter once at startup and update search bar + hidden component
|
413 |
demo_leaderboard.load(fn=load_query, outputs=[search_bar, hidden_search_bar])
|
414 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
|
416 |
# Submission demo
|
417 |
|
|
|
291 |
else:
|
292 |
label = task_type.value
|
293 |
with gr.Accordion(label, open=True, elem_classes="accordion"):
|
294 |
+
with gr.Row():
|
295 |
+
gr.Button("全選択", size="sm").click(
|
296 |
+
fn=lambda t=task_type.name: toggle_category_columns(t, "all", shown_columns_dict),
|
297 |
+
outputs=shown_columns_dict[task_type.name]
|
298 |
+
)
|
299 |
+
gr.Button("全解除", size="sm").click(
|
300 |
+
fn=lambda t=task_type.name: toggle_category_columns(t, "none", shown_columns_dict),
|
301 |
+
outputs=shown_columns_dict[task_type.name]
|
302 |
+
)
|
303 |
+
gr.Button("AVGのみ", size="sm").click(
|
304 |
+
fn=lambda t=task_type.name: toggle_category_columns(t, "avg_only", shown_columns_dict),
|
305 |
+
outputs=shown_columns_dict[task_type.name]
|
306 |
+
)
|
307 |
with gr.Row(height=110):
|
308 |
shown_column = gr.CheckboxGroup(
|
309 |
show_label=False,
|
310 |
+
# choicesは全ての選択肢を含む(既存と同じ)
|
311 |
choices=[
|
312 |
c.name
|
313 |
for c in fields(AutoEvalColumn)
|
314 |
if not c.hidden and not c.never_hidden and not c.dummy and c.task_type == task_type
|
|
|
|
|
315 |
],
|
316 |
+
# valueは初期表示としてAVGのみを表示
|
317 |
value=[
|
318 |
c.name
|
319 |
for c in fields(AutoEvalColumn)
|
320 |
+
if not c.hidden and not c.never_hidden
|
|
|
|
|
321 |
and c.task_type == task_type
|
322 |
+
and (
|
323 |
+
(task_type == TaskType.AVG) or # AVGカテゴリの場合は全て
|
324 |
+
(task_type != TaskType.AVG and c.average) # その他のカテゴリはAVGのみ
|
325 |
+
)
|
326 |
],
|
327 |
elem_id="column-select",
|
328 |
container=False,
|
329 |
)
|
330 |
shown_columns_dict[task_type.name] = shown_column
|
331 |
+
# with gr.Row(height=110):
|
332 |
+
# shown_column = gr.CheckboxGroup(
|
333 |
+
# show_label=False,
|
334 |
+
# choices=[
|
335 |
+
# c.name
|
336 |
+
# for c in fields(AutoEvalColumn)
|
337 |
+
# if not c.hidden and not c.never_hidden and not c.dummy and c.task_type == task_type
|
338 |
+
# # and not c.average
|
339 |
+
# # or (task_type == TaskType.AVG and c.average)
|
340 |
+
# ],
|
341 |
+
# value=[
|
342 |
+
# c.name
|
343 |
+
# for c in fields(AutoEvalColumn)
|
344 |
+
# if c.displayed_by_default
|
345 |
+
# and not c.hidden
|
346 |
+
# and not c.never_hidden
|
347 |
+
# and c.task_type == task_type
|
348 |
+
# # and not c.average
|
349 |
+
# # or (task_type == TaskType.AVG and c.average)
|
350 |
+
# ],
|
351 |
+
# elem_id="column-select",
|
352 |
+
# container=False,
|
353 |
+
# )
|
354 |
+
# shown_columns_dict[task_type.name] = shown_column
|
355 |
with gr.Row():
|
356 |
filter_columns_type = gr.CheckboxGroup(
|
357 |
label="Model types",
|
|
|
449 |
# Check query parameter once at startup and update search bar + hidden component
|
450 |
demo_leaderboard.load(fn=load_query, outputs=[search_bar, hidden_search_bar])
|
451 |
|
452 |
+
def toggle_category_columns(task_type: str, action: str, shown_columns_dict: dict):
|
453 |
+
"""カテゴリーごとのチェックボックスを制御する関数"""
|
454 |
+
columns = [
|
455 |
+
c.name for c in fields(AutoEvalColumn)
|
456 |
+
if not c.hidden and not c.never_hidden and not c.dummy
|
457 |
+
and c.task_type.name == task_type
|
458 |
+
]
|
459 |
+
|
460 |
+
if action == "all":
|
461 |
+
return columns
|
462 |
+
elif action == "none":
|
463 |
+
return []
|
464 |
+
elif action == "avg_only":
|
465 |
+
if task_type == TaskType.AVG.name:
|
466 |
+
return columns # 全体AVGの場合
|
467 |
+
return [
|
468 |
+
c.name for c in fields(AutoEvalColumn)
|
469 |
+
if not c.hidden and not c.never_hidden and c.average
|
470 |
+
and c.task_type.name == task_type # カテゴリー別AVGの場合
|
471 |
+
]
|
472 |
+
|
473 |
|
474 |
# Submission demo
|
475 |
|