Spaces:
Sleeping
Sleeping
File size: 5,058 Bytes
b6e6a2b a996a40 b6e6a2b e4a312e a996a40 cca07a7 e4a312e a996a40 3f0cb4b 75e3c0f e4a312e 988a6d0 e4a312e 988a6d0 75e3c0f 3f0cb4b 75e3c0f e4a312e 75e3c0f 3f0cb4b a996a40 3f0cb4b 1624352 75e3c0f cca07a7 f2dd1ab cca07a7 f2dd1ab cca07a7 34205ff 1624352 75e3c0f b92775c 75e3c0f d60cf7d 75e3c0f 34205ff 1624352 75e3c0f d60cf7d 75e3c0f 34205ff 75e3c0f d60cf7d 75e3c0f 34205ff 75e3c0f 34205ff d60cf7d 75e3c0f 1624352 75e3c0f d60cf7d 75e3c0f 1624352 d60cf7d 75e3c0f bcbdc1b 75e3c0f 1624352 b92775c 75e3c0f cca07a7 75e3c0f bcbdc1b 75e3c0f 3f0cb4b a996a40 b92775c 75e3c0f 62f89ca |
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 |
import json
import gradio as gr
with open("results.json") as f:
raw_data = json.load(f)
# Extract task info
task_name = raw_data.get("task", "Leaderboard")
task_description = raw_data.get("description", "")
# Extract rows from the new format
data = raw_data["datasets"][0]["sota"]["rows"]
# Sort by driving score
data = sorted(data, key=lambda x: float(x["metrics"]["Driving Score"]), reverse=True)
rows_html = ""
for idx, d in enumerate(data, 1):
# Extract paper info
paper_title = d.get("paper_title", "")
paper_url = d.get("paper_url", "")
paper = f'<a href="{paper_url}" target="_blank">📄 {paper_title}</a>' if paper_url and paper_title else ""
# Extract repository info
code_links = d.get("code_links", [])
if code_links and len(code_links) > 0:
repo_url = code_links[0]["url"]
repo = f'<a href="{repo_url}" target="_blank"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path></svg></a>'
else:
repo = "-"
row_class = "row-even" if idx % 2 == 0 else "row-odd"
rows_html += f"""
<tr class="{row_class}">
<td class="model-name">{d["model_name"]}</td>
<td class="score">{d["metrics"]["Driving Score"]}</td>
<td class="paper-cell">{paper}</td>
<td class="repo-cell">{repo}</td>
</tr>
"""
html = f"""
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');
* {{
box-sizing: border-box;
}}
.leaderboard-container {{
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
max-width: 1200px;
margin: 0 auto;
padding: 40px 20px;
}}
.task-header {{
margin-bottom: 32px;
}}
.task-title {{
font-size: 32px;
font-weight: 600;
color: #1f2937;
margin: 0 0 12px 0;
}}
.task-description {{
font-size: 15px;
line-height: 1.6;
color: #6b7280;
margin: 0 0 8px 0;
}}
.last-updated {{
font-size: 13px;
color: #9ca3af;
margin: 0 0 32px 0;
font-style: italic;
}}
.table-leaderboard {{
width: 100%;
border-collapse: separate;
border-spacing: 0;
background: white;
font-size: 14px;
border: 1px solid #f0f0f0;
border-radius: 12px;
overflow: hidden;
}}
.table-leaderboard thead th {{
text-align: left;
padding: 14px 16px;
font-weight: 500;
font-size: 13px;
color: #d1d5db;
background: #fafbfc;
border-bottom: 1px solid #f9f9f9;
border-left: none !important;
border-right: none !important;
border-top: none !important;
}}
.table-leaderboard tbody tr {{
transition: background-color 0.15s ease;
}}
.table-leaderboard tbody tr:not(:last-child) td {{
border-bottom: 1px solid #fafafa;
}}
.table-leaderboard tbody tr:hover {{
background-color: #f9fafb;
}}
.table-leaderboard td {{
padding: 14px 16px;
color: #374151;
vertical-align: middle;
border-left: none !important;
border-right: none !important;
border-top: none !important;
}}
.table-leaderboard .model-name {{
font-weight: 500;
color: #1f2937;
font-size: 14px;
}}
.table-leaderboard .score {{
font-weight: 500;
color: #1f2937;
font-size: 14px;
}}
.table-leaderboard .paper-cell {{
max-width: 600px;
line-height: 1.5;
}}
.table-leaderboard .paper-cell a {{
color: #3b82f6;
text-decoration: none;
font-size: 14px;
}}
.table-leaderboard .paper-cell a:hover {{
text-decoration: underline;
}}
.table-leaderboard .repo-cell {{
text-align: center;
width: 80px;
}}
.table-leaderboard .repo-cell a {{
color: #9ca3af;
text-decoration: none;
display: inline-flex;
align-items: center;
justify-content: center;
}}
.table-leaderboard .repo-cell a:hover {{
color: #3b82f6;
}}
</style>
<div class="leaderboard-container">
<div class="task-header">
<h1 class="task-title">{task_name}</h1>
<p class="task-description">{task_description}</p>
</div>
<table class="table-leaderboard">
<thead>
<tr>
<th>Model Name</th>
<th>Driving Score ↑</th>
<th>Paper Title</th>
<th style="text-align: center;">Repository</th>
</tr>
</thead>
<tbody>
{rows_html}
</tbody>
</table>
</div>
"""
with gr.Blocks(css="""
#component-0 {
max-width: 1400px;
margin: auto;
padding: 40px 20px;
}
""") as demo:
gr.HTML(html)
demo.launch()
|