bgamazay commited on
Commit
2cd90e2
Β·
verified Β·
1 Parent(s): d3ee32e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +361 -95
app.py CHANGED
@@ -1,135 +1,401 @@
1
- import os, glob
2
- import pandas as pd
3
  import gradio as gr
4
- from datasets import load_dataset
5
- from huggingface_hub import HfApi
 
 
6
 
7
- OWNER = "AIEnergyScore"
8
- TOKEN = os.environ.get("DEBUG")
9
- API = HfApi(token=TOKEN)
 
 
 
 
 
10
 
11
- def get_leaderboard_models():
12
- """
13
- Reads CSV files from the leaderboard directory and returns a DataFrame
14
- containing the 'model' and 'task' columns.
15
- If no CSV files are found, returns an empty DataFrame with those columns.
16
- """
17
- path = r'leaderboard_v0_data/energy'
18
- filenames = glob.glob(os.path.join(path, "*.csv"))
19
- data = []
20
- for filename in filenames:
21
- data.append(pd.read_csv(filename))
22
- if not data:
23
- return pd.DataFrame(columns=['model', 'task'])
24
- leaderboard_data = pd.concat(data, ignore_index=True)
25
- return leaderboard_data[['model', 'task']]
26
-
27
- def print_existing_models():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  """
29
- Loads a dataset of requests and returns the models that have been benchmarked.
 
 
 
 
 
30
  """
31
- requests = load_dataset("AIEnergyScore/requests_debug", split="test", token=TOKEN)
32
- requests_dset = requests.to_pandas()
33
- model_df = requests_dset[['model', 'status']]
34
- model_df = model_df[model_df['status'] == 'COMPLETED']
35
- return model_df
36
-
37
- def highlight_cols(x):
38
- df = x.copy()
39
- df[df['status'] == 'COMPLETED'] = 'color: green'
40
- df[df['status'] == 'PENDING'] = 'color: orange'
41
- df[df['status'] == 'FAILED'] = 'color: red'
42
- return df
43
-
44
- # Apply styling to the recently benchmarked models table.
45
- existing_models = print_existing_models()
46
- formatted_df = existing_models.style.apply(highlight_cols, axis=None)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  def get_zip_data_link():
49
- """
50
- Returns an HTML link for downloading logs.
51
- """
52
- return (
53
- '<a href="https://example.com/download.zip" '
54
- 'style="text-decoration: none; font-weight: bold; font-size: 1.1em; '
55
- 'color: black; font-family: \'Inter\', sans-serif;">Download Logs</a>'
 
 
 
56
  )
 
57
 
58
- with gr.Blocks() as demo:
59
- # --- Custom CSS for layout and styling ---
60
- gr.HTML('''
61
- <style>
62
- /* Evenly space the header links */
63
- .header-links {
64
- display: flex;
65
- justify-content: space-evenly;
66
- align-items: center;
67
- margin: 10px 0;
68
- }
69
- /* Center the subtitle text */
70
- .centered-subtitle {
71
- text-align: center;
72
- font-size: 1.4em;
73
- margin-bottom: 20px;
74
- }
75
- /* Full width container for matching widget edges */
76
- .full-width {
77
- width: 100% !important;
78
- }
79
- </style>
80
- ''')
81
 
