narugo1992 commited on
Commit
65abdbf
1 Parent(s): 851f856

dev(narugo): init application

Browse files
Files changed (11) hide show
  1. .gitignore +1215 -0
  2. LICENSE +201 -0
  3. app.py +57 -0
  4. attack.py +122 -0
  5. attacker/FGSM.py +49 -0
  6. attacker/PGD.py +92 -0
  7. attacker/__init__.py +3 -0
  8. attacker/base.py +32 -0
  9. imgs/atk.jpg +0 -0
  10. imgs/clean.jpg +0 -0
  11. requirements.txt +14 -0
.gitignore ADDED
@@ -0,0 +1,1215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Created by .ignore support plugin (hsz.mobi)
2
+ ### Example user template template
3
+ ### Example user template
4
+
5
+ # IntelliJ project files
6
+ .idea
7
+ *.iml
8
+ out
9
+ gen
10
+ ### CVS template
11
+ /CVS/*
12
+ **/CVS/*
13
+ .cvsignore
14
+ */.cvsignore
15
+
16
+ ### C++ template
17
+ # Prerequisites
18
+ *.d
19
+
20
+ # Compiled Object files
21
+ *.slo
22
+ *.lo
23
+ *.o
24
+ *.obj
25
+
26
+ # Precompiled Headers
27
+ *.gch
28
+ *.pch
29
+
30
+ # Compiled Dynamic libraries
31
+ *.so
32
+ *.dylib
33
+ *.dll
34
+
35
+ # Fortran module files
36
+ *.mod
37
+ *.smod
38
+
39
+ # Compiled Static libraries
40
+ *.lai
41
+ *.la
42
+ *.a
43
+ *.lib
44
+
45
+ # Executables
46
+ *.exe
47
+ *.out
48
+ *.app
49
+
50
+ ### CUDA template
51
+ *.i
52
+ *.ii
53
+ *.gpu
54
+ *.ptx
55
+ *.cubin
56
+ *.fatbin
57
+
58
+ ### SVN template
59
+ .svn/
60
+
61
+ ### Images template
62
+ # JPEG
63
+ *.jpe
64
+ *.jif
65
+ *.jfif
66
+ *.jfi
67
+
68
+ # JPEG 2000
69
+ *.jp2
70
+ *.j2k
71
+ *.jpf
72
+ *.jpx
73
+ *.jpm
74
+ *.mj2
75
+
76
+ # JPEG XR
77
+ *.jxr
78
+ *.hdp
79
+ *.wdp
80
+
81
+ # Graphics Interchange Format
82
+ *.gif
83
+
84
+ # RAW
85
+ *.raw
86
+
87
+ # Web P
88
+ *.webp
89
+
90
+ # Animated Portable Network Graphics
91
+ *.apng
92
+
93
+ # Multiple-image Network Graphics
94
+ *.mng
95
+
96
+ # Tagged Image File Format
97
+ *.tiff
98
+ *.tif
99
+
100
+ # Scalable Vector Graphics
101
+ *.svg
102
+ *.svgz
103
+
104
+ # Portable Document Format
105
+ *.pdf
106
+
107
+ # X BitMap
108
+ *.xbm
109
+
110
+ # BMP
111
+ *.bmp
112
+ *.dib
113
+
114
+ # ICO
115
+ *.ico
116
+
117
+ # 3D Images
118
+ *.3dm
119
+ *.max
120
+
121
+ ### Eclipse template
122
+ .metadata
123
+ bin/
124
+ tmp/
125
+ *.tmp
126
+ *.bak
127
+ *.swp
128
+ *~.nib
129
+ local.properties
130
+ .settings/
131
+ .loadpath
132
+ .recommenders
133
+
134
+ # External tool builders
135
+ .externalToolBuilders/
136
+
137
+ # Locally stored "Eclipse launch configurations"
138
+ *.launch
139
+
140
+ # PyDev specific (Python IDE for Eclipse)
141
+ *.pydevproject
142
+
143
+ # CDT-specific (C/C++ Development Tooling)
144
+ .cproject
145
+
146
+ # CDT- autotools
147
+ .autotools
148
+
149
+ # Java annotation processor (APT)
150
+ .factorypath
151
+
152
+ # PDT-specific (PHP Development Tools)
153
+ .buildpath
154
+
155
+ # sbteclipse plugin
156
+ .target
157
+
158
+ # Tern plugin
159
+ .tern-project
160
+
161
+ # TeXlipse plugin
162
+ .texlipse
163
+
164
+ # STS (Spring Tool Suite)
165
+ .springBeans
166
+
167
+ # Code Recommenders
168
+ .recommenders/
169
+
170
+ # Annotation Processing
171
+ .apt_generated/
172
+ .apt_generated_test/
173
+
174
+ # Scala IDE specific (Scala & Java development for Eclipse)
175
+ .cache-main
176
+ .scala_dependencies
177
+ .worksheet
178
+
179
+ # Uncomment this line if you wish to ignore the project description file.
180
+ # Typically, this file would be tracked if it contains build/dependency configurations:
181
+ #.project
182
+
183
+ ### Diff template
184
+ *.patch
185
+ *.diff
186
+
187
+ ### macOS template
188
+ # General
189
+ .DS_Store
190
+ .AppleDouble
191
+ .LSOverride
192
+
193
+ # Icon must end with two \r
194
+ Icon
195
+
196
+ # Thumbnails
197
+ ._*
198
+
199
+ # Files that might appear in the root of a volume
200
+ .DocumentRevisions-V100
201
+ .fseventsd
202
+ .Spotlight-V100
203
+ .TemporaryItems
204
+ .Trashes
205
+ .VolumeIcon.icns
206
+ .com.apple.timemachine.donotpresent
207
+
208
+ # Directories potentially created on remote AFP share
209
+ .AppleDB
210
+ .AppleDesktop
211
+ Network Trash Folder
212
+ Temporary Items
213
+ .apdisk
214
+
215
+ ### CMake template
216
+ CMakeLists.txt.user
217
+ CMakeCache.txt
218
+ CMakeFiles
219
+ CMakeScripts
220
+ Testing
221
+ cmake_install.cmake
222
+ install_manifest.txt
223
+ compile_commands.json
224
+ CTestTestfile.cmake
225
+ _deps
226
+
227
+ ### Linux template
228
+ *~
229
+
230
+ # temporary files which can be created if a process still has a handle open of a deleted file
231
+ .fuse_hidden*
232
+
233
+ # KDE directory preferences
234
+ .directory
235
+
236
+ # Linux trash folder which might appear on any partition or disk
237
+ .Trash-*
238
+
239
+ # .nfs files are created when an open file is removed but is still being accessed
240
+ .nfs*
241
+
242
+ ### MicrosoftOffice template
243
+ *.tmp
244
+
245
+ # Word temporary
246
+ ~$*.doc*
247
+
248
+ # Word Auto Backup File
249
+ Backup of *.doc*
250
+
251
+ # Excel temporary
252
+ ~$*.xls*
253
+
254
+ # Excel Backup File
255
+ *.xlk
256
+
257
+ # PowerPoint temporary
258
+ ~$*.ppt*
259
+
260
+ # Visio autosave temporary files
261
+ *.~vsd*
262
+
263
+ ### VisualStudio template
264
+ ## Ignore Visual Studio temporary files, build results, and
265
+ ## files generated by popular Visual Studio add-ons.
266
+ ##
267
+ ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
268
+
269
+ # User-specific files
270
+ *.rsuser
271
+ *.suo
272
+ *.user
273
+ *.userosscache
274
+ *.sln.docstates
275
+
276
+ # User-specific files (MonoDevelop/Xamarin Studio)
277
+ *.userprefs
278
+
279
+ # Mono auto generated files
280
+ mono_crash.*
281
+
282
+ # Build results
283
+ [Dd]ebug/
284
+ [Dd]ebugPublic/
285
+ [Rr]elease/
286
+ [Rr]eleases/
287
+ x64/
288
+ x86/
289
+ [Ww][Ii][Nn]32/
290
+ [Aa][Rr][Mm]/
291
+ [Aa][Rr][Mm]64/
292
+ bld/
293
+ [Bb]in/
294
+ [Oo]bj/
295
+ [Ll]og/
296
+ [Ll]ogs/
297
+
298
+ # Visual Studio 2015/2017 cache/options directory
299
+ .vs/
300
+ # Uncomment if you have tasks that create the project's static files in wwwroot
301
+ #wwwroot/
302
+
303
+ # Visual Studio 2017 auto generated files
304
+ Generated\ Files/
305
+
306
+ # MSTest test Results
307
+ [Tt]est[Rr]esult*/
308
+ [Bb]uild[Ll]og.*
309
+
310
+ # NUnit
311
+ *.VisualState.xml
312
+ TestResult.xml
313
+ nunit-*.xml
314
+
315
+ # Build Results of an ATL Project
316
+ [Dd]ebugPS/
317
+ [Rr]eleasePS/
318
+ dlldata.c
319
+
320
+ # Benchmark Results
321
+ BenchmarkDotNet.Artifacts/
322
+
323
+ # .NET Core
324
+ project.lock.json
325
+ project.fragment.lock.json
326
+ artifacts/
327
+
328
+ # ASP.NET Scaffolding
329
+ ScaffoldingReadMe.txt
330
+
331
+ # StyleCop
332
+ StyleCopReport.xml
333
+
334
+ # Files built by Visual Studio
335
+ *_i.c
336
+ *_p.c
337
+ *_h.h
338
+ *.ilk
339
+ *.meta
340
+ *.obj
341
+ *.iobj
342
+ *.pch
343
+ *.pdb
344
+ *.ipdb
345
+ *.pgc
346
+ *.pgd
347
+ *.rsp
348
+ *.sbr
349
+ *.tlb
350
+ *.tli
351
+ *.tlh
352
+ *.tmp
353
+ *.tmp_proj
354
+ *_wpftmp.csproj
355
+ *.log
356
+ *.vspscc
357
+ *.vssscc
358
+ .builds
359
+ *.pidb
360
+ *.svclog
361
+ *.scc
362
+
363
+ # Chutzpah Test files
364
+ _Chutzpah*
365
+
366
+ # Visual C++ cache files
367
+ ipch/
368
+ *.aps
369
+ *.ncb
370
+ *.opendb
371
+ *.opensdf
372
+ *.sdf
373
+ *.cachefile
374
+ *.VC.db
375
+ *.VC.VC.opendb
376
+
377
+ # Visual Studio profiler
378
+ *.psess
379
+ *.vsp
380
+ *.vspx
381
+ *.sap
382
+
383
+ # Visual Studio Trace Files
384
+ *.e2e
385
+
386
+ # TFS 2012 Local Workspace
387
+ $tf/
388
+
389
+ # Guidance Automation Toolkit
390
+ *.gpState
391
+
392
+ # ReSharper is a .NET coding add-in
393
+ _ReSharper*/
394
+ *.[Rr]e[Ss]harper
395
+ *.DotSettings.user
396
+
397
+ # TeamCity is a build add-in
398
+ _TeamCity*
399
+
400
+ # DotCover is a Code Coverage Tool
401
+ *.dotCover
402
+
403
+ # AxoCover is a Code Coverage Tool
404
+ .axoCover/*
405
+ !.axoCover/settings.json
406
+
407
+ # Coverlet is a free, cross platform Code Coverage Tool
408
+ coverage*.json
409
+ coverage*.xml
410
+ coverage*.info
411
+
412
+ # Visual Studio code coverage results
413
+ *.coverage
414
+ *.coveragexml
415
+
416
+ # NCrunch
417
+ _NCrunch_*
418
+ .*crunch*.local.xml
419
+ nCrunchTemp_*
420
+
421
+ # MightyMoose
422
+ *.mm.*
423
+ AutoTest.Net/
424
+
425
+ # Web workbench (sass)
426
+ .sass-cache/
427
+
428
+ # Installshield output folder
429
+ [Ee]xpress/
430
+
431
+ # DocProject is a documentation generator add-in
432
+ DocProject/buildhelp/
433
+ DocProject/Help/*.HxT
434
+ DocProject/Help/*.HxC
435
+ DocProject/Help/*.hhc
436
+ DocProject/Help/*.hhk
437
+ DocProject/Help/*.hhp
438
+ DocProject/Help/Html2
439
+ DocProject/Help/html
440
+
441
+ # Click-Once directory
442
+ publish/
443
+
444
+ # Publish Web Output
445
+ *.[Pp]ublish.xml
446
+ *.azurePubxml
447
+ # Note: Comment the next line if you want to checkin your web deploy settings,
448
+ # but database connection strings (with potential passwords) will be unencrypted
449
+ *.pubxml
450
+ *.publishproj
451
+
452
+ # Microsoft Azure Web App publish settings. Comment the next line if you want to
453
+ # checkin your Azure Web App publish settings, but sensitive information contained
454
+ # in these scripts will be unencrypted
455
+ PublishScripts/
456
+
457
+ # NuGet Packages
458
+ *.nupkg
459
+ # NuGet Symbol Packages
460
+ *.snupkg
461
+ # The packages folder can be ignored because of Package Restore
462
+ **/[Pp]ackages/*
463
+ # except build/, which is used as an MSBuild target.
464
+ !**/[Pp]ackages/build/
465
+ # Uncomment if necessary however generally it will be regenerated when needed
466
+ #!**/[Pp]ackages/repositories.config
467
+ # NuGet v3's project.json files produces more ignorable files
468
+ *.nuget.props
469
+ *.nuget.targets
470
+
471
+ # Microsoft Azure Build Output
472
+ csx/
473
+ *.build.csdef
474
+
475
+ # Microsoft Azure Emulator
476
+ ecf/
477
+ rcf/
478
+
479
+ # Windows Store app package directories and files
480
+ AppPackages/
481
+ BundleArtifacts/
482
+ Package.StoreAssociation.xml
483
+ _pkginfo.txt
484
+ *.appx
485
+ *.appxbundle
486
+ *.appxupload
487
+
488
+ # Visual Studio cache files
489
+ # files ending in .cache can be ignored
490
+ *.[Cc]ache
491
+ # but keep track of directories ending in .cache
492
+ !?*.[Cc]ache/
493
+
494
+ # Others
495
+ ClientBin/
496
+ ~$*
497
+ *~
498
+ *.dbmdl
499
+ *.dbproj.schemaview
500
+ *.jfm
501
+ *.pfx
502
+ *.publishsettings
503
+ orleans.codegen.cs
504
+
505
+ # Including strong name files can present a security risk
506
+ # (https://github.com/github/gitignore/pull/2483#issue-259490424)
507
+ #*.snk
508
+
509
+ # Since there are multiple workflows, uncomment next line to ignore bower_components
510
+ # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
511
+ #bower_components/
512
+
513
+ # RIA/Silverlight projects
514
+ Generated_Code/
515
+
516
+ # Backup & report files from converting an old project file
517
+ # to a newer Visual Studio version. Backup files are not needed,
518
+ # because we have git ;-)
519
+ _UpgradeReport_Files/
520
+ Backup*/
521
+ UpgradeLog*.XML
522
+ UpgradeLog*.htm
523
+ ServiceFabricBackup/
524
+ *.rptproj.bak
525
+
526
+ # SQL Server files
527
+ *.mdf
528
+ *.ldf
529
+ *.ndf
530
+
531
+ # Business Intelligence projects
532
+ *.rdl.data
533
+ *.bim.layout
534
+ *.bim_*.settings
535
+ *.rptproj.rsuser
536
+ *- [Bb]ackup.rdl
537
+ *- [Bb]ackup ([0-9]).rdl
538
+ *- [Bb]ackup ([0-9][0-9]).rdl
539
+
540
+ # Microsoft Fakes
541
+ FakesAssemblies/
542
+
543
+ # GhostDoc plugin setting file
544
+ *.GhostDoc.xml
545
+
546
+ # Node.js Tools for Visual Studio
547
+ .ntvs_analysis.dat
548
+ node_modules/
549
+
550
+ # Visual Studio 6 build log
551
+ *.plg
552
+
553
+ # Visual Studio 6 workspace options file
554
+ *.opt
555
+
556
+ # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
557
+ *.vbw
558
+
559
+ # Visual Studio LightSwitch build output
560
+ **/*.HTMLClient/GeneratedArtifacts
561
+ **/*.DesktopClient/GeneratedArtifacts
562
+ **/*.DesktopClient/ModelManifest.xml
563
+ **/*.Server/GeneratedArtifacts
564
+ **/*.Server/ModelManifest.xml
565
+ _Pvt_Extensions
566
+
567
+ # Paket dependency manager
568
+ .paket/paket.exe
569
+ paket-files/
570
+
571
+ # FAKE - F# Make
572
+ .fake/
573
+
574
+ # CodeRush personal settings
575
+ .cr/personal
576
+
577
+ # Python Tools for Visual Studio (PTVS)
578
+ __pycache__/
579
+ *.pyc
580
+
581
+ # Cake - Uncomment if you are using it
582
+ # tools/**
583
+ # !tools/packages.config
584
+
585
+ # Tabs Studio
586
+ *.tss
587
+
588
+ # Telerik's JustMock configuration file
589
+ *.jmconfig
590
+
591
+ # BizTalk build output
592
+ *.btp.cs
593
+ *.btm.cs
594
+ *.odx.cs
595
+ *.xsd.cs
596
+
597
+ # OpenCover UI analysis results
598
+ OpenCover/
599
+
600
+ # Azure Stream Analytics local run output
601
+ ASALocalRun/
602
+
603
+ # MSBuild Binary and Structured Log
604
+ *.binlog
605
+
606
+ # NVidia Nsight GPU debugger configuration file
607
+ *.nvuser
608
+
609
+ # MFractors (Xamarin productivity tool) working folder
610
+ .mfractor/
611
+
612
+ # Local History for Visual Studio
613
+ .localhistory/
614
+
615
+ # BeatPulse healthcheck temp database
616
+ healthchecksdb
617
+
618
+ # Backup folder for Package Reference Convert tool in Visual Studio 2017
619
+ MigrationBackup/
620
+
621
+ # Ionide (cross platform F# VS Code tools) working folder
622
+ .ionide/
623
+
624
+ # Fody - auto-generated XML schema
625
+ FodyWeavers.xsd
626
+
627
+ ### Vim template
628
+ # Swap
629
+ [._]*.s[a-v][a-z]
630
+ !*.svg # comment out if you don't need vector files
631
+ [._]*.sw[a-p]
632
+ [._]s[a-rt-v][a-z]
633
+ [._]ss[a-gi-z]
634
+ [._]sw[a-p]
635
+
636
+ # Session
637
+ Session.vim
638
+ Sessionx.vim
639
+
640
+ # Temporary
641
+ .netrwhist
642
+ *~
643
+ # Auto-generated tag files
644
+ tags
645
+ # Persistent undo
646
+ [._]*.un~
647
+
648
+ ### Backup template
649
+ *.bak
650
+ *.gho
651
+ *.ori
652
+ *.orig
653
+ *.tmp
654
+
655
+ ### SublimeText template
656
+ # Cache files for Sublime Text
657
+ *.tmlanguage.cache
658
+ *.tmPreferences.cache
659
+ *.stTheme.cache
660
+
661
+ # Workspace files are user-specific
662
+ *.sublime-workspace
663
+
664
+ # Project files should be checked into the repository, unless a significant
665
+ # proportion of contributors will probably not be using Sublime Text
666
+ # *.sublime-project
667
+
668
+ # SFTP configuration file
669
+ sftp-config.json
670
+ sftp-config-alt*.json
671
+
672
+ # Package control specific files
673
+ Package Control.last-run
674
+ Package Control.ca-list
675
+ Package Control.ca-bundle
676
+ Package Control.system-ca-bundle
677
+ Package Control.cache/
678
+ Package Control.ca-certs/
679
+ Package Control.merged-ca-bundle
680
+ Package Control.user-ca-bundle
681
+ oscrypto-ca-bundle.crt
682
+ bh_unicode_properties.cache
683
+
684
+ # Sublime-github package stores a github token in this file
685
+ # https://packagecontrol.io/packages/sublime-github
686
+ GitHub.sublime-settings
687
+
688
+ ### C template
689
+ # Prerequisites
690
+ *.d
691
+
692
+ # Object files
693
+ *.o
694
+ *.ko
695
+ *.obj
696
+ *.elf
697
+
698
+ # Linker output
699
+ *.ilk
700
+ *.map
701
+ *.exp
702
+
703
+ # Precompiled Headers
704
+ *.gch
705
+ *.pch
706
+
707
+ # Libraries
708
+ *.lib
709
+ *.a
710
+ *.la
711
+ *.lo
712
+
713
+ # Shared objects (inc. Windows DLLs)
714
+ *.dll
715
+ *.so
716
+ *.so.*
717
+ *.dylib
718
+
719
+ # Executables
720
+ *.exe
721
+ *.out
722
+ *.app
723
+ *.i*86
724
+ *.x86_64
725
+ *.hex
726
+
727
+ # Debug files
728
+ *.dSYM/
729
+ *.su
730
+ *.idb
731
+ *.pdb
732
+
733
+ # Kernel Module Compile Results
734
+ *.mod*
735
+ *.cmd
736
+ .tmp_versions/
737
+ modules.order
738
+ Module.symvers
739
+ Mkfile.old
740
+ dkms.conf
741
+
742
+ ### VirtualEnv template
743
+ # Virtualenv
744
+ # http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
745
+ .Python
746
+ [Bb]in
747
+ [Ii]nclude
748
+ [Ll]ib
749
+ [Ll]ib64
750
+ [Ll]ocal
751
+ [Ss]cripts
752
+ pyvenv.cfg
753
+ .venv
754
+ pip-selfcheck.json
755
+
756
+ ### LibreOffice template
757
+ # LibreOffice locks
758
+ .~lock.*#
759
+
760
+ ### Xilinx template
761
+ # gitignore template for Xilinx Vivado Design Suite
762
+ # website: https://www.xilinx.com/support/download.html
763
+
764
+ # [home]
765
+ *.jou
766
+ *.log
767
+ *.debug
768
+ *.str
769
+ *.tmp
770
+ *.os
771
+ *.js
772
+ *.pb
773
+ *.dcp
774
+ *.hwdef
775
+ *.vds
776
+ *.veo
777
+ *.wdf
778
+ *.vdi
779
+ *.dmp
780
+ *.rpx
781
+ *.rpt
782
+ *_stub.v
783
+ *_stub.vhdl
784
+ *_funcsim.v
785
+ *_funcsim.vhdl
786
+ .project
787
+
788
+ # [dir]
789
+ *.cache
790
+ .metadata
791
+ *.data
792
+ *.ipdefs
793
+ .Xil
794
+ *.sdk
795
+ *.hw
796
+ *.ip_user_files
797
+
798
+ ### IP synth
799
+ *_synth_*
800
+
801
+ .jobs
802
+
803
+ ### project synth
804
+ */*.runs/synth*/*.xml
805
+ */*.runs/synth*/*.txt
806
+ */*.runs/synth*/*.sh
807
+ */*.runs/synth*/*.tcl
808
+ */*.runs/synth*/*.bat
809
+ */*.runs/synth*/*.xdc
810
+ !*/*.runs/synth*/*utilization*.rpt
811
+
812
+ *.runs/synth*/*.xml
813
+ *.runs/synth*/*.txt
814
+ *.runs/synth*/*.sh
815
+ *.runs/synth*/*.tcl
816
+ *.runs/synth*/*.bat
817
+ *.runs/synth*/*.xdc
818
+ !*.runs/synth*/*utilization*.rpt
819
+
820
+ ### project impl
821
+ */*.runs/impl*/*.xml
822
+ */*.runs/impl*/*.html
823
+ */*.runs/impl*/*.txt
824
+ */*.runs/impl*/*.sh
825
+ */*.runs/impl*/*.tcl
826
+ */*.runs/impl*/*.bat
827
+ !*/*.runs/impl*/*utilization*.rpt
828
+
829
+ *.runs/impl*/*.xml
830
+ *.runs/impl*/*.html
831
+ *.runs/impl*/*.txt
832
+ *.runs/impl*/*.sh
833
+ *.runs/impl*/*.tcl
834
+ *.runs/impl*/*.bat
835
+ !*.runs/impl*/*utilization*.rpt
836
+
837
+ ### block design
838
+ */*/bd/*/hdl
839
+ */*/*/bd/*/hdl
840
+
841
+ */*/bd/*/*.xdc
842
+ */*/*/bd/*/*.xdc
843
+
844
+ */*/bd/*/ip/*/*.xdc
845
+ */*/*/bd/*/ip/*/*.xdc
846
+
847
+ */*/bd/*/ip/*/*/
848
+ */*/*/bd/*/ip/*/*/
849
+
850
+ */*/bd/*/ip/*/*.vhd
851
+ */*/*/bd/*/ip/*/*.vhd
852
+
853
+ */*/bd/*/ip/*/*.xml
854
+ */*/*/bd/*/ip/*/*.xml
855
+
856
+ *.c
857
+ *.cpp
858
+ *.h
859
+ *.vho
860
+ */*/bd/*/ip/*/*.tcl
861
+ */*/*/bd/*/ip/*/*.tcl
862
+ hw_handoff
863
+ ipshared
864
+
865
+ ### Lua template
866
+ # Compiled Lua sources
867
+ luac.out
868
+
869
+ # luarocks build files
870
+ *.src.rock
871
+ *.zip
872
+
873
+ # Object files
874
+ *.o
875
+ *.os
876
+ *.ko
877
+ *.obj
878
+ *.elf
879
+
880
+ # Precompiled Headers
881
+ *.gch
882
+ *.pch
883
+
884
+ # Libraries
885
+ *.lib
886
+ *.a
887
+ *.la
888
+ *.lo
889
+ *.def
890
+ *.exp
891
+
892
+ # Shared objects (inc. Windows DLLs)
893
+ *.dll
894
+ *.so
895
+ *.so.*
896
+ *.dylib
897
+
898
+ # Executables
899
+ *.exe
900
+ *.out
901
+ *.app
902
+ *.i*86
903
+ *.x86_64
904
+ *.hex
905
+
906
+
907
+ ### Vagrant template
908
+ # General
909
+ .vagrant/
910
+
911
+ # Log files (if you are creating logs in debug mode, uncomment this)
912
+ # *.log
913
+
914
+ ### PuTTY template
915
+ # Private key
916
+ *.ppk
917
+
918
+ ### Patch template
919
+ *.orig
920
+ *.rej
921
+
922
+ ### Python template
923
+ # Byte-compiled / optimized / DLL files
924
+ __pycache__/
925
+ *.py[cod]
926
+ *$py.class
927
+
928
+ # C extensions
929
+ *.so
930
+
931
+ # Distribution / packaging
932
+ .Python
933
+ build/
934
+ develop-eggs/
935
+ /dist
936
+ wheelhouse/
937
+ downloads/
938
+ eggs/
939
+ .eggs/
940
+ lib/
941
+ lib64/
942
+ parts/
943
+ sdist/
944
+ var/
945
+ wheels/
946
+ share/python-wheels/
947
+ *.egg-info/
948
+ .installed.cfg
949
+ *.egg
950
+ MANIFEST
951
+
952
+ # PyInstaller
953
+ # Usually these files are written by a python script from a template
954
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
955
+ *.manifest
956
+ *.spec
957
+
958
+ # Installer logs
959
+ pip-log.txt
960
+ pip-delete-this-directory.txt
961
+
962
+ # Unit test / coverage reports
963
+ htmlcov/
964
+ .tox/
965
+ .nox/
966
+ .coverage
967
+ .coverage.*
968
+ .cache
969
+ nosetests.xml
970
+ coverage.xml
971
+ *.cover
972
+ *.py,cover
973
+ .hypothesis/
974
+ .pytest_cache/
975
+ cover/
976
+
977
+ # Translations
978
+ *.mo
979
+ *.pot
980
+
981
+ # Django stuff:
982
+ *.log
983
+ local_settings.py
984
+ db.sqlite3
985
+ db.sqlite3-journal
986
+
987
+ # Flask stuff:
988
+ instance/
989
+ .webassets-cache
990
+
991
+ # Scrapy stuff:
992
+ .scrapy
993
+
994
+ # Sphinx documentation
995
+ docs/_build/
996
+
997
+ # PyBuilder
998
+ .pybuilder/
999
+ target/
1000
+
1001
+ # Jupyter Notebook
1002
+ .ipynb_checkpoints
1003
+
1004
+ # IPython
1005
+ profile_default/
1006
+ ipython_config.py
1007
+
1008
+ # pyenv
1009
+ # For a library or package, you might want to ignore these files since the code is
1010
+ # intended to run in multiple environments; otherwise, check them in:
1011
+ # .python-version
1012
+
1013
+ # pipenv
1014
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
1015
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
1016
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
1017
+ # install all needed dependencies.
1018
+ #Pipfile.lock
1019
+
1020
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
1021
+ __pypackages__/
1022
+
1023
+ # Celery stuff
1024
+ celerybeat-schedule
1025
+ celerybeat.pid
1026
+
1027
+ # SageMath parsed files
1028
+ *.sage.py
1029
+
1030
+ # Environments
1031
+ .env
1032
+ .venv
1033
+ /env/
1034
+ venv/
1035
+ ENV/
1036
+ env.bak/
1037
+ venv.bak/
1038
+
1039
+ # Spyder project settings
1040
+ .spyderproject
1041
+ .spyproject
1042
+
1043
+ # Rope project settings
1044
+ .ropeproject
1045
+
1046
+ # mkdocs documentation
1047
+ /site
1048
+
1049
+ # mypy
1050
+ .mypy_cache/
1051
+ .dmypy.json
1052
+ dmypy.json
1053
+
1054
+ # Pyre type checker
1055
+ .pyre/
1056
+
1057
+ # pytype static type analyzer
1058
+ .pytype/
1059
+
1060
+ # Cython debug symbols
1061
+ cython_debug/
1062
+
1063
+ ### Windows template
1064
+ # Windows thumbnail cache files
1065
+ Thumbs.db
1066
+ Thumbs.db:encryptable
1067
+ ehthumbs.db
1068
+ ehthumbs_vista.db
1069
+
1070
+ # Dump file
1071
+ *.stackdump
1072
+
1073
+ # Folder config file
1074
+ [Dd]esktop.ini
1075
+
1076
+ # Recycle Bin used on file shares
1077
+ $RECYCLE.BIN/
1078
+
1079
+ # Windows Installer files
1080
+ *.cab
1081
+ *.msi
1082
+ *.msix
1083
+ *.msm
1084
+ *.msp
1085
+
1086
+ # Windows shortcuts
1087
+ *.lnk
1088
+
1089
+ ### Xcode template
1090
+ # Xcode
1091
+ #
1092
+ # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
1093
+
1094
+ ## User settings
1095
+ xcuserdata/
1096
+
1097
+ ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
1098
+ *.xcscmblueprint
1099
+ *.xccheckout
1100
+
1101
+ ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
1102
+ build/
1103
+ DerivedData/
1104
+ *.moved-aside
1105
+ *.pbxuser
1106
+ !default.pbxuser
1107
+ *.mode1v3
1108
+ !default.mode1v3
1109
+ *.mode2v3
1110
+ !default.mode2v3
1111
+ *.perspectivev3
1112
+ !default.perspectivev3
1113
+
1114
+ ## Gcc Patch
1115
+ /*.gcno
1116
+
1117
+ ### JetBrains template
1118
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
1119
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
1120
+
1121
+ # User-specific stuff
1122
+ .idea/**/workspace.xml
1123
+ .idea/**/tasks.xml
1124
+ .idea/**/usage.statistics.xml
1125
+ .idea/**/dictionaries
1126
+ .idea/**/shelf
1127
+
1128
+ # Generated files
1129
+ .idea/**/contentModel.xml
1130
+
1131
+ # Sensitive or high-churn files
1132
+ .idea/**/dataSources/
1133
+ .idea/**/dataSources.ids
1134
+ .idea/**/dataSources.local.xml
1135
+ .idea/**/sqlDataSources.xml
1136
+ .idea/**/dynamic.xml
1137
+ .idea/**/uiDesigner.xml
1138
+ .idea/**/dbnavigator.xml
1139
+
1140
+ # Gradle
1141
+ .idea/**/gradle.xml
1142
+ .idea/**/libraries
1143
+
1144
+ # Gradle and Maven with auto-import
1145
+ # When using Gradle or Maven with auto-import, you should exclude module files,
1146
+ # since they will be recreated, and may cause churn. Uncomment if using
1147
+ # auto-import.
1148
+ # .idea/artifacts
1149
+ # .idea/compiler.xml
1150
+ # .idea/jarRepositories.xml
1151
+ # .idea/modules.xml
1152
+ # .idea/*.iml
1153
+ # .idea/modules
1154
+ # *.iml
1155
+ # *.ipr
1156
+
1157
+ # CMake
1158
+ cmake-build-*/
1159
+
1160
+ # Mongo Explorer plugin
1161
+ .idea/**/mongoSettings.xml
1162
+
1163
+ # File-based project format
1164
+ *.iws
1165
+
1166
+ # IntelliJ
1167
+ out/
1168
+
1169
+ # mpeltonen/sbt-idea plugin
1170
+ .idea_modules/
1171
+
1172
+ # JIRA plugin
1173
+ atlassian-ide-plugin.xml
1174
+
1175
+ # Cursive Clojure plugin
1176
+ .idea/replstate.xml
1177
+
1178
+ # Crashlytics plugin (for Android Studio and IntelliJ)
1179
+ com_crashlytics_export_strings.xml
1180
+ crashlytics.properties
1181
+ crashlytics-build.properties
1182
+ fabric.properties
1183
+
1184
+ # Editor-based Rest Client
1185
+ .idea/httpRequests
1186
+
1187
+ # Android studio 3.1+ serialized cache file
1188
+ .idea/caches/build_file_checksums.ser
1189
+
1190
+ /test_*
1191
+ .python-version
1192
+ /docs/build
1193
+ /public
1194
+ /docs/source/**/*.puml.svg
1195
+ /docs/source/**/*.puml.png
1196
+ /docs/source/**/*.gv.svg
1197
+ /docs/source/**/*.gv.png
1198
+ /docs/source/**/*.py.txt
1199
+ /docs/source/**/*.py.err
1200
+ /docs/source/**/*.py.exitcode
1201
+ /docs/source/**/*.sh.txt
1202
+ /docs/source/**/*.sh.err
1203
+ /docs/source/**/*.sh.exitcode
1204
+ /docs/source/**/*.dat.*
1205
+ !/docs/source/_static/**/*
1206
+ /cartpole_dqn_*
1207
+ /extra
1208
+ /resource/yolort/*
1209
+ !/resource/yolort/Makefile
1210
+ /images
1211
+ /output
1212
+ /ckpt
1213
+ /ckpts
1214
+ /.benchmarks
1215
+ /onnxs
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
app.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import glob
2
+ import os.path
3
+ import tempfile
4
+
5
+ import gradio as gr
6
+ from PIL import Image
7
+
8
+ from attack import Attacker, make_args
9
+
10
+
11
+ def attack_given_image(image: Image.Image, target: str, steps: int, eps: float, progress=gr.Progress()):
12
+ if image.mode != 'RGB':
13
+ image = image.convert('RGB')
14
+
15
+ with tempfile.TemporaryDirectory() as td_input, tempfile.TemporaryDirectory() as td_output:
16
+ image_filename = os.path.join(td_input, 'image.png')
17
+ image.save(image_filename)
18
+
19
+ def _step_func(current_step: int):
20
+ progress(current_step / steps)
21
+
22
+ args = make_args([
23
+ image_filename,
24
+ '--out_dir', str(td_output),
25
+ '--target', target,
26
+ '--eps', str(eps),
27
+ '--step_size', '0.135914',
28
+ '--steps', str(steps),
29
+ ])
30
+ attacker = Attacker(args)
31
+ before_prediction = attacker.image_predict(image)
32
+ attacker.attack(args.inputs, _step_func)
33
+
34
+ output_filename, *_ = glob.glob(os.path.join(td_output, '*.png'))
35
+ output_image = Image.open(output_filename)
36
+ after_prediction = attacker.image_predict(output_image)
37
+
38
+ return before_prediction, after_prediction, output_image
39
+
40
+
41
+ if __name__ == '__main__':
42
+ interface = gr.Interface(
43
+ attack_given_image,
44
+ inputs=[
45
+ gr.Image(type='pil', label='Original Image'),
46
+ gr.Radio(['auto', 'ai', 'human'], value='auto', label='Attack Target'),
47
+ gr.Slider(minimum=1, maximum=50, value=20, step=1, label='Steps'),
48
+ gr.Slider(minimum=1.0, maximum=16.0, value=1.0, step=1 / 8, label='Eps'),
49
+ ],
50
+ outputs=[
51
+ gr.Label(label='Before Prediction'),
52
+ gr.Label(label='After Prediction'),
53
+ gr.Image(type='pil', label='Attacked Image'),
54
+ ],
55
+ interpretation="default"
56
+ )
57
+ interface.queue(os.cpu_count()).launch()
attack.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import os
3
+ from typing import Mapping
4
+
5
+ import torch.nn.functional as F
6
+ from PIL import Image
7
+ from torch.nn import CrossEntropyLoss
8
+ from torchvision import transforms
9
+ from torchvision.utils import save_image
10
+ from transformers import BeitFeatureExtractor, BeitForImageClassification
11
+
12
+ from attacker import *
13
+
14
+ use_gpu = torch.cuda.is_available()
15
+ device = torch.device("cuda" if use_gpu else "cpu")
16
+
17
+
18
+ def make_args(args_=None):
19
+ parser = argparse.ArgumentParser(description='PyTorch MS_COCO Training')
20
+
21
+ parser.add_argument('inputs', type=str)
22
+ parser.add_argument('--out_dir', type=str, default='./output')
23
+ parser.add_argument('--target', type=str, default='auto', help='[auto, ai, human]')
24
+ parser.add_argument('--eps', type=float, default=8 / 8, help='Noise intensity ')
25
+ parser.add_argument('--step_size', type=float, default=1.087313 / 8, help='Attack step size')
26
+ parser.add_argument('--steps', type=int, default=20, help='Attack step count')
27
+
28
+ parser.add_argument('--test_atk', action='store_true')
29
+
30
+ return parser.parse_args(args_)
31
+
32
+
33
+ IMAGE_EXTS = ('.bmp', '.dib', '.png', '.jpg', '.jpeg',
34
+ '.pbm', '.pgm', '.ppm', '.tif', '.tiff')
35
+
36
+
37
+ class Attacker:
38
+ def __init__(self, args):
39
+ self.args = args
40
+ os.makedirs(args.out_dir, exist_ok=True)
41
+
42
+ print('正在加载模型...')
43
+ self.feature_extractor = BeitFeatureExtractor.from_pretrained('saltacc/anime-ai-detect')
44
+ self.model = BeitForImageClassification.from_pretrained('saltacc/anime-ai-detect')
45
+ if use_gpu:
46
+ self.model = self.model.cuda()
47
+ print('加载完毕')
48
+
49
+ if args.target == 'ai': # 攻击成被识别为AI
50
+ self.target = torch.tensor([1]).to(device)
51
+ elif args.target == 'human':
52
+ self.target = torch.tensor([0]).to(device)
53
+
54
+ dataset_mean_t = torch.tensor([0.5, 0.5, 0.5]).view(1, -1, 1, 1)
55
+ dataset_std_t = torch.tensor([0.5, 0.5, 0.5]).view(1, -1, 1, 1)
56
+ if use_gpu:
57
+ dataset_mean_t = dataset_mean_t.cuda()
58
+ dataset_std_t = dataset_std_t.cuda()
59
+ self.pgd = PGD(self.model, img_transform=(
60
+ lambda x: (x - dataset_mean_t) / dataset_std_t, lambda x: x * dataset_std_t + dataset_mean_t))
61
+ self.pgd.set_para(eps=(args.eps * 2) / 255, alpha=lambda: (args.step_size * 2) / 255, iters=args.steps)
62
+ self.pgd.set_loss(CrossEntropyLoss())
63
+
64
+ def save_image(self, image, noise, img_name):
65
+ # 缩放图片只缩放噪声
66
+ W, H = image.size
67
+ noise = F.interpolate(noise, size=(H, W), mode='bicubic')
68
+ img_save = transforms.ToTensor()(image) + noise
69
+ save_image(img_save, os.path.join(self.args.out_dir, f'{img_name[:img_name.rfind(".")]}_atk.png'))
70
+
71
+ def attack_(self, image, step_func=None):
72
+ inputs = self.feature_extractor(images=image, return_tensors="pt")['pixel_values']
73
+ if use_gpu:
74
+ inputs = inputs.cuda()
75
+
76
+ if self.args.target == 'auto':
77
+ with torch.no_grad():
78
+ outputs = self.model(inputs)
79
+ logits = outputs.logits
80
+ cls = logits.argmax(-1).item()
81
+ target = torch.tensor([cls]).to(device)
82
+ else:
83
+ target = self.target
84
+
85
+ if self.args.test_atk:
86
+ self.test_image(inputs, 'before attack')
87
+
88
+ atk_img = self.pgd.attack(inputs, target, step_func)
89
+
90
+ noise = self.pgd.img_transform[1](atk_img).detach().cpu() - self.pgd.img_transform[1](inputs).detach().cpu()
91
+
92
+ if self.args.test_atk:
93
+ self.test_image(atk_img, 'after attack')
94
+
95
+ return atk_img, noise
96
+
97
+ def attack_one(self, path, step_func=None):
98
+ image = Image.open(path).convert('RGB')
99
+ atk_img, noise = self.attack_(image, step_func)
100
+ self.save_image(image, noise, os.path.basename(path))
101
+
102
+ def attack(self, path, step_func=None):
103
+ self.attack_one(path, step_func)
104
+
105
+ @torch.no_grad()
106
+ def test_image(self, img, pre_fix=None):
107
+ outputs = self.model(img)
108
+ logits = outputs.logits
109
+ _ = pre_fix
110
+ confidences = torch.softmax(logits.reshape(-1), dim=0)
111
+ return {self.model.config.id2label[i]: float(conf) for i, conf in enumerate(confidences)}
112
+
113
+ @torch.no_grad()
114
+ def image_predict(self, image: Image.Image) -> Mapping[str, float]:
115
+ inputs = self.feature_extractor(images=image, return_tensors="pt")['pixel_values']
116
+ return self.test_image(inputs)
117
+
118
+
119
+ if __name__ == '__main__':
120
+ args = make_args()
121
+ attacker = Attacker(args)
122
+ attacker.attack(args.inputs)
attacker/FGSM.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from torch.cuda import amp
3
+
4
+ from .base import Attacker
5
+
6
+
7
+ class FGSM(Attacker):
8
+ def __init__(self, model, img_transform=(lambda x: x, lambda x: x), use_amp=False):
9
+ super().__init__(model, img_transform)
10
+ self.use_amp = use_amp
11
+
12
+ if use_amp:
13
+ self.scaler = amp.GradScaler()
14
+
15
+ def set_para(self, eps=8, alpha=lambda: 8, **kwargs):
16
+ super().set_para(eps=eps, alpha=alpha, **kwargs)
17
+
18
+ def step(self, images, labels, loss):
19
+ with amp.autocast(enabled=self.use_amp):
20
+ images.requires_grad = True
21
+ outputs = self.model(images).logits
22
+
23
+ self.model.zero_grad()
24
+ cost = loss(outputs, labels)
25
+
26
+ if self.use_amp:
27
+ self.scaler.scale(cost).backward()
28
+ else:
29
+ cost.backward()
30
+
31
+ adv_images = (images + self.alpha() * images.grad.sign()).detach_()
32
+ eta = torch.clamp(adv_images - self.ori_images, min=-self.eps, max=self.eps)
33
+ images = self.img_transform[0](
34
+ torch.clamp(self.img_transform[1](self.ori_images + eta), min=0, max=255).detach_())
35
+
36
+ return images
37
+
38
+ def attack(self, images, labels):
39
+ # images = deepcopy(images)
40
+ # self.ori_images = deepcopy(images)
41
+
42
+ self.model.eval()
43
+
44
+ images = self.forward(self, images, labels)
45
+
46
+ self.model.zero_grad()
47
+ self.model.train()
48
+
49
+ return images
attacker/PGD.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from copy import deepcopy
2
+
3
+ import torch
4
+ from torch import nn
5
+ from torch.cuda import amp
6
+ from tqdm import tqdm
7
+
8
+ from .base import Attacker, Empty
9
+
10
+
11
+ class PGD(Attacker):
12
+ def __init__(self, model, img_transform=(lambda x: x, lambda x: x), use_amp=False):
13
+ super().__init__(model, img_transform)
14
+ self.use_amp = use_amp
15
+ self.call_back = None
16
+ self.img_loader = None
17
+ self.img_hook = None
18
+
19
+ self.scaler = amp.GradScaler(enabled=use_amp)
20
+
21
+ def set_para(self, eps=8, alpha=lambda: 8, iters=20, **kwargs):
22
+ super().set_para(eps=eps, alpha=alpha, iters=iters, **kwargs)
23
+
24
+ def set_call_back(self, call_back):
25
+ self.call_back = call_back
26
+
27
+ def set_img_loader(self, img_loader):
28
+ self.img_loader = img_loader
29
+
30
+ def step(self, images, labels, loss):
31
+ with amp.autocast(enabled=self.use_amp):
32
+ images.requires_grad = True
33
+ outputs = self.model(images).logits
34
+
35
+ self.model.zero_grad()
36
+ cost = loss(outputs,
37
+ labels) # +outputs[2].view(-1)[0]*0+outputs[1].view(-1)[0]*0+outputs[0].view(-1)[0]*0 #support DDP
38
+
39
+ self.scaler.scale(cost).backward()
40
+
41
+ adv_images = (images + self.alpha() * images.grad.sign()).detach_()
42
+ eta = torch.clamp(adv_images - self.ori_images, min=-self.eps, max=self.eps)
43
+ images = self.img_transform[0](
44
+ torch.clamp(self.img_transform[1](self.ori_images + eta), min=0, max=1).detach_())
45
+
46
+ return images
47
+
48
+ def set_data(self, images, labels):
49
+ self.ori_images = deepcopy(images)
50
+ self.images = images
51
+ self.labels = labels
52
+
53
+ def __iter__(self):
54
+ self.atk_step = 0
55
+ return self
56
+
57
+ def __next__(self):
58
+ self.atk_step += 1
59
+ if self.atk_step > self.iters:
60
+ raise StopIteration
61
+
62
+ with self.model.no_sync() if isinstance(self.model, nn.parallel.DistributedDataParallel) else Empty():
63
+ self.model.eval()
64
+
65
+ self.images = self.forward(self, self.images, self.labels)
66
+
67
+ self.model.zero_grad()
68
+ self.model.train()
69
+
70
+ return self.ori_images, self.images.detach(), self.labels
71
+
72
+ def attack(self, images, labels, step_func=None):
73
+ # images = deepcopy(images)
74
+ self.ori_images = deepcopy(images)
75
+
76
+ for i in tqdm(range(self.iters)):
77
+ self.model.eval()
78
+
79
+ images = self.forward(self, images, labels)
80
+
81
+ self.model.zero_grad()
82
+ self.model.train()
83
+ if self.call_back:
84
+ self.call_back(self.ori_images, images.detach(), labels)
85
+
86
+ if self.img_hook is not None:
87
+ images = self.img_hook(self.ori_images, images.detach())
88
+
89
+ if step_func:
90
+ step_func(i + 1)
91
+
92
+ return images
attacker/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from .FGSM import *
2
+ from .PGD import *
3
+ from .base import *
attacker/base.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class Attacker:
2
+ def __init__(self, model, img_transform=(lambda x: x, lambda x: x)):
3
+ self.model = model # 必须是pytorch的model
4
+ '''self.model.eval()
5
+ for k, v in self.model.named_parameters():
6
+ v.requires_grad = False'''
7
+ self.img_transform = img_transform
8
+ self.forward = lambda attacker, images, labels: attacker.step(images, labels, attacker.loss)
9
+
10
+ def set_para(self, **kwargs):
11
+ for k, v in kwargs.items():
12
+ setattr(self, k, v)
13
+
14
+ def set_forward(self, forward):
15
+ self.forward = forward
16
+
17
+ def step(self, images, labels, loss):
18
+ pass
19
+
20
+ def set_loss(self, loss):
21
+ self.loss = loss
22
+
23
+ def attack(self, images, labels):
24
+ pass
25
+
26
+
27
+ class Empty:
28
+ def __enter__(self):
29
+ pass
30
+
31
+ def __exit__(self, exc_type, exc_val, exc_tb):
32
+ pass
imgs/atk.jpg ADDED
imgs/clean.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ torch
2
+ torchvision
3
+ timm
4
+ Pillow
5
+ blobfile
6
+ mypy
7
+ numpy
8
+ pytest
9
+ requests
10
+ einops
11
+ tensorboardX
12
+ scipy
13
+ transformers
14
+ gradio==3.16.2