Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,9 +41,9 @@ def get_plots(task):
|
|
| 41 |
df = pd.read_csv('data/energy/' + task)
|
| 42 |
if df.columns[0].startswith("Unnamed:"):
|
| 43 |
df = df.iloc[:, 1:]
|
| 44 |
-
# Convert GPU energy to float
|
| 45 |
df['total_gpu_energy'] = df['total_gpu_energy'].astype(float)
|
| 46 |
-
# Convert energy_score to categorical string for proper discrete coloring
|
| 47 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
| 48 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
| 49 |
|
|
@@ -59,7 +59,7 @@ def get_plots(task):
|
|
| 59 |
width=800,
|
| 60 |
color_discrete_map=color_map
|
| 61 |
)
|
| 62 |
-
# Hover text
|
| 63 |
fig.update_traces(
|
| 64 |
hovertemplate="<br>".join([
|
| 65 |
"Model: %{y}",
|
|
@@ -67,11 +67,10 @@ def get_plots(task):
|
|
| 67 |
"Energy Score: %{customdata[0]}"
|
| 68 |
])
|
| 69 |
)
|
| 70 |
-
#
|
| 71 |
fig.update_layout(
|
| 72 |
xaxis_title="GPU Energy (Wh)",
|
| 73 |
-
yaxis_title="Model"
|
| 74 |
-
xaxis=dict(tickformat=".4f")
|
| 75 |
)
|
| 76 |
return fig
|
| 77 |
|
|
@@ -108,8 +107,7 @@ def get_all_plots():
|
|
| 108 |
)
|
| 109 |
fig.update_layout(
|
| 110 |
xaxis_title="GPU Energy (Wh)",
|
| 111 |
-
yaxis_title="Model"
|
| 112 |
-
xaxis=dict(tickformat=".4f")
|
| 113 |
)
|
| 114 |
return fig
|
| 115 |
|
|
@@ -118,7 +116,7 @@ def get_model_names(task):
|
|
| 118 |
if df.columns[0].startswith("Unnamed:"):
|
| 119 |
df = df.iloc[:, 1:]
|
| 120 |
df['energy_score'] = df['energy_score'].astype(int)
|
| 121 |
-
#
|
| 122 |
df['GPU Energy (Wh)'] = df['total_gpu_energy'].astype(float).apply(lambda x: f"{x:.4f}")
|
| 123 |
df['Model'] = df['model'].apply(make_link)
|
| 124 |
df['Score'] = df['energy_score'].apply(format_stars)
|
|
@@ -148,6 +146,7 @@ def get_text_generation_plots(model_class):
|
|
| 148 |
# Filter by the selected model class if the "class" column exists
|
| 149 |
if 'class' in df.columns:
|
| 150 |
df = df[df['class'] == model_class]
|
|
|
|
| 151 |
df['total_gpu_energy'] = df['total_gpu_energy'].astype(float)
|
| 152 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
| 153 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
|
@@ -173,8 +172,7 @@ def get_text_generation_plots(model_class):
|
|
| 173 |
)
|
| 174 |
fig.update_layout(
|
| 175 |
xaxis_title="GPU Energy (Wh)",
|
| 176 |
-
yaxis_title="Model"
|
| 177 |
-
xaxis=dict(tickformat=".4f")
|
| 178 |
)
|
| 179 |
return fig
|
| 180 |
|
|
@@ -216,10 +214,7 @@ with demo:
|
|
| 216 |
gr.Markdown(
|
| 217 |
"""# AI Energy Score Leaderboard
|
| 218 |
### Welcome to the leaderboard for the [AI Energy Score Project!](https://huggingface.co/AIEnergyScore)
|
| 219 |
-
|
| 220 |
-
)
|
| 221 |
-
gr.Markdown(
|
| 222 |
-
"""Test your own models via the [submission portal](https://huggingface.co/spaces/AIEnergyScore/submission_portal)"""
|
| 223 |
)
|
| 224 |
|
| 225 |
with gr.Tabs():
|
|
|
|
| 41 |
df = pd.read_csv('data/energy/' + task)
|
| 42 |
if df.columns[0].startswith("Unnamed:"):
|
| 43 |
df = df.iloc[:, 1:]
|
| 44 |
+
# Convert GPU energy to float (use the raw values from the CSV)
|
| 45 |
df['total_gpu_energy'] = df['total_gpu_energy'].astype(float)
|
| 46 |
+
# Convert energy_score to a categorical string for proper discrete coloring
|
| 47 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
| 48 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
| 49 |
|
|
|
|
| 59 |
width=800,
|
| 60 |
color_discrete_map=color_map
|
| 61 |
)
|
| 62 |
+
# Hover text shows GPU Energy rounded to 4 decimals
|
| 63 |
fig.update_traces(
|
| 64 |
hovertemplate="<br>".join([
|
| 65 |
"Model: %{y}",
|
|
|
|
| 67 |
"Energy Score: %{customdata[0]}"
|
| 68 |
])
|
| 69 |
)
|
| 70 |
+
# Remove forced tickformat so the x-axis uses the raw numbers
|
| 71 |
fig.update_layout(
|
| 72 |
xaxis_title="GPU Energy (Wh)",
|
| 73 |
+
yaxis_title="Model"
|
|
|
|
| 74 |
)
|
| 75 |
return fig
|
| 76 |
|
|
|
|
| 107 |
)
|
| 108 |
fig.update_layout(
|
| 109 |
xaxis_title="GPU Energy (Wh)",
|
| 110 |
+
yaxis_title="Model"
|
|
|
|
| 111 |
)
|
| 112 |
return fig
|
| 113 |
|
|
|
|
| 116 |
if df.columns[0].startswith("Unnamed:"):
|
| 117 |
df = df.iloc[:, 1:]
|
| 118 |
df['energy_score'] = df['energy_score'].astype(int)
|
| 119 |
+
# For leaderboard display, format GPU Energy to 4 decimals
|
| 120 |
df['GPU Energy (Wh)'] = df['total_gpu_energy'].astype(float).apply(lambda x: f"{x:.4f}")
|
| 121 |
df['Model'] = df['model'].apply(make_link)
|
| 122 |
df['Score'] = df['energy_score'].apply(format_stars)
|
|
|
|
| 146 |
# Filter by the selected model class if the "class" column exists
|
| 147 |
if 'class' in df.columns:
|
| 148 |
df = df[df['class'] == model_class]
|
| 149 |
+
# Use the raw GPU energy values from the CSV
|
| 150 |
df['total_gpu_energy'] = df['total_gpu_energy'].astype(float)
|
| 151 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
| 152 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
|
|
|
| 172 |
)
|
| 173 |
fig.update_layout(
|
| 174 |
xaxis_title="GPU Energy (Wh)",
|
| 175 |
+
yaxis_title="Model"
|
|
|
|
| 176 |
)
|
| 177 |
return fig
|
| 178 |
|
|
|
|
| 214 |
gr.Markdown(
|
| 215 |
"""# AI Energy Score Leaderboard
|
| 216 |
### Welcome to the leaderboard for the [AI Energy Score Project!](https://huggingface.co/AIEnergyScore)
|
| 217 |
+
Select different tasks to see scored models. Submit open models for testing and learn about testing proprietary models via the [submission portal](https://huggingface.co/spaces/AIEnergyScore/submission_portal)"""
|
|
|
|
|
|
|
|
|
|
| 218 |
)
|
| 219 |
|
| 220 |
with gr.Tabs():
|