File size: 31,926 Bytes
dff685f
 
 
 
 
 
 
 
 
 
 
 
 
 
e4588a1
dff685f
 
 
 
e4588a1
 
 
 
 
 
 
dff685f
 
 
e4588a1
dff685f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
import yaml
import gradio as gr
import pandas as pd
import numpy as np
import altair as alt
import plotly.express as px
import pickle
import os

from src.assets.css_html_js import custom_css
from src.assets.awesome_mapping import paper_mapping, section_mapping, bibtex_mapping, venue_mapping, citation_key_mapping

TITLE = "🔥CNN Structured Pruning Leaderboard"
PAPER_LINK = 'https://arxiv.org/abs/2303.00566'
PAPER_LINK_IEEE = 'https://ieeexplore.ieee.org/document/10330640'
AWESOME_PRUNING_LINK = 'https://github.com/he-y/Awesome-Pruning'
BIBTEX = '''
@article{he2023structured,
  author={He, Yang and Xiao, Lingao},
  journal={IEEE Transactions on Pattern Analysis and Machine Intelligence}, 
  title={Structured Pruning for Deep Convolutional Neural Networks: A Survey}, 
  year={2023},
  volume={},
  number={},
  pages={1-20},
  doi={10.1109/TPAMI.2023.3334614}}
'''
INTRO = f"""
Welcome to our dedicated site for the survey paper: "[Structured Pruning for Deep Convolutional Neural Networks: A Survey]({PAPER_LINK})". 
Our survey is accepted by IEEE T-PAMI. Links include [arXiv]({PAPER_LINK}) and [IEEE Xplore]({PAPER_LINK_IEEE}).

Github Repo: [Awesome Pruning: A curated list of neural network pruning resources]({AWESOME_PRUNING_LINK}).

This platform serves as a repository and visual representation of the benchmarks from studies covered in our survey.

Here, you can explore the reported accuracy and FLOPs metrics from various papers, providing an at-a-glance view of the advancements and methodologies in the domain of structured pruning. 

If you find this website helpful, please consider citing our paper 😊
"""

COLS_KEEP = ['sec', 'year', 'method', 'model', 'acc', 'acc-pruned', 'acc-change', 'flops-pruned', 'flops-drop', 'param-pruned', 'param-drop', 'dataset']
COLS = ['sec', 'year', 'method', 'model', 'acc', 'acc-pruned', 'acc-change', 'flops', 'flops-pruned', 'flops-drop', 'param', 'param-pruned', 'param-drop', 'dataset']

MISC_GROUP = ['model', 'dataset', 'method', 'year', 'sec']
ACC_GROUP = ['acc', 'acc-pruned', 'acc-change']
FLOPS_GROUP = ['flops', 'flops-pruned', 'flops-drop']
PARAM_GROUP = ['param', 'param-pruned', 'param-drop']

# Define a mapping from original headers to custom headers
CUSTOM_HEADER_MAP = {
    'sec': 'Section',
    'year': 'Year',
    'method': 'Method',
    'model': 'Model',
    'acc': 'Acc',
    'acc-pruned': 'Acc Pruned',
    # 'acc-change': 'Acc. Δ (%)',
    'acc-change': 'Acc ↓ (%)',
    'flops': 'FLOPs (M)',
    'flops-pruned': 'FLOPs Pruned (M)',
    'flops-drop': 'FLOPs ↓ (%)',
    'param': 'Params (M)',
    'param-pruned': 'Params Pruned (M)',
    'param-drop': 'Params ↓ (%)',
    'dataset': 'Dataset'
}
CUSTOM_HEADER_MAP.update({v: k for k, v in CUSTOM_HEADER_MAP.items()})

df = pickle.load(open("src/assets/data.pkl", "rb"))
baseline = pickle.load(open("src/assets/baseline.pkl", "rb"))

