Spaces:
Running
Running
File size: 8,554 Bytes
4097ba4 6e61bd8 2b552ac 4097ba4 0d86923 c4f95f5 0d86923 c4f95f5 2b552ac c4f95f5 2b552ac c4f95f5 37b185d 2b552ac 37b185d 0d86923 37b185d 0d86923 2b552ac c4f95f5 2b552ac c4f95f5 37b185d 2b552ac 4097ba4 0d86923 2b552ac 4097ba4 2b552ac 4097ba4 2b552ac 0d86923 4097ba4 2b552ac 4097ba4 37b185d 4097ba4 2b552ac 4097ba4 0d86923 4097ba4 37b185d 4097ba4 2b552ac 4097ba4 2b552ac 6e61bd8 2b552ac 4097ba4 c4f95f5 2b552ac 4097ba4 2b552ac 4097ba4 c4f95f5 4097ba4 c4f95f5 2b552ac c4f95f5 2b552ac c4f95f5 4097ba4 2b552ac 4097ba4 c4f95f5 0d86923 c4f95f5 2b552ac c4f95f5 4097ba4 2b552ac eb27c59 2b552ac 4097ba4 eb27c59 4097ba4 2b552ac 4097ba4 eb27c59 4097ba4 2b552ac 0d86923 2b552ac c4f95f5 4097ba4 c4f95f5 2b552ac c4f95f5 2b552ac c4f95f5 2b552ac c4f95f5 2b552ac c4f95f5 4097ba4 2b552ac 4097ba4 2b552ac c4f95f5 4097ba4 2b552ac c4f95f5 4097ba4 37b185d 4097ba4 9cf40f9 2b552ac 4097ba4 2b552ac 4097ba4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | import pandas as pd
def get_academic_css() -> str:
return """
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css');
:root {
/* Light mode (default) */
--primary: #2563eb;
--primary-dark: #1d4ed8;
--accent: #06b6d4;
--text-primary: #1a1a1a;
--text-secondary: #4a4a4a;
--text-muted: #666666;
--border: #e5e5e5;
--success: #10b981;
--danger: #ef4444;
/* Table colors */
--table-header: #64748b;
--table-header-light: #94a3b8;
--table-border: #cbd5e0;
--table-bg-odd: #f8fafc;
--table-bg-even: #f1f5f9;
--table-bg-hover: #e2e8f0;
--best-score-bg: #e6fffa;
--best-score-color: #2c7a7b;
--category-bg: #e2e8f0;
--category-color: #475569;
}
@media (prefers-color-scheme: dark) {
:root {
--primary: #3b82f6;
--primary-dark: #2563eb;
--accent: #22d3ee;
--text-primary: #ecf0f1;
--text-secondary: #b0b0b0;
--text-muted: #94a3b8;
--border: #3a4a5a;
--success: #34d399;
--danger: #f87171;
--table-header: #4a5a6a;
--table-header-light: #5a6a7a;
--table-border: #3a4a5a;
--table-bg-odd: #2a3745;
--table-bg-even: #1e2b38;
--table-bg-hover: #354454;
--best-score-bg: #1a3a3a;
--best-score-color: #7fc9c9;
--category-bg: #3a4a5a;
--category-color: #cbd5e0;
}
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
color: var(--text-primary);
margin: 0;
padding: 0;
/* Background set by system */
}
.gradio-container {
max-width: 1400px !important;
/* Background set by system */
color: var(--text-primary);
}
h1 {
color: var(--primary) !important;
font-weight: 700 !important;
}
.subtitle {
color: var(--text-secondary);
font-size: 1.1rem;
margin-top: 0.5rem;
opacity: 0.8;
}
.emoji {
font-size: 1.5em;
}
/* Title row links (aligned with LaTeX: magenta / teal / black / orange–yellow + FA icons) */
.project-links-bar {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
gap: clamp(1rem, 3vw, 2.65rem);
margin: 0.85rem auto 0.25rem;
font-size: 1rem;
line-height: 1.45;
max-width: 100%;
}
.project-links-bar .pl-link {
text-decoration: none;
white-space: nowrap;
}
.project-links-bar .pl-link:hover {
text-decoration: underline;
text-underline-offset: 0.2em;
}
.project-links-bar .pl-link em {
font-style: italic;
font-weight: 500;
}
.project-links-bar .pl-link i.fa-solid {
margin-right: 0.28em;
}
.pl-project { color: #c026d3; }
.pl-dataset { color: #0d9488; }
.pl-code { color: #111827; }
.pl-leaderboard { color: #eab308; }
@media (prefers-color-scheme: dark) {
.pl-code { color: #e5e7eb; }
.pl-leaderboard { color: #fcd34d; }
}
/* Leaderboard table styling */
.leaderboard-table {
width: 100%;
border-collapse: collapse;
font-size: 0.9rem;
margin-top: 1rem;
border: 1px solid var(--table-border);
background-color: transparent;
}
.leaderboard-table th {
background: var(--table-header);
color: white;
padding: 12px 8px;
text-align: center;
font-weight: 600;
position: sticky;
top: 0;
border-right: 1px solid rgba(255,255,255,0.15);
cursor: pointer; /* Indicate sortable */
}
.leaderboard-table th:last-child {
border-right: none;
}
.leaderboard-table th:hover {
background-color: var(--table-header-light);
}
.leaderboard-table td {
padding: 10px 8px;
text-align: center;
border-bottom: 1px solid var(--table-border);
border-right: 1px solid var(--table-border);
color: var(--text-secondary);
}
.leaderboard-table td:last-child {
border-right: none;
}
.leaderboard-table tr:nth-child(odd) {
background-color: var(--table-bg-odd);
}
.leaderboard-table tr:nth-child(even) {
background-color: var(--table-bg-even);
}
.leaderboard-table tr:hover {
background-color: var(--table-bg-hover) !important;
}
/* Rank styles */
.rank-1 { background: linear-gradient(135deg, #ffd700 0%, #ffed4a 100%) !important; font-weight: bold; color: #1a1a1a !important; }
.rank-2 { background: linear-gradient(135deg, #c0c0c0 0%, #e5e7eb 100%) !important; font-weight: bold; color: #1a1a1a !important; }
.rank-3 { background: linear-gradient(135deg, #cd7f32 0%, #fdba74 100%) !important; font-weight: bold; color: #1a1a1a !important; }
/* Best score highlight */
.best-score {
font-weight: 700;
color: var(--best-score-color);
background: var(--best-score-bg) !important;
}
/* Category row (for group headers) */
.category-row {
background: var(--category-bg) !important;
font-weight: 600;
color: var(--category-color);
text-align: left;
font-size: 0.85rem;
}
.category-row td {
padding: 10px 15px;
color: var(--category-color);
border-bottom: 2px solid var(--table-border);
}
.check {
color: var(--success);
font-weight: bold;
font-size: 1.2em;
}
.cross {
color: var(--danger);
font-weight: bold;
font-size: 1.2em;
}
.category-tag {
display: inline-block;
padding: 2px 8px;
border-radius: 12px;
font-size: 0.8rem;
font-weight: 500;
}
.cat-text { background: #dbeafe; color: #1e40af; }
.cat-onehot { background: #d1fae5; color: #065f46; }
.cat-camera { background: #fef3c7; color: #92400e; }
/* Links */
.leaderboard-table a {
color: var(--primary);
text-decoration: none;
font-size: 1.2rem;
}
.leaderboard-table a:hover {
opacity: 0.7;
}
/* Buttons */
button.primary {
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
color: white !important;
border: none;
}
/* Status indicators (hidden) */
.status-success { color: var(--success); }
.status-error { color: var(--danger); }
"""
def dataframe_to_html(df: pd.DataFrame) -> str:
if df.empty:
return "<div class='placeholder'>No data available</div>"
# Include sorttable.js for column sorting
html = ['<script src="https://www.kryogenix.org/code/browser/sorttable/sorttable.js"></script>']
html.append('<table class="leaderboard-table sortable">')
html.append("<thead><tr>")
for col in df.columns:
html.append(f"<th>{col}</th>")
html.append("</tr></thead>")
html.append("<tbody>")
for idx, row in df.iterrows():
rank_class = ""
if "Rank" in df.columns:
rank = row["Rank"]
if rank == 1:
rank_class = "rank-1"
elif rank == 2:
rank_class = "rank-2"
elif rank == 3:
rank_class = "rank-3"
html.append(f'<tr class="{rank_class}">')
for col in df.columns:
val = row[col]
if col == "Category":
cat_class = {
"Text-Conditioned": "cat-text",
"One-hot": "cat-onehot",
"Intrinsics/Extrinsics": "cat-camera"
}.get(val, "")
val = f'<span class="category-tag {cat_class}">{val}</span>'
html.append(f"<td>{val}</td>")
html.append("</tr>")
html.append("</tbody></table>")
return "".join(html) |