bgamazay commited on
Commit
5dc7166
Β·
verified Β·
1 Parent(s): 78da67f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +345 -190
app.py CHANGED
@@ -1,212 +1,367 @@
1
  import gradio as gr
2
  import pandas as pd
3
- from huggingface_hub import list_models
4
- import plotly.express as px
 
5
 
6
  CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
7
- CITATION_BUTTON_TEXT = r"""@misc{energystarai-leaderboard,
8
- author = {Sasha Luccioni and Boris Gamazaychikov and Emma Strubell and Sara Hooker and Yacine Jernite and Carole-Jean Wu and Margaret Mitchell},
9
- title = {AI Energy Score Leaderboard v.0},
10
- year = {2024},
11
- publisher = {Hugging Face},
12
- howpublished = "\url{https://huggingface.co/spaces/EnergyStarAI/2024_Leaderboard}",
13
- }
14
- """
15
- tasks = ['asr.csv', 'object_detection.csv', 'text_classification.csv', 'image_captioning.csv',
16
- 'question_answering.csv', 'text_generation.csv', 'image_classification.csv',
17
- 'sentence_similarity.csv', 'image_generation.csv', 'summarization.csv']
18
-
19
- def get_plots(task):
20
- #TO DO : hover text with energy efficiency number, parameters
21
- task_df= pd.read_csv('data/energy/'+task)
22
- params_df = pd.read_csv('data/params/'+task)
23
- params_df= params_df.rename(columns={"Link": "model"})
24
- all_df = pd.merge(task_df, params_df, on='model')
25
- all_df['Total GPU Energy (Wh)'] = all_df['total_gpu_energy']*1000
26
- all_df = all_df.sort_values(by=['Total GPU Energy (Wh)'])
27
- all_df['parameters'] = all_df['parameters'].apply(format_params)
28
- all_df['energy_star'] = pd.cut(all_df['Total GPU Energy (Wh)'], 3, labels=["⭐⭐⭐", "⭐⭐", "⭐"])
29
- fig = px.scatter(all_df, x="model", y='Total GPU Energy (Wh)', custom_data=['parameters'], height= 500, width= 800, color = 'energy_star', color_discrete_map={"⭐": 'red', "⭐⭐": "orange", "⭐⭐⭐": "green"})
30
- fig.update_traces(
31
- hovertemplate="<br>".join([
32
- "Total Energy: %{y}",
33
- "Parameters: %{customdata[0]}"])
34
- )
35
- return fig
36
-
37
- def get_all_plots():
38
- all_df = pd.DataFrame(columns= ['model', 'parameters', 'total_gpu_energy'])
39
- for task in tasks:
40
- task_df= pd.read_csv('data/energy/'+task)
41
- params_df = pd.read_csv('data/params/'+task)
42
- params_df= params_df.rename(columns={"Link": "model"})
43
- tasks_df = pd.merge(task_df, params_df, on='model')
44
- tasks_df= tasks_df[['model', 'parameters', 'total_gpu_energy']]
45
- tasks_df['Total GPU Energy (Wh)'] = tasks_df['total_gpu_energy']*1000
46
- tasks_df['energy_star'] = pd.cut(tasks_df['Total GPU Energy (Wh)'], 3, labels=["⭐⭐⭐", "⭐⭐", "⭐"])
47
- all_df = pd.concat([all_df, tasks_df])
48
- all_df = all_df.sort_values(by=['Total GPU Energy (Wh)'])
49
- all_df['parameters'] = all_df['parameters'].apply(format_params)
50
- fig = px.scatter(all_df, x="model", y='Total GPU Energy (Wh)', custom_data=['parameters'], height= 500, width= 800, color = 'energy_star', color_discrete_map={"⭐": 'red', "⭐⭐": "orange", "⭐⭐⭐": "green"})
51
- fig.update_traces(
52
- hovertemplate="<br>".join([
53
- "Total Energy: %{y}",
54
- "Parameters: %{customdata[0]}"])
55
- )
56
- return fig
57
 
58
  def make_link(mname):
