Spaces:
Running
Running
✨ Added links to hf spaces and publications
Browse files- frontend/layout.py +42 -2
- frontend/leaderboard.py +1 -0
frontend/layout.py
CHANGED
|
@@ -11,6 +11,7 @@ import os
|
|
| 11 |
import pandas as pd
|
| 12 |
from gradio_leaderboard import Leaderboard, SearchColumns, ColumnFilter, SelectColumns
|
| 13 |
from pathlib import Path
|
|
|
|
| 14 |
|
| 15 |
from config.leaderboard import COLUMN_WIDTHS, TASK_NAMES
|
| 16 |
|
|
@@ -56,6 +57,9 @@ def create_leaderboard_tab(refresh_callback: Callable = None) -> gr.TabItem:
|
|
| 56 |
colspan = 0
|
| 57 |
|
| 58 |
for i, (top, sub) in enumerate(df.columns):
|
|
|
|
|
|
|
|
|
|
| 59 |
# Handle blank top headers directly (span both rows)
|
| 60 |
if top == "" or top is None:
|
| 61 |
# close any previous group first
|
|
@@ -84,18 +88,54 @@ def create_leaderboard_tab(refresh_callback: Callable = None) -> gr.TabItem:
|
|
| 84 |
# --- Second header row ---
|
| 85 |
html += "<tr>"
|
| 86 |
for top, sub in df.columns:
|
|
|
|
|
|
|
|
|
|
| 87 |
if top not in ("", None):
|
| 88 |
html += f"<th>{sub}</th>"
|
| 89 |
html += "</tr>"
|
| 90 |
|
| 91 |
html += "</thead>"
|
| 92 |
else:
|
| 93 |
-
html += "<thead><tr>" + "".join(f"<th>{col}</th>" for col in df.columns) + "</tr></thead>"
|
| 94 |
|
| 95 |
# --- Body ---
|
| 96 |
html += "<tbody>"
|
| 97 |
for _, row in df.iterrows():
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
html += "</tbody></table></div>"
|
| 100 |
return html
|
| 101 |
|
|
|
|
| 11 |
import pandas as pd
|
| 12 |
from gradio_leaderboard import Leaderboard, SearchColumns, ColumnFilter, SelectColumns
|
| 13 |
from pathlib import Path
|
| 14 |
+
import inspect
|
| 15 |
|
| 16 |
from config.leaderboard import COLUMN_WIDTHS, TASK_NAMES
|
| 17 |
|
|
|
|
| 57 |
colspan = 0
|
| 58 |
|
| 59 |
for i, (top, sub) in enumerate(df.columns):
|
| 60 |
+
# Skip hidden columns
|
| 61 |
+
if (top, sub) in [("", "HF_Space_Tag"), ("", "Publication Link")]:
|
| 62 |
+
continue
|
| 63 |
# Handle blank top headers directly (span both rows)
|
| 64 |
if top == "" or top is None:
|
| 65 |
# close any previous group first
|
|
|
|
| 88 |
# --- Second header row ---
|
| 89 |
html += "<tr>"
|
| 90 |
for top, sub in df.columns:
|
| 91 |
+
# Skip hidden columns
|
| 92 |
+
if (top, sub) in [("", "HF_Space_Tag"), ("", "Publication Link")]:
|
| 93 |
+
continue
|
| 94 |
if top not in ("", None):
|
| 95 |
html += f"<th>{sub}</th>"
|
| 96 |
html += "</tr>"
|
| 97 |
|
| 98 |
html += "</thead>"
|
| 99 |
else:
|
| 100 |
+
html += "<thead><tr>" + "".join(f"<th>{col}</th>" for col in df.columns if col not in [("", "HF_Space_Tag"), ("", "Publication Link")]) + "</tr></thead>"
|
| 101 |
|
| 102 |
# --- Body ---
|
| 103 |
html += "<tbody>"
|
| 104 |
for _, row in df.iterrows():
|
| 105 |
+
# First pass: extract hidden columns for creating links
|
| 106 |
+
hf_space_tag = ""
|
| 107 |
+
publication_link = ""
|
| 108 |
+
if ("", "HF_Space_Tag") in df.columns:
|
| 109 |
+
hf_space_tag = row[("", "HF_Space_Tag")]
|
| 110 |
+
if ("", "Publication Link") in df.columns:
|
| 111 |
+
publication_link = row[("", "Publication Link")]
|
| 112 |
+
|
| 113 |
+
# Second pass: render cells
|
| 114 |
+
html += "<tr>"
|
| 115 |
+
for col, val in zip(df.columns, row):
|
| 116 |
+
# Skip hidden columns
|
| 117 |
+
if col in [("", "HF_Space_Tag"), ("", "Publication Link")]:
|
| 118 |
+
continue
|
| 119 |
+
|
| 120 |
+
# Create clickable link for Model column if HF space tag exists
|
| 121 |
+
if col == ("", "Model"):
|
| 122 |
+
tag_str = str(hf_space_tag).strip().lower()
|
| 123 |
+
if hf_space_tag and tag_str and tag_str not in ['none', 'nan', '', '.']:
|
| 124 |
+
html += f"<td><a href='https://huggingface.co/spaces/{hf_space_tag}' target='_blank' style='color: #20C2D9; text-decoration: none;'>{val}</a></td>"
|
| 125 |
+
else:
|
| 126 |
+
html += f"<td>{val}</td>"
|
| 127 |
+
|
| 128 |
+
# Create clickable link for Publication column if publication link exists
|
| 129 |
+
elif col == ("", "Publication"):
|
| 130 |
+
link_str = str(publication_link).strip().lower()
|
| 131 |
+
if publication_link and link_str and link_str not in ['none', 'nan', '', '.']:
|
| 132 |
+
html += f"<td><a href='{publication_link}' target='_blank' style='color: #20C2D9; text-decoration: none;'>{val}</a></td>"
|
| 133 |
+
else:
|
| 134 |
+
html += f"<td>{val}</td>"
|
| 135 |
+
|
| 136 |
+
else:
|
| 137 |
+
html += f"<td>{val}</td>"
|
| 138 |
+
html += "</tr>"
|
| 139 |
html += "</tbody></table></div>"
|
| 140 |
return html
|
| 141 |
|
frontend/leaderboard.py
CHANGED
|
@@ -54,6 +54,7 @@ def format_leaderboard_data(raw_data: dict) -> pd.DataFrame:
|
|
| 54 |
# Create a row with all the data
|
| 55 |
row = {
|
| 56 |
("", "Model"): config["model_name"],
|
|
|
|
| 57 |
("", "Organization"): config.get("organization", ""),
|
| 58 |
("", "Avg. AUC"): results["overall_score"]["roc_auc"],
|
| 59 |
("", "Avg. ΔAUC-PR"): results["overall_score"].get("delta_auprc"),
|
|
|
|
| 54 |
# Create a row with all the data
|
| 55 |
row = {
|
| 56 |
("", "Model"): config["model_name"],
|
| 57 |
+
("", "HF_Space_Tag"): config.get("hf_space_tag", ""), # Hidden column for links
|
| 58 |
("", "Organization"): config.get("organization", ""),
|
| 59 |
("", "Avg. AUC"): results["overall_score"]["roc_auc"],
|
| 60 |
("", "Avg. ΔAUC-PR"): results["overall_score"].get("delta_auprc"),
|