File size: 3,408 Bytes
6c61a43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Adapted from the SEED-Bench Leaderboard by AILab-CVC
Source: https://huggingface.co/spaces/AILab-CVC/SEED-Bench_Leaderboard
"""

import gradio as gr
import pandas as pd
from constants import *
global data_component, filter_component

def upload_file(files):
    file_paths = [file.name for file in files]
    return file_paths

def get_baseline_df():
    df = pd.read_csv(CSV_DIR)
    df = df.sort_values(by=DEFAULT_SPLIT, ascending=False)
    present_columns = MODEL_INFO + [DEFAULT_SPLIT]
    df = df[present_columns]
    # print(df)
    return df

def get_all_df():
    df = pd.read_csv(CSV_DIR)
    df = df.sort_values(by=DEFAULT_SPLIT, ascending=False)
    # print(df)
    return df

block = gr.Blocks()


with block:
    gr.Markdown(
        LEADERBORAD_INTRODUCTION
    )
    with gr.Tabs(elem_classes="tab-buttons") as tabs:
        with gr.TabItem("🏅 EgoPlan Benchmark", elem_id="evalcrafter-benchmark-tab-table", id=0):
    
            gr.Markdown(
                TABLE_INTRODUCTION
            )

            dropdown_value = gr.inputs.Dropdown(
                choices=SPLIT_INFO,
                default=DEFAULT_SPLIT
            )

            # pdb.set_trace()
            data_component = gr.components.Dataframe(
                value=get_baseline_df, 
                headers=COLUMN_NAMES,
                type="pandas", 
                datatype=DATA_TITILE_TYPE,
                interactive=False,
                visible=True,
                )

            def on_dropdown_value_change(selected_split):
                # pdb.set_trace()
                present_columns = MODEL_INFO + [selected_split]
                updated_data = get_all_df()[present_columns].dropna()
                updated_data = updated_data.sort_values(by=present_columns[-1], ascending=False)
                updated_headers = present_columns
                update_datatype = [DATA_TITILE_TYPE[COLUMN_NAMES.index(x)] for x in updated_headers]

                # pdb.set_trace()
                filter_component = gr.components.Dataframe(
                    value=updated_data,
                    headers=updated_headers,
                    type="pandas",
                    datatype=update_datatype,
                    interactive=False,
                    visible=True,
                    )
                # pdb.set_trace()
                return filter_component.value

            dropdown_value.change(fn=on_dropdown_value_change, inputs=dropdown_value, outputs=data_component)
    
        # table 2
        with gr.TabItem("📝 About", elem_id="egoplan-benchmark-tab-table", id=2):
            gr.Markdown(LEADERBORAD_INFO, elem_classes="markdown-text")
    

    with gr.Row():
        data_run = gr.Button("Refresh")
        data_run.click(
            get_baseline_df, outputs=data_component
        )

    gr.Markdown(r"""
        Please cite this paper if you find it useful ♥️:

        ```bibtex
        @article{chen2023egoplan,
          title={EgoPlan-Bench: Benchmarking Multimodal Large Language Models for Human-Level Planning},
          author={Chen, Yi and Ge, Yuying and Ge, Yixiao and Ding, Mingyu and Li, Bohao and Wang, Rui and Xu, Ruifeng and Shan, Ying and Liu, Xihui},
          journal={arXiv preprint arXiv:2312.06722},
          year={2023}
        }
        ```
        """)
    # block.load(get_baseline_df, outputs=data_title)

block.launch(share=False)