def filter_table_combined(leaderboard, search_box, search_box_method, search_box_year, search_box_section, acc_base_box, acc_box, acc_change, flops_base_box, flops_box, flops_drop, param_base_box, param_box, param_drop):
    search_boxes = [search_box, search_box_method, search_box_year, search_box_section, acc_base_box, acc_box, acc_change, flops_base_box, flops_box, flops_drop, param_base_box, param_box, param_drop]
    column_names = ['model', 'method', 'year', 'sec', 'acc', 'acc-pruned', 'acc-change', 'flops', 'flops-pruned', 'flops-drop', 'param', 'param-pruned', 'param-drop']

    filtered_df = leaderboard.copy()
    for idx, (q, col_name) in enumerate(zip(search_boxes, column_names)):
        if q != '':
            if idx == 3:  # Special case for section
                if q[0] != '2':  # Does not start with 2
                    q = "2." + q[0]
                elif len(q) < 5:
                    filtered_df = filtered_df[filtered_df[col_name].str.slice(0, len(q)).str.lower() == q.strip().lower()]
                else:
                    filtered_df = filtered_df[filtered_df[col_name].astype(str).str.lower() == q.strip().lower()]
            elif idx < 4:  # Similar to original filter_table
                filtered_df = filtered_df[filtered_df[col_name].astype(str).str.contains(q, case=False)]
            else:  # Similar to original filter_table_by_acc
                filtered_df[col_name].replace('', np.nan, inplace=True)
                filtered_df.dropna(subset=[col_name], inplace=True)
                if idx in [4, 5, 9, 12]:
                    filtered_df = filtered_df[filtered_df[col_name].astype(float) > float(q)]
                else:
                    filtered_df = filtered_df[filtered_df[col_name].astype(float) < float(q)]
    return filtered_df

# Function to update columns
def update_columns(leaderboard, columns: list):
    return leaderboard[leaderboard.columns.intersection(columns)].rename(columns=CUSTOM_HEADER_MAP)

def update_table(leaderboard, search_box, search_box_method, search_box_year, search_box_section, acc_base_box, acc_box, acc_change, flops_base_box, flops_box, flops_drop, param_base_box, param_box, param_drop):
    updated_df = filter_table_combined(leaderboard, search_box, search_box_method, search_box_year, search_box_section, acc_base_box, acc_box, acc_change, flops_base_box, flops_box, flops_drop, param_base_box, param_box, param_drop)
    updated_df = update_columns(updated_df, COLS)
    return updated_df

def update_text(x):
    return CUSTOM_HEADER_MAP[x]

def get_shown_columns(misc_checkbox_group, acc_checkbox_group, flops_checkbox_group, param_checkbox_group):
    # return all columns if all checkbox groups are selected
    updated_columns = [CUSTOM_HEADER_MAP[col] for col in misc_checkbox_group + acc_checkbox_group + flops_checkbox_group + param_checkbox_group]
    print("Columns updated to", updated_columns, "\n")
    return updated_columns

def make_plot(data, y_axis='acc-change', x_axis='flops-drop', color_sorting='model'):
    y_axis = CUSTOM_HEADER_MAP[y_axis]
    x_axis = x_axis
    color_sorting = color_sorting

    # Drop rows where y_axis and x_axis columns are null
    data.replace('', np.nan, inplace=True)
    data.dropna(subset=[y_axis, x_axis], how='any', inplace=True)

    # Convert 'year' to string
    data[CUSTOM_HEADER_MAP['year']] = data[CUSTOM_HEADER_MAP['year']].astype(str)

    # Sort by y_axis
    data.sort_values(by=[y_axis], ascending=[False], inplace=True)

    # Get min and max for x and y axes
    x_min, x_max = data[x_axis].min(), data[x_axis].max()
    y_min, y_max = data[y_axis].min(), data[y_axis].max()

    if data is None or data.empty:
        # plot with title:
        # "No results found or bad query"
        return alt.Chart(pd.DataFrame({'x': [], 'y': []})).mark_point().encode().properties(title="No results found or bad query")

    # Create a selection that filters data based on the legend
    legend_selection = alt.selection_point(fields=[color_sorting], bind='legend')

    # Create a selection for hover
    hover_selection = alt.selection_point(on='mouseover', nearest=False, empty=True)
    
    # Create Altair scatter plot
    scatter = alt.Chart(data).mark_point().encode(
        x=alt.X(x_axis, title=x_axis, scale=alt.Scale(domain=(x_min-2, x_max+2))),
        y=alt.Y(y_axis, title=y_axis, scale=alt.Scale(domain=(y_min-2, y_max+2))),
        color=color_sorting,
        tooltip=[CUSTOM_HEADER_MAP['method'], CUSTOM_HEADER_MAP['model'], CUSTOM_HEADER_MAP['acc-pruned'], CUSTOM_HEADER_MAP['acc-change'], CUSTOM_HEADER_MAP['flops-pruned'], CUSTOM_HEADER_MAP['flops-drop'], CUSTOM_HEADER_MAP['year'], CUSTOM_HEADER_MAP['sec']],
        opacity=alt.condition(hover_selection, alt.value(1), alt.value(0.2))
    ).add_params(
        legend_selection,
        hover_selection,
    ).transform_filter(
        legend_selection
    ).interactive()
    
    return scatter


