File size: 5,853 Bytes
308f73c
 
8c1a582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ab501f0
8c1a582
 
ab501f0
8c1a582
 
 
6fab635
 
 
8c1a582
 
 
6fab635
8c1a582
 
308f73c
 
 
 
6fab635
8c1a582
6fab635
8c1a582
 
 
 
6fab635
8c1a582
 
 
 
 
6fab635
 
 
 
 
8c1a582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9365321
 
 
8c1a582
 
 
 
 
9365321
 
 
aa32379
 
9365321
 
 
 
 
6fab635
9365321
 
 
 
 
 
 
6fab635
9365321
 
 
 
 
 
8c1a582
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6fab635
8c1a582
 
 
 
6fab635
 
 
 
8c1a582
 
 
 
 
 
 
 
 
 
213ad26
8c1a582
 
 
213ad26
8c1a582
 
 
 
 
 
 
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
import gradio as gr
import pandas as pd
from src.display.about import (
    CITATION_BUTTON_LABEL,
    CITATION_BUTTON_TEXT,
    EVALUATION_QUEUE_TEXT,
    INTRODUCTION_TEXT,
    LLM_BENCHMARKS_TEXT,
    FAQ_TEXT,
    TITLE,
)
from src.display.css_html_js import custom_css
from src.display.utils import (
    BENCHMARK_COLS,
    COLS,
    EVAL_COLS,
    EVAL_TYPES,
    NUMERIC_INTERVALS,
    TYPES,
    AutoEvalColumn,
    ModelType,
    fields,
    WeightType,
    Precision
)
from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, H4_TOKEN, IS_PUBLIC, QUEUE_REPO, REPO_ID, RESULTS_REPO
from PIL import Image
from dummydatagen import dummy_data_for_plot, create_metric_plot_obj_1, dummydf
import copy


def restart_space():
    API.restart_space(repo_id=REPO_ID, token=H4_TOKEN)

# Searching and filtering
gtbench_raw_data = dummydf()
methods = list(set(gtbench_raw_data['Method']))
metrics = ["Style-UA", "Style-IRA", "Style-CRA", "Object-UA", "Object-IRA", "Object-CRA", "FID", "Time (s)", "Storage (GB)", "Memory (GB)"]

def update_table(
    hidden_df: pd.DataFrame,
    columns_1: list,
    columns_2: list,
    columns_3: list,
    model1: list,
):

    filtered_df = select_columns(hidden_df, columns_1, columns_2, columns_3)

    filtered_df = filter_model1(filtered_df, model1)

    return filtered_df


def select_columns(df: pd.DataFrame, columns_1: list, columns_2: list,  columns_3: list) -> pd.DataFrame:
    always_here_cols = [
        "Method"
    ]
    # We use COLS to maintain sorting
    all_columns = metrics

    if (len(columns_1)+len(columns_2) + len(columns_3)) == 0:
        filtered_df = df[
            always_here_cols +
            [c for c in all_columns if c in df.columns]
        ]

    else:
        filtered_df = df[
            always_here_cols +
            [c for c in all_columns if c in df.columns and (c in columns_1 or c in columns_2 or c in columns_3 ) ]
        ]

    return filtered_df


def filter_model1(
    df: pd.DataFrame, model_query: list
) -> pd.DataFrame:
    # Show all models
    if len(model_query) == 0:
        return df
    filtered_df = df

    filtered_df = filtered_df[filtered_df["Model"].isin(
        model_query)]
    return filtered_df



demo = gr.Blocks(css=custom_css)


with demo:
    with gr.Row():
        gr.Image("./assets/logo.png", height="200px", width="200px", scale=0.1,
                 show_download_button=False, container=False)
        gr.HTML(TITLE, elem_id="title")

    gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
    with gr.Tabs(elem_classes="tab-buttons") as tabs:
        with gr.TabItem("πŸ… UnlearnCanvas Benchmark", elem_id="llm-benchmark-tab-table", id=0):
            with gr.Row():
                with gr.Column():
                    with gr.Row():
                        model1_column = gr.CheckboxGroup(
                        label="Unlearning Methods",
                        choices=methods,
                        interactive=True,
                        elem_id="filter-columns-type",
                    )
                        
                    with gr.Row():
                        shown_columns_1 = gr.CheckboxGroup(
                            choices=["Style-UA", "Style-IRA", "Style-CRA", "Object-UA", "Object-IRA", "Object-CRA"],
                            label="Style / Object  Unlearning Effectiveness",
                            elem_id="column-select",
                            interactive=True,
                        )
                        
                    with gr.Row():
                        shown_columns_2 = gr.CheckboxGroup(
                            choices=["FID"],
                            label="Image Quality",
                            elem_id="column-select",
                            interactive=True,
                        )
                    
                    with gr.Row():
                        shown_columns_3 = gr.CheckboxGroup(
                            choices=["Time (s)", "Memory (GB)", "Storage (GB)"],
                            label="Resource Costs",
                            elem_id="column-select",
                            interactive=True,
                        )
                    

            leaderboard_table = gr.components.Dataframe(
                value=gtbench_raw_data,
                elem_id="leaderboard-table",
                interactive=False,
                visible=True,
                # column_widths=["2%", "33%"]
            )

            game_bench_df_for_search = gr.components.Dataframe(
                value=gtbench_raw_data,
                elem_id="leaderboard-table",
                interactive=False,
                visible=False,
                # column_widths=["2%", "33%"]
            )


            for selector in [shown_columns_1,shown_columns_2, shown_columns_3, model1_column]:
                selector.change(
                    update_table,
                    [   
                        game_bench_df_for_search,
                        shown_columns_1,
                        shown_columns_2,
                        shown_columns_3,
                        model1_column, 
                    ],
                    leaderboard_table,
                    queue=True,
                )

        with gr.TabItem("πŸ“ About", elem_id="llm-benchmark-tab-table", id=2):
            gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="markdown-text")
            gr.Markdown(FAQ_TEXT, elem_classes="markdown-text")

    with gr.Row():
        with gr.Accordion("πŸ“™ Citation", open=True):
            citation_button = gr.Textbox(
                value=CITATION_BUTTON_TEXT,
                label=CITATION_BUTTON_LABEL,
                lines=8,
                elem_id="citation-button",
                show_copy_button=True,
            )


demo.launch()