ln2697 commited on
Commit
8911b98
·
1 Parent(s): e4f5d74
Files changed (3) hide show
  1. Makefile +13 -0
  2. app.py +204 -0
  3. pyproject.toml +13 -0
Makefile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .PHONY: style format
2
+
3
+
4
+ style:
5
+ python -m black --line-length 119 .
6
+ python -m isort .
7
+ ruff check --fix .
8
+
9
+
10
+ quality:
11
+ python -m black --check --line-length 119 .
12
+ python -m isort --check-only .
13
+ ruff check .
app.py ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import gradio as gr
3
+
4
+ with open("results.json") as f:
5
+ raw_data = json.load(f)
6
+
7
+ # Extract task info
8
+ task_name = raw_data.get("task", "Leaderboard")
9
+ task_description = raw_data.get("description", "")
10
+
11
+ # Extract rows from the new format
12
+ data = raw_data["datasets"][0]["sota"]["rows"]
13
+
14
+ # Sort by driving score
15
+ data = sorted(data, key=lambda x: float(x["metrics"]["Driving Score"]), reverse=True)
16
+
17
+ rows_html = ""
18
+ for idx, d in enumerate(data, 1):
19
+ # Extract paper info
20
+ paper_title = d.get("paper_title", "")
21
+ paper_url = d.get("paper_url", "")
22
+ paper = f'<a href="{paper_url}" target="_blank">📄 {paper_title}</a>' if paper_url and paper_title else ""
23
+
24
+ # Extract repository info
25
+ code_links = d.get("code_links", [])
26
+ if code_links and len(code_links) > 0:
27
+ repo_url = code_links[0]["url"]
28
+ 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>'
29
+ else:
30
+ repo = "-"
31
+
32
+ row_class = "row-even" if idx % 2 == 0 else "row-odd"
33
+ rows_html += f"""
34
+ <tr class="{row_class}">
35
+ <td class="model-name">{d["model_name"]}</td>
36
+ <td class="score">{d["metrics"]["Driving Score"]}</td>
37
+ <td class="paper-cell">{paper}</td>
38
+ <td class="repo-cell">{repo}</td>
39
+ </tr>
40
+ """
41
+
42
+ html = f"""
43
+ <style>
44
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');
45
+
46
+ * {{
47
+ box-sizing: border-box;
48
+ }}
49
+
50
+ .leaderboard-container {{
51
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
52
+ max-width: 1200px;
53
+ margin: 0 auto;
54
+ padding: 40px 20px;
55
+ }}
56
+
57
+ .task-header {{
58
+ margin-bottom: 32px;
59
+ }}
60
+
61
+ .task-title {{
62
+ font-size: 32px;
63
+ font-weight: 600;
64
+ color: #1f2937;
65
+ margin: 0 0 12px 0;
66
+ }}
67
+
68
+ .task-description {{
69
+ font-size: 15px;
70
+ line-height: 1.6;
71
+ color: #6b7280;
72
+ margin: 0 0 8px 0;
73
+ }}
74
+
75
+ .last-updated {{
76
+ font-size: 13px;
77
+ color: #9ca3af;
78
+ margin: 0 0 32px 0;
79
+ font-style: italic;
80
+ }}
81
+
82
+ .table-leaderboard {{
83
+ width: 100%;
84
+ border-collapse: separate;
85
+ border-spacing: 0;
86
+ background: white;
87
+ font-size: 14px;
88
+ border: 1px solid #f0f0f0;
89
+ border-radius: 12px;
90
+ overflow: hidden;
91
+ }}
92
+
93
+ .table-leaderboard thead th {{
94
+ text-align: left;
95
+ padding: 14px 16px;
96
+ font-weight: 500;
97
+ font-size: 13px;
98
+ color: #d1d5db;
99
+ background: #fafbfc;
100
+ border-bottom: 1px solid #f9f9f9;
101
+ border-left: none !important;
102
+ border-right: none !important;
103
+ border-top: none !important;
104
+ }}
105
+
106
+ .table-leaderboard tbody tr {{
107
+ transition: background-color 0.15s ease;
108
+ }}
109
+
110
+ .table-leaderboard tbody tr:not(:last-child) td {{
111
+ border-bottom: 1px solid #fafafa;
112
+ }}
113
+
114
+ .table-leaderboard tbody tr:hover {{
115
+ background-color: #f9fafb;
116
+ }}
117
+
118
+ .table-leaderboard td {{
119
+ padding: 14px 16px;
120
+ color: #374151;
121
+ vertical-align: middle;
122
+ border-left: none !important;
123
+ border-right: none !important;
124
+ border-top: none !important;
125
+ }}
126
+
127
+ .table-leaderboard .model-name {{
128
+ font-weight: 500;
129
+ color: #1f2937;
130
+ font-size: 14px;
131
+ }}
132
+
133
+ .table-leaderboard .score {{
134
+ font-weight: 500;
135
+ color: #1f2937;
136
+ font-size: 14px;
137
+ }}
138
+
139
+ .table-leaderboard .paper-cell {{
140
+ max-width: 600px;
141
+ line-height: 1.5;
142
+ }}
143
+
144
+ .table-leaderboard .paper-cell a {{
145
+ color: #3b82f6;
146
+ text-decoration: none;
147
+ font-size: 14px;
148
+ }}
149
+
150
+ .table-leaderboard .paper-cell a:hover {{
151
+ text-decoration: underline;
152
+ }}
153
+
154
+ .table-leaderboard .repo-cell {{
155
+ text-align: center;
156
+ width: 80px;
157
+ }}
158
+
159
+ .table-leaderboard .repo-cell a {{
160
+ color: #9ca3af;
161
+ text-decoration: none;
162
+ display: inline-flex;
163
+ align-items: center;
164
+ justify-content: center;
165
+ }}
166
+
167
+ .table-leaderboard .repo-cell a:hover {{
168
+ color: #3b82f6;
169
+ }}
170
+ </style>
171
+
172
+ <div class="leaderboard-container">
173
+ <div class="task-header">
174
+ <h1 class="task-title">{task_name}</h1>
175
+ <p class="task-description">{task_description}</p>
176
+ </div>
177
+
178
+ <table class="table-leaderboard">
179
+ <thead>
180
+ <tr>
181
+ <th>Model Name</th>
182
+ <th>Driving Score ↑</th>
183
+ <th>Paper Title</th>
184
+ <th style="text-align: center;">Repository</th>
185
+ </tr>
186
+ </thead>
187
+ <tbody>
188
+ {rows_html}
189
+ </tbody>
190
+ </table>
191
+ </div>
192
+ """
193
+
194
+
195
+ with gr.Blocks(css="""
196
+ #component-0 {
197
+ max-width: 1400px;
198
+ margin: auto;
199
+ padding: 40px 20px;
200
+ }
201
+ """) as demo:
202
+ gr.HTML(html)
203
+
204
+ demo.launch()
pyproject.toml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [tool.ruff]
2
+ # Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
3
+ select = ["E", "F"]
4
+ ignore = ["E501"] # line too long (black is taking care of this)
5
+ line-length = 119
6
+ fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
7
+
8
+ [tool.isort]
9
+ profile = "black"
10
+ line_length = 119
11
+
12
+ [tool.black]
13
+ line-length = 119