59
- link = "["+ str(mname).split('/')[1] +'](https://huggingface.co/'+str(mname)+")"
60
- return link
61
-
62
- def get_model_names(task):
63
- task_df= pd.read_csv('data/params/'+task)
64
- energy_df= pd.read_csv('data/energy/'+task)
65
- task_df= task_df.rename(columns={"Link": "model"})
66
- all_df = pd.merge(task_df, energy_df, on='model')
67
- all_df=all_df.drop_duplicates(subset=['model'])
68
- all_df['Parameters'] = all_df['parameters'].apply(format_params)
69
- all_df['Model'] = all_df['model'].apply(make_link)
70
- all_df['Total GPU Energy (Wh)'] = all_df['total_gpu_energy']*1000
71
- all_df['Total GPU Energy (Wh)'] = all_df['Total GPU Energy (Wh)'].round(2)
72
- all_df['Rating'] = pd.cut(all_df['Total GPU Energy (Wh)'], 3, labels=["⭐⭐⭐", "⭐⭐", "⭐"])
73
- all_df= all_df.sort_values('Total GPU Energy (Wh)')
74
- model_names = all_df[['Model','Rating','Total GPU Energy (Wh)', 'Parameters']]
75
- return model_names
76
-
77
- def get_all_model_names():
78
- #TODO: add link to results in model card of each model
79
- all_df = pd.DataFrame(columns = ['model', 'parameters', 'total_gpu_energy'])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  for task in tasks:
81
- task_df= pd.read_csv('data/params/'+task)
82
- energy_df= pd.read_csv('data/energy/'+task)
83
- task_df= task_df.rename(columns={"Link": "model"})
84
- tasks_df = pd.merge(task_df, energy_df, on='model')
85
- tasks_df= tasks_df[['model', 'parameters', 'total_gpu_energy']]
86
- tasks_df['Total GPU Energy (Wh)'] = tasks_df['total_gpu_energy']*1000
87
- tasks_df['Total GPU Energy (Wh)'] = tasks_df['Total GPU Energy (Wh)'].round(2)
88
- tasks_df['Rating'] = pd.cut(tasks_df['Total GPU Energy (Wh)'], 3, labels=["⭐⭐⭐", "⭐⭐", "⭐"])
89
- all_df = pd.concat([all_df, tasks_df])
90
- all_df=all_df.drop_duplicates(subset=['model'])
91
- all_df['Parameters'] = all_df['parameters'].apply(format_params)
92
- all_df['Model'] = all_df['model'].apply(make_link)
93
- all_df= all_df.sort_values('Total GPU Energy (Wh)')
94
- model_names = all_df[['Model','Rating','Total GPU Energy (Wh)', 'Parameters']]
95
- return model_names
96
-
97
-
98
- def format_params(num):
99
- if num > 1000000000:
100
- if not num % 1000000000:
101
- return f'{num // 1000000000}B'
102
- return f'{round(num / 1000000000, 1)}B'
103
- return f'{num // 1000000}M'
104
-
105
-
106
-
107
- demo = gr.Blocks()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
  with demo:
110
- gr.Markdown(
111
- """# AI Energy Score Leaderboard - v.0 (2024) 🌎 πŸ’» 🌟
112
- ### Welcome to the leaderboard for the [AI Energy Score Project!](https://huggingface.co/EnergyStarAI)
113
- Click through the tasks below to see how different models measure up in terms of energy efficiency"""
114
- )
115
- gr.Markdown(
116
- """Test your own models via the [submission portal](https://huggingface.co/spaces/AIEnergyScore/submission_portal)!"""
117
- )
 
 
 
 
 
118
  with gr.Tabs():
 
119
  with gr.TabItem("Text Generation πŸ’¬"):
120
  with gr.Row():
121
- with gr.Column(scale=1.3):
122
- plot = gr.Plot(get_plots('text_generation.csv'))
123
- with gr.Column(scale=1):
124
- table = gr.Dataframe(get_model_names('text_generation.csv'), datatype="markdown")
125
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  with gr.TabItem("Image Generation πŸ“·"):
127
- with gr.Row():
128
- with gr.Column():
129
- plot = gr.Plot(get_plots('image_generation.csv'))
130
- with gr.Column():
131
- table = gr.Dataframe(get_model_names('image_generation.csv'), datatype="markdown")
132
-
 
 
 
