Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
import plotly.express as px
|
|
|
|
| 4 |
|
| 5 |
CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
|
| 6 |
CITATION_BUTTON_TEXT = r"""@misc{aienergyscore-leaderboard,
|
|
@@ -38,7 +39,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 - Modified) ---
|
| 42 |
|
| 43 |
def get_plots(task):
|
| 44 |
df = pd.read_csv('data/energy/' + task)
|
|
@@ -50,12 +51,6 @@ 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 |
-
# --- 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,11 +76,10 @@ def get_plots(task):
|
|
| 81 |
fig.update_layout(
|
| 82 |
xaxis_title="Model",
|
| 83 |
yaxis_title="GPU Energy (Wh)",
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
# )
|
| 89 |
)
|
| 90 |
return fig
|
| 91 |
|
|
@@ -101,13 +95,6 @@ def get_all_plots():
|
|
| 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,15 +117,14 @@ def get_all_plots():
|
|
| 130 |
fig.update_layout(
|
| 131 |
xaxis_title="Model",
|
| 132 |
yaxis_title="GPU Energy (Wh)",
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 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,12 +137,6 @@ def get_text_generation_plots(model_class):
|
|
| 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 |
|
|
@@ -180,11 +160,10 @@ def get_text_generation_plots(model_class):
|
|
| 180 |
fig.update_layout(
|
| 181 |
xaxis_title="Model",
|
| 182 |
yaxis_title="GPU Energy (Wh)",
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
# )
|
| 188 |
)
|
| 189 |
return fig
|
| 190 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
| 3 |
import plotly.express as px
|
| 4 |
+
import numpy as np # Import numpy
|
| 5 |
|
| 6 |
CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
|
| 7 |
CITATION_BUTTON_TEXT = r"""@misc{aienergyscore-leaderboard,
|
|
|
|
| 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)
|
|
|
|
| 51 |
# Create a display model column for labeling
|
| 52 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
# Use the energy score to control color
|
| 55 |
color_map = {"1": "red", "2": "orange", "3": "yellow", "4": "lightgreen", "5": "green"}
|
| 56 |
|
|
|
|
| 76 |
fig.update_layout(
|
| 77 |
xaxis_title="Model",
|
| 78 |
yaxis_title="GPU Energy (Wh)",
|
| 79 |
+
yaxis = dict(
|
| 80 |
+
tickformat=".4f",
|
| 81 |
+
tickvals = list(np.arange(0, df['total_gpu_energy'].max() + 1, 0.5)) # Ticks every 0.5 units
|
| 82 |
+
)
|
|
|
|
| 83 |
)
|
| 84 |
return fig
|
| 85 |
|
|
|
|
| 95 |
all_df = pd.concat([all_df, df], ignore_index=True)
|
| 96 |
all_df = all_df.drop_duplicates(subset=['model'])
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
color_map = {"1": "red", "2": "orange", "3": "yellow", "4": "lightgreen", "5": "green"}
|
| 99 |
|
| 100 |
fig = px.bar(
|
|
|
|
| 117 |
fig.update_layout(
|
| 118 |
xaxis_title="Model",
|
| 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, 0.5)) # Ticks every 0.5 units
|
| 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')
|
|
|
|
| 137 |
df['energy_score'] = df['energy_score'].astype(int).astype(str)
|
| 138 |
df['Display Model'] = df['model'].apply(lambda m: m.split('/')[-1])
|
| 139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
color_map = {"1": "red", "2": "orange", "3": "yellow", "4": "lightgreen", "5": "green"}
|
| 142 |
|
|
|
|
| 160 |
fig.update_layout(
|
| 161 |
xaxis_title="Model",
|
| 162 |
yaxis_title="GPU Energy (Wh)",
|
| 163 |
+
yaxis = dict(
|
| 164 |
+
tickformat=".4f",
|
| 165 |
+
tickvals = list(np.arange(0, df['total_gpu_energy'].max() + 1, 0.5)) # Ticks every 0.5 units
|
| 166 |
+
)
|
|
|
|
| 167 |
)
|
| 168 |
return fig
|
| 169 |
|