Spaces:
Runtime error
Runtime error
Commit
•
2fc9c42
1
Parent(s):
cd05b03
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import pandas as pd
|
2 |
import streamlit as st
|
3 |
from huggingface_hub import HfApi
|
4 |
-
from utils import ascending_metrics, metric_ranges
|
5 |
import numpy as np
|
6 |
from st_aggrid import AgGrid, GridOptionsBuilder, JsCode
|
7 |
from os.path import exists
|
@@ -155,114 +155,96 @@ dataset_df = dataset_df[dataset_df.split == split]
|
|
155 |
|
156 |
dataset_df = dataset_df.dropna(axis="columns", how="all")
|
157 |
|
158 |
-
selectable_datasets = [dataset]
|
159 |
dataset = st.sidebar.selectbox(
|
160 |
"Dataset",
|
161 |
-
|
162 |
index=0,
|
163 |
)
|
164 |
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
)
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
gb =
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
)
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
for name in selectable_metrics:
|
253 |
-
gb.configure_column(name, type=["numericColumn","numberColumnFilter","customNumericFormat"], precision=4, aggFunc='sum')
|
254 |
-
|
255 |
-
gb.configure_column(
|
256 |
-
sorting_metric,
|
257 |
-
sortable=True,
|
258 |
-
cellStyle=JsCode('''function(params) { return {'backgroundColor': '#FFD21E'}}''')
|
259 |
-
)
|
260 |
-
|
261 |
-
go = gb.build()
|
262 |
-
fit_columns = len(dataset_df.columns) < 10
|
263 |
-
AgGrid(dataset_df, gridOptions=go, height=28*len(dataset_df) + (35 if fit_columns else 41), allow_unsafe_jscode=True, fit_columns_on_grid_load=fit_columns, enable_enterprise_modules=False)
|
264 |
-
|
265 |
-
else:
|
266 |
-
st.markdown(
|
267 |
-
"No " + ("verified" if only_verified_results else "unverified") + " results to display. Try toggling the verified results filter."
|
268 |
-
)
|
|
|
1 |
import pandas as pd
|
2 |
import streamlit as st
|
3 |
from huggingface_hub import HfApi
|
4 |
+
from utils import ascending_metrics, metric_ranges, LANGUAGES
|
5 |
import numpy as np
|
6 |
from st_aggrid import AgGrid, GridOptionsBuilder, JsCode
|
7 |
from os.path import exists
|
|
|
155 |
|
156 |
dataset_df = dataset_df.dropna(axis="columns", how="all")
|
157 |
|
|
|
158 |
dataset = st.sidebar.selectbox(
|
159 |
"Dataset",
|
160 |
+
[dataset],
|
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 |
+
not_selectable_metrics = ["model_id", "dataset", "split", "config", "pipeline_tag", "only_verified"]
|
189 |
+
# also ignore irrelevant ASR metrics
|
190 |
+
not_selectable_metrics.extend(["wer_without_norm", "mer"])
|
191 |
+
|
192 |
+
selectable_metrics = list(filter(lambda column: column not in not_selectable_metrics, dataset_df.columns))
|
193 |
+
|
194 |
+
dataset_df = dataset_df.filter(["model_id"] + (["dataset"] if dataset == "-any-" else []) + selectable_metrics)
|
195 |
+
dataset_df = dataset_df.dropna(thresh=2) # Want at least two non-na values (one for model_id and one for a metric).
|
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 |
+
current_query_params.update({"metric": [sorting_metric]})
|
205 |
+
|
206 |
+
st.experimental_set_query_params(**current_query_params)
|
207 |
+
|
208 |
+
st.markdown(
|
209 |
+
f"This is the leaderboard for {LANGUAGES[config]} ({config})."
|
210 |
+
)
|
211 |
+
|
212 |
+
st.markdown(
|
213 |
+
"Please click on the model's name to be redirected to its model card."
|
214 |
+
)
|
215 |
+
|
216 |
+
st.markdown(
|
217 |
+
"Want to beat the leaderboard? Don't see your model here? Simply ..."
|
218 |
+
)
|
219 |
+
|
220 |
+
# Make the default metric appear right after model names and dataset names
|
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 |
+
# Sort the leaderboard, giving the sorting metric highest priority and then ordering by other metrics in the case of equal values.
|
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(dataset_df)
|
233 |
+
gb.configure_default_column(sortable=False)
|
234 |
+
gb.configure_column(
|
235 |
+
"model_id",
|
236 |
+
cellRenderer=JsCode('''function(params) {return '<a target="_blank" href="https://huggingface.co/'+params.value+'">'+params.value+'</a>'}'''),
|
237 |
+
)
|
238 |
+
|
239 |
+
for name in selectable_metrics:
|
240 |
+
gb.configure_column(name, type=["numericColumn","numberColumnFilter","customNumericFormat"], precision=4, aggFunc='sum')
|
241 |
+
|
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(dataset_df.columns) < 10
|
250 |
+
AgGrid(dataset_df, gridOptions=go, height=28*len(dataset_df) + (35 if fit_columns else 41), allow_unsafe_jscode=True, fit_columns_on_grid_load=fit_columns, enable_enterprise_modules=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|