133
  with gr.TabItem("Text Classification 🎭"):
134
- with gr.Row():
135
- with gr.Column():
136
- plot = gr.Plot(get_plots('text_classification.csv'))
137
- with gr.Column():
138
- table = gr.Dataframe(get_model_names('text_classification.csv'), datatype="markdown")
139
-
 
 
 
140
  with gr.TabItem("Image Classification πŸ–ΌοΈ"):
141
- with gr.Row():
142
- with gr.Column():
143
- plot = gr.Plot(get_plots('image_classification.csv'))
144
- with gr.Column():
145
- table = gr.Dataframe(get_model_names('image_classification.csv'), datatype="markdown")
146
-
 
 
 
147
  with gr.TabItem("Image Captioning πŸ“"):
148
- with gr.Row():
149
- with gr.Column():
150
- plot = gr.Plot(get_plots('image_captioning.csv'))
151
- with gr.Column():
152
- table = gr.Dataframe(get_model_names('image_captioning.csv'), datatype="markdown")
 
 
 
 
153
  with gr.TabItem("Summarization πŸ“ƒ"):
154
- with gr.Row():
155
- with gr.Column():
156
- plot = gr.Plot(get_plots('summarization.csv'))
157
- with gr.Column():
158
- table = gr.Dataframe(get_model_names('summarization.csv'), datatype="markdown")
159
-
160
- with gr.TabItem("Automatic Speech Recognition πŸ’¬ "):
161
- with gr.Row():
162
- with gr.Column():
163
- plot = gr.Plot(get_plots('asr.csv'))
164
- with gr.Column():
165
- table = gr.Dataframe(get_model_names('asr.csv'), datatype="markdown")
166
-
 
 
 
 
 
 
167
  with gr.TabItem("Object Detection 🚘"):
168
- with gr.Row():
169
- with gr.Column():
170
- plot = gr.Plot(get_plots('object_detection.csv'))
171
- with gr.Column():
172
- table = gr.Dataframe(get_model_names('object_detection.csv'), datatype="markdown")
173
-
 
 
 
174
  with gr.TabItem("Sentence Similarity πŸ“š"):
175
- with gr.Row():
176
- with gr.Column():
177
- plot = gr.Plot(get_plots('sentence_similarity.csv'))
178
- with gr.Column():
179
- table = gr.Dataframe(get_model_names('sentence_similarity.csv'), datatype="markdown")
180
-
 
 
 
181
  with gr.TabItem("Extractive QA ❔"):
182
- with gr.Row():
183
- with gr.Column():
184
- plot = gr.Plot(get_plots('question_answering.csv'))
185
- with gr.Column():
186
- table = gr.Dataframe(get_model_names('question_answering.csv'), datatype="markdown")
187
-
 
 
 
188
  with gr.TabItem("All Tasks πŸ’‘"):
189
- with gr.Row():
190
- with gr.Column():
191
- plot = gr.Plot(get_all_plots)
192
- with gr.Column():
193
- table = gr.Dataframe(get_all_model_names, datatype="markdown")
194
-
195
- with gr.Accordion("Methodology", open = False):
196
- gr.Markdown(
197
- """For each of the ten tasks above, we created a custom dataset with 1,000 entries (see all of the datasets on our [org Hub page](https://huggingface.co/EnergyStarAI)).
198
- We then tested each of the models from the leaderboard on the appropriate task on Nvidia H100 GPUs, measuring the energy consumed using [Code Carbon](https://mlco2.github.io/codecarbon/), an open-source Python package for tracking the environmental impacts of code.
199
- We developed and used a [Docker container](https://github.com/huggingface/EnergyStarAI/) to maximize the reproducibility of results, and to enable members of the community to benchmark internal models.
200
- Reach out to us if you want to collaborate!
201
- """)
202
- with gr.Accordion("πŸ“™ Citation", open=False):
203
- citation_button = gr.Textbox(
204
- value=CITATION_BUTTON_TEXT,
205
- label=CITATION_BUTTON_LABEL,
206
- elem_id="citation-button",
207
- lines=10,
208
- show_copy_button=True,
209
  )
