Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -38,7 +38,7 @@ def make_link(mname):
|
|
38 |
display_name = parts[1] if len(parts) > 1 else mname
|
39 |
return f'[{display_name}](https://huggingface.co/{mname})'
|
40 |
|
41 |
-
# --- Plot Functions (Bar Chart) ---
|
42 |
|
43 |
def get_plots(task):
|
44 |
df = pd.read_csv('data/energy/' + task)
|
@@ -50,6 +50,12 @@ def get_plots(task):
|
|
50 |
# Create a display model column for labeling
|
51 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
# Use the energy score to control color
|
54 |
color_map = {"1": "red", "2": "orange", "3": "yellow", "4": "lightgreen", "5": "green"}
|
55 |
|
@@ -75,10 +81,11 @@ def get_plots(task):
|
|
75 |
fig.update_layout(
|
76 |
xaxis_title="Model",
|
77 |
yaxis_title="GPU Energy (Wh)",
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
82 |
)
|
83 |
return fig
|
84 |
|
@@ -94,6 +101,13 @@ def get_all_plots():
|
|
94 |
all_df = pd.concat([all_df, df], ignore_index=True)
|
95 |
all_df = all_df.drop_duplicates(subset=['model'])
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
color_map = {"1": "red", "2": "orange", "3": "yellow", "4": "lightgreen", "5": "green"}
|
98 |
|
99 |
fig = px.bar(
|
@@ -116,14 +130,15 @@ def get_all_plots():
|
|
116 |
fig.update_layout(
|
117 |
xaxis_title="Model",
|
118 |
yaxis_title="GPU Energy (Wh)",
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
123 |
)
|
124 |
return fig
|
125 |
|
126 |
-
# --- New functions for Text Generation filtering by model class (with Bar Chart) ---
|
127 |
|
128 |
def get_text_generation_plots(model_class):
|
129 |
df = pd.read_csv('data/energy/text_generation.csv')
|
@@ -136,6 +151,13 @@ def get_text_generation_plots(model_class):
|
|
136 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
137 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
color_map = {"1": "red", "2": "orange", "3": "yellow", "4": "lightgreen", "5": "green"}
|
140 |
|
141 |
fig = px.bar(
|
@@ -158,10 +180,11 @@ def get_text_generation_plots(model_class):
|
|
158 |
fig.update_layout(
|
159 |
xaxis_title="Model",
|
160 |
yaxis_title="GPU Energy (Wh)",
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
165 |
)
|
166 |
return fig
|
167 |
|
|
|
38 |
display_name = parts[1] if len(parts) > 1 else mname
|
39 |
return f'[{display_name}](https://huggingface.co/{mname})'
|
40 |
|
41 |
+
# --- Plot Functions (Bar Chart - Modified) ---
|
42 |
|
43 |
def get_plots(task):
|
44 |
df = pd.read_csv('data/energy/' + task)
|
|
|
50 |
# Create a display model column for labeling
|
51 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
52 |
|
53 |
+
# --- Debugging: Check data type and dataframe ---
|
54 |
+
print(f"Data type of total_gpu_energy: {df['total_gpu_energy'].dtype}")
|
55 |
+
print("DataFrame head before plotting:")
|
56 |
+
print(df.head())
|
57 |
+
# --- End Debugging ---
|
58 |
+
|
59 |
# Use the energy score to control color
|
60 |
color_map = {"1": "red", "2": "orange", "3": "yellow", "4": "lightgreen", "5": "green"}
|
61 |
|
|
|
81 |
fig.update_layout(
|
82 |
xaxis_title="Model",
|
83 |
yaxis_title="GPU Energy (Wh)",
|
84 |
+
# --- Removed explicit y-axis formatting for now ---
|
85 |
+
# yaxis_tickformat=".4f",
|
86 |
+
# yaxis = dict(
|
87 |
+
# tickformat=".4f"
|
88 |
+
# )
|
89 |
)
|
90 |
return fig
|
91 |
|
|
|
101 |
all_df = pd.concat([all_df, df], ignore_index=True)
|
102 |
all_df = all_df.drop_duplicates(subset=['model'])
|
103 |
|
104 |
+
# --- Debugging: Check data type and dataframe ---
|
105 |
+
print(f"Data type of total_gpu_energy (all_plots): {all_df['total_gpu_energy'].dtype}")
|
106 |
+
print("DataFrame head before plotting (all_plots):")
|
107 |
+
print(all_df.head())
|
108 |
+
# --- End Debugging ---
|
109 |
+
|
110 |
+
|
111 |
color_map = {"1": "red", "2": "orange", "3": "yellow", "4": "lightgreen", "5": "green"}
|
112 |
|
113 |
fig = px.bar(
|
|
|
130 |
fig.update_layout(
|
131 |
xaxis_title="Model",
|
132 |
yaxis_title="GPU Energy (Wh)",
|
133 |
+
# --- Removed explicit y-axis formatting for now ---
|
134 |
+
# yaxis_tickformat=".4f",
|
135 |
+
# yaxis = dict(
|
136 |
+
# tickformat=".4f"
|
137 |
+
# )
|
138 |
)
|
139 |
return fig
|
140 |
|
141 |
+
# --- New functions for Text Generation filtering by model class (with Bar Chart - Modified) ---
|
142 |
|
143 |
def get_text_generation_plots(model_class):
|
144 |
df = pd.read_csv('data/energy/text_generation.csv')
|
|
|
151 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
152 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
153 |
|
154 |
+
# --- Debugging: Check data type and dataframe ---
|
155 |
+
print(f"Data type of total_gpu_energy (text_gen): {df['total_gpu_energy'].dtype}")
|
156 |
+
print("DataFrame head before plotting (text_gen):")
|
157 |
+
print(df.head())
|
158 |
+
# --- End Debugging ---
|
159 |
+
|
160 |
+
|
161 |
color_map = {"1": "red", "2": "orange", "3": "yellow", "4": "lightgreen", "5": "green"}
|
162 |
|
163 |
fig = px.bar(
|
|
|
180 |
fig.update_layout(
|
181 |
xaxis_title="Model",
|
182 |
yaxis_title="GPU Energy (Wh)",
|
183 |
+
# --- Removed explicit y-axis formatting for now ---
|
184 |
+
# yaxis_tickformat=".4f",
|
185 |
+
# yaxis = dict(
|
186 |
+
# tickformat=".4f"
|
187 |
+
# )
|
188 |
)
|
189 |
return fig
|
190 |
|