Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -39,14 +39,14 @@ def make_link(mname):
|
|
39 |
display_name = parts[1] if len(parts) > 1 else mname
|
40 |
return f'[{display_name}](https://huggingface.co/{mname})'
|
41 |
|
42 |
-
# --- Plot Functions (Bar Chart - Modified with explicit tickvals) ---
|
43 |
|
44 |
def get_plots(task):
|
45 |
df = pd.read_csv('data/energy/' + task)
|
46 |
if df.columns[0].startswith("Unnamed:"):
|
47 |
df = df.iloc[:, 1:]
|
48 |
-
# Use the raw numeric value from the CSV for GPU Energy
|
49 |
-
df['total_gpu_energy'] = pd.to_numeric(df['total_gpu_energy'], errors='raise')
|
50 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
51 |
# Create a display model column for labeling
|
52 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
@@ -78,7 +78,7 @@ def get_plots(task):
|
|
78 |
yaxis_title="GPU Energy (Wh)",
|
79 |
yaxis = dict(
|
80 |
tickformat=".4f",
|
81 |
-
tickvals = list(np.arange(0, df['total_gpu_energy'].max()
|
82 |
)
|
83 |
)
|
84 |
return fig
|
@@ -89,7 +89,7 @@ def get_all_plots():
|
|
89 |
df = pd.read_csv('data/energy/' + task)
|
90 |
if df.columns[0].startswith("Unnamed:"):
|
91 |
df = df.iloc[:, 1:]
|
92 |
-
df['total_gpu_energy'] = pd.to_numeric(df['total_gpu_energy'], errors='raise')
|
93 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
94 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
95 |
all_df = pd.concat([all_df, df], ignore_index=True)
|
@@ -119,12 +119,12 @@ def get_all_plots():
|
|
119 |
yaxis_title="GPU Energy (Wh)",
|
120 |
yaxis = dict(
|
121 |
tickformat=".4f",
|
122 |
-
tickvals = list(np.arange(0, all_df['total_gpu_energy'].max()
|
123 |
)
|
124 |
)
|
125 |
return fig
|
126 |
|
127 |
-
# --- New functions for Text Generation filtering by model class (with Bar Chart - Modified explicit tickvals) ---
|
128 |
|
129 |
def get_text_generation_plots(model_class):
|
130 |
df = pd.read_csv('data/energy/text_generation.csv')
|
@@ -133,7 +133,7 @@ def get_text_generation_plots(model_class):
|
|
133 |
# Filter by the selected model class if the "class" column exists
|
134 |
if 'class' in df.columns:
|
135 |
df = df[df['class'] == model_class]
|
136 |
-
df['total_gpu_energy'] = pd.to_numeric(df['total_gpu_energy'], errors='raise')
|
137 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
138 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
139 |
|
@@ -162,22 +162,21 @@ def get_text_generation_plots(model_class):
|
|
162 |
yaxis_title="GPU Energy (Wh)",
|
163 |
yaxis = dict(
|
164 |
tickformat=".4f",
|
165 |
-
tickvals = list(np.arange(0, df['total_gpu_energy'].max()
|
166 |
)
|
167 |
)
|
168 |
return fig
|
169 |
|
170 |
|
171 |
-
# --- Leaderboard Table Functions
|
172 |
-
# (Keep the rest of the code same as previous response)
|
173 |
|
174 |
def get_model_names(task):
|
175 |
df = pd.read_csv('data/energy/' + task)
|
176 |
if df.columns[0].startswith("Unnamed:"):
|
177 |
df = df.iloc[:, 1:]
|
178 |
df['energy_score'] = df['energy_score'].astype(int)
|
179 |
-
# For leaderboard display, format GPU Energy to 4 decimals
|
180 |
-
df['GPU Energy (Wh)'] = pd.to_numeric(df['total_gpu_energy'], errors='raise').apply(lambda x: f"{x:.4f}")
|
181 |
df['Model'] = df['model'].apply(make_link)
|
182 |
df['Score'] = df['energy_score'].apply(format_stars)
|
183 |
# Remove any Class column if it exists
|
@@ -190,7 +189,7 @@ def get_all_model_names():
|
|
190 |
for task in tasks:
|
191 |
df = pd.read_csv('data/energy/' + task)
|
192 |
df['energy_score'] = df['energy_score'].astype(int)
|
193 |
-
df['GPU Energy (Wh)'] = pd.to_numeric(df['total_gpu_energy'], errors='raise').apply(lambda x: f"{x:.4f}")
|
194 |
df['Model'] = df['model'].apply(make_link)
|
195 |
df['Score'] = df['energy_score'].apply(format_stars)
|
196 |
all_df = pd.concat([all_df, df], ignore_index=True)
|
@@ -206,7 +205,7 @@ def get_text_generation_model_names(model_class):
|
|
206 |
if 'class' in df.columns:
|
207 |
df = df[df['class'] == model_class]
|
208 |
df['energy_score'] = df['energy_score'].astype(int)
|
209 |
-
df['GPU Energy (Wh)'] = pd.to_numeric(df['total_gpu_energy'], errors='raise').apply(lambda x: f"{x:.4f}")
|
210 |
df['Model'] = df['model'].apply(make_link)
|
211 |
df['Score'] = df['energy_score'].apply(format_stars)
|
212 |
# Remove the Class column if it exists
|
|
|
39 |
display_name = parts[1] if len(parts) > 1 else mname
|
40 |
return f'[{display_name}](https://huggingface.co/{mname})'
|
41 |
|
42 |
+
# --- Plot Functions (Bar Chart - Modified with kWh to Wh conversion and explicit tickvals) ---
|
43 |
|
44 |
def get_plots(task):
|
45 |
df = pd.read_csv('data/energy/' + task)
|
46 |
if df.columns[0].startswith("Unnamed:"):
|
47 |
df = df.iloc[:, 1:]
|
48 |
+
# Use the raw numeric value from the CSV for GPU Energy and convert kWh to Wh
|
49 |
+
df['total_gpu_energy'] = pd.to_numeric(df['total_gpu_energy'], errors='raise') * 1000
|
50 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
51 |
# Create a display model column for labeling
|
52 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
|
|
78 |
yaxis_title="GPU Energy (Wh)",
|
79 |
yaxis = dict(
|
80 |
tickformat=".4f",
|
81 |
+
tickvals = list(np.arange(0, df['total_gpu_energy'].max() * 1.1, 100)) # Ticks every 100 Wh, adjust as needed
|
82 |
)
|
83 |
)
|
84 |
return fig
|
|
|
89 |
df = pd.read_csv('data/energy/' + task)
|
90 |
if df.columns[0].startswith("Unnamed:"):
|
91 |
df = df.iloc[:, 1:]
|
92 |
+
df['total_gpu_energy'] = pd.to_numeric(df['total_gpu_energy'], errors='raise') * 1000
|
93 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
94 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
95 |
all_df = pd.concat([all_df, df], ignore_index=True)
|
|
|
119 |
yaxis_title="GPU Energy (Wh)",
|
120 |
yaxis = dict(
|
121 |
tickformat=".4f",
|
122 |
+
tickvals = list(np.arange(0, all_df['total_gpu_energy'].max() * 1.1, 100)) # Ticks every 100 Wh, adjust as needed
|
123 |
)
|
124 |
)
|
125 |
return fig
|
126 |
|
127 |
+
# --- New functions for Text Generation filtering by model class (with Bar Chart - Modified kWh to Wh and explicit tickvals) ---
|
128 |
|
129 |
def get_text_generation_plots(model_class):
|
130 |
df = pd.read_csv('data/energy/text_generation.csv')
|
|
|
133 |
# Filter by the selected model class if the "class" column exists
|
134 |
if 'class' in df.columns:
|
135 |
df = df[df['class'] == model_class]
|
136 |
+
df['total_gpu_energy'] = pd.to_numeric(df['total_gpu_energy'], errors='raise') * 1000
|
137 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
138 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
139 |
|
|
|
162 |
yaxis_title="GPU Energy (Wh)",
|
163 |
yaxis = dict(
|
164 |
tickformat=".4f",
|
165 |
+
tickvals = list(np.arange(0, df['total_gpu_energy'].max() * 1.1, 100)) # Ticks every 100 Wh, adjust as needed
|
166 |
)
|
167 |
)
|
168 |
return fig
|
169 |
|
170 |
|
171 |
+
# --- Leaderboard Table Functions (Modified kWh to Wh conversion) ---
|
|
|
172 |
|
173 |
def get_model_names(task):
|
174 |
df = pd.read_csv('data/energy/' + task)
|
175 |
if df.columns[0].startswith("Unnamed:"):
|
176 |
df = df.iloc[:, 1:]
|
177 |
df['energy_score'] = df['energy_score'].astype(int)
|
178 |
+
# For leaderboard display, format GPU Energy to 4 decimals and convert kWh to Wh
|
179 |
+
df['GPU Energy (Wh)'] = (pd.to_numeric(df['total_gpu_energy'], errors='raise') * 1000).apply(lambda x: f"{x:.4f}")
|
180 |
df['Model'] = df['model'].apply(make_link)
|
181 |
df['Score'] = df['energy_score'].apply(format_stars)
|
182 |
# Remove any Class column if it exists
|
|
|
189 |
for task in tasks:
|
190 |
df = pd.read_csv('data/energy/' + task)
|
191 |
df['energy_score'] = df['energy_score'].astype(int)
|
192 |
+
df['GPU Energy (Wh)'] = (pd.to_numeric(df['total_gpu_energy'], errors='raise') * 1000).apply(lambda x: f"{x:.4f}")
|
193 |
df['Model'] = df['model'].apply(make_link)
|
194 |
df['Score'] = df['energy_score'].apply(format_stars)
|
195 |
all_df = pd.concat([all_df, df], ignore_index=True)
|
|
|
205 |
if 'class' in df.columns:
|
206 |
df = df[df['class'] == model_class]
|
207 |
df['energy_score'] = df['energy_score'].astype(int)
|
208 |
+
df['GPU Energy (Wh)'] = (pd.to_numeric(df['total_gpu_energy'], errors='raise') * 1000).apply(lambda x: f"{x:.4f}")
|
209 |
df['Model'] = df['model'].apply(make_link)
|
210 |
df['Score'] = df['energy_score'].apply(format_stars)
|
211 |
# Remove the Class column if it exists
|