210
- gr.Markdown(
211
- """Last updated: October 1st, 2024 by [Sasha Luccioni](https://huggingface.co/sasha)""")
212
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import pandas as pd
3
+ import os
4
+ import zipfile
5
+ import base64
6
 
7
  CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
8
+ CITATION_BUTTON_TEXT = r"""@misc{aienergyscore-leaderboard,
9
+ author = {Sasha Luccioni and Boris Gamazaychikov and Emma Strubell and Sara Hooker and Yacine Jernite and Carole-Jean Wu and Margaret Mitchell},
10
+ title = {AI Energy Score Leaderboard - February 2025},
11
+ year = {2025},
12
+ publisher = {Hugging Face},
13
+ howpublished = "\url{https://huggingface.co/spaces/AIEnergyScore/Leaderboard}",
14
+ }"""
15
+
16
+ # List of tasks (CSV filenames)
17
+ tasks = [
18
+ 'asr.csv',
19
+ 'object_detection.csv',
20
+ 'text_classification.csv',
21
+ 'image_captioning.csv',
22
+ 'question_answering.csv',
23
+ 'text_generation.csv',
24
+ 'image_classification.csv',
25
+ 'sentence_similarity.csv',
26
+ 'image_generation.csv',
27
+ 'summarization.csv'
28
+ ]
29
+
30
+ def format_stars(score):
31
+ try:
32
+ score_int = int(score)
33
+ except Exception:
34
+ score_int = 0
35
+ # Render stars in black with a slightly larger font.
36
+ return f'<span style="color: black; font-size:1.5em;">{"β˜…" * score_int}</span>'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  def make_link(mname):
39
+ parts = str(mname).split('/')
40
+ display_name = parts[1] if len(parts) > 1 else mname
41
+ return f'<a href="https://huggingface.co/{mname}" target="_blank">{display_name}</a>'
42
+
43
+ def extract_link_text(html_link):
44
+ """Extracts the inner text from an HTML link."""
45
+ start = html_link.find('>') + 1
46
+ end = html_link.rfind('</a>')
47
+ if start > 0 and end > start:
48
+ return html_link[start:end]
49
+ else:
50
+ return html_link
51
+
52
+ def generate_html_table_from_df(df):
53
+ """
54
+ Given a dataframe with a numeric energy column (gpu_energy_numeric),
55
+ generate an HTML table with three columns:
56
+ - Model (the link, with a fixed width based on the longest model name)
57
+ - GPU Energy (Wh) plus a horizontal bar whose width is proportional
58
+ to the energy value relative to the maximum in the table.
59
+ - Score (displayed as stars)
60
+ """
61
+ # Compute a static width (in pixels) for the Model column based on the longest model name.
62
+ if not df.empty:
63
+ max_length = max(len(extract_link_text(link)) for link in df['Model'])
64
+ else:
65
+ max_length = 10
66
+ # Multiply by an estimated average character width (10 pixels) and add some extra padding.
67
+ static_width = max_length * 10 + 16
68
+
69
+ max_energy = df['gpu_energy_numeric'].max() if not df.empty else 1
70
+ color_map = {"1": "black", "2": "black", "3": "black", "4": "black", "5": "black"}
71
+ html = '<table style="width:100%; border-collapse: collapse; font-family: Inter, sans-serif;">'
72
+ # Keep only one header (the one with hover text)
73
+ html += '<thead><tr style="background-color: #f2f2f2;">'
74
+ html += '<th style="text-align: left; padding: 8px;" title="Model name with link to Hugging Face">Model</th>'
75
+ html += '<th style="text-align: left; padding: 8px;" title="GPU energy consumed in Watt-hours for 1,000 queries">GPU Energy (Wh)</th>'
76
+ html += '<th style="text-align: left; padding: 8px;" title="5 is most efficient, 1 is least. Relative energy efficiency score relative to other models in task/class at the time of leaderboard launch">Score</th>'
77
+ html += '</tr></thead>'
78
+ html += '<tbody>'
79
+ for _, row in df.iterrows():
80
+ energy_numeric = row['gpu_energy_numeric']
81
+ energy_str = f"{energy_numeric:.2f}"
82
+ # Compute the relative width (as a percentage)
83
+ bar_width = (energy_numeric / max_energy) * 100
84
+ score_val = row['energy_score']
85
+ bar_color = color_map.get(str(score_val), "gray")
86
+ html += '<tr>'
87
+ html += f'<td style="padding: 8px; width: {static_width}px;">{row["Model"]}</td>'
88
+ html += (
89
+ f'<td style="padding: 8px;">{energy_str}<br>'
90
+ f'<div style="background-color: {bar_color}; width: {bar_width:.1f}%; height: 10px;"></div></td>'
91
+ )
92
+ html += f'<td style="padding: 8px;">{row["Score"]}</td>'
93
+ html += '</tr>'
94
+ html += '</tbody></table>'
95
+ return html
96
+
97
+ # --- Function to zip all CSV files ---
98
+ def zip_csv_files():
99
+ data_dir = "data/energy"
100
+ zip_filename = "data.zip"
101
+ with zipfile.ZipFile(zip_filename, "w", zipfile.ZIP_DEFLATED) as zipf:
102
+ for filename in os.listdir(data_dir):
103
+ if filename.endswith(".csv"):
104
+ filepath = os.path.join(data_dir, filename)
105
+ zipf.write(filepath, arcname=filename)
106
+ return zip_filename
107
+
108
+ def get_zip_data_link():
109
+ """Creates a data URI download link for the ZIP file."""
110
+ zip_filename = zip_csv_files()
111
+ with open(zip_filename, "rb") as f:
112
+ data = f.read()
113
+ b64 = base64.b64encode(data).decode()
114
+ href = f'<a href="data:application/zip;base64,{b64}" download="data.zip" style="margin: 0 15px; text-decoration: none; font-weight: bold; font-size: 1.1em;">Download Data</a>'
115
+ return href
116
+
117
+ # --- Modified functions to include a sort_order parameter ---
118
+ def get_model_names_html(task, sort_order="Low to High"):
119
+ df = pd.read_csv('data/energy/' + task)
120
+ if df.columns[0].startswith("Unnamed:"):
121
+ df = df.iloc[:, 1:]
122
+ df['energy_score'] = df['energy_score'].astype(int)
123
+ # Convert kWh to Wh:
124
+ df['gpu_energy_numeric'] = pd.to_numeric(df['total_gpu_energy'], errors='raise') * 1000
125
+ df['Model'] = df['model'].apply(make_link)
126
+ df['Score'] = df['energy_score'].apply(format_stars)
127
+ ascending = True if sort_order == "Low to High" else False
128
+ df = df.sort_values(by='gpu_energy_numeric', ascending=ascending)
129
+ return generate_html_table_from_df(df)
130
+
131
+ def get_all_model_names_html(sort_order="Low to High"):
132
+ all_df = pd.DataFrame()
133
  for task in tasks:
134
+ df = pd.read_csv('data/energy/' + task)
135
+ if df.columns[0].startswith("Unnamed:"):
136
+ df = df.iloc[:, 1:]
137
+ df['energy_score'] = df['energy_score'].astype(int)
138
+ df['gpu_energy_numeric'] = pd.to_numeric(df['total_gpu_energy'], errors='raise') * 1000
139
+ df['Model'] = df['model'].apply(make_link)
140
+ df['Score'] = df['energy_score'].apply(format_stars)
141
+ all_df = pd.concat([all_df, df], ignore_index=True)
142
+ all_df = all_df.drop_duplicates(subset=['model'])
143
+ ascending = True if sort_order == "Low to High" else False
144
+ all_df = all_df.sort_values(by='gpu_energy_numeric', ascending=ascending)
145
+ return generate_html_table_from_df(all_df)
146
+
147
+ def get_text_generation_model_names_html(model_class, sort_order="Low to High"):
148
+ df = pd.read_csv('data/energy/text_generation.csv')
149
+ if df.columns[0].startswith("Unnamed:"):
150
+ df = df.iloc[:, 1:]
151
+ if 'class' in df.columns:
152
+ df = df[df['class'] == model_class]
153
+ df['energy_score'] = df['energy_score'].astype(int)
154
+ df['gpu_energy_numeric'] = pd.to_numeric(df['total_gpu_energy'], errors='raise') * 1000
155
+ df['Model'] = df['model'].apply(make_link)
156
+ df['Score'] = df['energy_score'].apply(format_stars)
157
+ ascending = True if sort_order == "Low to High" else False
158
+ df = df.sort_values(by='gpu_energy_numeric', ascending=ascending)
159
+ return generate_html_table_from_df(df)
160
+
161
+ # --- Update functions for dropdown changes ---
162
+
163
+ # For Text Generation, two dropdowns: model class and sort order.
164
+ def update_text_generation(selected_display, sort_order):
165
+ mapping = {
166
+ "A (Single Consumer GPU) <20B parameters": "A",
167
+ "B (Single Cloud GPU) 20-66B parameters": "B",
168
+ "C (Multiple Cloud GPUs) >66B parameters": "C"
169
+ }
170
+ model_class = mapping.get(selected_display, "A")
171
+ return get_text_generation_model_names_html(model_class, sort_order)
172
+
173
+ # For the other tabs, each update function simply takes the sort_order.
174
+ def update_image_generation(sort_order):
175
+ return get_model_names_html('image_generation.csv', sort_order)
176
+
177
+ def update_text_classification(sort_order):
178
+ return get_model_names_html('text_classification.csv', sort_order)
179
+
180
+ def update_image_classification(sort_order):
181
+ return get_model_names_html('image_classification.csv', sort_order)
182
+
183
+ def update_image_captioning(sort_order):
184
+ return get_model_names_html('image_captioning.csv', sort_order)
185
+
186
+ def update_summarization(sort_order):
187
+ return get_model_names_html('summarization.csv', sort_order)
188
+
189
+ def update_asr(sort_order):
190
+ return get_model_names_html('asr.csv', sort_order)
191
+
192
+ def update_object_detection(sort_order):
193
+ return get_model_names_html('object_detection.csv', sort_order)
194
+
195
+ def update_sentence_similarity(sort_order):
196
+ return get_model_names_html('sentence_similarity.csv', sort_order)
197
+
198
+ def update_extractive_qa(sort_order):
199
+ return get_model_names_html('question_answering.csv', sort_order)
200
+
201
+ def update_all_tasks(sort_order):
202
+ return get_all_model_names_html(sort_order)
203
+
204
+ # --- Build the Gradio Interface ---
205
+
206
+ demo = gr.Blocks(css="""
207
+ .gr-dataframe table {
208
+ table-layout: fixed;
209
+ width: 100%;
210
+ }
211
+ .gr-dataframe th, .gr-dataframe td {
212
+ max-width: 150px;
213
+ white-space: nowrap;
214
+ overflow: hidden;
215
+ text-overflow: ellipsis;
216
+ }
217
+ """)
218
 
