xinchen9 commited on
Commit
e1c712c
β€’
1 Parent(s): b979c01

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +313 -313
app.py CHANGED
@@ -1,314 +1,314 @@
1
- import subprocess
2
- import gradio as gr
3
- import pandas as pd
4
- from apscheduler.schedulers.background import BackgroundScheduler
5
- from huggingface_hub import snapshot_download
6
-
7
- from src.about import (
8
- CITATION_BUTTON_LABEL,
9
- CITATION_BUTTON_TEXT,
10
- EVALUATION_QUEUE_TEXT,
11
- INTRODUCTION_TEXT,
12
- LLM_BENCHMARKS_TEXT,
13
- TITLE,
14
- )
15
- from src.display.css_html_js import custom_css
16
- from src.display.utils import (
17
- BENCHMARK_COLS,
18
- COLS,
19
- EVAL_COLS,
20
- EVAL_TYPES,
21
- NUMERIC_INTERVALS,
22
- TYPES,
23
- AutoEvalColumn,
24
- ModelType,
25
- fields,
26
- WeightType,
27
- Precision
28
- )
29
- from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REPO_ID, RESULTS_REPO, TOKEN
30
- # from src.populate import get_evaluation_queue_df, get_leaderboard_df
31
- # from src.submission.submit import add_new_eval
32
- from PIL import Image
33
- from dummydatagen import dummy_data_for_plot, create_metric_plot_obj_1, dummydf
34
- import copy
35
-
36
- def load_data(data_path):
37
- columns = ['Unlearned_Methods','Source', 'Diffusion_Models','Pre-ASR', 'Post-ASR','Pre-FID', 'Post-FID']
38
- columns_sorted = ['Unlearned_Methods','Source', 'Diffusion_Models','Pre-ASR','Post-ASR','Pre-FID','Post-FID']
39
-
40
- df = pd.read_csv(data_path).dropna()
41
- df['Post-ASR'] = df['Post-ASR'].round(0)
42
-
43
- # rank according to the Score column
44
- df = df.sort_values(by='Post-ASR', ascending=False)
45
- # reorder the columns
46
- df = df[columns_sorted]
47
-
48
-
49
- return df
50
-
51
- def restart_space():
52
- API.restart_space(repo_id=REPO_ID)
53
-
54
- # try:
55
- # print(EVAL_REQUESTS_PATH)
56
- # snapshot_download(
57
- # repo_id=QUEUE_REPO, local_dir=EVAL_REQUESTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30, token=TOKEN
58
- # )
59
- # except Exception:
60
- # restart_space()
61
- # try:
62
- # print(EVAL_RESULTS_PATH)
63
- # snapshot_download(
64
- # repo_id=RESULTS_REPO, local_dir=EVAL_RESULTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30, token=TOKEN
65
- # )
66
- # except Exception:
67
- # restart_space()
68
-
69
-
70
- # raw_data, original_df = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
71
- # leaderboard_df = original_df.copy()
72
-
73
- # (
74
- # finished_eval_queue_df,
75
- # running_eval_queue_df,
76
- # pending_eval_queue_df,
77
- # ) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
78
-
79
- all_columns = ['Unlearned_Methods','Source', 'Diffusion_Models','Pre-ASR','Pre-ASR','Post-FID']
80
- show_columns = ['Unlearned_Methods','Source', 'Diffusion_Models','Pre-ASR','Pre-ASR','Post-FID']
81
- TYPES = ['str', 'markdown', 'str', 'number', 'number', 'number', 'number']
82
- files = ['church','garbage','parachute','tench', 'vangogh', 'nudity', 'violence','illegal_activity']
83
- csv_path='./assets/'+files[0]+'.csv'
84
- df_results = load_data(csv_path)
85
- methods = list(set(df_results['Unlearned_Methods']))
86
- df_results_init = df_results.copy()[show_columns]
87
-
88
- def update_table(
89
- hidden_df: pd.DataFrame,
90
- model1_column: list,
91
- #type_query: list,
92
- #open_query: list,
93
- # precision_query: str,
94
- # size_query: list,
95
- # show_deleted: bool,
96
- query: str,
97
- ):
98
- # filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, show_deleted)
99
- # filtered_df = filter_queries(query, filtered_df)
100
- # df = select_columns(filtered_df, columns)
101
- filtered_df = hidden_df.copy()
102
- # print(open_query)
103
-
104
- # filtered_df = filtered_df[filtered_df['Unlearned_Methods'].isin(open_query)]
105
- # map_open = {'open': 'Yes', 'closed': 'No'}
106
- # filtered_df = filtered_df[filtered_df['Open?'].isin([map_open[o] for o in open_query])]
107
- filtered_df=select_columns(filtered_df,model1_column)
108
- filtered_df = filter_queries(query, filtered_df)
109
- # map_open = {'SD V1.4', 'SD V1.5', 'SD V2.0'}
110
- # filtered_df = filtered_df[filtered_df["Diffusion_Models"].isin([o for o in open_query])]
111
- # filtered_df = filtered_df[[map_columns[k] for k in columns]]
112
- # deduplication
113
- # df = df.drop_duplicates(subset=["Model"])
114
- df = filtered_df.drop_duplicates()
115
- # df = df[show_columns]
116
- return df
117
-
118
-
119
- def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
120
- return df[(df['Unlearned_Methods'].str.contains(query, case=False))]
121
-
122
-
123
- def filter_queries(query: str, filtered_df: pd.DataFrame) -> pd.DataFrame:
124
- final_df = []
125
- if query != "":
126
- queries = [q.strip() for q in query.split(";")]
127
- for _q in queries:
128
- _q = _q.strip()
129
- if _q != "":
130
- temp_filtered_df = search_table(filtered_df, _q)
131
- if len(temp_filtered_df) > 0:
132
- final_df.append(temp_filtered_df)
133
- if len(final_df) > 0:
134
- filtered_df = pd.concat(final_df)
135
-
136
- return filtered_df
137
-
138
- def search_table_model(df: pd.DataFrame, query: str) -> pd.DataFrame:
139
- return df[(df['Diffusion_Models'].str.contains(query, case=False))]
140
-
141
-
142
- def filter_queries_model(query: str, filtered_df: pd.DataFrame) -> pd.DataFrame:
143
- final_df = []
144
- # if query != "":
145
- # queries = [q.strip() for q in query.split(";")]
146
- for _q in query:
147
- print(_q)
148
- if _q != "":
149
- temp_filtered_df = search_table_model(filtered_df, _q)
150
- if len(temp_filtered_df) > 0:
151
- final_df.append(temp_filtered_df)
152
- if len(final_df) > 0:
153
- filtered_df = pd.concat(final_df)
154
-
155
- return filtered_df
156
-
157
- def select_columns(df: pd.DataFrame, columns_1: list) -> pd.DataFrame:
158
- always_here_cols = ['Unlearned_Methods','Source', 'Diffusion_Models']
159
-
160
- # We use COLS to maintain sorting
161
- all_columns =['Pre-ASR','Post-ASR','PreFID','Post-FID']
162
-
163
- if (len(columns_1)) == 0:
164
- filtered_df = df[
165
- always_here_cols +
166
- [c for c in all_columns if c in df.columns]
167
- ]
168
-
169
- else:
170
- filtered_df = df[
171
- always_here_cols +
172
- [c for c in all_columns if c in df.columns and (c in columns_1) ]
173
- ]
174
-
175
- return filtered_df
176
-
177
-
178
- demo = gr.Blocks(css=custom_css)
179
- with demo:
180
- gr.HTML(TITLE)
181
- gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
182
- gr.Markdown(EVALUATION_QUEUE_TEXT,elem_classes="eval-text")
183
-
184
- with gr.Tabs(elem_classes="tab-buttons") as tabs:
185
- with gr.TabItem("UnlearnDiffAtk Benchmark", elem_id="UnlearnDiffAtk-benchmark-tab-table", id=0):
186
- with gr.Row():
187
- with gr.Column():
188
- with gr.Row():
189
- search_bar = gr.Textbox(
190
- placeholder=" πŸ” Search for your model (separate multiple queries with `;`) and press ENTER...",
191
- show_label=False,
192
- elem_id="search-bar",
193
- )
194
- with gr.Row():
195
- model1_column = gr.CheckboxGroup(
196
- label="Evaluation Metrics",
197
- choices=['Pre-ASR', 'Post-ASR','Pre-FID','Post-FID'],
198
- interactive=True,
199
- elem_id="column-select",
200
- )
201
-
202
- # with gr.Column(min_width=320):
203
- # with gr.Row():
204
- # shown_columns_1 = gr.CheckboxGroup(
205
- # choices=["Church","Parachute","Tench", "Garbage Truck"],
206
- # label="Undersirable Objects",
207
- # elem_id="column-object",
208
- # interactive=True,
209
- # )
210
- # with gr.Row():
211
- # shown_columns_2 = gr.CheckboxGroup(
212
- # choices=["Van Gogh"],
213
- # label="Undersirable Styles",
214
- # elem_id="column-style",
215
- # interactive=True,
216
- # )
217
- # with gr.Row():
218
- # shown_columns_3 = gr.CheckboxGroup(
219
- # choices=["Violence","Illegal Activity","Nudity"],
220
- # label="Undersirable Concepts (Outputs that may be offensive in nature)",
221
- # elem_id="column-select",
222
- # interactive=True,
223
- # )
224
- # with gr.Row():
225
- # shown_columns_4 = gr.Slider(
226
- # 1, 100, value=40,
227
- # step=1, label="Attacking Steps", info="Choose between 1 and 100",
228
- # interactive=True,)
229
- for i in range(len(files)):
230
- if files[i] == "church":
231
- name = "### Unlearned Objects "+" Church"
232
- csv_path = './assets/'+files[i]+'.csv'
233
- elif files[i] == 'garbage':
234
- name = "### Unlearned Objects "+" Garbage"
235
- csv_path = './assets/'+files[i]+'.csv'
236
- elif files[i] == 'tench':
237
- name = "### Unlearned Objects "+" Tench"
238
- csv_path = './assets/'+files[i]+'.csv'
239
- elif files[i] == 'parachute':
240
- name = "### Unlearned Objects "+" Parachute"
241
- csv_path = './assets/'+files[i]+'.csv'
242
- elif files[i] == 'vangogh':
243
- name = "### Unlearned Stype "+" Van Gogh"
244
- csv_path = './assets/'+files[i]+'.csv'
245
- elif files[i] == 'nudity':
246
- name = "### Unlearned Concepts "+" Nudity"
247
- csv_path = './assets/'+files[i]+'.csv'
248
- elif files[i] == 'violence':
249
- name = "### Unlearned Concepts "+" Violence"
250
- csv_path = './assets/'+files[i]+'.csv'
251
- elif files[i] == 'illegal_activity':
252
- name = "### Unlearned Concepts "+" Illgal Activity"
253
- csv_path = './assets/'+files[i]+'.csv'
254
-
255
-
256
- gr.Markdown(name)
257
- df_results = load_data(csv_path)
258
- df_results_init = df_results.copy()[show_columns]
259
- leaderboard_table = gr.components.Dataframe(
260
- value = df_results,
261
- datatype = TYPES,
262
- elem_id = "leaderboard-table",
263
- interactive = False,
264
- visible=True,
265
- )
266
-
267
-
268
- hidden_leaderboard_table_for_search = gr.components.Dataframe(
269
- value=df_results_init,
270
- interactive=False,
271
- visible=False,
272
- )
273
-
274
- search_bar.submit(
275
- update_table,
276
- [
277
-
278
- hidden_leaderboard_table_for_search,
279
- model1_column,
280
- search_bar,
281
- ],
282
- leaderboard_table,
283
- )
284
-
285
- for selector in [model1_column]:
286
- selector.change(
287
- update_table,
288
- [
289
- hidden_leaderboard_table_for_search,
290
- model1_column,
291
- search_bar,
292
- ],
293
- leaderboard_table,
294
- )
295
-
296
-
297
-
298
-
299
-
300
-
301
- with gr.Row():
302
- with gr.Accordion("πŸ“™ Citation", open=True):
303
- citation_button = gr.Textbox(
304
- value=CITATION_BUTTON_TEXT,
305
- label=CITATION_BUTTON_LABEL,
306
- lines=10,
307
- elem_id="citation-button",
308
- show_copy_button=True,
309
- )
310
-
311
- scheduler = BackgroundScheduler()
312
- scheduler.add_job(restart_space, "interval", seconds=1800)
313
- scheduler.start()
314
  demo.queue().launch(share=True)
 
