unknown commited on
Commit
3f9b15d
·
1 Parent(s): b767870
Files changed (3) hide show
  1. about.py +0 -11
  2. app.py +272 -20
  3. css_html_js.py +0 -106
about.py DELETED
@@ -1,11 +0,0 @@
1
- TITLE = """<h1 align="center" id="space-title">SGI-Bench Leaderboard</h1>"""
2
-
3
- CITATION_BUTTON_LABEL = "📖 Citation"
4
- CITATION_BUTTON_TEXT = r"""
5
- @article{sgi2025,
6
- title={SGI-Bench: Scientific Intelligence Benchmark via Scientist-Aligned Workflows},
7
- author={Research Team},
8
- journal={arXiv preprint arXiv:2401.xxxxx},
9
- year={2025}
10
- }
11
- """
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -1,13 +1,260 @@
1
  import gradio as gr
2
  from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
3
  import pandas as pd
4
- from about import (
5
- CITATION_BUTTON_LABEL,
6
- CITATION_BUTTON_TEXT,
7
- TITLE,
8
- )
9
- from css_html_js import custom_css
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  LEADERBOARD_DATA = [
13
  {"name": "Intern-S1", "type": "Open", "scores": [15.74, 38.09, 28.79, 29.02, 28.87]},
@@ -66,25 +313,30 @@ def init_leaderboard(dataframe):
66
  ),
67
  search_columns=["Model"],
68
  hide_columns=[],
69
- filter_columns=[ColumnFilter("Type", type="checkboxgroup", label="Model types")],
70
  interactive=False,
71
  )
72
 
73
 
74
- demo = gr.Blocks(css=custom_css)
75
  with demo:
76
  gr.HTML(TITLE)
77
-
78
- leaderboard = init_leaderboard(LEADERBOARD_DF)
 
 
 
79
 
80
  with gr.Row():
81
- with gr.Group():
82
- citation_button = gr.Textbox(
83
- value=CITATION_BUTTON_TEXT,
84
- label=CITATION_BUTTON_LABEL,
85
- lines=CITATION_BUTTON_TEXT.count('\n')+1,
86
- elem_id="citation-button",
87
- show_copy_button=True,
88
- )
89
-
90
- demo.queue(default_concurrency_limit=40).launch()
 
 
 
1
  import gradio as gr
2
  from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
3
  import pandas as pd
 
 
 
 
 
 
4
 
