Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,9 +41,8 @@ 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 |
-
#
|
| 45 |
-
df['total_gpu_energy'] = df['total_gpu_energy']
|
| 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,7 +58,8 @@ def get_plots(task):
|
|
| 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,7 +67,6 @@ def get_plots(task):
|
|
| 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"
|
|
@@ -80,7 +79,7 @@ def get_all_plots():
|
|
| 80 |
df = pd.read_csv('data/energy/' + task)
|
| 81 |
if df.columns[0].startswith("Unnamed:"):
|
| 82 |
df = df.iloc[:, 1:]
|
| 83 |
-
df['total_gpu_energy'] = df['total_gpu_energy']
|
| 84 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
| 85 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
| 86 |
all_df = pd.concat([all_df, df], ignore_index=True)
|
|
@@ -117,7 +116,7 @@ def get_model_names(task):
|
|
| 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']
|
| 121 |
df['Model'] = df['model'].apply(make_link)
|
| 122 |
df['Score'] = df['energy_score'].apply(format_stars)
|
| 123 |
# Remove any Class column if it exists
|
|
@@ -130,7 +129,7 @@ def get_all_model_names():
|
|
| 130 |
for task in tasks:
|
| 131 |
df = pd.read_csv('data/energy/' + task)
|
| 132 |
df['energy_score'] = df['energy_score'].astype(int)
|
| 133 |
-
df['GPU Energy (Wh)'] = df['total_gpu_energy']
|
| 134 |
df['Model'] = df['model'].apply(make_link)
|
| 135 |
df['Score'] = df['energy_score'].apply(format_stars)
|
| 136 |
all_df = pd.concat([all_df, df], ignore_index=True)
|
|
@@ -146,8 +145,8 @@ def get_text_generation_plots(model_class):
|
|
| 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
|
| 150 |
-
df['total_gpu_energy'] = df['total_gpu_energy']
|
| 151 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
| 152 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
| 153 |
|
|
@@ -183,7 +182,7 @@ def get_text_generation_model_names(model_class):
|
|
| 183 |
if 'class' in df.columns:
|
| 184 |
df = df[df['class'] == model_class]
|
| 185 |
df['energy_score'] = df['energy_score'].astype(int)
|
| 186 |
-
df['GPU Energy (Wh)'] = df['total_gpu_energy']
|
| 187 |
df['Model'] = df['model'].apply(make_link)
|
| 188 |
df['Score'] = df['energy_score'].apply(format_stars)
|
| 189 |
# Remove the Class column if it exists
|
|
|
|
| 41 |
df = pd.read_csv('data/energy/' + task)
|
| 42 |
if df.columns[0].startswith("Unnamed:"):
|
| 43 |
df = df.iloc[:, 1:]
|
| 44 |
+
# Use the raw numeric value from the CSV
|
| 45 |
+
df['total_gpu_energy'] = pd.to_numeric(df['total_gpu_energy'], errors='raise')
|
|
|
|
| 46 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
| 47 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
| 48 |
|
|
|
|
| 58 |
width=800,
|
| 59 |
color_discrete_map=color_map
|
| 60 |
)
|
| 61 |
+
# Hover text shows GPU Energy rounded to 4 decimals,
|
| 62 |
+
# but note that no formatting is applied to the x-axis ticks.
|
| 63 |
fig.update_traces(
|
| 64 |
hovertemplate="<br>".join([
|
| 65 |
"Model: %{y}",
|
|
|
|
| 67 |
"Energy Score: %{customdata[0]}"
|
| 68 |
])
|
| 69 |
)
|
|
|
|
| 70 |
fig.update_layout(
|
| 71 |
xaxis_title="GPU Energy (Wh)",
|
| 72 |
yaxis_title="Model"
|
|
|
|
| 79 |
df = pd.read_csv('data/energy/' + task)
|
| 80 |
if df.columns[0].startswith("Unnamed:"):
|
| 81 |
df = df.iloc[:, 1:]
|
| 82 |
+
df['total_gpu_energy'] = pd.to_numeric(df['total_gpu_energy'], errors='raise')
|
| 83 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
| 84 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
| 85 |
all_df = pd.concat([all_df, df], ignore_index=True)
|
|
|
|
| 116 |
df = df.iloc[:, 1:]
|
| 117 |
df['energy_score'] = df['energy_score'].astype(int)
|
| 118 |
# For leaderboard display, format GPU Energy to 4 decimals
|
| 119 |
+
df['GPU Energy (Wh)'] = pd.to_numeric(df['total_gpu_energy'], errors='raise').apply(lambda x: f"{x:.4f}")
|
| 120 |
df['Model'] = df['model'].apply(make_link)
|
| 121 |
df['Score'] = df['energy_score'].apply(format_stars)
|
| 122 |
# Remove any Class column if it exists
|
|
|
|
| 129 |
for task in tasks:
|
| 130 |
df = pd.read_csv('data/energy/' + task)
|
| 131 |
df['energy_score'] = df['energy_score'].astype(int)
|
| 132 |
+
df['GPU Energy (Wh)'] = pd.to_numeric(df['total_gpu_energy'], errors='raise').apply(lambda x: f"{x:.4f}")
|
| 133 |
df['Model'] = df['model'].apply(make_link)
|
| 134 |
df['Score'] = df['energy_score'].apply(format_stars)
|
| 135 |
all_df = pd.concat([all_df, df], ignore_index=True)
|
|
|
|
| 145 |
# Filter by the selected model class if the "class" column exists
|
| 146 |
if 'class' in df.columns:
|
| 147 |
df = df[df['class'] == model_class]
|
| 148 |
+
# Use the raw numeric value from the CSV
|
| 149 |
+
df['total_gpu_energy'] = pd.to_numeric(df['total_gpu_energy'], errors='raise')
|
| 150 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
| 151 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
| 152 |
|
|
|
|
| 182 |
if 'class' in df.columns:
|
| 183 |
df = df[df['class'] == model_class]
|
| 184 |
df['energy_score'] = df['energy_score'].astype(int)
|
| 185 |
+
df['GPU Energy (Wh)'] = pd.to_numeric(df['total_gpu_energy'], errors='raise').apply(lambda x: f"{x:.4f}")
|
| 186 |
df['Model'] = df['model'].apply(make_link)
|
| 187 |
df['Score'] = df['energy_score'].apply(format_stars)
|
| 188 |
# Remove the Class column if it exists
|