219
  with demo:
220
+ # Replace title with a centered logo and a centered subtitle.
221
+ gr.HTML('<div style="text-align: center;"><img src="https://huggingface.co/spaces/bgamazay/Leaderboard_test/resolve/main/logo.png" alt="Logo"></div>')
222
+ gr.Markdown('<p style="text-align: center;">Welcome to the leaderboard for the <a href="https://huggingface.co/AIEnergyScore">AI Energy Score Project!</a> β€” Select different tasks to see scored models.</p>')
223
+
224
+ # Header links (using a row of components, including a Download Data link)
225
+ with gr.Row():
226
+ submission_link = gr.HTML('<a href="https://huggingface.co/spaces/AIEnergyScore/submission_portal" style="margin: 0 10px; text-decoration: none; font-weight: bold; font-size: 1.1em;">Submission Portal</a>')
227
+ label_link = gr.HTML('<a href="https://huggingface.co/spaces/AIEnergyScore/Label" style="margin: 0 10px; text-decoration: none; font-weight: bold; font-size: 1.1em;">Label Generator</a>')
228
+ faq_link = gr.HTML('<a href="https://huggingface.github.io/AIEnergyScore/#faq" style="margin: 0 10px; text-decoration: none; font-weight: bold; font-size: 1.1em;">FAQ</a>')
229
+ documentation_link = gr.HTML('<a href="https://huggingface.github.io/AIEnergyScore/#documentation" style="margin: 0 10px; text-decoration: none; font-weight: bold; font-size: 1.1em;">Documentation</a>')
230
+ download_link = gr.HTML(get_zip_data_link())
231
+ community_link = gr.HTML('<a href="https://huggingface.co/spaces/AIEnergyScore/README/discussions" style="margin: 0 10px; text-decoration: none; font-weight: bold; font-size: 1.1em;">Community</a>')
232
+
233
  with gr.Tabs():
