CodeGoat24 commited on
Commit
c9a01a3
·
verified ·
1 Parent(s): b705648

Delete display

Browse files
Files changed (3) hide show
  1. display/css_html_js.py +0 -282
  2. display/formatting.py +0 -27
  3. display/utils.py +0 -110
display/css_html_js.py DELETED
@@ -1,282 +0,0 @@
1
- custom_css = """
2
-
3
- .markdown-text {
4
- font-size: 16px !important;
5
- line-height: 1.6 !important;
6
- }
7
-
8
- .gradio-dataframe table {
9
- table-layout: auto; /* 根据内容自动分配列宽 */
10
- width: 100%; /* 占满容器宽度 */
11
- }
12
-
13
- .gradio-dataframe th,
14
- .gradio-dataframe td {
15
- white-space: nowrap; /* 不换行 */
16
- padding: 6px 10px; /* 内边距更美观 */
17
- }
18
-
19
- /* Enhanced Leaderboard table styling */
20
- .dataframe {
21
- background: white !important;
22
- border-radius: 12px !important;
23
- box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08) !important;
24
- overflow: hidden !important;
25
- border: 1px solid #e8ecef !important;
26
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif !important;
27
- }
28
-
29
- .dataframe th {
30
- background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
31
- color: #2c3e50 !important;
32
- font-weight: 600 !important;
33
- font-size: 11px !important;
34
- padding: 16px 12px !important;
35
- text-align: center !important;
36
- border-bottom: 2px solid #dee2e6 !important;
37
- letter-spacing: 0.025em !important;
38
- text-transform: uppercase !important;
39
- }
40
-
41
- /* Override any conflicting styles */
42
- .dataframe thead th {
43
- font-size: 11px !important;
44
- }
45
-
46
- .dataframe th span {
47
- font-size: 11px !important;
48
- }
49
-
50
- .dataframe td {
51
- padding: 14px 12px !important;
52
- border-bottom: 1px solid #f0f2f5 !important;
53
- text-align: center !important;
54
- vertical-align: middle !important;
55
- font-size: 15px !important;
56
- color: #2c3e50 !important;
57
- line-height: 1.4 !important;
58
- }
59
-
60
- .dataframe tr:hover td {
61
- background-color: #f8f9fa !important;
62
- transition: background-color 0.2s ease !important;
63
- }
64
-
65
- .dataframe tr:nth-child(even) td {
66
- background-color: #fdfdfd !important;
67
- }
68
-
69
- /* Enhanced hyperlinks in table */
70
- .dataframe a {
71
- color: #0066cc !important;
72
- text-decoration: underline !important;
73
- font-weight: 500 !important;
74
- transition: all 0.2s ease !important;
75
- border-radius: 4px !important;
76
- padding: 2px 6px !important;
77
- display: inline-block !important;
78
- }
79
-
80
- .dataframe a:hover {
81
- color: #004499 !important;
82
- background-color: rgba(0, 102, 204, 0.1) !important;
83
- text-decoration: underline !important;
84
- transform: translateY(-1px) !important;
85
- }
86
-
87
- .dataframe a:visited {
88
- color: #5a6c7d !important;
89
- }
90
-
91
- /* Model name styling (assuming first column contains model names) */
92
- .dataframe td:first-child {
93
- font-weight: 600 !important;
94
- color: #1a202c !important;
95
- text-align: left !important;
96
- padding-left: 16px !important;
97
- }
98
-
99
- /* Score highlighting */
100
- .dataframe td:last-child {
101
- font-weight: 600 !important;
102
- font-size: 16px !important;
103
- }
104
-
105
- #models-to-add-text {
106
- font-size: 18px !important;
107
- }
108
-
109
- #citation-button span {
110
- font-size: 16px !important;
111
- }
112
-
113
- #citation-button textarea {
114
- font-size: 16px !important;
115
- }
116
-
117
- #citation-button > label > button {
118
- margin: 6px;
119
- transform: scale(1.3);
120
- }
121
-
122
- /* Citation section styling */
123
- #citation-textbox textarea {
124
- background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
125
- border: 2px solid #dee2e6 !important;
126
- border-radius: 12px !important;
127
- font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace !important;
128
- font-size: 12px !important;
129
- padding: 20px !important;
130
- line-height: 1.6 !important;
131
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
132
- }
133
-
134
- #citation-textbox label > button {
135
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
136
- border: none !important;
137
- border-radius: 8px !important;
138
- color: white !important;
139
- padding: 8px 16px !important;
140
- margin: 8px !important;
141
- transform: scale(1.1);
142
- transition: transform 0.2s ease;
143
- }
144
-
145
- #citation-textbox label > button:hover {
146
- transform: scale(1.15) !important;
147
- }
148
-
149
- #leaderboard-table {
150
- margin-top: 25px !important;
151
- }
152
-
153
- #leaderboard-table-lite {
154
- margin-top: 25px !important;
155
- }
156
-
157
- #search-bar-table-box > div:first-child {
158
- background: none;
159
- border: none;
160
- }
161
-
162
- #search-bar {
163
- padding: 0px;
164
- }
165
-
166
- /* Enhanced table column widths and responsiveness */
167
- #leaderboard-table td:nth-child(2),
168
- #leaderboard-table th:nth-child(2) {
169
- max-width: 400px;
170
- overflow: hidden;
171
- text-overflow: ellipsis;
172
- white-space: nowrap;
173
- }
174
-
175
- /* Responsive table improvements */
176
- .dataframe {
177
- width: 100% !important;
178
- margin: 16px 0 !important;
179
- }
180
-
181
- /* Better mobile responsiveness */
182
- @media (max-width: 768px) {
183
- .dataframe th,
184
- .dataframe td {
185
- padding: 8px 6px !important;
186
- font-size: 13px !important;
187
- }
188
-
189
- .dataframe th {
190
- font-size: 12px !important;
191
- }
192
-
193
- #leaderboard-table td:nth-child(2),
194
- #leaderboard-table th:nth-child(2) {
195
- max-width: 200px;
196
- }
197
- }
198
-
199
- /* Rank column special styling */
200
- .dataframe td:nth-child(1) {
201
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
202
- color: white !important;
203
- font-weight: 700 !important;
204
- font-size: 16px !important;
205
- border-radius: 8px !important;
206
- margin: 4px !important;
207
- min-width: 40px !important;
208
- }
209
-
210
- .dataframe tr:nth-child(1) td:nth-child(1) {
211
- background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%) !important;
212
- color: #8b4513 !important;
213
- }
214
-
215
- .dataframe tr:nth-child(2) td:nth-child(1) {
216
- background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%) !important;
217
- color: #4a4a4a !important;
218
- }
219
-
220
- .dataframe tr:nth-child(3) td:nth-child(1) {
221
- background: linear-gradient(135deg, #cd7f32 0%, #daa520 100%) !important;
222
- color: white !important;
223
- }
224
-
225
- .tab-buttons button {
226
- font-size: 20px;
227
- }
228
-
229
- #scale-logo {
230
- border-style: none !important;
231
- box-shadow: none;
232
- display: block;
233
- margin-left: auto;
234
- margin-right: auto;
235
- max-width: 600px;
236
- }
237
-
238
- #scale-logo .download {
239
- display: none;
240
- }
241
- #filter_type{
242
- border: 0;
243
- padding-left: 0;
244
- padding-top: 0;
245
- }
246
- #filter_type label {
247
- display: flex;
248
- }
249
- #filter_type label > span{
250
- margin-top: var(--spacing-lg);
251
- margin-right: 0.5em;
252
- }
253
- #filter_type label > .wrap{
254
- width: 103px;
255
- }
256
- #filter_type label > .wrap .wrap-inner{
257
- padding: 2px;
258
- }
259
- #filter_type label > .wrap .wrap-inner input{
260
- width: 1px
261
- }
262
- #filter-columns-type{
263
- border:0;
264
- padding:0.5;
265
- }
266
- #filter-columns-size{
267
- border:0;
268
- padding:0.5;
269
- }
270
- #box-filter > .form{
271
- border: 0
272
- }
273
- """
274
-
275
-
276
- get_window_url_params = """
277
- function(url_params) {
278
- const params = new URLSearchParams(window.location.search);
279
- url_params = Object.fromEntries(params);
280
- return url_params;
281
- }
282
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
display/formatting.py DELETED
@@ -1,27 +0,0 @@
1
- def model_hyperlink(link, model_name):
2
- return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
3
-
4
-
5
- def make_clickable_model(model_name):
6
- link = f"https://huggingface.co/{model_name}"
7
- return model_hyperlink(link, model_name)
8
-
9
-
10
- def styled_error(error):
11
- return f"<p style='color: red; font-size: 20px; text-align: center;'>{error}</p>"
12
-
13
-
14
- def styled_warning(warn):
15
- return f"<p style='color: orange; font-size: 20px; text-align: center;'>{warn}</p>"
16
-
17
-
18
- def styled_message(message):
19
- return f"<p style='color: green; font-size: 20px; text-align: center;'>{message}</p>"
20
-
21
-
22
- def has_no_nan_values(df, columns):
23
- return df[columns].notna().all(axis=1)
24
-
25
-
26
- def has_nan_values(df, columns):
27
- return df[columns].isna().any(axis=1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
display/utils.py DELETED
@@ -1,110 +0,0 @@
1
- from dataclasses import dataclass, make_dataclass
2
- from enum import Enum
3
-
4
- import pandas as pd
5
-
6
- from src.about import Tasks
7
-
8
- def fields(raw_class):
9
- return [v for k, v in raw_class.__dict__.items() if k[:2] != "__" and k[-2:] != "__"]
10
-
11
-
12
- # These classes are for user facing column names,
13
- # to avoid having to change them all around the code
14
- # when a modif is needed
15
- @dataclass
16
- class ColumnContent:
17
- name: str
18
- type: str
19
- displayed_by_default: bool
20
- hidden: bool = False
21
- never_hidden: bool = False
22
-
23
- ## Leaderboard columns
24
- auto_eval_column_dict = []
25
- # Init
26
- auto_eval_column_dict.append(["model_type_symbol", ColumnContent, ColumnContent("T", "str", True, never_hidden=True)])
27
- auto_eval_column_dict.append(["model", ColumnContent, ColumnContent("Model", "markdown", True, never_hidden=True)])
28
- #Scores
29
- auto_eval_column_dict.append(["average", ColumnContent, ColumnContent("Average ⬆️", "number", True)])
30
- for task in Tasks:
31
- auto_eval_column_dict.append([task.name, ColumnContent, ColumnContent(task.value.col_name, "number", True)])
32
- # Model information
33
- auto_eval_column_dict.append(["model_type", ColumnContent, ColumnContent("Type", "str", False)])
34
- auto_eval_column_dict.append(["architecture", ColumnContent, ColumnContent("Architecture", "str", False)])
35
- auto_eval_column_dict.append(["weight_type", ColumnContent, ColumnContent("Weight type", "str", False, True)])
36
- auto_eval_column_dict.append(["precision", ColumnContent, ColumnContent("Precision", "str", False)])
37
- auto_eval_column_dict.append(["license", ColumnContent, ColumnContent("Hub License", "str", False)])
38
- auto_eval_column_dict.append(["params", ColumnContent, ColumnContent("#Params (B)", "number", False)])
39
- auto_eval_column_dict.append(["likes", ColumnContent, ColumnContent("Hub ❤️", "number", False)])
40
- auto_eval_column_dict.append(["still_on_hub", ColumnContent, ColumnContent("Available on the hub", "bool", False)])
41
- auto_eval_column_dict.append(["revision", ColumnContent, ColumnContent("Model sha", "str", False, False)])
42
-
43
- # We use make dataclass to dynamically fill the scores from Tasks
44
- AutoEvalColumn = make_dataclass("AutoEvalColumn", auto_eval_column_dict, frozen=True)
45
-
46
- ## For the queue columns in the submission tab
47
- @dataclass(frozen=True)
48
- class EvalQueueColumn: # Queue column
49
- model = ColumnContent("model", "markdown", True)
50
- revision = ColumnContent("revision", "str", True)
51
- private = ColumnContent("private", "bool", True)
52
- precision = ColumnContent("precision", "str", True)
53
- weight_type = ColumnContent("weight_type", "str", "Original")
54
- status = ColumnContent("status", "str", True)
55
-
56
- ## All the model information that we might need
57
- @dataclass
58
- class ModelDetails:
59
- name: str
60
- display_name: str = ""
61
- symbol: str = "" # emoji
62
-
63
-
64
- class ModelType(Enum):
65
- PT = ModelDetails(name="pretrained", symbol="🟢")
66
- FT = ModelDetails(name="fine-tuned", symbol="🔶")
67
- IFT = ModelDetails(name="instruction-tuned", symbol="⭕")
68
- RL = ModelDetails(name="RL-tuned", symbol="🟦")
69
- Unknown = ModelDetails(name="", symbol="?")
70
-
71
- def to_str(self, separator=" "):
72
- return f"{self.value.symbol}{separator}{self.value.name}"
73
-
74
- @staticmethod
75
- def from_str(type):
76
- if "fine-tuned" in type or "🔶" in type:
77
- return ModelType.FT
78
- if "pretrained" in type or "🟢" in type:
79
- return ModelType.PT
80
- if "RL-tuned" in type or "🟦" in type:
81
- return ModelType.RL
82
- if "instruction-tuned" in type or "⭕" in type:
83
- return ModelType.IFT
84
- return ModelType.Unknown
85
-
86
- class WeightType(Enum):
87
- Adapter = ModelDetails("Adapter")
88
- Original = ModelDetails("Original")
89
- Delta = ModelDetails("Delta")
90
-
91
- class Precision(Enum):
92
- float16 = ModelDetails("float16")
93
- bfloat16 = ModelDetails("bfloat16")
94
- Unknown = ModelDetails("?")
95
-
96
- def from_str(precision):
97
- if precision in ["torch.float16", "float16"]:
98
- return Precision.float16
99
- if precision in ["torch.bfloat16", "bfloat16"]:
100
- return Precision.bfloat16
101
- return Precision.Unknown
102
-
103
- # Column selection
104
- COLS = [c.name for c in fields(AutoEvalColumn) if not c.hidden]
105
-
106
- EVAL_COLS = [c.name for c in fields(EvalQueueColumn)]
107
- EVAL_TYPES = [c.type for c in fields(EvalQueueColumn)]
108
-
109
- BENCHMARK_COLS = [t.value.col_name for t in Tasks]
110
-