def item_selected(leaderboard: gr.Dataframe, evt: gr.SelectData):
    # evt.index
    # evt.value
    item = leaderboard.loc[leaderboard[CUSTOM_HEADER_MAP['method']] == evt.value]
    if len(item) == 0:
        return "✖️ Invalid cell! Please click on **Method Name** to see details...", "✖️ Invalid cell! Please click on **Method Name** to see details..."
    elif len(item) > 1:
        item = item.iloc[0]
    section = item[CUSTOM_HEADER_MAP['sec']]
    method = item[CUSTOM_HEADER_MAP['method']]

    # check if type is pandas Series
    if type(section) is pd.Series:
        section = section.iloc[0]
    if type(method) is pd.Series:
        method = method.iloc[0]

    sec_record = section_mapping[section]    # (section, sub section)
    awesome_record = paper_mapping[method]    # (paper, code)
    bibtex_record = bibtex_mapping[method]    # (bibtex, score)
    # replace any KEY with value in venue_mapping
    for k, v in venue_mapping.items():
        if k in bibtex_record:
            bibtex_record = bibtex_record.replace(k, v)

    # process section:  (section, sub section)
    main_section = sec_record[0]
    sub_section = sec_record[1]

    # process awesome_record:  " | paper | conf | type | code | "
    paper = "Not Recorded 😭"
    conf = "Not Recorded 😭"
    code = "Not Recorded 😭"
    if awesome_record is not None: 
        splitted = awesome_record.split('|')
        paper = splitted[1].strip()
        conf = splitted[2].strip()
        code = splitted[-2].strip()
        if code == "" or code == "-":
            code = "Not Recorded 😭"

    text = f"""
    Section: {main_section}{sub_section} ({section})
    
    Paper: {paper}

    Venue: {conf}

    Code: {code}
    """
    return text, bibtex_record

