Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,212 +1,367 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
-
|
4 |
-
import
|
|
|
5 |
|
6 |
CITATION_BUTTON_LABEL = "Copy the following snippet to cite these results"
|
7 |
-
CITATION_BUTTON_TEXT = r"""@misc{
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
return
|
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 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
for task in tasks:
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
all_df
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
with demo:
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
)
|
115 |
-
gr.
|
116 |
-
|
117 |
-
)
|
|
|
|
|
|
|
|
|
|
|
118 |
with gr.Tabs():
|
|
|
119 |
with gr.TabItem("Text Generation π¬"):
|
120 |
with gr.Row():
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
with gr.TabItem("Image Generation π·"):
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
133 |
with gr.TabItem("Text Classification π"):
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
140 |
with gr.TabItem("Image Classification πΌοΈ"):
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
|
|
|
|
|
|
147 |
with gr.TabItem("Image Captioning π"):
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
|
|
153 |
with gr.TabItem("Summarization π"):
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
with gr.TabItem("Object Detection π"):
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
174 |
with gr.TabItem("Sentence Similarity π"):
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
|
|
|
|
|
|
181 |
with gr.TabItem("Extractive QA β"):
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
|
|
|
|
|
|
188 |
with gr.TabItem("All Tasks π‘"):
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
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 |
-
|
211 |
-
|
212 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|