5
+ # 🎨 增强后的自定义 CSS
6
+ custom_css = """
7
+ /* 全局设置:简洁、高级的字体和背景 */
8
+ :root {
9
+ --color-background-primary: #f8f8f8; /* 浅米白色背景 */
10
+ --color-background-secondary: #ffffff; /* 卡片背景 */
11
+ --color-text-primary: #333333;
12
+ --color-accent: #8e80ff; /* 浅紫色强调色 (Primary) */
13
+ --color-accent-light: #a99dff; /* 浅紫色悬停色 */
14
+ --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.08);
15
+ }
16
+
17
+ body {
18
+ background-color: var(--color-background-primary) !important;
19
+ }
20
+
21
+ /* 增加容器最大宽度以展示完整表格 */
22
+ .gradio-container {
23
+ max-width: 1400px; /* 宽度从 1800px 调窄到 1400px */
24
+ margin: 0 auto;
25
+ padding: 20px;
26
+ }
27
+
28
+ /* 标题样式 */
29
+ #space-title {
30
+ color: var(--color-text-primary);
31
+ font-size: 3em;
32
+ font-weight: 700;
33
+ margin-bottom: 0.5em;
34
+ padding-top: 20px;
35
+ }
36
+
37
+ /* Group/Block 组件的卡片样式 */
38
+ .gr-group, .gr-block {
39
+ background-color: var(--color-background-secondary);
40
+ border-radius: 12px;
41
+ box-shadow: var(--shadow-medium);
42
+ transition: box-shadow 0.3s ease;
43
+ padding: 15px;
44
+ margin-bottom: 20px;
45
+ }
46
+
47
+ .gr-group:hover, .gr-block:hover {
48
+ box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
49
+ }
50
+
51
+ /* Leaderboard 容器:调整内部布局的关键 */
52
+ .leaderboard_root {
53
+ padding: 0 !important;
54
+ }
55
+
56
+ /* 搜索栏布局调整 (第一行) */
57
+ .leaderboard_root > div:nth-child(1) {
58
+ padding: 0 15px 15px 15px;
59
+ }
60
+
61
+ /* 过滤器和列选择布局调整 (第二行) */
62
+ .leaderboard_root > div:nth-child(2) {
63
+ display: flex;
64
+ padding: 0 15px 15px 15px;
65
+ }
66
+
67
+ .leaderboard_root .gr-form {
68
+ border: none;
69
+ }
70
+
71
+ /* Search Bar */
72
+ #search-bar-table-box {
73
+ width: 100%;
74
+ margin-bottom: 10px;
75
+ }
76
+ #search-bar-table-box > div:first-child {
77
+ background: none;
78
+ border: none;
79
+ }
80
+
81
+ /* === Select Columns to Display: 强制单行展示 === */
82
+ /* 定位 SelectColumns 的内部复选框容器 */
83
+ .leaderboard-filter-column:first-child .gr-form-checkbox-group {
84
+ /* 使用 flex 容器 */
85
+ display: flex !important;
86
+ flex-wrap: nowrap !important; /* 强制不换行 */
87
+ overflow-x: auto !important; /* 允许水平滚动 */
88
+ gap: 10px;
89
+ padding-bottom: 5px;
90
+ }
91
+
92
+ /* 确保每个复选框标签保持内联块级元素 */
93
+ .leaderboard-filter-column:first-child .gr-form-checkbox-group label {
94
+ flex-shrink: 0 !important; /* 防止选项被压缩 */
95
+ display: inline-block !important; /* 确保每个选项占据其自然宽度 */
96
+ margin: 0;
97
+ white-space: nowrap; /* 确保文字也不换行 */
98
+ }
99
+
100
+ #leaderboard-table, #leaderboard-table-lite {
101
+ margin-top: 15px;
102
+ border-radius: 8px;
103
+ overflow: hidden;
104
+ }
105
+
106
+ #leaderboard-table th {
107
+ background-color: var(--color-accent);
108
+ color: white;
109
+ font-weight: 600;
110
+ text-transform: uppercase;
111
+ border-bottom: 2px solid var(--color-accent-light);
112
+ }
113
+
114
+ #leaderboard-table tr:hover {
115
+ background-color: #f0f0f0;
116
+ cursor: pointer;
117
+ transition: background-color 0.2s ease;
118
+ }
119
+
120
+ #leaderboard-table td:nth-child(2),
121
+ #leaderboard-table th:nth-child(2) {
122
+ max-width: 400px;
123
+ overflow: auto;
124
+ white-space: nowrap;
125
+ }
126
+
127
+ #leaderboard-table td:nth-child(3) {
128
+ font-weight: bold;
129
+ color: var(--color-accent);
130
+ }
131
+
132
+ /* Citation 区域 */
133
+ #citation-group {
134
+ padding: 20px;
135
+ margin-top: 10px;
136
+ }
137
+
138
+ #citation-button {
139
+ margin-top: 0;
140
+ padding: 0;
141
+ }
142
+
143
+ /* 修复 Citation 复制图标重叠问题 */
144
+ #citation-button label {
145
+ display: block;
146
+ position: relative;
147
+ }
148
+
149
+ #citation-button textarea {
150
+ font-family: monospace;
151
+ background-color: #f1f1f1;
152
+ border: 1px solid #cccccc;
153
+ border-radius: 6px;
154
+ padding: 10px;
155
+ padding-right: 40px !important; /* 为复制按钮腾出空间 */
156
+ font-size: 14px !important;
157
+ width: 100% !important;
158
+ box-sizing: border-box;
159
+ }
160
+
161
+ /* 调整复制按钮的位置 */
162
+ #citation-button > label > button {
163
+ position: absolute;
164
+ top: 10px;
165
+ right: 10px;
166
+ margin: 0;
167
+ transform: scale(1.1);
168
+ transition: transform 0.2s ease;
169
+ background-color: var(--color-accent) !important;
170
+ color: white !important;
171
+ border: none !important;
172
+ border-radius: 6px;
173
+ z-index: 10;
174
+ }
175
+
176
+ #citation-button > label > button:hover {
177
+ transform: scale(1.2);
178
+ background-color: var(--color-accent-light) !important;
179
+ }
180
+
181
+ /* Leaderboard 内部过滤/选择组件微调 */
182
+ .leaderboard_root .leaderboard-filter-column:last-child {
183
+ flex-grow: 1;
184
+ max-width: 50%;
185
+ }
186
+
187
+ .leaderboard_root .leaderboard-filter-column:first-child {
188
+ max-width: 50%;
189
+ padding-right: 20px;
190
+ }
191
+
192
+ #filter_type{
193
+ border: 0;
194
+ padding-left: 0;
195
+ padding-top: 0;
196
+ }
197
+ #filter_type label {
198
+ display: flex;
199
+ }
200
+ #filter_type label > span{
201
+ margin-top: var(--spacing-lg);
202
+ margin-right: 0.5em;
203
+ }
204
+ #filter_type label > .wrap{
205
+ width: 103px;
206
+ }
207
+ #filter_type label > .wrap .wrap-inner{
208
+ padding: 2px;
209
+ }
210
+ #filter_type label > .wrap .wrap-inner input{
211
+ width: 1px
212
+ }
213
+ #filter-columns-type{
214
+ border:0;
215
+ padding:0.5;
216
+ }
217
+ #filter-columns-size{
218
+ border:0;
219
+ padding:0.5;
220
+ }
221
+ #box-filter > .form{
222
+ border: 0
223
+ }
224
+ /* 其他 Gradio 元素的简洁化 */
225
+ .wrap-inner input[type="text"], .wrap-inner input[type="number"] {
226
+ border-radius: 6px;
227
+ border: 1px solid #cccccc;
228
+ padding: 8px 12px;
229
+ }
230
+ """
231
+
232
+ get_window_url_params = """
233
+ function(url_params) {
234
+ const params = new URLSearchParams(window.location.search);
235
+ url_params = Object.fromEntries(params);
236
+ return url_params;
237
+ }
238
+ """
239
+
240
+
241
+ TITLE = """<h1 align="center" id="space-title">SGI-Bench Leaderboard 🏆</h1>"""
242
+ INFO = """<p align="center">
243
+ <a href="https://arxiv.org/abs/2401.xxxxx"><b>Paper</b></a> ·
244
+ <a href="https://github.com/InternScience/SGI-Bench"><b>GitHub</b></a> ·
245
+ <a href="https://internscience.github.io/SGI-Page/"><b>Page</b></a> ·
246
+ <a href="https://huggingface.co/collections/InternScience/sgi-bench"><b>HuggingFace</b></a>
247
+ </p>"""
248
+
249
+ CITATION_BUTTON_LABEL = "📖 Citation"
250
+ CITATION_BUTTON_TEXT = r"""
251
+ @article{sgi2025,
252
+ title={SGI-Bench: Scientific Intelligence Benchmark via Scientist-Aligned Workflows},
253
+ author={Research Team},
254
+ journal={arXiv preprint arXiv:2401.xxxxx},
255
+ year={2025}
256
+ }
257
+ """
258
 
