File size: 3,406 Bytes
df32536
 
 
 
 
 
 
7036416
 
 
 
 
df32536
 
 
 
 
 
 
 
 
da544b6
df32536
 
 
bc0f422
df32536
 
 
bc0f422
df32536
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65684de
df32536
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65684de
df32536
 
 
 
 
 
 
bc0f422
df32536
 
bc0f422
df32536
 
7036416
 
 
bc0f422
df32536
 
 
 
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
import gradio as gr

from utils import *
from content import *

head_style = """
<style>
.main a {
    color: blue;
    text-decoration: underline;
}

@media (min-width: 1536px)
{
    .gradio-container {
        min-width: var(--size-full) !important;
    }
}
</style>
"""

with gr.Blocks(title=f'{benchname} Leaderboard', head=head_style) as demo:
    gr.Markdown(intro_md)

    with gr.Tabs(elem_classes='tab-buttons') as tabs:
        with gr.TabItem('πŸ… Main Leaderboard', elem_id='main', id=0):
            table, type_map = build_df()
            headers = [coln for coln in table.columns if not coln.startswith('_')]
            datatypes = [type_map[x] for x in headers]
            colwidths = [80, 400, 120, 130] + [155 for _ in headers[4:]]

            with gr.Row():
                model_name = gr.Textbox(
                    value=search_default_val,
                    label='Model Name',
                    interactive=True,
                    visible=True,
                )
                model_size = gr.CheckboxGroup(
                    choices=MODEL_SIZE,
                    value=MODEL_SIZE,
                    label='Model Size',
                    interactive=True,
                )
                model_type = gr.CheckboxGroup(
                    choices=MODEL_TYPE,
                    value=MODEL_TYPE,
                    label='Model Type',
                    interactive=True,
                )
            data_component = gr.components.DataFrame(
                value=table[headers],
                type='pandas',
                datatype=datatypes,
                interactive=False,
                wrap=True,
                visible=True,
                column_widths=colwidths,
            )

            def filter_df(model_name, model_size, model_type):
                df = table.copy(deep=True)
                df['_vis'] = [model_size_flag(x, model_size) for x in df['_parameters']]
                df['_vis'] &= pd.Series([model_type_flag(df.iloc[i], model_type) for i in range(len(df))])
                if model_name != search_default_val:
                    model_name_lower = model_name.lower()
                    df['_vis'] &= pd.Series([(model_name_lower in name.lower()) for name in df['_name'].tolist()])
                df = df[df['_vis']]

                df['Rank'] = list(range(1, len(df)+1))

                ret = gr.components.DataFrame(
                    value=df[headers],
                    type='pandas',
                    datatype=datatypes,
                    interactive=False,
                    wrap=True,
                    visible=True,
                    column_widths=colwidths,
                )
                return ret

            model_name.submit(filter_df, [model_name, model_size, model_type], data_component)
            model_size.change(filter_df, [model_name, model_size, model_type], data_component)
            model_type.change(filter_df, [model_name, model_size, model_type], data_component)

        with gr.TabItem('πŸ“ About', elem_id='about', id=1):
            gr.Markdown(about_md)

        with gr.TabItem('πŸš€ Submit your model', elem_id='submit', id=2):
            gr.Markdown(submit_md)

    # with gr.Row():
    #     with gr.Accordion('Citation', open=False):
    #         gr.Markdown(citation_md)
    gr.Markdown(Bottom_logo)


if __name__=="__main__":
    demo.launch()