Spaces:
Runtime error
Runtime error
Kieran Fraser
commited on
Commit
·
b47d208
1
Parent(s):
1985d41
Added default images and descriptions
Browse filesSigned-off-by: Kieran Fraser <[email protected]>
- app.py +24 -4
- data/.DS_Store +0 -0
- data/default/clean/0_fish.png +0 -0
- data/default/clean/1_fish.png +0 -0
- data/default/clean/2_fish.png +0 -0
- data/default/clean/3_fish.png +0 -0
- data/default/clean/4_fish.png +0 -0
- data/default/clean/5_fish.png +0 -0
- data/default/clean/6_fish.png +0 -0
- data/default/clean/7_fish.png +0 -0
- data/default/poisoned/0_fish.png +0 -0
- data/default/poisoned/1_fish.png +0 -0
- data/default/poisoned/2_fish.png +0 -0
- data/default/poisoned/3_fish.png +0 -0
- data/default/poisoned/4_fish.png +0 -0
- data/default/poisoned/5_fish.png +0 -0
- data/default/poisoned/6_fish.png +0 -0
- data/default/poisoned/7_fish.png +0 -0
app.py
CHANGED
@@ -59,6 +59,26 @@ model = transformers.AutoModelForImageClassification.from_pretrained(
|
|
59 |
num_labels=10
|
60 |
)
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
def sample_imagenette():
|
63 |
import torchvision
|
64 |
label_names = [
|
@@ -311,8 +331,8 @@ with gr.Blocks(css=css, theme='Tshackelton/IBMPlex-DenseReadable') as demo:
|
|
311 |
'parachutte',], value='church')
|
312 |
eval_btn_patch = gr.Button("Evaluate ✨", elem_classes="eval-bt")
|
313 |
with gr.Column(scale=10):
|
314 |
-
clean_gallery = gr.Gallery(label="Clean", preview=False, show_download_button=True, height=600)
|
315 |
-
clean_accuracy = gr.Number(label="Clean Accuracy", precision=2)
|
316 |
with gr.Column(scale=1, min_width=0, elem_classes='symbols'):
|
317 |
gr.Markdown('''➕''')
|
318 |
with gr.Column(scale=3, elem_classes='symbols'):
|
@@ -320,8 +340,8 @@ with gr.Blocks(css=css, theme='Tshackelton/IBMPlex-DenseReadable') as demo:
|
|
320 |
with gr.Column(scale=1, min_width=0):
|
321 |
gr.Markdown('''🟰''', elem_classes='symbols')
|
322 |
with gr.Column(scale=10):
|
323 |
-
poison_gallery = gr.Gallery(label="Poisoned", preview=False, show_download_button=True, height=600)
|
324 |
-
poison_success = gr.Number(label="Poison Success", precision=2)
|
325 |
|
326 |
eval_btn_patch.click(clf_poison_evaluate, inputs=[attack, trigger_image, target_class],
|
327 |
outputs=[clean_gallery, poison_gallery, clean_accuracy, poison_success])
|
|
|
59 |
num_labels=10
|
60 |
)
|
61 |
|
62 |
+
def default_clean():
|
63 |
+
return [('./data/default/clean/0_fish.png', 'fish'),
|
64 |
+
('./data/default/clean/1_fish.png', 'fish'),
|
65 |
+
('./data/default/clean/2_fish.png', 'church'),
|
66 |
+
('./data/default/clean/3_fish.png', 'fish'),
|
67 |
+
('./data/default/clean/4_fish.png', 'church'),
|
68 |
+
('./data/default/clean/5_fish.png', 'fish'),
|
69 |
+
('./data/default/clean/6_fish.png', 'fish'),
|
70 |
+
('./data/default/clean/7_fish.png', 'fish')]
|
71 |
+
|
72 |
+
def default_poisoned():
|
73 |
+
return [('./data/default/poisoned/0_fish.png', 'church'),
|
74 |
+
('./data/default/poisoned/1_fish.png', 'church'),
|
75 |
+
('./data/default/poisoned/2_fish.png', 'church'),
|
76 |
+
('./data/default/poisoned/3_fish.png', 'church'),
|
77 |
+
('./data/default/poisoned/4_fish.png', 'church'),
|
78 |
+
('./data/default/poisoned/5_fish.png', 'church'),
|
79 |
+
('./data/default/poisoned/6_fish.png', 'church'),
|
80 |
+
('./data/default/poisoned/7_fish.png', 'church')]
|
81 |
+
|
82 |
def sample_imagenette():
|
83 |
import torchvision
|
84 |
label_names = [
|
|
|
331 |
'parachutte',], value='church')
|
332 |
eval_btn_patch = gr.Button("Evaluate ✨", elem_classes="eval-bt")
|
333 |
with gr.Column(scale=10):
|
334 |
+
clean_gallery = gr.Gallery(default_clean(), label="Clean", preview=False, show_download_button=True, height=600)
|
335 |
+
clean_accuracy = gr.Number(0.97, label="Clean Accuracy", precision=2, info="The percent of correctly classified images without trigger.")
|
336 |
with gr.Column(scale=1, min_width=0, elem_classes='symbols'):
|
337 |
gr.Markdown('''➕''')
|
338 |
with gr.Column(scale=3, elem_classes='symbols'):
|
|
|
340 |
with gr.Column(scale=1, min_width=0):
|
341 |
gr.Markdown('''🟰''', elem_classes='symbols')
|
342 |
with gr.Column(scale=10):
|
343 |
+
poison_gallery = gr.Gallery(default_poisoned(), label="Poisoned", preview=False, show_download_button=True, height=600)
|
344 |
+
poison_success = gr.Number(1.0, label="Poison Success", precision=2, info="The percent of images with trigger classified as the target.")
|
345 |
|
346 |
eval_btn_patch.click(clf_poison_evaluate, inputs=[attack, trigger_image, target_class],
|
347 |
outputs=[clean_gallery, poison_gallery, clean_accuracy, poison_success])
|
data/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
data/default/clean/0_fish.png
ADDED
data/default/clean/1_fish.png
ADDED
data/default/clean/2_fish.png
ADDED
data/default/clean/3_fish.png
ADDED
data/default/clean/4_fish.png
ADDED
data/default/clean/5_fish.png
ADDED
data/default/clean/6_fish.png
ADDED
data/default/clean/7_fish.png
ADDED
data/default/poisoned/0_fish.png
ADDED
data/default/poisoned/1_fish.png
ADDED
data/default/poisoned/2_fish.png
ADDED
data/default/poisoned/3_fish.png
ADDED
data/default/poisoned/4_fish.png
ADDED
data/default/poisoned/5_fish.png
ADDED
data/default/poisoned/6_fish.png
ADDED
data/default/poisoned/7_fish.png
ADDED