Spaces:
Running
Running
sanchit-gandhi
commited on
Commit
·
fcfc2f6
1
Parent(s):
ae10915
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import streamlit as st
|
3 |
+
from huggingface_hub import Repository
|
4 |
+
from pandas import read_csv
|
5 |
+
from st_aggrid import AgGrid, GridOptionsBuilder, JsCode
|
6 |
+
|
7 |
+
st.set_page_config(layout="wide")
|
8 |
+
|
9 |
+
|
10 |
+
st.markdown("# 🤗 Whisper Event: Final Leaderboard")
|
11 |
+
|
12 |
+
RESULTS_REPO = "results"
|
13 |
+
RESULTS_URL = os.path.join(
|
14 |
+
"https://huggingface.co/datasets/whisper-event", RESULTS_REPO
|
15 |
+
)
|
16 |
+
|
17 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
18 |
+
|
19 |
+
results_repo = Repository(
|
20 |
+
local_dir="results", clone_from=RESULTS_URL, use_auth_token=HF_TOKEN
|
21 |
+
)
|
22 |
+
|
23 |
+
results_repo.git_pull()
|
24 |
+
|
25 |
+
query_params = st.experimental_get_query_params()
|
26 |
+
if "first_query_params" not in st.session_state:
|
27 |
+
st.session_state.first_query_params = query_params
|
28 |
+
first_query_params = st.session_state.first_query_params
|
29 |
+
|
30 |
+
selectable_datasets = ["mozilla-foundation/common_voice_11_0", "google/fleurs"]
|
31 |
+
selectable_metrics = ["wer", "cer"]
|
32 |
+
sorting_metric = selectable_metrics[0]
|
33 |
+
split = "test"
|
34 |
+
|
35 |
+
dataset = st.selectbox(
|
36 |
+
"Dataset",
|
37 |
+
selectable_datasets,
|
38 |
+
help="Select a dataset to see the leaderboard!"
|
39 |
+
)
|
40 |
+
|
41 |
+
dataset_df = read_csv(f"results/{dataset.split('/')[-1]}/results.csv")
|
42 |
+
|
43 |
+
current_query_params = {"dataset": [dataset]}
|
44 |
+
st.experimental_set_query_params(**current_query_params)
|
45 |
+
|
46 |
+
# Make the leaderboard
|
47 |
+
gb = GridOptionsBuilder.from_dataframe(dataset_df)
|
48 |
+
gb.configure_default_column(sortable=False)
|
49 |
+
gb.configure_column(
|
50 |
+
"model_id",
|
51 |
+
cellRenderer=JsCode('''function(params) {return '<a target="_blank" href="https://huggingface.co/'+params.value+'">'+params.value+'</a>'}'''),
|
52 |
+
)
|
53 |
+
|
54 |
+
for name in selectable_metrics:
|
55 |
+
gb.configure_column(name, type=["numericColumn", "numberColumnFilter", "customNumericFormat"], precision=2, aggFunc='sum')
|
56 |
+
|
57 |
+
gb.configure_column(
|
58 |
+
sorting_metric,
|
59 |
+
sortable=True,
|
60 |
+
)
|
61 |
+
|
62 |
+
go = gb.build()
|
63 |
+
fit_columns = len(dataset_df.columns) < 10
|
64 |
+
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)
|