Spaces:
Running
Running
Improve table styling and scrolling
Browse files
app.py
CHANGED
|
@@ -45,11 +45,40 @@ def build_tab(df, name):
|
|
| 45 |
if df.empty:
|
| 46 |
return gr.TabItem(name)
|
| 47 |
|
|
|
|
| 48 |
datasets = sorted(df["Dataset"].unique().tolist())
|
| 49 |
models = sorted(df["Model"].unique().tolist())
|
| 50 |
organizations = sorted(df["Organization"].unique().tolist())
|
| 51 |
metric_cols = [col for col in df.columns if col not in ["Model", "Organization", "Dataset"]]
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
with gr.TabItem(name, elem_id="llm-benchmark-tab-table"):
|
| 55 |
with gr.Row():
|
|
@@ -68,7 +97,7 @@ def build_tab(df, name):
|
|
| 68 |
)
|
| 69 |
|
| 70 |
table = gr.Dataframe(
|
| 71 |
-
value=
|
| 72 |
wrap=True,
|
| 73 |
interactive=False,
|
| 74 |
elem_id="leaderboard-table"
|
|
@@ -91,22 +120,28 @@ def build_tab(df, name):
|
|
| 91 |
elem_classes="filter-group"
|
| 92 |
)
|
| 93 |
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
)
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
|
| 112 |
custom_css = """
|
|
@@ -116,6 +151,49 @@ custom_css = """
|
|
| 116 |
|
| 117 |
#leaderboard-table {
|
| 118 |
margin-top: 15px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
}
|
| 120 |
|
| 121 |
#search-bar {
|
|
@@ -127,13 +205,6 @@ custom_css = """
|
|
| 127 |
border-radius: 8px !important;
|
| 128 |
}
|
| 129 |
|
| 130 |
-
table td:first-child,
|
| 131 |
-
table th:first-child {
|
| 132 |
-
max-width: 400px;
|
| 133 |
-
overflow: auto;
|
| 134 |
-
white-space: nowrap;
|
| 135 |
-
}
|
| 136 |
-
|
| 137 |
.tab-buttons button {
|
| 138 |
font-size: 20px;
|
| 139 |
}
|
|
@@ -186,8 +257,18 @@ with demo:
|
|
| 186 |
|
| 187 |
To submit your model's results to the Mars Vision Leaderboard, please provide the following information.
|
| 188 |
All submissions will be reviewed before being added to the leaderboard.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
-
|
| 191 |
""")
|
| 192 |
|
| 193 |
with gr.Row():
|
|
@@ -251,14 +332,6 @@ with demo:
|
|
| 251 |
)
|
| 252 |
|
| 253 |
gr.Markdown("""
|
| 254 |
-
### How to submit:
|
| 255 |
-
1. Fill out the form above
|
| 256 |
-
2. Click "Generate Submission Text"
|
| 257 |
-
3. Copy the generated text
|
| 258 |
-
4. Go to the [Community tab](https://huggingface.co/spaces/gremlin97/MarsBoard/discussions)
|
| 259 |
-
5. Click "New discussion"
|
| 260 |
-
6. Paste the text and submit
|
| 261 |
-
|
| 262 |
We'll review your submission and add it to the leaderboard if approved.
|
| 263 |
""")
|
| 264 |
|
|
|
|
| 45 |
if df.empty:
|
| 46 |
return gr.TabItem(name)
|
| 47 |
|
| 48 |
+
# Pivot the dataframe to have columns like "Dataset1 (Metric1)", "Dataset1 (Metric2)", etc.
|
| 49 |
datasets = sorted(df["Dataset"].unique().tolist())
|
| 50 |
models = sorted(df["Model"].unique().tolist())
|
| 51 |
organizations = sorted(df["Organization"].unique().tolist())
|
| 52 |
metric_cols = [col for col in df.columns if col not in ["Model", "Organization", "Dataset"]]
|
| 53 |
+
|
| 54 |
+
# Create pivoted dataframe
|
| 55 |
+
pivoted_data = []
|
| 56 |
+
for model in models:
|
| 57 |
+
for org in organizations:
|
| 58 |
+
model_org_data = df[(df["Model"] == model) & (df["Organization"] == org)]
|
| 59 |
+
if not model_org_data.empty:
|
| 60 |
+
row = {"Model": model, "Organization": org}
|
| 61 |
+
for dataset in datasets:
|
| 62 |
+
dataset_data = model_org_data[model_org_data["Dataset"] == dataset]
|
| 63 |
+
if not dataset_data.empty:
|
| 64 |
+
for metric in metric_cols:
|
| 65 |
+
col_name = f"{dataset} ({metric})"
|
| 66 |
+
row[col_name] = dataset_data[metric].values[0]
|
| 67 |
+
else:
|
| 68 |
+
for metric in metric_cols:
|
| 69 |
+
col_name = f"{dataset} ({metric})"
|
| 70 |
+
row[col_name] = "-"
|
| 71 |
+
pivoted_data.append(row)
|
| 72 |
+
|
| 73 |
+
pivoted_df = pd.DataFrame(pivoted_data)
|
| 74 |
+
|
| 75 |
+
# Build column list for selector
|
| 76 |
+
metric_combo_cols = []
|
| 77 |
+
for dataset in datasets:
|
| 78 |
+
for metric in metric_cols:
|
| 79 |
+
metric_combo_cols.append(f"{dataset} ({metric})")
|
| 80 |
+
|
| 81 |
+
all_cols = ["Model", "Organization"] + metric_combo_cols
|
| 82 |
|
| 83 |
with gr.TabItem(name, elem_id="llm-benchmark-tab-table"):
|
| 84 |
with gr.Row():
|
|
|
|
| 97 |
)
|
| 98 |
|
| 99 |
table = gr.Dataframe(
|
| 100 |
+
value=pivoted_df,
|
| 101 |
wrap=True,
|
| 102 |
interactive=False,
|
| 103 |
elem_id="leaderboard-table"
|
|
|
|
| 120 |
elem_classes="filter-group"
|
| 121 |
)
|
| 122 |
|
| 123 |
+
def update(search, md, org, cols):
|
| 124 |
+
filtered = pivoted_df.copy()
|
| 125 |
+
|
| 126 |
+
if search:
|
| 127 |
+
mask = filtered.apply(lambda row: row.astype(str).str.contains(search, case=False).any(), axis=1)
|
| 128 |
+
filtered = filtered[mask]
|
|
|
|
| 129 |
|
| 130 |
+
if md:
|
| 131 |
+
filtered = filtered[filtered["Model"].isin(md)]
|
| 132 |
+
if org:
|
| 133 |
+
filtered = filtered[filtered["Organization"].isin(org)]
|
| 134 |
|
| 135 |
+
if cols:
|
| 136 |
+
display_cols = [col for col in cols if col in filtered.columns]
|
| 137 |
+
filtered = filtered[display_cols]
|
| 138 |
+
|
| 139 |
+
return filtered
|
| 140 |
+
|
| 141 |
+
search_bar.change(update, [search_bar, model_filter, org_filter, col_selector], table)
|
| 142 |
+
model_filter.change(update, [search_bar, model_filter, org_filter, col_selector], table)
|
| 143 |
+
org_filter.change(update, [search_bar, model_filter, org_filter, col_selector], table)
|
| 144 |
+
col_selector.change(update, [search_bar, model_filter, org_filter, col_selector], table)
|
| 145 |
|
| 146 |
|
| 147 |
custom_css = """
|
|
|
|
| 151 |
|
| 152 |
#leaderboard-table {
|
| 153 |
margin-top: 15px;
|
| 154 |
+
max-height: 600px;
|
| 155 |
+
overflow-y: auto;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
#leaderboard-table table {
|
| 159 |
+
width: 100%;
|
| 160 |
+
table-layout: auto;
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
#leaderboard-table thead th {
|
| 164 |
+
font-weight: bold;
|
| 165 |
+
text-align: center;
|
| 166 |
+
padding: 12px 8px;
|
| 167 |
+
background-color: #f8f9fa;
|
| 168 |
+
white-space: normal;
|
| 169 |
+
word-wrap: break-word;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
#leaderboard-table tbody td {
|
| 173 |
+
text-align: center;
|
| 174 |
+
padding: 10px 8px;
|
| 175 |
+
white-space: nowrap;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
#leaderboard-table tbody td:first-child,
|
| 179 |
+
#leaderboard-table thead th:first-child {
|
| 180 |
+
text-align: left;
|
| 181 |
+
font-weight: 500;
|
| 182 |
+
min-width: 120px;
|
| 183 |
+
max-width: 200px;
|
| 184 |
+
white-space: nowrap;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
#leaderboard-table tbody td:nth-child(2),
|
| 188 |
+
#leaderboard-table thead th:nth-child(2) {
|
| 189 |
+
text-align: left;
|
| 190 |
+
min-width: 100px;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
/* Remove any interactive elements from table */
|
| 194 |
+
#leaderboard-table input[type="range"],
|
| 195 |
+
#leaderboard-table .slider {
|
| 196 |
+
display: none !important;
|
| 197 |
}
|
| 198 |
|
| 199 |
#search-bar {
|
|
|
|
| 205 |
border-radius: 8px !important;
|
| 206 |
}
|
| 207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
.tab-buttons button {
|
| 209 |
font-size: 20px;
|
| 210 |
}
|
|
|
|
| 257 |
|
| 258 |
To submit your model's results to the Mars Vision Leaderboard, please provide the following information.
|
| 259 |
All submissions will be reviewed before being added to the leaderboard.
|
| 260 |
+
""")
|
| 261 |
+
|
| 262 |
+
gr.Markdown("""
|
| 263 |
+
### How to submit:
|
| 264 |
+
1. Fill out the form below
|
| 265 |
+
2. Click "Generate Submission Text"
|
| 266 |
+
3. Copy the generated text
|
| 267 |
+
4. Go to the [Community tab](https://huggingface.co/spaces/gremlin97/MarsBoard/discussions)
|
| 268 |
+
5. Click "New discussion"
|
| 269 |
+
6. Paste the text and submit
|
| 270 |
|
| 271 |
+
---
|
| 272 |
""")
|
| 273 |
|
| 274 |
with gr.Row():
|
|
|
|
| 332 |
)
|
| 333 |
|
| 334 |
gr.Markdown("""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
We'll review your submission and add it to the leaderboard if approved.
|
| 336 |
""")
|
| 337 |
|