Spaces:
Running
Running
:lipstick: Improve frontend
Browse files- frontend/layout.py +35 -12
- frontend/leaderboard.py +12 -3
- frontend/styles.css +1 -1
frontend/layout.py
CHANGED
|
@@ -86,9 +86,12 @@ def create_leaderboard_tab(refresh_callback: Callable = None) -> gr.TabItem:
|
|
| 86 |
)
|
| 87 |
filtered = filtered[mask]
|
| 88 |
|
| 89 |
-
# Type filter
|
| 90 |
if type_filter and len(type_filter) > 0:
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
# Min AUC filter
|
| 94 |
if min_auc and min_auc > 0:
|
|
@@ -164,7 +167,9 @@ def create_leaderboard_tab(refresh_callback: Callable = None) -> gr.TabItem:
|
|
| 164 |
if (top, sub) not in selected_columns:
|
| 165 |
continue
|
| 166 |
if top not in ("", None):
|
| 167 |
-
|
|
|
|
|
|
|
| 168 |
col_idx += 1
|
| 169 |
html += "</tr>"
|
| 170 |
|
|
@@ -204,6 +209,7 @@ def create_leaderboard_tab(refresh_callback: Callable = None) -> gr.TabItem:
|
|
| 204 |
|
| 205 |
# Determine CSS class based on column type
|
| 206 |
col_name = col[1] if isinstance(col, tuple) else col
|
|
|
|
| 207 |
css_class = ""
|
| 208 |
if col_name == "Type":
|
| 209 |
css_class = "col-type"
|
|
@@ -221,7 +227,7 @@ def create_leaderboard_tab(refresh_callback: Callable = None) -> gr.TabItem:
|
|
| 221 |
css_class = "col-date"
|
| 222 |
elif col_name in ["Pretrained", "Zero-shot", "Few-shot"]:
|
| 223 |
css_class = "col-boolean"
|
| 224 |
-
elif "AUC" in col_name or "ΔAUC" in col_name or "Avg." in col_name:
|
| 225 |
css_class = "col-score"
|
| 226 |
|
| 227 |
# Get string value for title attribute (escape quotes for HTML)
|
|
@@ -272,7 +278,17 @@ def create_leaderboard_tab(refresh_callback: Callable = None) -> gr.TabItem:
|
|
| 272 |
html += f"<td class='{css_class}'{data_value_attr}{title_attr}>{formatted_val}</td>"
|
| 273 |
|
| 274 |
else:
|
| 275 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
html += f"<td class='{css_class}'{title_attr}>{display_val}</td>"
|
| 277 |
html += "</tr>"
|
| 278 |
html += "</tbody></table></div>"
|
|
@@ -427,11 +443,18 @@ def create_leaderboard_tab(refresh_callback: Callable = None) -> gr.TabItem:
|
|
| 427 |
min-width: 240px !important;
|
| 428 |
}
|
| 429 |
|
| 430 |
-
.leaderboard-table td.col-score,
|
| 431 |
-
.leaderboard-table th.col-score {
|
| 432 |
-
|
| 433 |
-
|
| 434 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
}
|
| 436 |
|
| 437 |
.leaderboard-table td.col-boolean,
|
|
@@ -498,9 +521,9 @@ def create_leaderboard_tab(refresh_callback: Callable = None) -> gr.TabItem:
|
|
| 498 |
with gr.Row():
|
| 499 |
# Type filter (multi-select checkboxes)
|
| 500 |
type_filter = gr.CheckboxGroup(
|
| 501 |
-
choices=["0️⃣", "1️⃣", "⤵️", "🔼"],
|
| 502 |
label="Model Type",
|
| 503 |
-
value=["0️⃣", "1️⃣", "⤵️", "🔼"], # All selected by default
|
| 504 |
interactive=True
|
| 505 |
)
|
| 506 |
|
|
|
|
| 86 |
)
|
| 87 |
filtered = filtered[mask]
|
| 88 |
|
| 89 |
+
# Type filter - extract just the emoji from the checkbox values
|
| 90 |
if type_filter and len(type_filter) > 0:
|
| 91 |
+
# Extract emoji by splitting on space and taking first part
|
| 92 |
+
# e.g., "0️⃣ Zero-shot" -> "0️⃣"
|
| 93 |
+
type_emojis = [t.split(' ')[0] if ' ' in t else t for t in type_filter]
|
| 94 |
+
filtered = filtered[filtered[("", "Type")].isin(type_emojis)]
|
| 95 |
|
| 96 |
# Min AUC filter
|
| 97 |
if min_auc and min_auc > 0:
|
|
|
|
| 167 |
if (top, sub) not in selected_columns:
|
| 168 |
continue
|
| 169 |
if top not in ("", None):
|
| 170 |
+
# Add col-score class to AUC columns for consistent width handling
|
| 171 |
+
extra_class = " col-score" if "AUC" in top or "ΔAUC" in top else ""
|
| 172 |
+
html += f"<th class='sortable-header{extra_class}' data-column='{col_idx}' onclick='sortTable({col_idx})'>{sub} <span class='sort-indicator'></span></th>"
|
| 173 |
col_idx += 1
|
| 174 |
html += "</tr>"
|
| 175 |
|
|
|
|
| 209 |
|
| 210 |
# Determine CSS class based on column type
|
| 211 |
col_name = col[1] if isinstance(col, tuple) else col
|
| 212 |
+
col_group = col[0] if isinstance(col, tuple) else ""
|
| 213 |
css_class = ""
|
| 214 |
if col_name == "Type":
|
| 215 |
css_class = "col-type"
|
|
|
|
| 227 |
css_class = "col-date"
|
| 228 |
elif col_name in ["Pretrained", "Zero-shot", "Few-shot"]:
|
| 229 |
css_class = "col-boolean"
|
| 230 |
+
elif "AUC" in col_name or "ΔAUC" in col_name or "Avg." in col_name or "AUC" in col_group or "ΔAUC" in col_group:
|
| 231 |
css_class = "col-score"
|
| 232 |
|
| 233 |
# Get string value for title attribute (escape quotes for HTML)
|
|
|
|
| 278 |
html += f"<td class='{css_class}'{data_value_attr}{title_attr}>{formatted_val}</td>"
|
| 279 |
|
| 280 |
else:
|
| 281 |
+
# Format score values (AUC, ΔAUC) to 3 decimal places
|
| 282 |
+
if is_empty_value(val):
|
| 283 |
+
display_val = ""
|
| 284 |
+
elif css_class == "col-score":
|
| 285 |
+
# Format as float with 3 decimal places
|
| 286 |
+
try:
|
| 287 |
+
display_val = f"{float(val):.3f}"
|
| 288 |
+
except (ValueError, TypeError):
|
| 289 |
+
display_val = val
|
| 290 |
+
else:
|
| 291 |
+
display_val = val
|
| 292 |
html += f"<td class='{css_class}'{title_attr}>{display_val}</td>"
|
| 293 |
html += "</tr>"
|
| 294 |
html += "</tbody></table></div>"
|
|
|
|
| 443 |
min-width: 240px !important;
|
| 444 |
}
|
| 445 |
|
| 446 |
+
table.leaderboard-table td.col-score,
|
| 447 |
+
table.leaderboard-table th.col-score {
|
| 448 |
+
/* Remove all width constraints - let columns auto-size based on header text */
|
| 449 |
+
max-width: 9999px !important;
|
| 450 |
+
min-width: 0 !important;
|
| 451 |
+
text-align: center !important;
|
| 452 |
+
vertical-align: middle !important;
|
| 453 |
+
white-space: nowrap !important; /* Prevent header text from wrapping */
|
| 454 |
+
overflow: visible !important; /* Override global ellipsis */
|
| 455 |
+
text-overflow: unset !important;
|
| 456 |
+
padding-left: 12px !important;
|
| 457 |
+
padding-right: 12px !important;
|
| 458 |
}
|
| 459 |
|
| 460 |
.leaderboard-table td.col-boolean,
|
|
|
|
| 521 |
with gr.Row():
|
| 522 |
# Type filter (multi-select checkboxes)
|
| 523 |
type_filter = gr.CheckboxGroup(
|
| 524 |
+
choices=["0️⃣ Zero-shot", "1️⃣ Few-shot", "⤵️ Pre-trained", "🔼 Models trained from scratch"],
|
| 525 |
label="Model Type",
|
| 526 |
+
value=["0️⃣ Zero-shot", "1️⃣ Few-shot", "⤵️ Pre-trained", "🔼 Models trained from scratch"], # All selected by default
|
| 527 |
interactive=True
|
| 528 |
)
|
| 529 |
|
frontend/leaderboard.py
CHANGED
|
@@ -65,11 +65,20 @@ def format_parameter_count(value):
|
|
| 65 |
value = float(value)
|
| 66 |
|
| 67 |
if value >= 1e9:
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
| 69 |
elif value >= 1e6:
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
| 71 |
elif value >= 1e3:
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
| 73 |
else:
|
| 74 |
return str(int(value))
|
| 75 |
|
|
|
|
| 65 |
value = float(value)
|
| 66 |
|
| 67 |
if value >= 1e9:
|
| 68 |
+
# Format as integer B if rounded to 1 decimal equals the integer, otherwise 1 decimal
|
| 69 |
+
formatted = value / 1e9
|
| 70 |
+
rounded = round(formatted, 1)
|
| 71 |
+
return f"{int(rounded)}B" if rounded == int(rounded) else f"{rounded}B"
|
| 72 |
elif value >= 1e6:
|
| 73 |
+
# Format as integer M if rounded to 1 decimal equals the integer, otherwise 1 decimal
|
| 74 |
+
formatted = value / 1e6
|
| 75 |
+
rounded = round(formatted, 1)
|
| 76 |
+
return f"{int(rounded)}M" if rounded == int(rounded) else f"{rounded}M"
|
| 77 |
elif value >= 1e3:
|
| 78 |
+
# Format as integer K if rounded to 1 decimal equals the integer, otherwise 1 decimal
|
| 79 |
+
formatted = value / 1e3
|
| 80 |
+
rounded = round(formatted, 1)
|
| 81 |
+
return f"{int(rounded)}K" if rounded == int(rounded) else f"{rounded}K"
|
| 82 |
else:
|
| 83 |
return str(int(value))
|
| 84 |
|
frontend/styles.css
CHANGED
|
@@ -138,7 +138,7 @@ a:active {
|
|
| 138 |
min-width: 100%;
|
| 139 |
border-collapse: separate; /* important */
|
| 140 |
border-spacing: 0; /* keeps it looking like collapse */
|
| 141 |
-
table-layout:
|
| 142 |
border: none !important;
|
| 143 |
}
|
| 144 |
|
|
|
|
| 138 |
min-width: 100%;
|
| 139 |
border-collapse: separate; /* important */
|
| 140 |
border-spacing: 0; /* keeps it looking like collapse */
|
| 141 |
+
table-layout: auto; /* Allow columns to size based on content */
|
| 142 |
border: none !important;
|
| 143 |
}
|
| 144 |
|