Spaces:
Runtime error
Runtime error
Commit
•
fcff974
1
Parent(s):
c4f6a3f
Update app.py
Browse files
app.py
CHANGED
@@ -161,75 +161,46 @@ dataset = st.sidebar.selectbox(
|
|
161 |
index=0,
|
162 |
)
|
163 |
|
164 |
-
selectable_configs = list(set(dataset_df["config"]))
|
165 |
-
selectable_configs.sort(key=lambda name: name.lower())
|
166 |
-
selectable_configs.remove("-unspecified-")
|
167 |
-
selectable_configs = [config for config in selectable_configs if config in LANGUAGES]
|
168 |
-
|
169 |
-
visual_configs = [f"{config}: {LANGUAGES[config]}" for config in selectable_configs]
|
170 |
-
|
171 |
-
config = st.sidebar.selectbox(
|
172 |
-
"Language",
|
173 |
-
visual_configs,
|
174 |
-
index=0,
|
175 |
-
help="Filter the results on the current leaderboard by language."
|
176 |
-
)
|
177 |
-
|
178 |
-
config = config.split(":")[0]
|
179 |
-
|
180 |
-
dataset_df = dataset_df[dataset_df.config == config]
|
181 |
-
|
182 |
split = st.sidebar.selectbox(
|
183 |
"Split",
|
184 |
[split],
|
185 |
index=0,
|
186 |
)
|
187 |
|
188 |
-
|
189 |
-
|
190 |
-
not_selectable_metrics.extend(["wer_without_norm", "mer"])
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
sorting_metric = st.sidebar.radio(
|
198 |
-
"Sorting Metric",
|
199 |
-
selectable_metrics,
|
200 |
-
index=selectable_metrics.index(default_metric) if default_metric in selectable_metrics else 0,
|
201 |
-
help="Select the metric to sort the leaderboard by. Click on the metric name in the leaderboard to reverse the sorting order."
|
202 |
-
)
|
203 |
|
204 |
-
|
|
|
205 |
|
206 |
-
|
|
|
207 |
|
208 |
-
|
209 |
-
f"This is the leaderboard for {LANGUAGES[config]} ({config})."
|
210 |
-
)
|
211 |
|
212 |
-
|
213 |
-
|
214 |
-
)
|
|
|
|
|
|
|
215 |
|
216 |
-
|
217 |
-
|
218 |
-
)
|
219 |
|
220 |
-
|
221 |
-
cols = dataset_df.columns.tolist()
|
222 |
-
cols.remove(sorting_metric)
|
223 |
-
sorting_metric_index = 1 if dataset != "-any-" else 2
|
224 |
-
cols = cols[:sorting_metric_index] + [sorting_metric] + cols[sorting_metric_index:]
|
225 |
-
dataset_df = dataset_df[cols]
|
226 |
|
227 |
-
|
228 |
-
dataset_df = dataset_df.sort_values(by=cols[sorting_metric_index:], ascending=[metric in ascending_metrics for metric in cols[sorting_metric_index:]])
|
229 |
-
dataset_df = dataset_df.replace(np.nan, '-')
|
230 |
|
231 |
# Make the leaderboard
|
232 |
-
gb = GridOptionsBuilder.from_dataframe(
|
233 |
gb.configure_default_column(sortable=False)
|
234 |
gb.configure_column(
|
235 |
"model_id",
|
@@ -242,9 +213,9 @@ for name in selectable_metrics:
|
|
242 |
gb.configure_column(
|
243 |
sorting_metric,
|
244 |
sortable=True,
|
245 |
-
cellStyle=JsCode('''function(params) { return {'backgroundColor': '#FFD21E'}}''')
|
246 |
)
|
247 |
|
248 |
go = gb.build()
|
249 |
-
fit_columns = len(
|
250 |
-
AgGrid(
|
|
|
161 |
index=0,
|
162 |
)
|
163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
split = st.sidebar.selectbox(
|
165 |
"Split",
|
166 |
[split],
|
167 |
index=0,
|
168 |
)
|
169 |
|
170 |
+
selectable_metrics = ["wer", "cer"]
|
171 |
+
sorting_metric = "wer"
|
|
|
172 |
|
173 |
+
selectable_configs = list(set(dataset_df["config"]))
|
174 |
+
selectable_configs.sort(key=lambda name: name.lower())
|
175 |
+
selectable_configs.remove("-unspecified-")
|
176 |
+
selectable_configs = [config for config in selectable_configs if config in LANGUAGES]
|
177 |
+
visual_configs = [f"{config}: {LANGUAGES[config]}" for config in selectable_configs]
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
+
dataset_df = dataset_df[["config", "model_id"] + selectable_metrics]
|
180 |
+
all_ds = []
|
181 |
|
182 |
+
for config in selectable_configs:
|
183 |
+
dataset_df_ds = dataset_df[dataset_df.config == config]
|
184 |
|
185 |
+
dataset_df_ds = dataset_df_ds.dropna(thresh=2) # Want at least two non-na values (one for model_id and one for a metric)
|
|
|
|
|
186 |
|
187 |
+
# Make the default metric appear right after model names and dataset names
|
188 |
+
cols = dataset_df_ds.columns.tolist()
|
189 |
+
cols.remove(sorting_metric)
|
190 |
+
sorting_metric_index = 1 if dataset != "-any-" else 2
|
191 |
+
cols = cols[:sorting_metric_index] + [sorting_metric] + cols[sorting_metric_index:]
|
192 |
+
dataset_df_ds = dataset_df_ds[cols]
|
193 |
|
194 |
+
# Sort the leaderboard, giving the sorting metric highest priority and then ordering by other metrics in the case of equal values.
|
195 |
+
dataset_df_ds = dataset_df_ds.sort_values(by=cols[sorting_metric_index:], ascending=[metric in ascending_metrics for metric in cols[sorting_metric_index:]])
|
196 |
+
dataset_df_ds = dataset_df_ds.replace(np.nan, '-')
|
197 |
|
198 |
+
all_ds.append(dataset_df_ds.iloc[0])
|
|
|
|
|
|
|
|
|
|
|
199 |
|
200 |
+
all_ds = pd.DataFrame(all_ds, columns=["config", "model_id", "wer", "cer"])
|
|
|
|
|
201 |
|
202 |
# Make the leaderboard
|
203 |
+
gb = GridOptionsBuilder.from_dataframe(all_ds)
|
204 |
gb.configure_default_column(sortable=False)
|
205 |
gb.configure_column(
|
206 |
"model_id",
|
|
|
213 |
gb.configure_column(
|
214 |
sorting_metric,
|
215 |
sortable=True,
|
216 |
+
#cellStyle=JsCode('''function(params) { return {'backgroundColor': '#FFD21E'}}''')
|
217 |
)
|
218 |
|
219 |
go = gb.build()
|
220 |
+
fit_columns = len(all_ds.columns) < 10
|
221 |
+
AgGrid(all_ds, gridOptions=go, height=28*len(all_ds) + (35 if fit_columns else 41), allow_unsafe_jscode=True, fit_columns_on_grid_load=fit_columns, enable_enterprise_modules=False)
|