234
+ # --- Text Generation Tab ---
235
  with gr.TabItem("Text Generation πŸ’¬"):
236
  with gr.Row():
237
+ model_class_options = [
238
+ "A (Single Consumer GPU) <20B parameters",
239
+ "B (Single Cloud GPU) 20-66B parameters",
240
+ "C (Multiple Cloud GPUs) >66B parameters"
241
+ ]
242
+ model_class_dropdown = gr.Dropdown(
243
+ choices=model_class_options,
244
+ label="Select Model Class",
245
+ value=model_class_options[0]
246
+ )
247
+ sort_dropdown_tg = gr.Dropdown(
248
+ choices=["Low to High", "High to Low"],
249
+ label="Sort",
250
+ value="Low to High"
251
+ )
252
+ tg_table = gr.HTML(get_text_generation_model_names_html("A", "Low to High"))
253
+ # When either dropdown changes, update the table.
254
+ model_class_dropdown.change(fn=update_text_generation, inputs=[model_class_dropdown, sort_dropdown_tg], outputs=tg_table)
255
+ sort_dropdown_tg.change(fn=update_text_generation, inputs=[model_class_dropdown, sort_dropdown_tg], outputs=tg_table)
256
+
257
+ # --- Image Generation Tab ---
258
  with gr.TabItem("Image Generation πŸ“·"):
259
+ sort_dropdown_img = gr.Dropdown(
260
+ choices=["Low to High", "High to Low"],
261
+ label="Sort",
262
+ value="Low to High"
263
+ )
264
+ img_table = gr.HTML(get_model_names_html('image_generation.csv', "Low to High"))
265
+ sort_dropdown_img.change(fn=update_image_generation, inputs=sort_dropdown_img, outputs=img_table)
266
+
267
+ # --- Text Classification Tab ---
268
  with gr.TabItem("Text Classification 🎭"):
269
+ sort_dropdown_tc = gr.Dropdown(
270
+ choices=["Low to High", "High to Low"],
271
+ label="Sort",
272
+ value="Low to High"
273
+ )
274
+ tc_table = gr.HTML(get_model_names_html('text_classification.csv', "Low to High"))
275
+ sort_dropdown_tc.change(fn=update_text_classification, inputs=sort_dropdown_tc, outputs=tc_table)
276
+
277
+ # --- Image Classification Tab ---
278
  with gr.TabItem("Image Classification πŸ–ΌοΈ"):
279
+ sort_dropdown_ic = gr.Dropdown(
280
+ choices=["Low to High", "High to Low"],
281
+ label="Sort",
282
+ value="Low to High"
283
+ )
284
+ ic_table = gr.HTML(get_model_names_html('image_classification.csv', "Low to High"))
285
+ sort_dropdown_ic.change(fn=update_image_classification, inputs=sort_dropdown_ic, outputs=ic_table)
286
+
287
+ # --- Image Captioning Tab ---
288
  with gr.TabItem("Image Captioning πŸ“"):
