Spaces:
Running
Running
Tristan Thrush
commited on
Commit
•
c84ed95
1
Parent(s):
341b6a4
added metric sort orders, added feature to display all metrics at the same time
Browse files- app.py +28 -7
- ascending_metrics.py +10 -0
- requirements.txt +2 -1
app.py
CHANGED
@@ -4,16 +4,20 @@ from tqdm.auto import tqdm
|
|
4 |
import streamlit as st
|
5 |
from huggingface_hub import HfApi, hf_hub_download
|
6 |
from huggingface_hub.repocard import metadata_load
|
|
|
|
|
7 |
|
8 |
|
9 |
def make_clickable(model_name):
|
10 |
link = "https://huggingface.co/" + model_name
|
11 |
return f'<a target="_blank" href="{link}">{model_name}</a>'
|
12 |
|
|
|
|
|
|
|
13 |
|
14 |
def get_model_ids():
|
15 |
api = HfApi()
|
16 |
-
# TODO: switch to hf-leaderboards for the final version.
|
17 |
models = api.list_models(filter="model-index")
|
18 |
model_ids = [x.modelId for x in models]
|
19 |
return model_ids
|
@@ -101,14 +105,16 @@ dataset = st.sidebar.selectbox(
|
|
101 |
dataset_df = dataframe[dataframe.dataset == dataset]
|
102 |
dataset_df = dataset_df.dropna(axis="columns", how="all")
|
103 |
|
104 |
-
|
105 |
-
|
106 |
-
|
|
|
107 |
)
|
108 |
|
109 |
-
dataset_df = dataset_df.filter(["model_id"
|
110 |
-
dataset_df = dataset_df.dropna()
|
111 |
-
dataset_df = dataset_df.sort_values(by=metric, ascending=
|
|
|
112 |
|
113 |
st.markdown(
|
114 |
"Please click on the model's name to be redirected to its model card which includes documentation and examples on how to use it."
|
@@ -120,7 +126,22 @@ dataset_df.index += 1
|
|
120 |
|
121 |
# turn the model ids into clickable links
|
122 |
dataset_df["model_id"] = dataset_df["model_id"].apply(make_clickable)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
|
|
124 |
table_html = dataset_df.to_html(escape=False)
|
125 |
table_html = table_html.replace("<th>", '<th align="left">') # left-align the headers
|
126 |
st.write(table_html, unsafe_allow_html=True)
|
|
|
4 |
import streamlit as st
|
5 |
from huggingface_hub import HfApi, hf_hub_download
|
6 |
from huggingface_hub.repocard import metadata_load
|
7 |
+
from ascending_metrics import ascending_metrics
|
8 |
+
import numpy as np
|
9 |
|
10 |
|
11 |
def make_clickable(model_name):
|
12 |
link = "https://huggingface.co/" + model_name
|
13 |
return f'<a target="_blank" href="{link}">{model_name}</a>'
|
14 |
|
15 |
+
def make_bold(value):
|
16 |
+
return f'<b>{value}</b>'
|
17 |
+
|
18 |
|
19 |
def get_model_ids():
|
20 |
api = HfApi()
|
|
|
21 |
models = api.list_models(filter="model-index")
|
22 |
model_ids = [x.modelId for x in models]
|
23 |
return model_ids
|
|
|
105 |
dataset_df = dataframe[dataframe.dataset == dataset]
|
106 |
dataset_df = dataset_df.dropna(axis="columns", how="all")
|
107 |
|
108 |
+
selectable_metrics = list(filter(lambda column: column not in ("model_id", "dataset"), dataset_df.columns))
|
109 |
+
metric = st.sidebar.radio(
|
110 |
+
"Sorting Metric",
|
111 |
+
selectable_metrics,
|
112 |
)
|
113 |
|
114 |
+
dataset_df = dataset_df.filter(["model_id"] + selectable_metrics)
|
115 |
+
dataset_df = dataset_df.dropna(thresh=2) # Want at least two non-na values (one for model_id and one for a metric).
|
116 |
+
dataset_df = dataset_df.sort_values(by=metric, ascending=metric in ascending_metrics)
|
117 |
+
dataset_df = dataset_df.replace(np.nan, '-')
|
118 |
|
119 |
st.markdown(
|
120 |
"Please click on the model's name to be redirected to its model card which includes documentation and examples on how to use it."
|
|
|
126 |
|
127 |
# turn the model ids into clickable links
|
128 |
dataset_df["model_id"] = dataset_df["model_id"].apply(make_clickable)
|
129 |
+
dataset_df[metric] = dataset_df[metric].apply(make_bold)
|
130 |
+
|
131 |
+
# Make the selected metric appear right after model names
|
132 |
+
cols = dataset_df.columns.tolist()
|
133 |
+
cols.remove(metric)
|
134 |
+
cols = cols[:1] + [metric] + cols[1:]
|
135 |
+
dataset_df = dataset_df[cols]
|
136 |
+
|
137 |
+
# Highlight selected metric
|
138 |
+
def highlight_cols(s):
|
139 |
+
huggingface_yellow = "#FFD21E"
|
140 |
+
return "background-color: %s" % huggingface_yellow
|
141 |
+
|
142 |
+
dataset_df = dataset_df.style.applymap(highlight_cols, subset=pd.IndexSlice[:, [metric]])
|
143 |
|
144 |
+
# Turn table into html
|
145 |
table_html = dataset_df.to_html(escape=False)
|
146 |
table_html = table_html.replace("<th>", '<th align="left">') # left-align the headers
|
147 |
st.write(table_html, unsafe_allow_html=True)
|
ascending_metrics.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ascending_metrics = {
|
2 |
+
"wer",
|
3 |
+
"cer",
|
4 |
+
"loss",
|
5 |
+
"mae",
|
6 |
+
"mahalanobis",
|
7 |
+
"mse",
|
8 |
+
"perplexity",
|
9 |
+
"ter",
|
10 |
+
}
|
requirements.txt
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
pandas
|
2 |
tqdm
|
3 |
streamlit
|
4 |
-
huggingface_hub
|
|
|
|
1 |
pandas
|
2 |
tqdm
|
3 |
streamlit
|
4 |
+
huggingface_hub
|
5 |
+
numpy
|