Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,5 @@
|
|
| 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,
|
|
@@ -26,6 +24,8 @@ tasks = [
|
|
| 26 |
'summarization.csv'
|
| 27 |
]
|
| 28 |
|
|
|
|
|
|
|
| 29 |
def format_stars(score):
|
| 30 |
try:
|
| 31 |
score_int = int(score)
|
|
@@ -39,162 +39,61 @@ 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 |
-
# ---
|
| 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])
|
| 53 |
-
|
| 54 |
-
# Use the energy score to control color
|
| 55 |
-
color_map = {"1": "red", "2": "orange", "3": "yellow", "4": "lightgreen", "5": "green"}
|
| 56 |
-
|
| 57 |
-
# Now plot as a bar chart
|
| 58 |
-
fig = px.bar(
|
| 59 |
-
df,
|
| 60 |
-
x="Display Model",
|
| 61 |
-
y="total_gpu_energy",
|
| 62 |
-
color="energy_score",
|
| 63 |
-
custom_data=['energy_score'],
|
| 64 |
-
height=500,
|
| 65 |
-
width=800,
|
| 66 |
-
color_discrete_map=color_map
|
| 67 |
-
)
|
| 68 |
-
# Update hover text to show the model and GPU Energy (with 4 decimals)
|
| 69 |
-
fig.update_traces(
|
| 70 |
-
hovertemplate="<br>".join([
|
| 71 |
-
"Model: %{x}",
|
| 72 |
-
"GPU Energy (Wh): %{y:.4f}",
|
| 73 |
-
"Energy Score: %{customdata[0]}"
|
| 74 |
-
])
|
| 75 |
-
)
|
| 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.1, 100)) # Ticks every 100 Wh, adjust as needed
|
| 82 |
-
)
|
| 83 |
-
)
|
| 84 |
-
return fig
|
| 85 |
-
|
| 86 |
-
def get_all_plots():
|
| 87 |
-
all_df = pd.DataFrame()
|
| 88 |
-
for task in tasks:
|
| 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)
|
| 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(
|
| 101 |
-
all_df,
|
| 102 |
-
x="Display Model",
|
| 103 |
-
y="total_gpu_energy",
|
| 104 |
-
color="energy_score",
|
| 105 |
-
custom_data=['energy_score'],
|
| 106 |
-
height=500,
|
| 107 |
-
width=800,
|
| 108 |
-
color_discrete_map=color_map
|
| 109 |
-
)
|
| 110 |
-
fig.update_traces(
|
| 111 |
-
hovertemplate="<br>".join([
|
| 112 |
-
"Model: %{x}",
|
| 113 |
-
"GPU Energy (Wh): %{y:.4f}",
|
| 114 |
-
"Energy Score: %{customdata[0]}"
|
| 115 |
-
])
|
| 116 |
-
)
|
| 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.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
|
| 130 |
-
|
| 131 |
-
if
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 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 |
-
|
| 140 |
-
|
| 141 |
-
color_map = {"1": "red", "2": "orange", "3": "yellow", "4": "lightgreen", "5": "green"}
|
| 142 |
-
|
| 143 |
-
fig = px.bar(
|
| 144 |
-
df,
|
| 145 |
-
x="Display Model",
|
| 146 |
-
y="total_gpu_energy",
|
| 147 |
-
color="energy_score",
|
| 148 |
-
custom_data=['energy_score'],
|
| 149 |
-
height=500,
|
| 150 |
-
width=800,
|
| 151 |
-
color_discrete_map=color_map
|
| 152 |
-
)
|
| 153 |
-
fig.update_traces(
|
| 154 |
-
hovertemplate="<br>".join([
|
| 155 |
-
"Model: %{x}",
|
| 156 |
-
"GPU Energy (Wh): %{y:.4f}",
|
| 157 |
-
"Energy Score: %{customdata[0]}"
|
| 158 |
-
])
|
| 159 |
-
)
|
| 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.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 |
-
|
| 179 |
-
|
|
|
|
|
|
|
|
|
|
| 180 |
df['Model'] = df['model'].apply(make_link)
|
| 181 |
df['Score'] = df['energy_score'].apply(format_stars)
|
| 182 |
-
|
| 183 |
-
df = df
|
| 184 |
-
df = df.
|
| 185 |
return df
|
| 186 |
|
| 187 |
def get_all_model_names():
|
| 188 |
all_df = pd.DataFrame()
|
|
|
|
| 189 |
for task in tasks:
|
| 190 |
df = pd.read_csv('data/energy/' + task)
|
|
|
|
| 191 |
df['energy_score'] = df['energy_score'].astype(int)
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
df['Score'] = df['energy_score'].apply(format_stars)
|
| 195 |
all_df = pd.concat([all_df, df], ignore_index=True)
|
| 196 |
all_df = all_df.drop_duplicates(subset=['model'])
|
| 197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
return all_df[['Model', 'GPU Energy (Wh)', 'Score']]
|
| 199 |
|
| 200 |
|
|
@@ -204,21 +103,25 @@ def get_text_generation_model_names(model_class):
|
|
| 204 |
df = df.iloc[:, 1:]
|
| 205 |
if 'class' in df.columns:
|
| 206 |
df = df[df['class'] == model_class]
|
|
|
|
| 207 |
df['energy_score'] = df['energy_score'].astype(int)
|
| 208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
df['Model'] = df['model'].apply(make_link)
|
| 210 |
df['Score'] = df['energy_score'].apply(format_stars)
|
| 211 |
-
|
| 212 |
-
df = df
|
| 213 |
-
df = df.
|
| 214 |
return df
|
| 215 |
|
| 216 |
def update_text_generation(model_class):
|
| 217 |
-
plot = get_text_generation_plots(model_class)
|
| 218 |
table = get_text_generation_model_names(model_class)
|
| 219 |
-
return
|
| 220 |
|
| 221 |
-
# --- Build the Gradio Interface ---
|
| 222 |
|
| 223 |
demo = gr.Blocks(css="""
|
| 224 |
.gr-dataframe table {
|
|
@@ -231,6 +134,17 @@ demo = gr.Blocks(css="""
|
|
| 231 |
overflow: hidden;
|
| 232 |
text-overflow: ellipsis;
|
| 233 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
""")
|
| 235 |
|
| 236 |
with demo:
|
|
@@ -243,89 +157,45 @@ Select different tasks to see scored models. Submit open models for testing and
|
|
| 243 |
with gr.Tabs():
|
| 244 |
# --- Text Generation Tab with Dropdown for Model Class ---
|
| 245 |
with gr.TabItem("Text Generation 💬"):
|
| 246 |
-
# Dropdown moved above the
|
| 247 |
model_class_dropdown = gr.Dropdown(choices=["A", "B", "C"],
|
| 248 |
label="Select Model Class",
|
| 249 |
value="A")
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
tg_plot = gr.Plot(get_text_generation_plots("A"))
|
| 253 |
-
with gr.Column(scale=1):
|
| 254 |
-
tg_table = gr.Dataframe(get_text_generation_model_names("A"), datatype="markdown")
|
| 255 |
-
# Update plot and table when the dropdown value changes
|
| 256 |
model_class_dropdown.change(fn=update_text_generation,
|
| 257 |
inputs=model_class_dropdown,
|
| 258 |
-
outputs=[
|
| 259 |
|
| 260 |
with gr.TabItem("Image Generation 📷"):
|
| 261 |
-
|
| 262 |
-
with gr.Column():
|
| 263 |
-
plot = gr.Plot(get_plots('image_generation.csv'))
|
| 264 |
-
with gr.Column():
|
| 265 |
-
table = gr.Dataframe(get_model_names('image_generation.csv'), datatype="markdown")
|
| 266 |
|
| 267 |
with gr.TabItem("Text Classification 🎭"):
|
| 268 |
-
|
| 269 |
-
with gr.Column():
|
| 270 |
-
plot = gr.Plot(get_plots('text_classification.csv'))
|
| 271 |
-
with gr.Column():
|
| 272 |
-
table = gr.Dataframe(get_model_names('text_classification.csv'), datatype="markdown")
|
| 273 |
|
| 274 |
with gr.TabItem("Image Classification 🖼️"):
|
| 275 |
-
|
| 276 |
-
with gr.Column():
|
| 277 |
-
plot = gr.Plot(get_plots('image_classification.csv'))
|
| 278 |
-
with gr.Column():
|
| 279 |
-
table = gr.Dataframe(get_model_names('image_classification.csv'), datatype="markdown")
|
| 280 |
|
| 281 |
with gr.TabItem("Image Captioning 📝"):
|
| 282 |
-
|
| 283 |
-
with gr.Column():
|
| 284 |
-
plot = gr.Plot(get_plots('image_captioning.csv'))
|
| 285 |
-
with gr.Column():
|
| 286 |
-
table = gr.Dataframe(get_model_names('image_captioning.csv'), datatype="markdown")
|
| 287 |
|
| 288 |
with gr.TabItem("Summarization 📃"):
|
| 289 |
-
|
| 290 |
-
with gr.Column():
|
| 291 |
-
plot = gr.Plot(get_plots('summarization.csv'))
|
| 292 |
-
with gr.Column():
|
| 293 |
-
table = gr.Dataframe(get_model_names('summarization.csv'), datatype="markdown")
|
| 294 |
|
| 295 |
with gr.TabItem("Automatic Speech Recognition 💬"):
|
| 296 |
-
|
| 297 |
-
with gr.Column():
|
| 298 |
-
plot = gr.Plot(get_plots('asr.csv'))
|
| 299 |
-
with gr.Column():
|
| 300 |
-
table = gr.Dataframe(get_model_names('asr.csv'), datatype="markdown")
|
| 301 |
|
| 302 |
with gr.TabItem("Object Detection 🚘"):
|
| 303 |
-
|
| 304 |
-
with gr.Column():
|
| 305 |
-
plot = gr.Plot(get_plots('object_detection.csv'))
|
| 306 |
-
with gr.Column():
|
| 307 |
-
table = gr.Dataframe(get_model_names('object_detection.csv'), datatype="markdown")
|
| 308 |
|
| 309 |
with gr.TabItem("Sentence Similarity 📚"):
|
| 310 |
-
|
| 311 |
-
with gr.Column():
|
| 312 |
-
plot = gr.Plot(get_plots('sentence_similarity.csv'))
|
| 313 |
-
with gr.Column():
|
| 314 |
-
table = gr.Dataframe(get_model_names('sentence_similarity.csv'), datatype="markdown")
|
| 315 |
|
| 316 |
with gr.TabItem("Extractive QA ❔"):
|
| 317 |
-
|
| 318 |
-
with gr.Column():
|
| 319 |
-
plot = gr.Plot(get_plots('question_answering.csv'))
|
| 320 |
-
with gr.Column():
|
| 321 |
-
table = gr.Dataframe(get_model_names('question_answering.csv'), datatype="markdown")
|
| 322 |
|
| 323 |
with gr.TabItem("All Tasks 💡"):
|
| 324 |
-
|
| 325 |
-
with gr.Column():
|
| 326 |
-
plot = gr.Plot(get_all_plots())
|
| 327 |
-
with gr.Column():
|
| 328 |
-
table = gr.Dataframe(get_all_model_names(), datatype="markdown")
|
| 329 |
|
| 330 |
with gr.Accordion("📙 Citation", open=False):
|
| 331 |
citation_button = gr.Textbox(
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import pandas as pd
|
|
|
|
|
|
|
| 3 |
|
| 4 |
CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
|
| 5 |
CITATION_BUTTON_TEXT = r"""@misc{aienergyscore-leaderboard,
|
|
|
|
| 24 |
'summarization.csv'
|
| 25 |
]
|
| 26 |
|
| 27 |
+
color_map = {"1": "red", "2": "orange", "3": "yellow", "4": "lightgreen", "5": "green"} # Keep color map
|
| 28 |
+
|
| 29 |
def format_stars(score):
|
| 30 |
try:
|
| 31 |
score_int = int(score)
|
|
|
|
| 39 |
display_name = parts[1] if len(parts) > 1 else mname
|
| 40 |
return f'[{display_name}](https://huggingface.co/{mname})'
|
| 41 |
|
| 42 |
+
# --- Leaderboard Table Functions (Modified to dynamically calculate max energy) ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
def create_minimal_bar_html(energy_value_wh, energy_score, max_energy_value):
|
| 45 |
+
"""Generates HTML for the minimal bar chart with dynamic max energy."""
|
| 46 |
+
if max_energy_value <= 0: # Avoid division by zero if max energy is 0 or negative
|
| 47 |
+
bar_percentage = 0
|
| 48 |
+
else:
|
| 49 |
+
bar_percentage = min(100, (energy_value_wh / max_energy_value) * 100) # Cap at 100%
|
| 50 |
+
bar_color = color_map.get(str(energy_score), "gray") # Default color if score is unexpected
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
+
html = f"""
|
| 53 |
+
<div style="display: flex; align-items: center; gap: 5px;">
|
| 54 |
+
<div style="width: {bar_percentage}%; height: 10px; background-color: {bar_color}; border-radius: 2px;"></div>
|
| 55 |
+
<span>{energy_value_wh:.4f} Wh</span>
|
| 56 |
+
</div>
|
| 57 |
+
"""
|
| 58 |
+
return html
|
| 59 |
|
|
|
|
| 60 |
|
| 61 |
def get_model_names(task):
|
| 62 |
df = pd.read_csv('data/energy/' + task)
|
| 63 |
if df.columns[0].startswith("Unnamed:"):
|
| 64 |
df = df.iloc[:, 1:]
|
| 65 |
+
df['total_gpu_energy'] = pd.to_numeric(df['total_gpu_energy'], errors='raise') * 1000 # kWh to Wh conversion
|
| 66 |
df['energy_score'] = df['energy_score'].astype(int)
|
| 67 |
+
max_energy_for_task = df['total_gpu_energy'].max() # Calculate max energy for this task
|
| 68 |
+
|
| 69 |
+
# Create HTML bar chart for GPU Energy column, passing dynamic max_energy_for_task
|
| 70 |
+
df['GPU Energy (Wh)'] = df.apply(lambda row: create_minimal_bar_html(row['total_gpu_energy'], row['energy_score'], max_energy_for_task), axis=1)
|
| 71 |
+
|
| 72 |
df['Model'] = df['model'].apply(make_link)
|
| 73 |
df['Score'] = df['energy_score'].apply(format_stars)
|
| 74 |
+
df = df[['Model', 'GPU Energy (Wh)', 'Score']] # Keep only these columns
|
| 75 |
+
df = df.sort_values(by='total_gpu_energy') # Sort by underlying energy value for table order
|
| 76 |
+
df = df.drop('total_gpu_energy', axis=1) # remove the original energy column that was used for sorting
|
| 77 |
return df
|
| 78 |
|
| 79 |
def get_all_model_names():
|
| 80 |
all_df = pd.DataFrame()
|
| 81 |
+
max_energy_overall = 0 # Initialize overall max energy
|
| 82 |
for task in tasks:
|
| 83 |
df = pd.read_csv('data/energy/' + task)
|
| 84 |
+
df['total_gpu_energy'] = pd.to_numeric(df['total_gpu_energy'], errors='raise') * 1000 # kWh to Wh conversion
|
| 85 |
df['energy_score'] = df['energy_score'].astype(int)
|
| 86 |
+
max_energy_overall = max(max_energy_overall, df['total_gpu_energy'].max()) # Update overall max
|
| 87 |
+
|
|
|
|
| 88 |
all_df = pd.concat([all_df, df], ignore_index=True)
|
| 89 |
all_df = all_df.drop_duplicates(subset=['model'])
|
| 90 |
+
|
| 91 |
+
# Create HTML bar chart for GPU Energy column, passing dynamic max_energy_overall
|
| 92 |
+
all_df['GPU Energy (Wh)'] = all_df.apply(lambda row: create_minimal_bar_html(row['total_gpu_energy'], row['energy_score'], max_energy_overall), axis=1)
|
| 93 |
+
all_df['Model'] = all_df['model'].apply(make_link)
|
| 94 |
+
all_df['Score'] = all_df['energy_score'].apply(format_stars)
|
| 95 |
+
all_df = all_df.sort_values(by='total_gpu_energy') # Sort by underlying energy value for table order
|
| 96 |
+
all_df = all_df.drop('total_gpu_energy', axis=1) # remove the original energy column that was used for sorting
|
| 97 |
return all_df[['Model', 'GPU Energy (Wh)', 'Score']]
|
| 98 |
|
| 99 |
|
|
|
|
| 103 |
df = df.iloc[:, 1:]
|
| 104 |
if 'class' in df.columns:
|
| 105 |
df = df[df['class'] == model_class]
|
| 106 |
+
df['total_gpu_energy'] = pd.to_numeric(df['total_gpu_energy'], errors='raise') * 1000 # kWh to Wh conversion
|
| 107 |
df['energy_score'] = df['energy_score'].astype(int)
|
| 108 |
+
max_energy_for_class = df['total_gpu_energy'].max() # Calculate max energy for this class
|
| 109 |
+
|
| 110 |
+
# Create HTML bar chart for GPU Energy column, passing dynamic max_energy_for_class
|
| 111 |
+
df['GPU Energy (Wh)'] = df.apply(lambda row: create_minimal_bar_html(row['total_gpu_energy'], row['energy_score'], max_energy_for_class), axis=1)
|
| 112 |
+
|
| 113 |
df['Model'] = df['model'].apply(make_link)
|
| 114 |
df['Score'] = df['energy_score'].apply(format_stars)
|
| 115 |
+
df = df[['Model', 'GPU Energy (Wh)', 'Score']] # Keep only these columns
|
| 116 |
+
df = df.sort_values(by='total_gpu_energy') # Sort by underlying energy value for table order
|
| 117 |
+
df = df.drop('total_gpu_energy', axis=1) # remove the original energy column that was used for sorting
|
| 118 |
return df
|
| 119 |
|
| 120 |
def update_text_generation(model_class):
|
|
|
|
| 121 |
table = get_text_generation_model_names(model_class)
|
| 122 |
+
return table
|
| 123 |
|
| 124 |
+
# --- Build the Gradio Interface (Plots Removed, Tables with Dynamic Bars) ---
|
| 125 |
|
| 126 |
demo = gr.Blocks(css="""
|
| 127 |
.gr-dataframe table {
|
|
|
|
| 134 |
overflow: hidden;
|
| 135 |
text-overflow: ellipsis;
|
| 136 |
}
|
| 137 |
+
/* CSS for minimal bar chart inside table cell */
|
| 138 |
+
.minimal-bar-container {
|
| 139 |
+
display: flex;
|
| 140 |
+
align-items: center;
|
| 141 |
+
gap: 5px; /* space between bar and text */
|
| 142 |
+
}
|
| 143 |
+
.minimal-bar {
|
| 144 |
+
height: 10px;
|
| 145 |
+
background-color: blue; /* default, will be overridden by dynamic color */
|
| 146 |
+
border-radius: 2px;
|
| 147 |
+
}
|
| 148 |
""")
|
| 149 |
|
| 150 |
with demo:
|
|
|
|
| 157 |
with gr.Tabs():
|
| 158 |
# --- Text Generation Tab with Dropdown for Model Class ---
|
| 159 |
with gr.TabItem("Text Generation 💬"):
|
| 160 |
+
# Dropdown moved above the leaderboard
|
| 161 |
model_class_dropdown = gr.Dropdown(choices=["A", "B", "C"],
|
| 162 |
label="Select Model Class",
|
| 163 |
value="A")
|
| 164 |
+
tg_table = gr.Dataframe(get_text_generation_model_names("A"), datatype="markdown") # No plot anymore
|
| 165 |
+
# Update table when the dropdown value changes
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
model_class_dropdown.change(fn=update_text_generation,
|
| 167 |
inputs=model_class_dropdown,
|
| 168 |
+
outputs=[tg_table])
|
| 169 |
|
| 170 |
with gr.TabItem("Image Generation 📷"):
|
| 171 |
+
table = gr.Dataframe(get_model_names('image_generation.csv'), datatype="markdown")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
with gr.TabItem("Text Classification 🎭"):
|
| 174 |
+
table = gr.Dataframe(get_model_names('text_classification.csv'), datatype="markdown")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
with gr.TabItem("Image Classification 🖼️"):
|
| 177 |
+
table = gr.Dataframe(get_model_names('image_classification.csv'), datatype="markdown")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
with gr.TabItem("Image Captioning 📝"):
|
| 180 |
+
table = gr.Dataframe(get_model_names('image_captioning.csv'), datatype="markdown")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
with gr.TabItem("Summarization 📃"):
|
| 183 |
+
table = gr.Dataframe(get_model_names('summarization.csv'), datatype="markdown")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
with gr.TabItem("Automatic Speech Recognition 💬"):
|
| 186 |
+
table = gr.Dataframe(get_model_names('asr.csv'), datatype="markdown")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
|
| 188 |
with gr.TabItem("Object Detection 🚘"):
|
| 189 |
+
table = gr.Dataframe(get_model_names('object_detection.csv'), datatype="markdown")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
with gr.TabItem("Sentence Similarity 📚"):
|
| 192 |
+
table = gr.Dataframe(get_model_names('sentence_similarity.csv'), datatype="markdown")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
with gr.TabItem("Extractive QA ❔"):
|
| 195 |
+
table = gr.Dataframe(get_model_names('question_answering.csv'), datatype="markdown")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
|
| 197 |
with gr.TabItem("All Tasks 💡"):
|
| 198 |
+
table = gr.Dataframe(get_all_model_names(), datatype="markdown")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
with gr.Accordion("📙 Citation", open=False):
|
| 201 |
citation_button = gr.Textbox(
|