289
+ sort_dropdown_icap = gr.Dropdown(
290
+ choices=["Low to High", "High to Low"],
291
+ label="Sort",
292
+ value="Low to High"
293
+ )
294
+ icap_table = gr.HTML(get_model_names_html('image_captioning.csv', "Low to High"))
295
+ sort_dropdown_icap.change(fn=update_image_captioning, inputs=sort_dropdown_icap, outputs=icap_table)
296
+
297
+ # --- Summarization Tab ---
298
  with gr.TabItem("Summarization πŸ“ƒ"):
299
+ sort_dropdown_sum = gr.Dropdown(
300
+ choices=["Low to High", "High to Low"],
301
+ label="Sort",
302
+ value="Low to High"
303
+ )
304
+ sum_table = gr.HTML(get_model_names_html('summarization.csv', "Low to High"))
305
+ sort_dropdown_sum.change(fn=update_summarization, inputs=sort_dropdown_sum, outputs=sum_table)
306
+
307
+ # --- Automatic Speech Recognition Tab ---
308
+ with gr.TabItem("Automatic Speech Recognition πŸ’¬"):
309
+ sort_dropdown_asr = gr.Dropdown(
310
+ choices=["Low to High", "High to Low"],
311
+ label="Sort",
312
+ value="Low to High"
313
+ )
314
+ asr_table = gr.HTML(get_model_names_html('asr.csv', "Low to High"))
315
+ sort_dropdown_asr.change(fn=update_asr, inputs=sort_dropdown_asr, outputs=asr_table)
316
+
317
+ # --- Object Detection Tab ---
318
  with gr.TabItem("Object Detection 🚘"):
319
+ sort_dropdown_od = gr.Dropdown(
320
+ choices=["Low to High", "High to Low"],
321
+ label="Sort",
322
+ value="Low to High"
323
+ )
324
+ od_table = gr.HTML(get_model_names_html('object_detection.csv', "Low to High"))
325
+ sort_dropdown_od.change(fn=update_object_detection, inputs=sort_dropdown_od, outputs=od_table)
326
+
327
+ # --- Sentence Similarity Tab ---
328
  with gr.TabItem("Sentence Similarity πŸ“š"):
329
+ sort_dropdown_ss = gr.Dropdown(
330
+ choices=["Low to High", "High to Low"],
331
+ label="Sort",
332
+ value="Low to High"
333
+ )
334
+ ss_table = gr.HTML(get_model_names_html('sentence_similarity.csv', "Low to High"))
335
+ sort_dropdown_ss.change(fn=update_sentence_similarity, inputs=sort_dropdown_ss, outputs=ss_table)
336
+
337
+ # --- Extractive QA Tab ---
338
  with gr.TabItem("Extractive QA ❔"):
339
+ sort_dropdown_qa = gr.Dropdown(
340
+ choices=["Low to High", "High to Low"],
341
+ label="Sort",
342
+ value="Low to High"
343
+ )
344
+ qa_table = gr.HTML(get_model_names_html('question_answering.csv', "Low to High"))
345
+ sort_dropdown_qa.change(fn=update_extractive_qa, inputs=sort_dropdown_qa, outputs=qa_table)
346
+
347
+ # --- All Tasks Tab ---
348
  with gr.TabItem("All Tasks πŸ’‘"):
349
+ sort_dropdown_all = gr.Dropdown(
350
+ choices=["Low to High", "High to Low"],
351
+ label="Sort",
352
+ value="Low to High"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
  )
354
+ all_table = gr.HTML(get_all_model_names_html("Low to High"))
355
+ sort_dropdown_all.change(fn=update_all_tasks, inputs=sort_dropdown_all, outputs=all_table)
356
+
357
+ with gr.Accordion("πŸ“™ Citation", open=False):
358
+ citation_button = gr.Textbox(
359
+ value=CITATION_BUTTON_TEXT,
360
+ label=CITATION_BUTTON_LABEL,
361
+ elem_id="citation-button",
362
+ lines=10,
363
+ show_copy_button=True,
364
+ )
365
+ gr.Markdown("""Last updated: February 2025""")
366
+
367
+ demo.launch()