Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -30,7 +30,7 @@ def format_stars(score):
|
|
30 |
Convert the energy_score (assumed to be an integer from 1 to 5)
|
31 |
into that many star characters wrapped in a span styled with color #3fa45bff
|
32 |
and with a font size increased to 2em.
|
33 |
-
The
|
34 |
"""
|
35 |
try:
|
36 |
score_int = int(score)
|
@@ -50,12 +50,15 @@ def make_link(mname):
|
|
50 |
def get_plots(task):
|
51 |
"""
|
52 |
Read the energy CSV for a given task and return a Plotly scatter plot.
|
53 |
-
|
54 |
-
|
55 |
"""
|
56 |
df = pd.read_csv('data/energy/' + task)
|
|
|
|
|
|
|
57 |
df['energy_score'] = df['energy_score'].astype(int)
|
58 |
-
# Use the
|
59 |
df['GPU Energy (Wh)'] = df['total_gpu_energy'].round(4)
|
60 |
# Create a column that displays only the model name (the part after '/')
|
61 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
@@ -97,6 +100,8 @@ def get_all_plots():
|
|
97 |
all_df = pd.DataFrame()
|
98 |
for task in tasks:
|
99 |
df = pd.read_csv('data/energy/' + task)
|
|
|
|
|
100 |
df['energy_score'] = df['energy_score'].astype(int)
|
101 |
df['GPU Energy (Wh)'] = df['total_gpu_energy'].round(4)
|
102 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
@@ -140,8 +145,10 @@ def get_model_names(task):
|
|
140 |
The final column order is: Model, GPU Energy (Wh), Score, [Class].
|
141 |
"""
|
142 |
df = pd.read_csv('data/energy/' + task)
|
|
|
|
|
143 |
df['energy_score'] = df['energy_score'].astype(int)
|
144 |
-
# Format the energy as a string with 4 decimals
|
145 |
df['GPU Energy (Wh)'] = df['total_gpu_energy'].apply(lambda x: f"{x:.4f}")
|
146 |
df['Model'] = df['model'].apply(make_link)
|
147 |
df['Score'] = df['energy_score'].apply(format_stars)
|
@@ -164,6 +171,8 @@ def get_all_model_names():
|
|
164 |
all_df = pd.DataFrame()
|
165 |
for task in tasks:
|
166 |
df = pd.read_csv('data/energy/' + task)
|
|
|
|
|
167 |
df['energy_score'] = df['energy_score'].astype(int)
|
168 |
df['GPU Energy (Wh)'] = df['total_gpu_energy'].apply(lambda x: f"{x:.4f}")
|
169 |
df['Model'] = df['model'].apply(make_link)
|
@@ -174,7 +183,19 @@ def get_all_model_names():
|
|
174 |
return all_df[['Model', 'GPU Energy (Wh)', 'Score']]
|
175 |
|
176 |
# Build the Gradio interface.
|
177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
with demo:
|
180 |
gr.Markdown(
|
|
|
30 |
Convert the energy_score (assumed to be an integer from 1 to 5)
|
31 |
into that many star characters wrapped in a span styled with color #3fa45bff
|
32 |
and with a font size increased to 2em.
|
33 |
+
The '!important' rules force the styling immediately.
|
34 |
"""
|
35 |
try:
|
36 |
score_int = int(score)
|
|
|
50 |
def get_plots(task):
|
51 |
"""
|
52 |
Read the energy CSV for a given task and return a Plotly scatter plot.
|
53 |
+
The x-axis uses the 'total_gpu_energy' column (rounded to 4 decimals) and
|
54 |
+
the y-axis displays only the model name (extracted from the 'model' column).
|
55 |
"""
|
56 |
df = pd.read_csv('data/energy/' + task)
|
57 |
+
# If an extra unnamed index column exists, drop it.
|
58 |
+
if df.columns[0].startswith("Unnamed:"):
|
59 |
+
df = df.iloc[:, 1:]
|
60 |
df['energy_score'] = df['energy_score'].astype(int)
|
61 |
+
# Use the correct column: "total_gpu_energy"
|
62 |
df['GPU Energy (Wh)'] = df['total_gpu_energy'].round(4)
|
63 |
# Create a column that displays only the model name (the part after '/')
|
64 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
|
|
100 |
all_df = pd.DataFrame()
|
101 |
for task in tasks:
|
102 |
df = pd.read_csv('data/energy/' + task)
|
103 |
+
if df.columns[0].startswith("Unnamed:"):
|
104 |
+
df = df.iloc[:, 1:]
|
105 |
df['energy_score'] = df['energy_score'].astype(int)
|
106 |
df['GPU Energy (Wh)'] = df['total_gpu_energy'].round(4)
|
107 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
|
|
145 |
The final column order is: Model, GPU Energy (Wh), Score, [Class].
|
146 |
"""
|
147 |
df = pd.read_csv('data/energy/' + task)
|
148 |
+
if df.columns[0].startswith("Unnamed:"):
|
149 |
+
df = df.iloc[:, 1:]
|
150 |
df['energy_score'] = df['energy_score'].astype(int)
|
151 |
+
# Format the energy as a string with 4 decimals
|
152 |
df['GPU Energy (Wh)'] = df['total_gpu_energy'].apply(lambda x: f"{x:.4f}")
|
153 |
df['Model'] = df['model'].apply(make_link)
|
154 |
df['Score'] = df['energy_score'].apply(format_stars)
|
|
|
171 |
all_df = pd.DataFrame()
|
172 |
for task in tasks:
|
173 |
df = pd.read_csv('data/energy/' + task)
|
174 |
+
if df.columns[0].startswith("Unnamed:"):
|
175 |
+
df = df.iloc[:, 1:]
|
176 |
df['energy_score'] = df['energy_score'].astype(int)
|
177 |
df['GPU Energy (Wh)'] = df['total_gpu_energy'].apply(lambda x: f"{x:.4f}")
|
178 |
df['Model'] = df['model'].apply(make_link)
|
|
|
183 |
return all_df[['Model', 'GPU Energy (Wh)', 'Score']]
|
184 |
|
185 |
# Build the Gradio interface.
|
186 |
+
# The css argument below makes all tables (e.g. leaderboard) use a fixed layout with narrower columns.
|
187 |
+
demo = gr.Blocks(css="""
|
188 |
+
.gr-dataframe table {
|
189 |
+
table-layout: fixed;
|
190 |
+
width: 100%;
|
191 |
+
}
|
192 |
+
.gr-dataframe th, .gr-dataframe td {
|
193 |
+
max-width: 150px;
|
194 |
+
white-space: nowrap;
|
195 |
+
overflow: hidden;
|
196 |
+
text-overflow: ellipsis;
|
197 |
+
}
|
198 |
+
""")
|
199 |
|
200 |
with demo:
|
201 |
gr.Markdown(
|