def create_tab(app, dataset_name, dataset_id, df):
    dataset = dataset_name.lower()
    df_dataset = df[df['dataset'] == dataset]
    original_df_pd = df_dataset.copy()

    if dataset == 'cifar10':
        dataset_label = 'CIFAR-10'
    elif dataset == 'cifar100':
        dataset_label = 'CIFAR-100'
    elif dataset == 'imagenet':
        dataset_label = 'ImageNet-1K'
    else:
        raise ValueError(f"Unknown dataset: {dataset}")

    with gr.TabItem(dataset_label, id=dataset_id):
        with gr.Row(equal_height=True):
            with gr.Column():

                with gr.Group():
                    with gr.Row():
                        gr.Markdown("**Search by below options:**", elem_classes="markdown-subtitle")
                    with gr.Row():
                        search_box = gr.Textbox(
                            placeholder="[press enter to search]",
                            label="Model",
                            show_label=True,
                        )

                        search_box_method = gr.Textbox(
                            placeholder="[press enter to search]",
                            label="Method",
                            show_label=True,
                        )

                        search_box_year = gr.Textbox(
                            placeholder="[press enter to search]",
                            label="Year",
                            show_label=True,
                        )

                        search_box_section = gr.Textbox(
                            placeholder="[press enter to search]",
                            label="Section",
                            show_label=True,
                        )

                    with gr.Row():
                        acc_base_box = gr.Textbox(
                            placeholder="[press enter to search]",
                            label="Baseline Accuracy",
                            info="E.g., `90` means search for baseline accuracy > 90%.",
                            show_label=True,
                        )
                        acc_box = gr.Textbox(
                            placeholder="[press enter to search]",
                            label="Accuracy After Pruning",
                            info="E.g., `90` means search for accuracy after pruning > 90%.",
                            show_label=True,
                        )
                        acc_change = gr.Textbox(
                            placeholder="[press enter to search]",
                            label="Accuracy Drop",
                            info="E.g., `2` means search for accuracy drop < 2%.",
                            show_label=True,
                        )
                    with gr.Row():
                        flops_base_box = gr.Textbox(
                            placeholder="[press enter to search]",
                            label="Baseline FLOPs",
                            info="E.g., `100` means search for baseline FLOPs < 100M.",
                            show_label=True,
                        )
                        flops_box = gr.Textbox(
                            placeholder="[press enter to search]",
                            label="FLOPs After Pruning",
                            info="E.g., `100` means search for FLOPs after pruning < 100M.",
                            show_label=True,
                        )
                        flops_drop = gr.Textbox(
                            placeholder="[press enter to search]",
                            label="FLOPs Drop",
                            info="E.g., `50` means search for FLOPs drop > 50%.",
                            show_label=True,
                        )
                    with gr.Row():
                        param_base_box = gr.Textbox(
                            placeholder="[press enter to search]",
                            label="Baseline Parameters",
                            info="E.g., `10` means search for baseline parameters < 10M.",
                            show_label=True,
                        )
                        param_box = gr.Textbox(
                            placeholder="[press enter to search]",
                            label="Parameters after Pruning",
                            info="E.g., `10` means search for parameters after pruning < 10M.",
                            show_label=True,
                        )
                        param_drop = gr.Textbox(
                            placeholder="[press enter to search]",
                            label="Parameters Drop",
                            info="E.g., `50` means search for parameters drop by > 50%.",
                            show_label=True,
                        )

                with gr.Accordion(label="See Model Baselines", open=False):
                    # text = gr.Text(value='Add baseline model specifications', label='Baseline FLOPs and Params', lines=2)
                    baseline_dataset = baseline[baseline['dataset'] == dataset]
                    baseline_no_dataset = baseline_dataset.drop(columns=['dataset'])
                    baseline_no_dataset = baseline_no_dataset.rename(columns=CUSTOM_HEADER_MAP)
                    baseline_df = gr.Dataframe(
                        value=baseline_no_dataset,
                        headers=list(baseline_no_dataset.columns),
                        interactive=False,
                        visible=True,
                        wrap=True,
                    )

            with gr.Column():
                with gr.Row():
                    with gr.Column(scale=1):
                        sort_choice_box = gr.Radio(choices=[CUSTOM_HEADER_MAP["model"], CUSTOM_HEADER_MAP["sec"], CUSTOM_HEADER_MAP["year"]], value=CUSTOM_HEADER_MAP["model"], label="Draw with", info="Draw with [model, section, year]")
                    with gr.Column(scale=1):
                        x_axis_box = gr.Radio([CUSTOM_HEADER_MAP["flops-drop"], CUSTOM_HEADER_MAP["flops-pruned"]], value=CUSTOM_HEADER_MAP["flops-drop"], label="Set x-axis", info="Set x-axis to [FLOPs after pruning, FLOPs drop (%)]")

                with gr.Column():
                    plot_acc_change = gr.Plot(label="Plot of Accuracy Change (%)")
                    y_axis_acc_change = gr.Text(value="acc-change", visible=False)

                    plot_acc = gr.Plot(label="Plot of Accuracy After Pruing")
                    y_axis_acc = gr.Text(value="acc-pruned", visible=False)
                
        original_df = gr.Dataframe(
            value=original_df_pd,
            headers=list(df_dataset.columns),
            max_rows=None,
            interactive=False,
            visible=False,
        )

        with gr.Row():  # table
            df_dataset = df_dataset.rename(columns=CUSTOM_HEADER_MAP)
            leaderboard_table = gr.Dataframe(
                value=df_dataset,
                headers=list(df_dataset.columns),
                max_rows=None,
                interactive=False,
                visible=True,
            )
        
        with gr.Row(): 
            details = gr.Markdown(value="*Click any **Method Name** in above table to see details...*", elem_classes='markdown-text')
            bibtex_code = gr.Code("Click any Method Name in above table to see details...", label="BibTeX")
        
        # app.load(new_plot, outputs=[plot_acc_change])
        app.load(make_plot, inputs=[leaderboard_table, y_axis_acc_change, x_axis_box, sort_choice_box], outputs=[plot_acc_change])
        app.load(make_plot, inputs=[leaderboard_table, y_axis_acc, x_axis_box, sort_choice_box], outputs=[plot_acc])

        boxes = [search_box, search_box_method, search_box_year, search_box_section, acc_base_box, acc_box, acc_change, flops_base_box, flops_box, flops_drop, param_base_box, param_box, param_drop]
        for search in boxes:
            search.submit(update_table, [original_df, search_box, search_box_method, search_box_year, search_box_section, acc_base_box, acc_box, acc_change, flops_base_box, flops_box, flops_drop, param_base_box, param_box, param_drop], outputs=[leaderboard_table])

        leaderboard_table.change(make_plot, inputs=[leaderboard_table, y_axis_acc_change, x_axis_box, sort_choice_box], outputs=[plot_acc_change])
        leaderboard_table.change(make_plot, inputs=[leaderboard_table, y_axis_acc, x_axis_box, sort_choice_box], outputs=[plot_acc])
        leaderboard_table.select(item_selected, inputs=[leaderboard_table], outputs=[details, bibtex_code])

        sort_choice_box.change(make_plot, [leaderboard_table, y_axis_acc, x_axis_box, sort_choice_box], outputs=[plot_acc])
        sort_choice_box.change(make_plot, [leaderboard_table, y_axis_acc_change, x_axis_box, sort_choice_box], outputs=[plot_acc_change])
        x_axis_box.change(make_plot, [leaderboard_table, y_axis_acc, x_axis_box, sort_choice_box], outputs=[plot_acc])
        x_axis_box.change(make_plot, [leaderboard_table, y_axis_acc_change, x_axis_box, sort_choice_box], outputs=[plot_acc_change])
        
