Commit
β’
e8db64e
1
Parent(s):
992c10c
refine (#12)
Browse files- refine (c701b95aa79c69ed8410f715ac8ccc6a251da091)
Co-authored-by: Yimeng Zhang <DamonDemon@users.noreply.huggingface.co>
app.py
CHANGED
@@ -177,13 +177,154 @@ def select_columns(df: pd.DataFrame, columns_1: list) -> pd.DataFrame:
|
|
177 |
|
178 |
demo = gr.Blocks(css=custom_css)
|
179 |
with demo:
|
180 |
-
gr.
|
|
|
|
|
|
|
181 |
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
182 |
gr.Markdown(EVALUATION_QUEUE_TEXT,elem_classes="eval-text")
|
183 |
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="reference-text")
|
184 |
|
185 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
186 |
-
with gr.TabItem("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
with gr.Row():
|
188 |
with gr.Column():
|
189 |
with gr.Row():
|
@@ -202,29 +343,17 @@ with demo:
|
|
202 |
|
203 |
for i in range(len(files)):
|
204 |
if files[i] == "church":
|
205 |
-
name = "### [Unlearned
|
206 |
csv_path = './assets/'+files[i]+'.csv'
|
207 |
elif files[i] == 'garbage':
|
208 |
-
name = "### [Unlearned
|
209 |
csv_path = './assets/'+files[i]+'.csv'
|
210 |
elif files[i] == 'tench':
|
211 |
-
name = "### [Unlearned
|
212 |
csv_path = './assets/'+files[i]+'.csv'
|
213 |
elif files[i] == 'parachute':
|
214 |
-
name = "### [Unlearned
|
215 |
csv_path = './assets/'+files[i]+'.csv'
|
216 |
-
elif files[i] == 'vangogh':
|
217 |
-
name = "### [Unlearned Style] "+" Van Gogh"
|
218 |
-
csv_path = './assets/'+files[i]+'.csv'
|
219 |
-
elif files[i] == 'nudity':
|
220 |
-
name = "### Unlearned Concepts "+" Nudity"
|
221 |
-
csv_path = './assets/'+files[i]+'.csv'
|
222 |
-
# elif files[i] == 'violence':
|
223 |
-
# name = "### Unlearned Concepts "+" Violence"
|
224 |
-
# csv_path = './assets/'+files[i]+'.csv'
|
225 |
-
# elif files[i] == 'illegal_activity':
|
226 |
-
# name = "### Unlearned Concepts "+" Illgal Activity"
|
227 |
-
# csv_path = './assets/'+files[i]+'.csv'
|
228 |
|
229 |
|
230 |
gr.Markdown(name)
|
|
|
177 |
|
178 |
demo = gr.Blocks(css=custom_css)
|
179 |
with demo:
|
180 |
+
with gr.Row():
|
181 |
+
gr.Image("./assets/logo.png", height="175px", width="675px", scale=0.2,
|
182 |
+
show_download_button=False, container=False)
|
183 |
+
gr.HTML(TITLE, elem_id="title")
|
184 |
gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
|
185 |
gr.Markdown(EVALUATION_QUEUE_TEXT,elem_classes="eval-text")
|
186 |
gr.Markdown(LLM_BENCHMARKS_TEXT, elem_classes="reference-text")
|
187 |
|
188 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
189 |
+
with gr.TabItem("π NSFW", elem_id="UnlearnDiffAtk-benchmark-tab-table", id=0):
|
190 |
+
files = ['nudity']
|
191 |
+
with gr.Row():
|
192 |
+
with gr.Column():
|
193 |
+
with gr.Row():
|
194 |
+
search_bar = gr.Textbox(
|
195 |
+
placeholder=" π Search for your model (separate multiple queries with `;`) and press ENTER...",
|
196 |
+
show_label=False,
|
197 |
+
elem_id="search-bar",
|
198 |
+
)
|
199 |
+
with gr.Row():
|
200 |
+
model1_column = gr.CheckboxGroup(
|
201 |
+
label="Evaluation Metrics",
|
202 |
+
choices=['Pre-ASR','Post-ASR','FID','CLIP-Score'],
|
203 |
+
interactive=True,
|
204 |
+
elem_id="column-select",
|
205 |
+
)
|
206 |
+
|
207 |
+
for i in range(len(files)):
|
208 |
+
|
209 |
+
if files[i] == 'nudity':
|
210 |
+
name = "### [Unlearned Concept]: "+" Nudity"
|
211 |
+
csv_path = './assets/'+files[i]+'.csv'
|
212 |
+
# elif files[i] == 'violence':
|
213 |
+
# name = "### Unlearned Concepts "+" Violence"
|
214 |
+
# csv_path = './assets/'+files[i]+'.csv'
|
215 |
+
# elif files[i] == 'illegal_activity':
|
216 |
+
# name = "### Unlearned Concepts "+" Illgal Activity"
|
217 |
+
# csv_path = './assets/'+files[i]+'.csv'
|
218 |
+
|
219 |
+
|
220 |
+
gr.Markdown(name)
|
221 |
+
df_results = load_data(csv_path)
|
222 |
+
df_results_init = df_results.copy()[show_columns]
|
223 |
+
leaderboard_table = gr.components.Dataframe(
|
224 |
+
value = df_results,
|
225 |
+
datatype = TYPES,
|
226 |
+
elem_id = "leaderboard-table",
|
227 |
+
interactive = False,
|
228 |
+
visible=True,
|
229 |
+
)
|
230 |
+
|
231 |
+
|
232 |
+
hidden_leaderboard_table_for_search = gr.components.Dataframe(
|
233 |
+
value=df_results_init,
|
234 |
+
# value=df_results,
|
235 |
+
interactive=False,
|
236 |
+
visible=False,
|
237 |
+
)
|
238 |
+
|
239 |
+
search_bar.submit(
|
240 |
+
update_table,
|
241 |
+
[
|
242 |
+
|
243 |
+
hidden_leaderboard_table_for_search,
|
244 |
+
model1_column,
|
245 |
+
search_bar,
|
246 |
+
],
|
247 |
+
leaderboard_table,
|
248 |
+
)
|
249 |
+
|
250 |
+
for selector in [model1_column]:
|
251 |
+
selector.change(
|
252 |
+
update_table,
|
253 |
+
[
|
254 |
+
hidden_leaderboard_table_for_search,
|
255 |
+
model1_column,
|
256 |
+
search_bar,
|
257 |
+
],
|
258 |
+
leaderboard_table,
|
259 |
+
)
|
260 |
+
|
261 |
+
with gr.TabItem("π¨ Style", elem_id="Style", id=1):
|
262 |
+
files = ['vangogh']
|
263 |
+
with gr.Row():
|
264 |
+
with gr.Column():
|
265 |
+
with gr.Row():
|
266 |
+
search_bar = gr.Textbox(
|
267 |
+
placeholder=" π Search for your model (separate multiple queries with `;`) and press ENTER...",
|
268 |
+
show_label=False,
|
269 |
+
elem_id="search-bar",
|
270 |
+
)
|
271 |
+
with gr.Row():
|
272 |
+
model1_column = gr.CheckboxGroup(
|
273 |
+
label="Evaluation Metrics",
|
274 |
+
choices=['Pre-ASR','Post-ASR','FID','CLIP-Score'],
|
275 |
+
interactive=True,
|
276 |
+
elem_id="column-select",
|
277 |
+
)
|
278 |
+
|
279 |
+
for i in range(len(files)):
|
280 |
+
|
281 |
+
if files[i] == 'vangogh':
|
282 |
+
name = "### [Unlearned Style]: "+" Van Gogh"
|
283 |
+
csv_path = './assets/'+files[i]+'.csv'
|
284 |
+
|
285 |
+
gr.Markdown(name)
|
286 |
+
df_results = load_data(csv_path)
|
287 |
+
df_results_init = df_results.copy()[show_columns]
|
288 |
+
leaderboard_table = gr.components.Dataframe(
|
289 |
+
value = df_results,
|
290 |
+
datatype = TYPES,
|
291 |
+
elem_id = "leaderboard-table",
|
292 |
+
interactive = False,
|
293 |
+
visible=True,
|
294 |
+
)
|
295 |
+
|
296 |
+
|
297 |
+
hidden_leaderboard_table_for_search = gr.components.Dataframe(
|
298 |
+
value=df_results_init,
|
299 |
+
# value=df_results,
|
300 |
+
interactive=False,
|
301 |
+
visible=False,
|
302 |
+
)
|
303 |
+
|
304 |
+
search_bar.submit(
|
305 |
+
update_table,
|
306 |
+
[
|
307 |
+
|
308 |
+
hidden_leaderboard_table_for_search,
|
309 |
+
model1_column,
|
310 |
+
search_bar,
|
311 |
+
],
|
312 |
+
leaderboard_table,
|
313 |
+
)
|
314 |
+
|
315 |
+
for selector in [model1_column]:
|
316 |
+
selector.change(
|
317 |
+
update_table,
|
318 |
+
[
|
319 |
+
hidden_leaderboard_table_for_search,
|
320 |
+
model1_column,
|
321 |
+
search_bar,
|
322 |
+
],
|
323 |
+
leaderboard_table,
|
324 |
+
)
|
325 |
+
|
326 |
+
with gr.TabItem("πͺ Object", elem_id="UnlearnDiffAtk-benchmark-tab-table", id=2):
|
327 |
+
files = ['church','garbage','parachute','tench']
|
328 |
with gr.Row():
|
329 |
with gr.Column():
|
330 |
with gr.Row():
|
|
|
343 |
|
344 |
for i in range(len(files)):
|
345 |
if files[i] == "church":
|
346 |
+
name = "### [Unlearned Object]: "+" Church"
|
347 |
csv_path = './assets/'+files[i]+'.csv'
|
348 |
elif files[i] == 'garbage':
|
349 |
+
name = "### [Unlearned Object]: "+" Garbage"
|
350 |
csv_path = './assets/'+files[i]+'.csv'
|
351 |
elif files[i] == 'tench':
|
352 |
+
name = "### [Unlearned Object]: "+" Tench"
|
353 |
csv_path = './assets/'+files[i]+'.csv'
|
354 |
elif files[i] == 'parachute':
|
355 |
+
name = "### [Unlearned Object]: "+" Parachute"
|
356 |
csv_path = './assets/'+files[i]+'.csv'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
|
358 |
|
359 |
gr.Markdown(name)
|