yangzhitao commited on
Commit
ba366ad
·
1 Parent(s): 58bbf33

refactor: update benchmark display in submit tab

Browse files
Files changed (2) hide show
  1. app.py +4 -4
  2. src/schemas/meta_toml.py +10 -1
app.py CHANGED
@@ -466,11 +466,11 @@ def create_submit_tab(tab_id: int, demo: gr.Blocks):
466
  for benchmark in benchmarks_list:
467
  with gr.Row():
468
  benchmark_checkbox = gr.Checkbox(
469
- label=f"{benchmark.title} ({benchmark.key})",
470
  value=False,
471
  )
472
  result_input = gr.Number(
473
- label="Result Value",
474
  value=None,
475
  interactive=True,
476
  visible=False,
@@ -567,8 +567,8 @@ def create_submit_tab(tab_id: int, demo: gr.Blocks):
567
  strict=True,
568
  ):
569
  if checkbox_checked:
570
- # TODO: metric
571
- results[benchmark.key] = {"acc": float(result_value) if result_value is not None else None}
572
 
573
  if not results:
574
  raise ValueError("At least one benchmark result is required.")
 
466
  for benchmark in benchmarks_list:
467
  with gr.Row():
468
  benchmark_checkbox = gr.Checkbox(
469
+ label=f"{benchmark.title} ({benchmark.default_metric_label})",
470
  value=False,
471
  )
472
  result_input = gr.Number(
473
+ label="Result Value (in %, e.g. 42.0 for 42.0%)",
474
  value=None,
475
  interactive=True,
476
  visible=False,
 
567
  strict=True,
568
  ):
569
  if checkbox_checked:
570
+ metric_key = benchmark.default_metric
571
+ results[benchmark.key] = {metric_key: float(result_value) if result_value is not None else None}
572
 
573
  if not results:
574
  raise ValueError("At least one benchmark result is required.")
src/schemas/meta_toml.py CHANGED
@@ -1,6 +1,6 @@
1
  from functools import cached_property
2
 
3
- from pydantic import BaseModel, ConfigDict
4
  from typing_extensions import Self
5
 
6
 
@@ -84,6 +84,15 @@ class _HashableComparableMixin(BaseModel):
84
  class MetaToml_Benchmark(_HashableComparableMixin):
85
  disabled: bool = False
86
 
 
 
 
 
 
 
 
 
 
87
 
88
  class MetaToml_Model(_HashableComparableMixin): ...
89
 
 
1
  from functools import cached_property
2
 
3
+ from pydantic import BaseModel, ConfigDict, computed_field
4
  from typing_extensions import Self
5
 
6
 
 
84
  class MetaToml_Benchmark(_HashableComparableMixin):
85
  disabled: bool = False
86
 
87
+ @computed_field
88
+ @property
89
+ def default_metric(self) -> str:
90
+ return "caa" if self.key.startswith("site") else "acc"
91
+
92
+ @property
93
+ def default_metric_label(self) -> str:
94
+ return "CAA" if self.default_metric == "caa" else "Acc."
95
+
96
 
97
  class MetaToml_Model(_HashableComparableMixin): ...
98