1
+ import subprocess
2
+ import gradio as gr
3
+ import pandas as pd
4
+ from apscheduler.schedulers.background import BackgroundScheduler
5
+ from huggingface_hub import snapshot_download
6
+
7
+ from src.about import (
8
+ CITATION_BUTTON_LABEL,
9
+ CITATION_BUTTON_TEXT,
10
+ EVALUATION_QUEUE_TEXT,
11
+ INTRODUCTION_TEXT,
12
+ LLM_BENCHMARKS_TEXT,
13
+ TITLE,
14
+ )
15
+ from src.display.css_html_js import custom_css
16
+ from src.display.utils import (
17
+ BENCHMARK_COLS,
18
+ COLS,
19
+ EVAL_COLS,
20
+ EVAL_TYPES,
21
+ NUMERIC_INTERVALS,
22
+ TYPES,
23
+ AutoEvalColumn,
24
+ ModelType,
25
+ fields,
26
+ WeightType,
27
+ Precision
28
+ )
29
+ from src.envs import API, EVAL_REQUESTS_PATH, EVAL_RESULTS_PATH, QUEUE_REPO, REPO_ID, RESULTS_REPO, TOKEN
30
+ # from src.populate import get_evaluation_queue_df, get_leaderboard_df
31
+ # from src.submission.submit import add_new_eval
32
+ # from PIL import Image
33
+ # from dummydatagen import dummy_data_for_plot, create_metric_plot_obj_1, dummydf
34
+ # import copy
35
+
36
+ def load_data(data_path):
37
+ columns = ['Unlearned_Methods','Pre-ASR', 'Post-ASR','FID', 'Clip-Score']
38
+ columns_sorted = [Unlearned_Methods','Pre-ASR', 'Post-ASR','FID', 'Clip-Score']
39
+
40
+ df = pd.read_csv(data_path).dropna()
41
+ df['Post-ASR'] = df['Post-ASR'].round(0)
42
+
43
+ # rank according to the Score column
44
+ df = df.sort_values(by='Post-ASR', ascending=False)
45
+ # reorder the columns
46
+ df = df[columns_sorted]
47
+
48
+
49
+ return df
50
+
51
+ def restart_space():
52
+ API.restart_space(repo_id=REPO_ID)
53
+
54
+ # try:
55
+ # print(EVAL_REQUESTS_PATH)
56
+ # snapshot_download(
57
+ # repo_id=QUEUE_REPO, local_dir=EVAL_REQUESTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30, token=TOKEN
58
+ # )
59
+ # except Exception:
60
+ # restart_space()
61
+ # try:
62
+ # print(EVAL_RESULTS_PATH)
63
+ # snapshot_download(
64
+ # repo_id=RESULTS_REPO, local_dir=EVAL_RESULTS_PATH, repo_type="dataset", tqdm_class=None, etag_timeout=30, token=TOKEN
65
+ # )
66
+ # except Exception:
67
+ # restart_space()
68
+
69
+
70
+ # raw_data, original_df = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
71
+ # leaderboard_df = original_df.copy()
72
+
73
+ # (
74
+ # finished_eval_queue_df,
75
+ # running_eval_queue_df,
76
+ # pending_eval_queue_df,
77
+ # ) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
78
+
79
+ all_columns = ['Unlearned_Methods','Source', 'Diffusion_Models','Pre-ASR','Pre-ASR','Post-FID']
80
+ show_columns = ['Unlearned_Methods','Source', 'Diffusion_Models','Pre-ASR','Pre-ASR','Post-FID']
81
+ TYPES = ['str', 'markdown', 'str', 'number', 'number', 'number', 'number']
82
+ files = ['vangogh', 'nudity','church','garbage','parachute','tench', 'vangogh']
83
+ csv_path='./assets/'+files[0]+'.csv'
84
+ df_results = load_data(csv_path)
85
+ methods = list(set(df_results['Unlearned_Methods']))
86
+ df_results_init = df_results.copy()[show_columns]
87
+
88
+ def update_table(
89
+ hidden_df: pd.DataFrame,
90
+ model1_column: list,
91
+ #type_query: list,
92
+ #open_query: list,
93
+ # precision_query: str,
94
+ # size_query: list,
95
+ # show_deleted: bool,
96
+ query: str,
97
+ ):
98
+ # filtered_df = filter_models(hidden_df, type_query, size_query, precision_query, show_deleted)
99
+ # filtered_df = filter_queries(query, filtered_df)
100
+ # df = select_columns(filtered_df, columns)
101
+ filtered_df = hidden_df.copy()
102
+ # print(open_query)
103
+
104
+ # filtered_df = filtered_df[filtered_df['Unlearned_Methods'].isin(open_query)]
105
+ # map_open = {'open': 'Yes', 'closed': 'No'}
106
+ # filtered_df = filtered_df[filtered_df['Open?'].isin([map_open[o] for o in open_query])]
107
+ filtered_df=select_columns(filtered_df,model1_column)
108
+ filtered_df = filter_queries(query, filtered_df)
109
+ # map_open = {'SD V1.4', 'SD V1.5', 'SD V2.0'}
110
+ # filtered_df = filtered_df[filtered_df["Diffusion_Models"].isin([o for o in open_query])]
111
+ # filtered_df = filtered_df[[map_columns[k] for k in columns]]
112
+ # deduplication
113
+ # df = df.drop_duplicates(subset=["Model"])
114
+ df = filtered_df.drop_duplicates()
115
+ # df = df[show_columns]
116
+ return df
117
+
118
+
119
+ def search_table(df: pd.DataFrame, query: str) -> pd.DataFrame:
120
+ return df[(df['Unlearned_Methods'].str.contains(query, case=False))]
121
+
122
+
123
+ def filter_queries(query: str, filtered_df: pd.DataFrame) -> pd.DataFrame:
124
+ final_df = []
125
+ if query != "":
126
+ queries = [q.strip() for q in query.split(";")]
127
+ for _q in queries:
128
+ _q = _q.strip()
129
+ if _q != "":
130
+ temp_filtered_df = search_table(filtered_df, _q)
131
+ if len(temp_filtered_df) > 0:
132
+ final_df.append(temp_filtered_df)
133
+ if len(final_df) > 0:
134
+ filtered_df = pd.concat(final_df)
135
+
136
+ return filtered_df
137
+
138
+ def search_table_model(df: pd.DataFrame, query: str) -> pd.DataFrame:
139
+ return df[(df['Diffusion_Models'].str.contains(query, case=False))]
140
+
141
+
142
+ def filter_queries_model(query: str, filtered_df: pd.DataFrame) -> pd.DataFrame:
143
+ final_df = []
144
+ # if query != "":
145
+ # queries = [q.strip() for q in query.split(";")]
146
+ for _q in query:
147
+ print(_q)
148
+ if _q != "":
149
+ temp_filtered_df = search_table_model(filtered_df, _q)
150
+ if len(temp_filtered_df) > 0:
151
+ final_df.append(temp_filtered_df)
152
+ if len(final_df) > 0:
153
+ filtered_df = pd.concat(final_df)
154
+
155
+ return filtered_df
156
+
157
+ def select_columns(df: pd.DataFrame, columns_1: list) -> pd.DataFrame:
158
+ always_here_cols = ['Unlearned_Methods']
159
+
160
+ # We use COLS to maintain sorting
161
+ all_columns =['Pre-ASR','Post-ASR','FID','Clip-Score']
162
+
163
+ if (len(columns_1)) == 0:
164
+ filtered_df = df[
165
+ always_here_cols +
166
+ [c for c in all_columns if c in df.columns]
167
+ ]
168
+
169
+ else:
170
+ filtered_df = df[
171
+ always_here_cols +
172
+ [c for c in all_columns if c in df.columns and (c in columns_1) ]
173
+ ]
174
+
175
+ return filtered_df
176
+
177
+
178
+ demo = gr.Blocks(css=custom_css)
179
+ with demo:
180
+ gr.HTML(TITLE)
181
+ gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
182
+ gr.Markdown(EVALUATION_QUEUE_TEXT,elem_classes="eval-text")
183
+
184
+ with gr.Tabs(elem_classes="tab-buttons") as tabs:
185
+ with gr.TabItem("UnlearnDiffAtk Benchmark", elem_id="UnlearnDiffAtk-benchmark-tab-table", id=0):
186
+ with gr.Row():
187
+ with gr.Column():
188
+ with gr.Row():
189
+ search_bar = gr.Textbox(
190
+ placeholder=" πŸ” Search for your model (separate multiple queries with `;`) and press ENTER...",
191
+ show_label=False,
192
+ elem_id="search-bar",
193
+ )
194
+ with gr.Row():
195
+ model1_column = gr.CheckboxGroup(
196
+ label="Evaluation Metrics",
197
+ choices=['Pre-ASR', 'Post-ASR','FID','Clip-score'],
198
+ interactive=True,
199
+ elem_id="column-select",
200
+ )
201
+
202
+ # with gr.Column(min_width=320):
203
+ # with gr.Row():
204
+ # shown_columns_1 = gr.CheckboxGroup(
205
+ # choices=["Church","Parachute","Tench", "Garbage Truck"],
206
+ # label="Undersirable Objects",
207
+ # elem_id="column-object",
208
+ # interactive=True,
209
+ # )
210
+ # with gr.Row():
211
+ # shown_columns_2 = gr.CheckboxGroup(
212
+ # choices=["Van Gogh"],
213
+ # label="Undersirable Styles",
214
+ # elem_id="column-style",
215
+ # interactive=True,
216
+ # )
217
+ # with gr.Row():
218
+ # shown_columns_3 = gr.CheckboxGroup(
219
+ # choices=["Violence","Illegal Activity","Nudity"],
220
+ # label="Undersirable Concepts (Outputs that may be offensive in nature)",
221
+ # elem_id="column-select",
222
+ # interactive=True,
223
+ # )
224
+ # with gr.Row():
225
+ # shown_columns_4 = gr.Slider(
226
+ # 1, 100, value=40,
227
+ # step=1, label="Attacking Steps", info="Choose between 1 and 100",
228
+ # interactive=True,)
229
+ for i in range(len(files)):
230
+ if files[i] == "church":
231
+ name = "### [Unlearned Objects] "+" Church"
232
+ csv_path = './assets/'+files[i]+'.csv'
233
+ elif files[i] == 'garbage':
234
+ name = "### [Unlearned Objects] "+" Garbage"
235
+ csv_path = './assets/'+files[i]+'.csv'
236
+ elif files[i] == 'tench':
237
+ name = "### [Unlearned Objects] "+" Tench"
238
+ csv_path = './assets/'+files[i]+'.csv'
239
+ elif files[i] == 'parachute':
240
+ name = "### [Unlearned Objects] "+" Parachute"
241
+ csv_path = './assets/'+files[i]+'.csv'
242
+ elif files[i] == 'vangogh':
243
+ name = "### [Unlearned Style] "+" Van Gogh"
244
+ csv_path = './assets/'+files[i]+'.csv'
245
+ elif files[i] == 'nudity':
246
+ name = "### Unlearned Concepts "+" Nudity"
247
+ csv_path = './assets/'+files[i]+'.csv'
248
+ # elif files[i] == 'violence':
249
+ # name = "### Unlearned Concepts "+" Violence"
250
+ # csv_path = './assets/'+files[i]+'.csv'
251
+ # elif files[i] == 'illegal_activity':
252
+ # name = "### Unlearned Concepts "+" Illgal Activity"
253
+ # csv_path = './assets/'+files[i]+'.csv'
254
+
255
+
256
+ gr.Markdown(name)
257
+ df_results = load_data(csv_path)
258
+ df_results_init = df_results.copy()[show_columns]
259
+ leaderboard_table = gr.components.Dataframe(
260
+ value = df_results,
261
+ datatype = TYPES,
262
+ elem_id = "leaderboard-table",
263
+ interactive = False,
264
+ visible=True,
265
+ )
266
+
267
+
268
+ hidden_leaderboard_table_for_search = gr.components.Dataframe(
269
+ value=df_results_init,
270
+ interactive=False,
271
+ visible=False,
272
+ )
273
+
274
+ search_bar.submit(
275
+ update_table,
276
+ [
277
+
278
+ hidden_leaderboard_table_for_search,
279
+ model1_column,
280
+ search_bar,
281
+ ],
282
+ leaderboard_table,
283
+ )
284
+
285
+ for selector in [model1_column]:
286
+ selector.change(
287
+ update_table,
288
+ [
289
+ hidden_leaderboard_table_for_search,
290
+ model1_column,
291
+ search_bar,
292
+ ],
293
+ leaderboard_table,
294
+ )
295
+
296
+
297
+
298
+
299
+
300
+
301
+ with gr.Row():
302
+ with gr.Accordion("πŸ“™ Citation", open=True):
303
+ citation_button = gr.Textbox(
304
+ value=CITATION_BUTTON_TEXT,
305
+ label=CITATION_BUTTON_LABEL,
306
+ lines=10,
307
+ elem_id="citation-button",
308
+ show_copy_button=True,
309
+ )
310
+
311
+ scheduler = BackgroundScheduler()
312
+ scheduler.add_job(restart_space, "interval", seconds=1800)
313
+ scheduler.start()
314
  demo.queue().launch(share=True)