-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathgtsrb_targeted.html
219 lines (210 loc) · 13.9 KB
/
gtsrb_targeted.html
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<!DOCTYPE html>
<html lang="en">
<head>
<title>GTSRB: Targeted Attacks</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="data/favicon.ico" />
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/skeleton.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<div id="header" class="row">
<div id="logo" class="one-half column"><a href="."><h1>adversarial.js</h1></a></div>
<div id="nav" class="one-half column">
<a href=".">Intro</a> · <a href="examples.html" class="active">Examples</a> · <a href="faq.html">FAQ</a> · <a href="api.html">API</a> · <a href="https://github.com/kennysong/adversarial.js" target="_blank">GitHub</a>
</div>
</div>
<a href="examples.html" class="back">‹ Back to all examples</a>
<h2>GTSRB: Targeted Attacks</h2>
<h3>Fast Gradient Sign Method (FGSM)</h3>
<button id="fgsmTargeted-run" class="button-primary">Run FGSM</button>
<div id="fgsmTargeted-success-rate"></div>
<table id="fgsmTargeted" style="display:none;">
<thead>
<td>Original</td>
<td>Stop Sign</td>
<td>Do Not Enter</td>
<td>20km/hr</td>
<td>120km/hr</td>
</thead>
<tbody>
<tr>
<td><canvas class="0 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="00 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="01 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="02 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="03 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
<tr>
<td><canvas class="1 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="10 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="11 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="12 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="13 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
<tr>
<td><canvas class="2 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="20 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="21 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="22 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="23 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
<tr>
<td><canvas class="3 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="30 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="31 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="32 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="33 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
</tbody>
</table>
<h3>Basic Iterative Method (BIM / PGD / I-FGSM)</h3>
<button id="bimTargeted-run" class="button-primary">Run BIM</button>
<div id="bimTargeted-success-rate"></div>
<table id="bimTargeted" style="display:none;">
<thead>
<td>Original</td>
<td>Stop Sign</td>
<td>Do Not Enter</td>
<td>20km/hr</td>
<td>120km/hr</td>
</thead>
<tbody>
<tr>
<td><canvas class="0 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="00 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="01 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="02 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="03 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
<tr>
<td><canvas class="1 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="10 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="11 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="12 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="13 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
<tr>
<td><canvas class="2 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="20 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="21 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="22 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="23 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
<tr>
<td><canvas class="3 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="30 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="31 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="32 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="33 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
</tbody>
</table>
<h3>Jacobian-based Saliency Map Attack, One-Pixel (JSMA One-Pixel)</h3>
<button id="jsmaOnePixel-run" class="button-primary">Run JSMA One-Pixel</button>
<div id="jsmaOnePixel-success-rate"></div>
<table id="jsmaOnePixel" style="display:none;">
<thead>
<td>Original</td>
<td>Stop Sign</td>
<td>Do Not Enter</td>
<td>20km/hr</td>
<td>120km/hr</td>
</thead>
<tbody>
<tr>
<td><canvas class="0 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="00 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="01 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="02 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="03 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
<tr>
<td><canvas class="1 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="10 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="11 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="12 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="13 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
<tr>
<td><canvas class="2 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="20 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="21 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="22 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="23 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
<tr>
<td><canvas class="3 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="30 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="31 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="32 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="33 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
</tbody>
</table>
<h3>Jacobian-based Saliency Map Attack (JSMA)</h3>
<button id="jsma-run" class="button-primary" disabled>Too Slow!</button>
<h3>Carlini & Wagner (C&W)</h3>
<button id="cw-run" class="button-primary">Run C&W</button>
<div id="cw-success-rate"></div>
<table id="cw" style="display:none;">
<thead>
<td>Original</td>
<td>Stop Sign</td>
<td>Do Not Enter</td>
<td>20km/hr</td>
<td>120km/hr</td>
</thead>
<tbody>
<tr>
<td><canvas class="0 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="00 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="01 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="02 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="03 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
<tr>
<td><canvas class="1 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="10 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="11 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="12 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="13 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
<tr>
<td><canvas class="2 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="20 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="21 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="22 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="23 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
<tr>
<td><canvas class="3 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="30 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="31 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="32 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
<td><canvas class="33 tableimg" width="128" height="128"></canvas><span class="caption"><br/><br/></span></td>
</tr>
</tbody>
</table>
</div>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js" type="text/javascript"></script>
<script type="module">
import {fgsmTargeted, bimTargeted, jsmaOnePixel, jsma, cw} from './js/adversarial.js';
import {runTargeted} from './js/gtsrb.js';
[fgsmTargeted, bimTargeted, jsmaOnePixel, jsma, cw].forEach((attack) => {
let name = attack.name;
document.getElementById(`${name}-run`).addEventListener("click", async () => {
document.getElementById(name).style.display = 'table';
document.getElementById(`${name}-run`).disabled = true;
document.getElementById(`${name}-run`).innerText = 'Running...';
await runTargeted(attack);
document.getElementById(`${name}-run`).innerText = 'Done!';
});
});
</script>
</body>
</html>