Spaces:
Running
Running
import os | |
import streamlit as st | |
from huggingface_hub import Repository | |
from pandas import read_csv | |
from st_aggrid import AgGrid, GridOptionsBuilder, JsCode | |
st.set_page_config(layout="wide") | |
st.markdown("# π€ Whisper Event: Final Leaderboard") | |
RESULTS_REPO = "results" | |
RESULTS_URL = os.path.join( | |
"https://huggingface.co/datasets/whisper-event", RESULTS_REPO | |
) | |
HF_TOKEN = os.environ.get("HF_TOKEN") | |
results_repo = Repository( | |
local_dir="results", clone_from=RESULTS_URL, use_auth_token=HF_TOKEN | |
) | |
results_repo.git_pull() | |
query_params = st.experimental_get_query_params() | |
if "first_query_params" not in st.session_state: | |
st.session_state.first_query_params = query_params | |
first_query_params = st.session_state.first_query_params | |
selectable_datasets = ["mozilla-foundation/common_voice_11_0", "google/fleurs"] | |
selectable_metrics = ["wer", "cer"] | |
sorting_metric = selectable_metrics[0] | |
split = "test" | |
dataset = st.selectbox( | |
"Dataset", | |
selectable_datasets, | |
help="Select a dataset to see the leaderboard!" | |
) | |
dataset_df = read_csv(f"results/{dataset.split('/')[-1]}/results.csv") | |
current_query_params = {"dataset": [dataset]} | |
st.experimental_set_query_params(**current_query_params) | |
# Make the leaderboard | |
gb = GridOptionsBuilder.from_dataframe(dataset_df) | |
gb.configure_default_column(sortable=False) | |
gb.configure_column( | |
"model_id", | |
cellRenderer=JsCode('''function(params) {return '<a target="_blank" href="https://huggingface.co/'+params.value+'">'+params.value+'</a>'}'''), | |
) | |
for name in selectable_metrics: | |
gb.configure_column(name, type=["numericColumn", "numberColumnFilter", "customNumericFormat"], precision=2, aggFunc='sum') | |
gb.configure_column( | |
sorting_metric, | |
sortable=True, | |
) | |
go = gb.build() | |
fit_columns = len(dataset_df.columns) < 10 | |
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) | |