82
- # --- Header Links ---
83
- with gr.Row(elem_classes="header-links"):
84
- leaderboard_link = gr.HTML(
85
- '<a href="https://huggingface.co/spaces/AIEnergyScore/Leaderboard" '
86
- 'style="text-decoration: none; font-weight: bold; font-size: 1.1em; '
87
- 'color: black; font-family: \'Inter\', sans-serif;">Leaderboard</a>'
88
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  submission_link = gr.HTML(
90
  '<a href="https://huggingface.co/spaces/AIEnergyScore/submission_portal" '
91
- 'style="text-decoration: none; font-weight: bold; font-size: 1.1em; '
92
  'color: black; font-family: \'Inter\', sans-serif;">Submission Portal</a>'
93
  )
94
  label_link = gr.HTML(
95
  '<a href="https://huggingface.co/spaces/AIEnergyScore/Label" '
96
- 'style="text-decoration: none; font-weight: bold; font-size: 1.1em; '
97
  'color: black; font-family: \'Inter\', sans-serif;">Label Generator</a>'
98
  )
99
  faq_link = gr.HTML(
100
  '<a href="https://huggingface.github.io/AIEnergyScore/#faq" '
101
- 'style="text-decoration: none; font-weight: bold; font-size: 1.1em; '
102
  'color: black; font-family: \'Inter\', sans-serif;">FAQ</a>'
103
  )
104
  documentation_link = gr.HTML(
105
  '<a href="https://huggingface.github.io/AIEnergyScore/#documentation" '
106
- 'style="text-decoration: none; font-weight: bold; font-size: 1.1em; '
107
  'color: black; font-family: \'Inter\', sans-serif;">Documentation</a>'
108
  )
109
  download_link = gr.HTML(get_zip_data_link())
110
  community_link = gr.HTML(
111
  '<a href="https://huggingface.co/spaces/AIEnergyScore/README/discussions" '
112
- 'style="text-decoration: none; font-weight: bold; font-size: 1.1em; '
113
  'color: black; font-family: \'Inter\', sans-serif;">Community</a>'
114
  )
115
 
116
- # --- Logo (Centered) ---
117
  gr.HTML('''
118
  <div style="text-align: center; margin-top: 20px;">
119
  <img src="https://huggingface.co/spaces/AIEnergyScore/Leaderboard/resolve/main/logo.png"
120
  alt="Logo"
121
- style="max-width: 500px; height: auto;">
122
  </div>
123
  ''')
124
 
125
- # --- Centered Subtitle ---
126
- gr.Markdown('<p class="centered-subtitle">Welcome to the AI Energy Score Leaderboard. Explore the top-performing models below.</p>')
127
-
128
- # --- Leaderboard Tables ---
129
- with gr.Column(elem_classes="full-width"):
130
- with gr.Accordion("Latest Leaderboard", open=True):
131
- gr.Dataframe(get_leaderboard_models(), elem_classes="full-width")
132
- with gr.Accordion("Recently Benchmarked Models", open=False):
133
- gr.Dataframe(formatted_df, elem_classes="full-width")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
- 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 = (
115
+ f'<a href="data:application/zip;base64,{b64}" '
116
+ 'download="data.zip" '
117
+ 'style="margin: 0 15px; text-decoration: none; font-weight: bold; font-size: 1.1em; '
118
+ 'color: black; font-family: \'Inter\', sans-serif;">Download Data</a>'
119
  )
120
+ return href
121
 
122
+ # --- Modified functions to include a sort_order parameter ---
123
+ def get_model_names_html(task, sort_order="Low to High"):
124
+ df = pd.read_csv('data/energy/' + task)
125
+ if df.columns[0].startswith("Unnamed:"):
126
+ df = df.iloc[:, 1:]
127
+ df['energy_score'] = df['energy_score'].astype(int)
128
+ # Convert kWh to Wh:
129
+ df['gpu_energy_numeric'] = pd.to_numeric(df['total_gpu_energy'], errors='raise') * 1000
130
+ df['Model'] = df['model'].apply(make_link)
131
+ df['Score'] = df['energy_score'].apply(format_stars)
132
+ ascending = True if sort_order == "Low to High" else False
133
+ df = df.sort_values(by='gpu_energy_numeric', ascending=ascending)
134
+ return generate_html_table_from_df(df)
 
 
 
 
 
 
 
 
 
 
135
 
136
+ def get_all_model_names_html(sort_order="Low to High"):
137
+ all_df = pd.DataFrame()
138
+ for task in tasks:
139
+ df = pd.read_csv('data/energy/' + task)
140
+ if df.columns[0].startswith("Unnamed:"):
141
+ df = df.iloc[:, 1:]
142
+ df['energy_score'] = df['energy_score'].astype(int)
143
+ df['gpu_energy_numeric'] = pd.to_numeric(df['total_gpu_energy'], errors='raise') * 1000
144
+ df['Model'] = df['model'].apply(make_link)
145
+ df['Score'] = df['energy_score'].apply(format_stars)
146
+ all_df = pd.concat([all_df, df], ignore_index=True)
147
+ all_df = all_df.drop_duplicates(subset=['model'])
148
+ ascending = True if sort_order == "Low to High" else False
149
+ all_df = all_df.sort_values(by='gpu_energy_numeric', ascending=ascending)
150
+ return generate_html_table_from_df(all_df)
151
+
152
+ def get_text_generation_model_names_html(model_class, sort_order="Low to High"):
153
+ df = pd.read_csv('data/energy/text_generation.csv')
154
+ if df.columns[0].startswith("Unnamed:"):
155
+ df = df.iloc[:, 1:]
156
+ if 'class' in df.columns:
157
+ df = df[df['class'] == model_class]
158
+ df['energy_score'] = df['energy_score'].astype(int)
159
+ df['gpu_energy_numeric'] = pd.to_numeric(df['total_gpu_energy'], errors='raise') * 1000
160
+ df['Model'] = df['model'].apply(make_link)
161
+ df['Score'] = df['energy_score'].apply(format_stars)
162
+ ascending = True if sort_order == "Low to High" else False
163
+ df = df.sort_values(by='gpu_energy_numeric', ascending=ascending)
164
+ return generate_html_table_from_df(df)
165
+
166
+ # --- Update functions for dropdown changes ---
167
+
168
+ # For Text Generation, two dropdowns: model class and sort order.
169
+ def update_text_generation(selected_display, sort_order):
170
+ mapping = {
171
+ "A (Single Consumer GPU) <20B parameters": "A",
172
+ "B (Single Cloud GPU) 20-66B parameters": "B",
173
+ "C (Multiple Cloud GPUs) >66B parameters": "C"
174
+ }
175
+ model_class = mapping.get(selected_display, "A")
176
+ return get_text_generation_model_names_html(model_class, sort_order)
177
+
178
+ # For the other tabs, each update function simply takes the sort_order.
179
+ def update_image_generation(sort_order):
180
+ return get_model_names_html('image_generation.csv', sort_order)
181
+
182
+ def update_text_classification(sort_order):
183
+ return get_model_names_html('text_classification.csv', sort_order)
184
+
185
+ def update_image_classification(sort_order):
186
+ return get_model_names_html('image_classification.csv', sort_order)
187
+
188
+ def update_image_captioning(sort_order):
189
+ return get_model_names_html('image_captioning.csv', sort_order)
190
+
191
+ def update_summarization(sort_order):
192
+ return get_model_names_html('summarization.csv', sort_order)
193
+
194
+ def update_asr(sort_order):
195
+ return get_model_names_html('asr.csv', sort_order)
196
+
197
+ def update_object_detection(sort_order):
198
+ return get_model_names_html('object_detection.csv', sort_order)
199
+
200
+ def update_sentence_similarity(sort_order):
201
+ return get_model_names_html('sentence_similarity.csv', sort_order)
202
+
203
+ def update_extractive_qa(sort_order):
204
+ return get_model_names_html('question_answering.csv', sort_order)
205
+
206
+ def update_all_tasks(sort_order):
207
+ return get_all_model_names_html(sort_order)
208
+
209
+ # --- Build the Gradio Interface ---
210
+
211
+ demo = gr.Blocks(css="""
212
+ .gr-dataframe table {
213
+ table-layout: fixed;
214
+ width: 100%;
215
+ }
216
+ .gr-dataframe th, .gr-dataframe td {
217
+ max-width: 150px;
218
+ white-space: nowrap;
219
+ overflow: hidden;
220
+ text-overflow: ellipsis;
221
+ }
222
+ """)
223
+
224
+ with demo:
225
+ # --- Header Links (at the very top) ---
226
+ with gr.Row():
227
  submission_link = gr.HTML(
228
  '<a href="https://huggingface.co/spaces/AIEnergyScore/submission_portal" '
229
+ 'style="margin: 0 10px; text-decoration: none; font-weight: bold; font-size: 1.1em; '
230
  'color: black; font-family: \'Inter\', sans-serif;">Submission Portal</a>'
231
  )
232
  label_link = gr.HTML(
233
  '<a href="https://huggingface.co/spaces/AIEnergyScore/Label" '
234
+ 'style="margin: 0 10px; text-decoration: none; font-weight: bold; font-size: 1.1em; '
235
  'color: black; font-family: \'Inter\', sans-serif;">Label Generator</a>'
236
  )
237
  faq_link = gr.HTML(
238
  '<a href="https://huggingface.github.io/AIEnergyScore/#faq" '
239
+ 'style="margin: 0 10px; text-decoration: none; font-weight: bold; font-size: 1.1em; '
240
  'color: black; font-family: \'Inter\', sans-serif;">FAQ</a>'
241
  )
242
  documentation_link = gr.HTML(
243
  '<a href="https://huggingface.github.io/AIEnergyScore/#documentation" '
244
+ 'style="margin: 0 10px; text-decoration: none; font-weight: bold; font-size: 1.1em; '
245
  'color: black; font-family: \'Inter\', sans-serif;">Documentation</a>'
246
  )
247
  download_link = gr.HTML(get_zip_data_link())
248
  community_link = gr.HTML(
249
  '<a href="https://huggingface.co/spaces/AIEnergyScore/README/discussions" '
250
+ 'style="margin: 0 10px; text-decoration: none; font-weight: bold; font-size: 1.1em; '
251
  'color: black; font-family: \'Inter\', sans-serif;">Community</a>'
252
  )
253
 
254
+ # --- Logo (centered) ---
255
  gr.HTML('''
256
  <div style="text-align: center; margin-top: 20px;">
257
  <img src="https://huggingface.co/spaces/AIEnergyScore/Leaderboard/resolve/main/logo.png"
258
  alt="Logo"
259
+ style="max-width: 300px; height: auto;">
260
  </div>
261
  ''')
262
 
263
+ # --- Subtitle (centered) ---
264
+ 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>')
265
+
266
+ # --- Tabs for the different tasks ---
267
+ with gr.Tabs():
268
+ # --- Text Generation Tab ---
269
+ with gr.TabItem("Text Generation πŸ’¬"):
270
+ with gr.Row():
271
+ model_class_options = [
272
+ "A (Single Consumer GPU) <20B parameters",
273
+ "B (Single Cloud GPU) 20-66B parameters",
274
+ "C (Multiple Cloud GPUs) >66B parameters"
275
+ ]
276
+ model_class_dropdown = gr.Dropdown(
277
+ choices=model_class_options,
278
+ label="Select Model Class",
279
+ value=model_class_options[0]
280
+ )
281
+ sort_dropdown_tg = gr.Dropdown(
282
+ choices=["Low to High", "High to Low"],
283
+ label="Sort",
284
+ value="Low to High"
285
+ )
286
+ tg_table = gr.HTML(get_text_generation_model_names_html("A", "Low to High"))
287
+ # When either dropdown changes, update the table.
288
+ model_class_dropdown.change(fn=update_text_generation, inputs=[model_class_dropdown, sort_dropdown_tg], outputs=tg_table)
289
+ sort_dropdown_tg.change(fn=update_text_generation, inputs=[model_class_dropdown, sort_dropdown_tg], outputs=tg_table)
290
+
291
+ # --- Image Generation Tab ---
292
+ with gr.TabItem("Image Generation πŸ“·"):
293
+ sort_dropdown_img = gr.Dropdown(
294
+ choices=["Low to High", "High to Low"],
295
+ label="Sort",
296
+ value="Low to High"
297
+ )
298
+ img_table = gr.HTML(get_model_names_html('image_generation.csv', "Low to High"))
299
+ sort_dropdown_img.change(fn=update_image_generation, inputs=sort_dropdown_img, outputs=img_table)
300
+
301
+ # --- Text Classification Tab ---
302
+ with gr.TabItem("Text Classification 🎭"):
303
+ sort_dropdown_tc = gr.Dropdown(
304
+ choices=["Low to High", "High to Low"],
305
+ label="Sort",
306
+ value="Low to High"
307
+ )
308
+ tc_table = gr.HTML(get_model_names_html('text_classification.csv', "Low to High"))
309
+ sort_dropdown_tc.change(fn=update_text_classification, inputs=sort_dropdown_tc, outputs=tc_table)
310
+
311
+ # --- Image Classification Tab ---
312
+ with gr.TabItem("Image Classification πŸ–ΌοΈ"):
313
+ sort_dropdown_ic = gr.Dropdown(
314
+ choices=["Low to High", "High to Low"],
315
+ label="Sort",
316
+ value="Low to High"
317
+ )
318
+ ic_table = gr.HTML(get_model_names_html('image_classification.csv', "Low to High"))
319
+ sort_dropdown_ic.change(fn=update_image_classification, inputs=sort_dropdown_ic, outputs=ic_table)
320
+
321
+ # --- Image Captioning Tab ---
322
+ with gr.TabItem("Image Captioning πŸ“"):
323
+ sort_dropdown_icap = gr.Dropdown(
324
+ choices=["Low to High", "High to Low"],
325
+ label="Sort",
326
+ value="Low to High"
327
+ )
328
+ icap_table = gr.HTML(get_model_names_html('image_captioning.csv', "Low to High"))
329
+ sort_dropdown_icap.change(fn=update_image_captioning, inputs=sort_dropdown_icap, outputs=icap_table)
330
+
331
+ # --- Summarization Tab ---
332
+ with gr.TabItem("Summarization πŸ“ƒ"):
333
+ sort_dropdown_sum = gr.Dropdown(
334
+ choices=["Low to High", "High to Low"],
335
+ label="Sort",
336
+ value="Low to High"
337
+ )
338
+ sum_table = gr.HTML(get_model_names_html('summarization.csv', "Low to High"))
339
+ sort_dropdown_sum.change(fn=update_summarization, inputs=sort_dropdown_sum, outputs=sum_table)
340
+
341
+ # --- Automatic Speech Recognition Tab ---
342
+ with gr.TabItem("Automatic Speech Recognition πŸ’¬"):
343
+ sort_dropdown_asr = gr.Dropdown(
344
+ choices=["Low to High", "High to Low"],
345
+ label="Sort",
346
+ value="Low to High"
347
+ )
348
+ asr_table = gr.HTML(get_model_names_html('asr.csv', "Low to High"))
349
+ sort_dropdown_asr.change(fn=update_asr, inputs=sort_dropdown_asr, outputs=asr_table)
350
+
351
+ # --- Object Detection Tab ---
352
+ with gr.TabItem("Object Detection 🚘"):
353
+ sort_dropdown_od = gr.Dropdown(
354
+ choices=["Low to High", "High to Low"],
355
+ label="Sort",
356
+ value="Low to High"
357
+ )
358
+ od_table = gr.HTML(get_model_names_html('object_detection.csv', "Low to High"))
359
+ sort_dropdown_od.change(fn=update_object_detection, inputs=sort_dropdown_od, outputs=od_table)
360
+
361
+ # --- Sentence Similarity Tab ---
362
+ with gr.TabItem("Sentence Similarity πŸ“š"):
363
+ sort_dropdown_ss = gr.Dropdown(
364
+ choices=["Low to High", "High to Low"],
365
+ label="Sort",
366
+ value="Low to High"
367
+ )
368
+ ss_table = gr.HTML(get_model_names_html('sentence_similarity.csv', "Low to High"))
369
+ sort_dropdown_ss.change(fn=update_sentence_similarity, inputs=sort_dropdown_ss, outputs=ss_table)
370
+
371
+ # --- Extractive QA Tab ---
372
+ with gr.TabItem("Extractive QA ❔"):
373
+ sort_dropdown_qa = gr.Dropdown(
374
+ choices=["Low to High", "High to Low"],
375
+ label="Sort",
376
+ value="Low to High"
377
+ )
378
+ qa_table = gr.HTML(get_model_names_html('question_answering.csv', "Low to High"))
379
+ sort_dropdown_qa.change(fn=update_extractive_qa, inputs=sort_dropdown_qa, outputs=qa_table)
380
+
381
+ # --- All Tasks Tab ---
382
+ with gr.TabItem("All Tasks πŸ’‘"):
383
+ sort_dropdown_all = gr.Dropdown(
384
+ choices=["Low to High", "High to Low"],
385
+ label="Sort",
386
+ value="Low to High"
387
+ )
388
+ all_table = gr.HTML(get_all_model_names_html("Low to High"))
389
+ sort_dropdown_all.change(fn=update_all_tasks, inputs=sort_dropdown_all, outputs=all_table)
390
+
391
+ with gr.Accordion("πŸ“™ Citation", open=False):
392
+ citation_button = gr.Textbox(
393
+ value=CITATION_BUTTON_TEXT,
394
+ label=CITATION_BUTTON_LABEL,
395
+ elem_id="citation-button",
396
+ lines=10,
397
+ show_copy_button=True,
398
+ )
399
+ gr.Markdown("""Last updated: February 2025""")
400
 
401
+ demo.launch()