259
  LEADERBOARD_DATA = [
260
  {"name": "Intern-S1", "type": "Open", "scores": [15.74, 38.09, 28.79, 29.02, 28.87]},
 
313
  ),
314
  search_columns=["Model"],
315
  hide_columns=[],
316
+ filter_columns=[ColumnFilter("Type", type="checkboxgroup", label="Model Types:")],
317
  interactive=False,
318
  )
319
 
320
 
321
+ demo = gr.Blocks(css=custom_css, theme=gr.themes.Soft())
322
  with demo:
323
  gr.HTML(TITLE)
324
+ gr.HTML(INFO)
325
+
326
+ # Leaderboard 主体包含 Search, Filters, Select Columns 和 Table
327
+ with gr.Group(elem_id="leaderboard-group"):
328
+ leaderboard = init_leaderboard(LEADERBOARD_DF)
329
 
330
  with gr.Row():
331
+ with gr.Column():
332
+ with gr.Group(elem_id="citation-group"):
333
+ citation_button = gr.Textbox(
334
+ value=CITATION_BUTTON_TEXT,
335
+ label=CITATION_BUTTON_LABEL,
336
+ lines=CITATION_BUTTON_TEXT.count('\n')+1,
337
+ elem_id="citation-button",
338
+ show_copy_button=True,
339
+ interactive=False
340
+ )
341
+
342
+ demo.queue(default_concurrency_limit=40).launch()
css_html_js.py DELETED
@@ -1,106 +0,0 @@
1
- custom_css = """
2
-
3
- .markdown-text {
4
- font-size: 16px !important;
5
- text-align: center;
6
- }
7
-
8
- #models-to-add-text {
9
- font-size: 18px !important;
10
- }
11
-
12
- #citation-button span {
13
- font-size: 16px !important;
14
- }
15
-
16
- #citation-button textarea {
17
- font-size: 16px !important;
18
- }
19
-
20
- #citation-button > label > button {
21
- margin: 6px;
22
- transform: scale(1.3);
23
- }
24
-
25
- #leaderboard-table {
26
- margin-top: 15px
27
- }
28
-
29
- #leaderboard-table-lite {
30
- margin-top: 15px
31
- }
32
-
33
- #search-bar-table-box > div:first-child {
34
- background: none;
35
- border: none;
36
- }
37
-
38
- #search-bar {
39
- padding: 0px;
40
- }
41
-
42
- /* Limit the width of the first AutoEvalColumn so that names don't expand too much */
43
- #leaderboard-table td:nth-child(2),
44
- #leaderboard-table th:nth-child(2) {
45
- max-width: 400px;
46
- overflow: auto;
47
- white-space: nowrap;
48
- }
49
-
50
- .tab-buttons button {
51
- font-size: 20px;
52
- }
53
-
54
- #scale-logo {
55
- border-style: none !important;
56
- box-shadow: none;
57
- display: block;
58
- margin-left: auto;
59
- margin-right: auto;
60
- max-width: 600px;
61
- }
62
-
63
- #scale-logo .download {
64
- display: none;
65
- }
66
- #filter_type{
67
- border: 0;
68
- padding-left: 0;
69
- padding-top: 0;
70
- }
71
- #filter_type label {
72
- display: flex;
73
- }
74
- #filter_type label > span{
75
- margin-top: var(--spacing-lg);
76
- margin-right: 0.5em;
77
- }
78
- #filter_type label > .wrap{
79
- width: 103px;
80
- }
81
- #filter_type label > .wrap .wrap-inner{
82
- padding: 2px;
83
- }
84
- #filter_type label > .wrap .wrap-inner input{
85
- width: 1px
86
- }
87
- #filter-columns-type{
88
- border:0;
89
- padding:0.5;
90
- }
91
- #filter-columns-size{
92
- border:0;
93
- padding:0.5;
94
- }
95
- #box-filter > .form{
96
- border: 0
97
- }
98
- """
99
-
100
- get_window_url_params = """
101
- function(url_params) {
102
- const params = new URLSearchParams(window.location.search);
103
- url_params = Object.fromEntries(params);
104
- return url_params;
105
- }
106
- """