def main():
    global df
    app = gr.Blocks(css=custom_css)
    with app:
        gr.Markdown(TITLE, elem_classes="markdown-title")
        with gr.Tabs(elem_classes="tab-buttons") as tabs:
            with gr.TabItem("👋 About", id=0):
                gr.Markdown(INTRO, elem_classes="markdown-text")
                gr.Code(BIBTEX, elem_classes="bibtex", label="BibTeX")
            with gr.TabItem("📑 User Guide", id=1):
                gr.Markdown("Guide to use this leaderboard", elem_classes="markdown-title")
                with gr.Accordion(label="0. Sections", open=True):
                    gr.Markdown("## Sections", elem_classes="markdown-text")
                    with gr.Row():
                        with gr.Column():
                            gr.Image("src/images/overview.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                        with gr.Column():
                            text = """
                            We divide the webpage into below sections:
                            1. Dataset Tabs
                            2. Query Section
                            3. Data Plotting
                            4. Data Table

                            More detailed functions are explained in the following sections.
                            """
                            gr.Markdown(text, elem_classes="markdown-text")
                with gr.Accordion(label="1. Dataset Tabs", open=False):
                    gr.Markdown("# Dataset Tabs", elem_classes="markdown-text")
                    with gr.Row():
                        gr.Image("src/images/cifar10-tab.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                        gr.Image("src/images/cifar100-tab.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                        gr.Image("src/images/imagenet-tab.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                    with gr.Row():
                        text = """
                        - Click the corresponding tabs to view the results of different datasets.
                        - We currently support three datasets: CIFAR-10, CIFAR-100, and ImageNet-1K.
                        - Results are 'isolated' for each dataset, i.e., the results of different datasets are not mixed together.
                        """
                        gr.Markdown(text, elem_classes="markdown-text")

                with gr.Accordion(label="2. Query Section", open=False):
                    gr.Markdown("## Query Section", elem_classes="markdown-text")
                    with gr.Row():
                        with gr.Column():
                            gr.Image("src/images/query-overview.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                        with gr.Column():
                            text = """
                            The query box includes two parts
                            -	<span style="color:red">red</span> box: query by paper attributes
                            -	<span style="color:blue">blue</span> box: query by experimental results 


                            Press [Enter] key to update.
                            -	update both plotting and table.
                            """
                            gr.Markdown(text, elem_classes="markdown-text")
                    with gr.Row():
                        with gr.Column():
                            gr.Image("src/images/use-case.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                        with gr.Column():
                            text = """
                            Example:
                            Here, we provide a use case and show how query works.

                            If a user wants to find methods that satisfy the followings:
                            1. Select Dataset: ImageNet-1K
                            2. Select Model: ResNet-50
                            3. Select Pruning Method: Regularization-based Pruning
                            4. Target 1: Accuracy after pruning > 75\%
                            5. Target 2: Pruned FLOPs > 40%
                            6. Target 3: Model size after pruning < 30M
                            
                            By entering the requirements to the corresponding query box, we can narrow down the results and compare the remaining ones.
                            """
                            gr.Markdown(text, elem_classes="markdown-text")

                with gr.Accordion(label="3. Data Plotting", open=False):
                    gr.Markdown("## Data Plotting", elem_classes="markdown-text")
                    with gr.Row():
                        with gr.Column():
                            gr.Image("src/images/plotting-overview.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                        with gr.Column():
                            text = """
                            The data plotting section can be split into two parts:
                            -	<span style="color:red">red</span> box: contains two radio buttons to select:
                                - (left) Group colors by ‘model’, ‘section’, or ‘year’.  
                                - (right) Change x-axis of the plots to ‘FLOPs drop (%)’ or ‘FLOPs after pruning (M)’.
                            -	<span style="color:blue">blue</span> box: interactive plots
                            """
                            gr.Markdown(text, elem_classes="markdown-text")

                    with gr.Row():
                        with gr.Column():
                            gr.Image("src/images/group-model.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                            text = """
                            Group by Model (default)
                            
                            X-axis: FLOPs drop (%) (default)
                            """
                            gr.Markdown(text, elem_classes="markdown-text")
                        with gr.Column():
                            gr.Image("src/images/group-section.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                            text = """
                            Group by Section
                            
                            X-axis: FLOPs drop (%) (default)
                            """
                            gr.Markdown(text, elem_classes="markdown-text")
                        with gr.Column():
                            gr.Image("src/images/group-year.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                            text = """
                            Group by Year

                            X-axis: FLOPs drop (%) (default)
                            """
                            gr.Markdown(text, elem_classes="markdown-text")
                        with gr.Column():
                            gr.Image("src/images/flops-pruned.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                            text = """
                            Group by Model (default)

                            X-axis: FLOPs after pruning (M)
                            """
                            gr.Markdown(text, elem_classes="markdown-text")

                    with gr.Row():
                        with gr.Column():
                            gr.Image("src/images/default.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                            text = """
                            Default Figure
                            """
                            gr.Markdown(text, elem_classes="markdown-text")
                        with gr.Column():
                            gr.Image("src/images/drag.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                            text = """
                            1.	Shift the graph by dragging. 
                            """
                            gr.Markdown(text, elem_classes="markdown-text")
                        with gr.Column():
                            gr.Image("src/images/zoom-out.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                            text = """
                            2.	Zoom-in/out by scrolling.
                            """
                            gr.Markdown(text, elem_classes="markdown-text")
                    with gr.Row():
                        with gr.Column():
                            gr.Image("src/images/hover.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                            text = """
                            3. Hover over the data point to see the details.
                            """
                            gr.Markdown(text, elem_classes="markdown-text")
                        with gr.Column():
                            gr.Image("src/images/legend-before.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                            text = """
                            4.	Click any legend to filter out others.
                            """
                            gr.Markdown(text, elem_classes="markdown-text")
                        with gr.Column():
                            gr.Image("src/images/legend-after.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                            text = """
                            4.	Click any legend to filter out others.
                            5.	Click white spaces/Double Click to restore to default scaling and legends.
                            """
                            gr.Markdown(text, elem_classes="markdown-text")

                with gr.Accordion(label="4. Data Table", open=False):
                    gr.Markdown("## Data Table", elem_classes="markdown-text")
                    with gr.Row():
                        with gr.Column():
                            with gr.Row():
                                gr.Image("src/images/drop-down-crop.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                                gr.Image("src/images/expand.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                        with gr.Column():
                            text = """
                            Click to the expand the table
                            -	The expanded table contains the baseline FLOPs and Parameters for each model.
                            """
                            gr.Markdown(text, elem_classes="markdown-text")
                    with gr.Row():
                        with gr.Column():
                            gr.Image("src/images/sort_btn.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                        with gr.Column():
                            text = """
                            Click the sort button:
                            -	Sort in ascending order.
                            -	click more than once to toggle ascending/descending. 
                            """
                            gr.Markdown(text, elem_classes="markdown-text")
                    with gr.Row():
                        with gr.Column():
                            gr.Image("src/images/detail.png", elem_classes="markdown-image", show_label=False, interactive=False, show_download_button=False)
                        with gr.Column():
                            text = """
                            Click any method name (highlighted in the <span style="color:red">red</span> box) to show details of the paper (<span style="color:blue">blue</span> box).

                            The details include:
                            -	detailed section
                            -	link of paper
                            -	venue of publication
                            -	released code (if any)
                            -	the BibTex used in our paper
                            """
                            gr.Markdown(text, elem_classes="markdown-text")

        with gr.Tabs(elem_classes="tab-buttons") as tabs:
            create_tab(app, "cifar10", 0, df)
            create_tab(app, "cifar100", 1, df)
            create_tab(app, "imagenet", 2, df)

    app.launch()

if __name__ == "__main__":
    main()