anton-l HF staff commited on
Commit
f85a0f8
β€’
1 Parent(s): c848fd7

Add config support

Browse files
Files changed (1) hide show
  1. app.py +24 -11
app.py CHANGED
@@ -61,16 +61,24 @@ def parse_metric_value(value):
61
  def parse_metrics_rows(meta):
62
  if "model-index" not in meta or "language" not in meta:
63
  return None
64
- lang = meta["language"]
65
- lang = lang[0] if isinstance(lang, list) else lang
66
- lang = aliases_lang[lang] if lang in aliases_lang else lang
67
  for result in meta["model-index"][0]["results"]:
68
  if "dataset" not in result or "metrics" not in result:
69
  continue
70
  dataset = result["dataset"]["type"]
71
- if "args" not in result["dataset"]:
72
- continue
73
- row = {"dataset": dataset, "lang": lang}
 
 
 
 
 
 
 
 
 
 
 
74
  for metric in result["metrics"]:
75
  type = metric["type"].lower().strip()
76
  if type not in ["wer", "cer"]:
@@ -174,12 +182,17 @@ dataset = st.sidebar.selectbox(
174
  dataset_df = lang_df[lang_df.dataset == dataset]
175
 
176
  # sort by WER or CER depending on the language
177
- if lang in cer_langs:
178
- dataset_df = dataset_df[["model_id", "cer"]]
179
- dataset_df.sort_values("cer", inplace=True)
 
 
 
180
  else:
181
- dataset_df = dataset_df[["model_id", "wer"]]
182
- dataset_df.sort_values("wer", inplace=True)
 
 
183
  dataset_df.rename(
184
  columns={
185
  "model_id": "Model",
 
61
  def parse_metrics_rows(meta):
62
  if "model-index" not in meta or "language" not in meta:
63
  return None
 
 
 
64
  for result in meta["model-index"][0]["results"]:
65
  if "dataset" not in result or "metrics" not in result:
66
  continue
67
  dataset = result["dataset"]["type"]
68
+ if "args" in result["dataset"] and "language" in result["dataset"]["args"]:
69
+ lang = result["dataset"]["args"]["language"]
70
+ else:
71
+ lang = meta["language"]
72
+ lang = lang[0] if isinstance(lang, list) else lang
73
+ lang = aliases_lang[lang] if lang in aliases_lang else lang
74
+ config = result["dataset"]["config"] if "config" in result["dataset"] else None
75
+ split = result["dataset"]["split"] if "split" in result["dataset"] else None
76
+ row = {
77
+ "dataset": dataset,
78
+ "lang": lang,
79
+ "config": config,
80
+ "split": split
81
+ }
82
  for metric in result["metrics"]:
83
  type = metric["type"].lower().strip()
84
  if type not in ["wer", "cer"]:
 
182
  dataset_df = lang_df[lang_df.dataset == dataset]
183
 
184
  # sort by WER or CER depending on the language
185
+ metric_col = "cer" if lang in cer_langs else "wer"
186
+ if dataset_df["config"].nunique() > 1:
187
+ # if there are more than one dataset config
188
+ dataset_df = dataset_df[["model_id", "config", metric_col]]
189
+ dataset_df = dataset_df.pivot_table(index=['model_id'], columns=["config"], values=[metric_col])
190
+ dataset_df = dataset_df.reset_index(level=0)
191
  else:
192
+ dataset_df = dataset_df[["model_id", metric_col]]
193
+ dataset_df.sort_values(dataset_df.columns[-1], inplace=True)
194
+ dataset_df = dataset_df.fillna("")
195
+
196
  dataset_df.rename(
197
  columns={
198
  "model_id": "Model",