Update app.py
Browse files
app.py
CHANGED
@@ -94,7 +94,9 @@ with gr.Blocks() as demo:
|
|
94 |
with gr.TabItem("Leaderboard"):
|
95 |
# ...existing code...
|
96 |
task_options = [col for col in df.columns if col not in ['model','hf_name','model_physical_size', 'precision']]
|
|
|
97 |
with gr.Row():
|
|
|
98 |
selected_tasks = gr.CheckboxGroup(choices=task_options, label="Select Tasks")
|
99 |
with gr.Row():
|
100 |
accuracy_plot = gr.Plot(label="Accuracy Plot")
|
@@ -108,6 +110,10 @@ with gr.Blocks() as demo:
|
|
108 |
def update_outputs(selected_tasks):
|
109 |
if not selected_tasks:
|
110 |
return df[['model', 'precision']], None, None
|
|
|
|
|
|
|
|
|
111 |
filtered_df = df[['model', 'precision', 'model_physical_size','hf_name'] + selected_tasks]
|
112 |
# average accuracy of selected tasks
|
113 |
filtered_df['avg_accuracy'] = filtered_df[selected_tasks].mean(axis=1)
|
@@ -117,12 +123,13 @@ with gr.Blocks() as demo:
|
|
117 |
pareto_df = filtered_df.sort_values('model_physical_size')
|
118 |
pareto_df = pareto_df.loc[pareto_df['avg_accuracy'].cummax().drop_duplicates().index]
|
119 |
# Add Pareto frontier to line_plot
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
126 |
|
127 |
# set title of bar_fig
|
128 |
bar_fig.update_layout(title=f'tasks: {", ".join(selected_tasks)}')
|
@@ -133,14 +140,13 @@ with gr.Blocks() as demo:
|
|
133 |
|
134 |
pareto_df = with_perf_df.sort_values('avg_e2e_latency')
|
135 |
pareto_df = pareto_df.loc[pareto_df['avg_accuracy'].cummax().drop_duplicates().index]
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
print(with_perf_df)
|
144 |
return with_perf_df, bar_fig, line_fig, throughput_line_fig, latency_line_fig
|
145 |
|
146 |
selected_tasks.change(
|
@@ -158,4 +164,4 @@ with gr.Blocks() as demo:
|
|
158 |
)
|
159 |
|
160 |
if __name__ == "__main__":
|
161 |
-
demo.launch()
|
|
|
94 |
with gr.TabItem("Leaderboard"):
|
95 |
# ...existing code...
|
96 |
task_options = [col for col in df.columns if col not in ['model','hf_name','model_physical_size', 'precision']]
|
97 |
+
task_options.append("plot_pareto")
|
98 |
with gr.Row():
|
99 |
+
# print pareto or not
|
100 |
selected_tasks = gr.CheckboxGroup(choices=task_options, label="Select Tasks")
|
101 |
with gr.Row():
|
102 |
accuracy_plot = gr.Plot(label="Accuracy Plot")
|
|
|
110 |
def update_outputs(selected_tasks):
|
111 |
if not selected_tasks:
|
112 |
return df[['model', 'precision']], None, None
|
113 |
+
plot_pareto=False
|
114 |
+
if "plot_pareto" in selected_tasks:
|
115 |
+
plot_pareto = True
|
116 |
+
selected_tasks.remove("plot_pareto")
|
117 |
filtered_df = df[['model', 'precision', 'model_physical_size','hf_name'] + selected_tasks]
|
118 |
# average accuracy of selected tasks
|
119 |
filtered_df['avg_accuracy'] = filtered_df[selected_tasks].mean(axis=1)
|
|
|
123 |
pareto_df = filtered_df.sort_values('model_physical_size')
|
124 |
pareto_df = pareto_df.loc[pareto_df['avg_accuracy'].cummax().drop_duplicates().index]
|
125 |
# Add Pareto frontier to line_plot
|
126 |
+
if plot_pareto:
|
127 |
+
line_fig.add_trace(go.Scatter(
|
128 |
+
x=pareto_df['model_physical_size'],
|
129 |
+
y=pareto_df['avg_accuracy'],
|
130 |
+
mode='lines+markers',
|
131 |
+
name='Pareto Frontier'
|
132 |
+
))
|
133 |
|
134 |
# set title of bar_fig
|
135 |
bar_fig.update_layout(title=f'tasks: {", ".join(selected_tasks)}')
|
|
|
140 |
|
141 |
pareto_df = with_perf_df.sort_values('avg_e2e_latency')
|
142 |
pareto_df = pareto_df.loc[pareto_df['avg_accuracy'].cummax().drop_duplicates().index]
|
143 |
+
if plot_pareto:
|
144 |
+
latency_line_fig.add_trace(go.Scatter(
|
145 |
+
x=pareto_df['avg_e2e_latency'],
|
146 |
+
y=pareto_df['avg_accuracy'],
|
147 |
+
mode='lines+markers',
|
148 |
+
name='Pareto Frontier'
|
149 |
+
))
|
|
|
150 |
return with_perf_df, bar_fig, line_fig, throughput_line_fig, latency_line_fig
|
151 |
|
152 |
selected_tasks.change(
|
|
|
164 |
)
|
165 |
|
166 |
if __name__ == "__main__":
|
167 |
+
demo.launch(share=True)
|