Spaces:
Running
Running
add rank, update css
Browse files- app.py +7 -12
- static/css/default.css +0 -57
- static/css/single_image.css +0 -57
- static/css/style.css +11 -3
- utils.py +7 -0
app.py
CHANGED
@@ -8,16 +8,13 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
8 |
|
9 |
# Construct paths to CSS files
|
10 |
base_css_file = os.path.join(current_dir, "static", "css", "style.css")
|
11 |
-
|
12 |
-
si_css_file = os.path.join(current_dir, "static", "css", "single_image.css")
|
13 |
|
14 |
# Read CSS files
|
15 |
with open(base_css_file, "r") as f:
|
16 |
base_css = f.read()
|
17 |
-
with open(
|
18 |
-
|
19 |
-
with open(si_css_file, "r") as f:
|
20 |
-
si_css = f.read()
|
21 |
|
22 |
# Initialize data loaders
|
23 |
default_loader = MEGABenchEvalDataLoader("./static/eval_results/Default")
|
@@ -26,7 +23,7 @@ si_loader = MEGABenchEvalDataLoader("./static/eval_results/SI")
|
|
26 |
with gr.Blocks() as block:
|
27 |
# Add a style element that we'll update
|
28 |
css_style = gr.HTML(
|
29 |
-
f"<style>{base_css}\n{
|
30 |
visible=False
|
31 |
)
|
32 |
|
@@ -81,7 +78,7 @@ with gr.Blocks() as block:
|
|
81 |
data_component = gr.Dataframe(
|
82 |
value=initial_data,
|
83 |
headers=initial_headers,
|
84 |
-
datatype=["html"] + ["number"] * (len(initial_headers) -
|
85 |
interactive=False,
|
86 |
elem_classes="custom-dataframe",
|
87 |
max_height=2400,
|
@@ -91,21 +88,19 @@ with gr.Blocks() as block:
|
|
91 |
if table_type == "Default":
|
92 |
headers, data = default_loader.get_leaderboard_data(super_group, model_group)
|
93 |
caption = default_caption
|
94 |
-
current_css = f"{base_css}\n{default_css}"
|
95 |
else: # Single-image
|
96 |
headers, data = si_loader.get_leaderboard_data(super_group, model_group)
|
97 |
caption = single_image_caption
|
98 |
-
current_css = f"{base_css}\n{si_css}"
|
99 |
|
100 |
return [
|
101 |
gr.Dataframe(
|
102 |
value=data,
|
103 |
headers=headers,
|
104 |
-
datatype=["html"] + ["number"] * (len(headers) -
|
105 |
interactive=False,
|
106 |
),
|
107 |
caption,
|
108 |
-
f"<style>{
|
109 |
]
|
110 |
|
111 |
def update_selectors(table_type):
|
|
|
8 |
|
9 |
# Construct paths to CSS files
|
10 |
base_css_file = os.path.join(current_dir, "static", "css", "style.css")
|
11 |
+
table_css_file = os.path.join(current_dir, "static", "css", "table.css")
|
|
|
12 |
|
13 |
# Read CSS files
|
14 |
with open(base_css_file, "r") as f:
|
15 |
base_css = f.read()
|
16 |
+
with open(table_css_file, "r") as f:
|
17 |
+
table_css = f.read()
|
|
|
|
|
18 |
|
19 |
# Initialize data loaders
|
20 |
default_loader = MEGABenchEvalDataLoader("./static/eval_results/Default")
|
|
|
23 |
with gr.Blocks() as block:
|
24 |
# Add a style element that we'll update
|
25 |
css_style = gr.HTML(
|
26 |
+
f"<style>{base_css}\n{table_css}</style>",
|
27 |
visible=False
|
28 |
)
|
29 |
|
|
|
78 |
data_component = gr.Dataframe(
|
79 |
value=initial_data,
|
80 |
headers=initial_headers,
|
81 |
+
datatype=["number"] + ["html"] + ["number"] * (len(initial_headers) - 2),
|
82 |
interactive=False,
|
83 |
elem_classes="custom-dataframe",
|
84 |
max_height=2400,
|
|
|
88 |
if table_type == "Default":
|
89 |
headers, data = default_loader.get_leaderboard_data(super_group, model_group)
|
90 |
caption = default_caption
|
|
|
91 |
else: # Single-image
|
92 |
headers, data = si_loader.get_leaderboard_data(super_group, model_group)
|
93 |
caption = single_image_caption
|
|
|
94 |
|
95 |
return [
|
96 |
gr.Dataframe(
|
97 |
value=data,
|
98 |
headers=headers,
|
99 |
+
datatype=["number"] + ["html"] + ["number"] * (len(headers) - 2),
|
100 |
interactive=False,
|
101 |
),
|
102 |
caption,
|
103 |
+
f"<style>{base_css}\n{table_css}</style>"
|
104 |
]
|
105 |
|
106 |
def update_selectors(table_type):
|
static/css/default.css
DELETED
@@ -1,57 +0,0 @@
|
|
1 |
-
.custom-dataframe thead th:nth-child(-n+4),
|
2 |
-
.custom-dataframe tbody td:nth-child(-n+4) {
|
3 |
-
background-color: var(--global-column-background) !important;
|
4 |
-
}
|
5 |
-
|
6 |
-
.custom-dataframe thead th:nth-child(n+5),
|
7 |
-
.custom-dataframe tbody td:nth-child(n+5) {
|
8 |
-
background-color: var(--dimension-column-background) !important;
|
9 |
-
}
|
10 |
-
|
11 |
-
.custom-dataframe tbody tr:nth-child(even) td:nth-child(-n+4) {
|
12 |
-
background-color: var(--row-even-global) !important;
|
13 |
-
}
|
14 |
-
|
15 |
-
.custom-dataframe tbody tr:nth-child(even) td:nth-child(n+5) {
|
16 |
-
background-color: var(--row-even-dimension) !important;
|
17 |
-
}
|
18 |
-
|
19 |
-
/* Dark mode styles */
|
20 |
-
@media (prefers-color-scheme: dark) {
|
21 |
-
.custom-dataframe {
|
22 |
-
color: var(--text-color) !important;
|
23 |
-
background-color: var(--background-color) !important;
|
24 |
-
}
|
25 |
-
|
26 |
-
.custom-dataframe thead th {
|
27 |
-
background-color: var(--header-background) !important;
|
28 |
-
color: var(--text-color) !important;
|
29 |
-
}
|
30 |
-
|
31 |
-
.custom-dataframe tbody td {
|
32 |
-
background-color: var(--background-color) !important;
|
33 |
-
color: var(--text-color) !important;
|
34 |
-
}
|
35 |
-
|
36 |
-
.custom-dataframe thead th:nth-child(-n+4),
|
37 |
-
.custom-dataframe tbody td:nth-child(-n+4) {
|
38 |
-
background-color: var(--global-column-background) !important;
|
39 |
-
}
|
40 |
-
|
41 |
-
.custom-dataframe thead th:nth-child(n+5),
|
42 |
-
.custom-dataframe tbody td:nth-child(n+5) {
|
43 |
-
background-color: var(--dimension-column-background) !important;
|
44 |
-
}
|
45 |
-
|
46 |
-
.custom-dataframe tbody tr:nth-child(even) td:nth-child(-n+4) {
|
47 |
-
background-color: var(--row-even-global) !important;
|
48 |
-
}
|
49 |
-
|
50 |
-
.custom-dataframe tbody tr:nth-child(even) td:nth-child(n+5) {
|
51 |
-
background-color: var(--row-even-dimension) !important;
|
52 |
-
}
|
53 |
-
|
54 |
-
.custom-dataframe tbody tr:hover td {
|
55 |
-
background-color: var(--hover-background) !important;
|
56 |
-
}
|
57 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static/css/single_image.css
DELETED
@@ -1,57 +0,0 @@
|
|
1 |
-
.custom-dataframe thead th:nth-child(-n+4),
|
2 |
-
.custom-dataframe tbody td:nth-child(-n+4) {
|
3 |
-
background-color: var(--global-column-background) !important;
|
4 |
-
}
|
5 |
-
|
6 |
-
.custom-dataframe thead th:nth-child(n+5),
|
7 |
-
.custom-dataframe tbody td:nth-child(n+5) {
|
8 |
-
background-color: var(--dimension-column-background) !important;
|
9 |
-
}
|
10 |
-
|
11 |
-
.custom-dataframe tbody tr:nth-child(even) td:nth-child(-n+4) {
|
12 |
-
background-color: var(--row-even-global) !important;
|
13 |
-
}
|
14 |
-
|
15 |
-
.custom-dataframe tbody tr:nth-child(even) td:nth-child(n+5) {
|
16 |
-
background-color: var(--row-even-dimension) !important;
|
17 |
-
}
|
18 |
-
|
19 |
-
/* Dark mode styles */
|
20 |
-
@media (prefers-color-scheme: dark) {
|
21 |
-
.custom-dataframe {
|
22 |
-
color: var(--text-color) !important;
|
23 |
-
background-color: var(--background-color) !important;
|
24 |
-
}
|
25 |
-
|
26 |
-
.custom-dataframe thead th {
|
27 |
-
background-color: var(--header-background) !important;
|
28 |
-
color: var(--text-color) !important;
|
29 |
-
}
|
30 |
-
|
31 |
-
.custom-dataframe tbody td {
|
32 |
-
background-color: var(--background-color) !important;
|
33 |
-
color: var(--text-color) !important;
|
34 |
-
}
|
35 |
-
|
36 |
-
.custom-dataframe thead th:nth-child(-n+4),
|
37 |
-
.custom-dataframe tbody td:nth-child(-n+4) {
|
38 |
-
background-color: var(--global-column-background) !important;
|
39 |
-
}
|
40 |
-
|
41 |
-
.custom-dataframe thead th:nth-child(n+5),
|
42 |
-
.custom-dataframe tbody td:nth-child(n+5) {
|
43 |
-
background-color: var(--dimension-column-background) !important;
|
44 |
-
}
|
45 |
-
|
46 |
-
.custom-dataframe tbody tr:nth-child(even) td:nth-child(-n+4) {
|
47 |
-
background-color: var(--row-even-global) !important;
|
48 |
-
}
|
49 |
-
|
50 |
-
.custom-dataframe tbody tr:nth-child(even) td:nth-child(n+5) {
|
51 |
-
background-color: var(--row-even-dimension) !important;
|
52 |
-
}
|
53 |
-
|
54 |
-
.custom-dataframe tbody tr:hover td {
|
55 |
-
background-color: var(--hover-background) !important;
|
56 |
-
}
|
57 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static/css/style.css
CHANGED
@@ -46,9 +46,17 @@
|
|
46 |
color: var(--text-color);
|
47 |
}
|
48 |
|
49 |
-
.custom-dataframe td:first-child
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
53 |
|
54 |
.custom-dataframe a {
|
|
|
46 |
color: var(--text-color);
|
47 |
}
|
48 |
|
49 |
+
.custom-dataframe td:first-child,
|
50 |
+
.custom-dataframe th:first-child {
|
51 |
+
width: 60px !important;
|
52 |
+
min-width: 60px !important;
|
53 |
+
max-width: 60px !important;
|
54 |
+
text-align: center !important;
|
55 |
+
}
|
56 |
+
|
57 |
+
.custom-dataframe td:nth-child(2) {
|
58 |
+
min-width: 220px !important;
|
59 |
+
white-space: nowrap !important;
|
60 |
}
|
61 |
|
62 |
.custom-dataframe a {
|
utils.py
CHANGED
@@ -130,16 +130,22 @@ class MEGABenchEvalDataLoader:
|
|
130 |
|
131 |
# Define headers with task counts
|
132 |
column_headers = {
|
|
|
133 |
"Models": "Models",
|
134 |
"Overall": f"Overall({total_tasks})",
|
135 |
"Core": f"Core({total_core_tasks})",
|
136 |
"Open-ended": f"Open-ended({total_open_tasks})"
|
137 |
}
|
138 |
|
|
|
|
|
|
|
|
|
139 |
# Rename the columns in DataFrame to match headers
|
140 |
df = df.rename(columns=column_headers)
|
141 |
|
142 |
headers = [
|
|
|
143 |
column_headers["Models"],
|
144 |
column_headers["Overall"],
|
145 |
column_headers["Core"],
|
@@ -147,6 +153,7 @@ class MEGABenchEvalDataLoader:
|
|
147 |
] + self.SUPER_GROUPS[selected_super_group]
|
148 |
|
149 |
data = df[[
|
|
|
150 |
column_headers["Models"],
|
151 |
column_headers["Overall"],
|
152 |
column_headers["Core"],
|
|
|
130 |
|
131 |
# Define headers with task counts
|
132 |
column_headers = {
|
133 |
+
"Rank": "Rank",
|
134 |
"Models": "Models",
|
135 |
"Overall": f"Overall({total_tasks})",
|
136 |
"Core": f"Core({total_core_tasks})",
|
137 |
"Open-ended": f"Open-ended({total_open_tasks})"
|
138 |
}
|
139 |
|
140 |
+
# Add rank column to DataFrame
|
141 |
+
df = df.reset_index(drop=True)
|
142 |
+
df.insert(0, 'Rank', range(1, len(df) + 1))
|
143 |
+
|
144 |
# Rename the columns in DataFrame to match headers
|
145 |
df = df.rename(columns=column_headers)
|
146 |
|
147 |
headers = [
|
148 |
+
column_headers["Rank"],
|
149 |
column_headers["Models"],
|
150 |
column_headers["Overall"],
|
151 |
column_headers["Core"],
|
|
|
153 |
] + self.SUPER_GROUPS[selected_super_group]
|
154 |
|
155 |
data = df[[
|
156 |
+
column_headers["Rank"],
|
157 |
column_headers["Models"],
|
158 |
column_headers["Overall"],
|
159 |
column_headers["Core"],
|