├── README.md ├── picture ├── 120.jpg ├── 40.jpeg ├── 60.jpeg ├── Original_Traffic_Sign_samples │ ├── 01_speed_limit_30.jpg │ ├── 02_no_entry.png │ ├── 03_turn_right.png │ ├── 04_no_entry.jpg │ ├── 05_no_vehicles.jpg │ ├── 06_speed_limit_60.png │ ├── 07_keep_left.png │ ├── 08_vehicle_prohibited.png │ ├── 09_speed_limit_30.jpg │ ├── 10_speed_limit_100.jpg │ ├── 11_speed_limit_60.jpg │ ├── 12_speed_limit_100.jpg │ ├── 13_no_passing.jpg │ ├── 14_stop.png │ ├── 15_stop.jpg │ ├── 16_roundabout_mandatory.png │ ├── 17_no_passing_big.png │ ├── 18_general_caution.png │ ├── 19_rightway.png │ ├── 20_speed_limit_50.png │ ├── 21_dangerous_curve_right.png │ ├── 22_end.png │ ├── 23_speed_limit_120.jpg │ ├── 24_speed_limit_80.jpg │ ├── 25_straight.png │ ├── 26_bicycles_crossing.png │ ├── 27_end_passing.png │ └── labels.txt ├── bigpig.jpeg ├── book5-home.graffle │ ├── data.plist │ ├── image1.png │ ├── image2.pdf │ ├── image3.png │ ├── image4.png │ └── image5.png ├── book5picture.graffle │ ├── data.plist │ ├── image1.png │ ├── image10.png │ ├── image2.tiff │ ├── image3.png │ ├── image4.png │ ├── image6.png │ ├── image7.pdf │ └── image8.png ├── cow.jpeg ├── cropped_panda.jpg ├── deepfool算法.png ├── hacked-pig-image-deepfool-d.png ├── hacked-pig-image-deepfool.png ├── hacked-pig-image-fgsm-d.png ├── hacked-pig-image-fgsm.png ├── hacked-pig-image.png ├── horse.jpeg ├── left.jpg ├── lena.jpeg ├── mug227.png ├── objectdetect │ ├── adv-case1.jpg │ ├── adv-case2.jpg │ ├── case1.jpeg │ ├── case2.jpeg │ ├── case3.jpeg │ ├── ssd-case1.jpeg │ ├── ssd-case2.jpeg │ ├── ssd-case3.jpeg │ └── ssd-case3.jpg ├── pig.jpg ├── road.jpg ├── sigmod函数.png ├── sign.jpeg ├── sign函数.png ├── smallpig.jpeg ├── sobel.jpeg ├── test_im1.jpg ├── test_im2.jpg ├── traffic_sign_samples │ ├── 0000.jpg │ ├── 0001.jpg │ ├── 0002.jpg │ ├── 0003.png │ ├── 0004.jpeg │ ├── 0005.jpg │ ├── 0006.jpg │ ├── 0006.png │ ├── 0007.jpg │ ├── 0008.jpg │ ├── 0009.jpg │ ├── 0010.jpg │ ├── 0011.jpg │ ├── 0012.jpg │ ├── 0013.jpg │ ├── 0014.jpg │ ├── 0015.jpg │ ├── 0016.jpg │ ├── 0017.jpg │ ├── 0018.jpg │ ├── 0019.jpg │ ├── 0020.jpg │ ├── 0021.jpg │ ├── 0022.jpg │ ├── 0023.jpg │ ├── 0024.jpg │ ├── 0025.jpg │ ├── 0026.jpg │ ├── 0027.jpg │ ├── 0028.jpg │ ├── 0029.jpg │ └── 0030.jpg ├── v.mp4 ├── 下载.png ├── 二分类问题里面的对抗样本.png ├── 作图.graffle ├── 分类问题原理图1.png ├── 分类问题原理图2.png ├── 向量化表示的点到直线的距离.png ├── 基于FGSM算法被识别为烤面包机的家猪-图1.png ├── 基于FGSM算法被识别为烤面包机的家猪-图2.png ├── 多分类问题的deepfool.png ├── 攻击图片经过拍照打印后依然可以欺骗图像分类模型.png ├── 点到直线的距离.png ├── 神经网络训练过程.graffle ├── 神经网络训练过程.png └── 针对图像分类模型的对抗样本.png ├── 白盒 ├── LocalSearchAttack │ ├── .ipynb_checkpoints │ │ └── LocalSearch-checkpoint.ipynb │ └── LocalSearch.ipynb ├── Universal │ ├── .ipynb_checkpoints │ │ └── UniversalAttack-checkpoint.ipynb │ ├── MNIST_data │ │ ├── t10k-images-idx3-ubyte │ │ ├── t10k-labels-idx1-ubyte │ │ ├── train-images-idx3-ubyte │ │ └── train-labels-idx1-ubyte │ └── UniversalAttack.ipynb ├── UniversalAttack │ ├── .gitignore │ ├── DeepFool │ │ └── Python │ │ │ ├── README.md │ │ │ └── deepfool.py │ ├── LICENSE │ ├── README.md │ ├── attack.ipynb │ ├── attack.py │ ├── data │ │ ├── dog.556.jpg │ │ ├── dog.557.jpg │ │ ├── dog.559.jpg │ │ ├── dog.560.jpg │ │ ├── dog.562.jpg │ │ └── dog.563.jpg │ ├── noise.pth │ └── uap.ipynb └── 单像素攻击 │ ├── .ipynb_checkpoints │ └── one-pixel-attack-checkpoint.ipynb │ ├── one-pixel-attack.ipynb │ └── runs │ └── Aug05_19-22-30_t630 │ └── events.out.tfevents.1565004150.t630 └── 黑盒 ├── CW ├── .ipynb_checkpoints │ └── CW-checkpoint.ipynb └── CW.ipynb ├── DeepFool ├── .ipynb_checkpoints │ ├── Notarget-checkpoint.ipynb │ └── Target-checkpoint.ipynb ├── Notarget.ipynb └── Target.ipynb ├── FGM ├── .ipynb_checkpoints │ └── FGM-checkpoint.ipynb └── FGM.ipynb ├── JSMA ├── .ipynb_checkpoints │ └── JSMA-checkpoint.ipynb └── JSMA.ipynb └── 梯度方向 ├── .ipynb_checkpoints └── 梯度方向-checkpoint.ipynb └── 梯度方向.ipynb /README.md: -------------------------------------------------------------------------------- 1 | # Adversarial-Examples 2 | AdvAttacks; adversarial examples; FGSM;JSMA;CW;single pixel attack; local search attack;deepfool 3 | 4 | 根据根据成本,分为白盒,黑盒,物理攻击。 白盒和黑盒文件夹标记反了 5 | -------------------------------------------------------------------------------- /picture/120.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/120.jpg -------------------------------------------------------------------------------- /picture/40.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/40.jpeg -------------------------------------------------------------------------------- /picture/60.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/60.jpeg -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/01_speed_limit_30.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/01_speed_limit_30.jpg -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/02_no_entry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/02_no_entry.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/03_turn_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/03_turn_right.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/04_no_entry.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/04_no_entry.jpg -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/05_no_vehicles.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/05_no_vehicles.jpg -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/06_speed_limit_60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/06_speed_limit_60.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/07_keep_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/07_keep_left.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/08_vehicle_prohibited.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/08_vehicle_prohibited.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/09_speed_limit_30.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/09_speed_limit_30.jpg -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/10_speed_limit_100.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/10_speed_limit_100.jpg -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/11_speed_limit_60.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/11_speed_limit_60.jpg -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/12_speed_limit_100.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/12_speed_limit_100.jpg -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/13_no_passing.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/13_no_passing.jpg -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/14_stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/14_stop.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/15_stop.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/15_stop.jpg -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/16_roundabout_mandatory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/16_roundabout_mandatory.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/17_no_passing_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/17_no_passing_big.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/18_general_caution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/18_general_caution.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/19_rightway.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/19_rightway.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/20_speed_limit_50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/20_speed_limit_50.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/21_dangerous_curve_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/21_dangerous_curve_right.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/22_end.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/22_end.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/23_speed_limit_120.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/23_speed_limit_120.jpg -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/24_speed_limit_80.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/24_speed_limit_80.jpg -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/25_straight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/25_straight.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/26_bicycles_crossing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/26_bicycles_crossing.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/27_end_passing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/Original_Traffic_Sign_samples/27_end_passing.png -------------------------------------------------------------------------------- /picture/Original_Traffic_Sign_samples/labels.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 17 3 | 33 4 | 17 5 | 15 6 | 3 7 | 39 8 | 16 9 | 1 10 | 7 11 | 3 12 | 7 13 | 9 14 | 14 15 | 14 16 | 40 17 | 10 18 | 18 19 | 11 20 | 2 21 | 20 22 | 32 23 | 8 24 | 5 25 | 35 26 | 29 27 | 41 28 | -------------------------------------------------------------------------------- /picture/bigpig.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/bigpig.jpeg -------------------------------------------------------------------------------- /picture/book5-home.graffle/data.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/book5-home.graffle/data.plist -------------------------------------------------------------------------------- /picture/book5-home.graffle/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/book5-home.graffle/image1.png -------------------------------------------------------------------------------- /picture/book5-home.graffle/image2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/book5-home.graffle/image2.pdf -------------------------------------------------------------------------------- /picture/book5-home.graffle/image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/book5-home.graffle/image3.png -------------------------------------------------------------------------------- /picture/book5-home.graffle/image4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/book5-home.graffle/image4.png -------------------------------------------------------------------------------- /picture/book5-home.graffle/image5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/book5-home.graffle/image5.png -------------------------------------------------------------------------------- /picture/book5picture.graffle/data.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/book5picture.graffle/data.plist -------------------------------------------------------------------------------- /picture/book5picture.graffle/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/book5picture.graffle/image1.png -------------------------------------------------------------------------------- /picture/book5picture.graffle/image10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/book5picture.graffle/image10.png -------------------------------------------------------------------------------- /picture/book5picture.graffle/image2.tiff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/book5picture.graffle/image2.tiff -------------------------------------------------------------------------------- /picture/book5picture.graffle/image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/book5picture.graffle/image3.png -------------------------------------------------------------------------------- /picture/book5picture.graffle/image4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/book5picture.graffle/image4.png -------------------------------------------------------------------------------- /picture/book5picture.graffle/image6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/book5picture.graffle/image6.png -------------------------------------------------------------------------------- /picture/book5picture.graffle/image7.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/book5picture.graffle/image7.pdf -------------------------------------------------------------------------------- /picture/book5picture.graffle/image8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/book5picture.graffle/image8.png -------------------------------------------------------------------------------- /picture/cow.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/cow.jpeg -------------------------------------------------------------------------------- /picture/cropped_panda.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/cropped_panda.jpg -------------------------------------------------------------------------------- /picture/deepfool算法.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/deepfool算法.png -------------------------------------------------------------------------------- /picture/hacked-pig-image-deepfool-d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/hacked-pig-image-deepfool-d.png -------------------------------------------------------------------------------- /picture/hacked-pig-image-deepfool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/hacked-pig-image-deepfool.png -------------------------------------------------------------------------------- /picture/hacked-pig-image-fgsm-d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/hacked-pig-image-fgsm-d.png -------------------------------------------------------------------------------- /picture/hacked-pig-image-fgsm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/hacked-pig-image-fgsm.png -------------------------------------------------------------------------------- /picture/hacked-pig-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/hacked-pig-image.png -------------------------------------------------------------------------------- /picture/horse.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/horse.jpeg -------------------------------------------------------------------------------- /picture/left.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/left.jpg -------------------------------------------------------------------------------- /picture/lena.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/lena.jpeg -------------------------------------------------------------------------------- /picture/mug227.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/mug227.png -------------------------------------------------------------------------------- /picture/objectdetect/adv-case1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/objectdetect/adv-case1.jpg -------------------------------------------------------------------------------- /picture/objectdetect/adv-case2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/objectdetect/adv-case2.jpg -------------------------------------------------------------------------------- /picture/objectdetect/case1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/objectdetect/case1.jpeg -------------------------------------------------------------------------------- /picture/objectdetect/case2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/objectdetect/case2.jpeg -------------------------------------------------------------------------------- /picture/objectdetect/case3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/objectdetect/case3.jpeg -------------------------------------------------------------------------------- /picture/objectdetect/ssd-case1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/objectdetect/ssd-case1.jpeg -------------------------------------------------------------------------------- /picture/objectdetect/ssd-case2.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/objectdetect/ssd-case2.jpeg -------------------------------------------------------------------------------- /picture/objectdetect/ssd-case3.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/objectdetect/ssd-case3.jpeg -------------------------------------------------------------------------------- /picture/objectdetect/ssd-case3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/objectdetect/ssd-case3.jpg -------------------------------------------------------------------------------- /picture/pig.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/pig.jpg -------------------------------------------------------------------------------- /picture/road.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/road.jpg -------------------------------------------------------------------------------- /picture/sigmod函数.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/sigmod函数.png -------------------------------------------------------------------------------- /picture/sign.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/sign.jpeg -------------------------------------------------------------------------------- /picture/sign函数.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/sign函数.png -------------------------------------------------------------------------------- /picture/smallpig.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/smallpig.jpeg -------------------------------------------------------------------------------- /picture/sobel.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/sobel.jpeg -------------------------------------------------------------------------------- /picture/test_im1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/test_im1.jpg -------------------------------------------------------------------------------- /picture/test_im2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/test_im2.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0000.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0001.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0001.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0002.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0002.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0003.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0003.png -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0004.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0004.jpeg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0005.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0005.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0006.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0006.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0006.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0006.png -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0007.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0007.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0008.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0008.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0009.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0009.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0010.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0010.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0011.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0011.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0012.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0012.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0013.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0013.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0014.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0014.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0015.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0015.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0016.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0016.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0017.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0017.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0018.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0018.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0019.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0019.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0020.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0020.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0021.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0021.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0022.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0022.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0023.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0023.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0024.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0024.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0025.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0025.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0026.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0026.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0027.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0027.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0028.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0028.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0029.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0029.jpg -------------------------------------------------------------------------------- /picture/traffic_sign_samples/0030.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/traffic_sign_samples/0030.jpg -------------------------------------------------------------------------------- /picture/v.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/v.mp4 -------------------------------------------------------------------------------- /picture/下载.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/下载.png -------------------------------------------------------------------------------- /picture/二分类问题里面的对抗样本.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/二分类问题里面的对抗样本.png -------------------------------------------------------------------------------- /picture/作图.graffle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/作图.graffle -------------------------------------------------------------------------------- /picture/分类问题原理图1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/分类问题原理图1.png -------------------------------------------------------------------------------- /picture/分类问题原理图2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/分类问题原理图2.png -------------------------------------------------------------------------------- /picture/向量化表示的点到直线的距离.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/向量化表示的点到直线的距离.png -------------------------------------------------------------------------------- /picture/基于FGSM算法被识别为烤面包机的家猪-图1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/基于FGSM算法被识别为烤面包机的家猪-图1.png -------------------------------------------------------------------------------- /picture/基于FGSM算法被识别为烤面包机的家猪-图2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/基于FGSM算法被识别为烤面包机的家猪-图2.png -------------------------------------------------------------------------------- /picture/多分类问题的deepfool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/多分类问题的deepfool.png -------------------------------------------------------------------------------- /picture/攻击图片经过拍照打印后依然可以欺骗图像分类模型.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/攻击图片经过拍照打印后依然可以欺骗图像分类模型.png -------------------------------------------------------------------------------- /picture/点到直线的距离.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/点到直线的距离.png -------------------------------------------------------------------------------- /picture/神经网络训练过程.graffle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/神经网络训练过程.graffle -------------------------------------------------------------------------------- /picture/神经网络训练过程.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/神经网络训练过程.png -------------------------------------------------------------------------------- /picture/针对图像分类模型的对抗样本.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/picture/针对图像分类模型的对抗样本.png -------------------------------------------------------------------------------- /白盒/LocalSearchAttack/.ipynb_checkpoints/LocalSearch-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import foolbox\n", 10 | "import keras\n", 11 | "import numpy as np\n", 12 | "from keras.applications.resnet50 import ResNet50,decode_predictions\n", 13 | "from foolbox.criteria import TargetClassProbability\n", 14 | "'''\n", 15 | "keras.backend.set_learning_pharse(0) # train model\n", 16 | "keras.backend.set_learning_pharse(1) # predict model\n", 17 | "之所以这么区分,是因为某些层在预测和训练时不同,比如BN和Dropout\n", 18 | "'''\n", 19 | "keras.backend.set_learning_phase(1)\n", 20 | "kmodel=ResNet50(weights='imagenet')\n", 21 | "preprocessing=(np.array([104,116,123]),1)\n", 22 | "fmodel=foolbox.models.KerasModel(kmodel,bounds=(0,255),preprocessing=preprocessing)\n", 23 | "# get source image and label\n", 24 | "image,label = foolbox.utils.imagenet_example()\n", 25 | "attack=foolbox.attacks.LocalSearchAttack(fmodel)\n", 26 | "adversarial = attack(image[:,:,:,-1],label) # if the attack fails,adversarial\n", 27 | "# will be None and a warning will be printed\n", 28 | "if adversarial is not None:\n", 29 | " adversarial_label=np.argmax(fmodel.predictions(adversarial))\n", 30 | " print('Adversarial label={}, Original label={}'.format(adversarial_label,label))\n", 31 | "else:\n", 32 | " print('Fail to LocalSearchAttack!')" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": null, 38 | "metadata": { 39 | "collapsed": true 40 | }, 41 | "outputs": [], 42 | "source": [ 43 | "%matplotlip inline\n", 44 | "import matplotlip.pyplot as plt\n", 45 | "plt.figure()\n", 46 | "plt.subplot(131)\n", 47 | "plt.title('Original')\n", 48 | "plt.imshow(image/255) # division by 255 to convert [0,255] to [0,1]\n", 49 | "plt.axis('off')\n", 50 | "\n", 51 | "plt.subplot(132)\n", 52 | "plt.title('Adversarial')\n", 53 | "plt.imshow(adversarial[:,:,::-1]/255) #::-1 to convert BGR to RGB\n", 54 | "plt.axis('off')\n", 55 | "\n", 56 | "plt.subplot(133)\n", 57 | "plt.title('Difference')\n", 58 | "difference=adversarial[:,:,::-1]-image\n", 59 | "plt.image(diffenrence/abs(difference).max() *0.2+0.5)\n", 60 | "plt.axis('off')\n", 61 | "plt.show()" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": null, 67 | "metadata": { 68 | "collapsed": true 69 | }, 70 | "outputs": [], 71 | "source": [ 72 | "print(np.where(difference!=0.0))" 73 | ] 74 | } 75 | ], 76 | "metadata": { 77 | "kernelspec": { 78 | "display_name": "Python 3", 79 | "language": "python", 80 | "name": "python3" 81 | }, 82 | "language_info": { 83 | "codemirror_mode": { 84 | "name": "ipython", 85 | "version": 3 86 | }, 87 | "file_extension": ".py", 88 | "mimetype": "text/x-python", 89 | "name": "python", 90 | "nbconvert_exporter": "python", 91 | "pygments_lexer": "ipython3", 92 | "version": "3.6.2" 93 | } 94 | }, 95 | "nbformat": 4, 96 | "nbformat_minor": 2 97 | } 98 | -------------------------------------------------------------------------------- /白盒/LocalSearchAttack/LocalSearch.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import foolbox\n", 10 | "import keras\n", 11 | "import numpy as np\n", 12 | "from keras.applications.resnet50 import ResNet50,decode_predictions\n", 13 | "from foolbox.criteria import TargetClassProbability\n", 14 | "'''\n", 15 | "keras.backend.set_learning_pharse(0) # train model\n", 16 | "keras.backend.set_learning_pharse(1) # predict model\n", 17 | "之所以这么区分,是因为某些层在预测和训练时不同,比如BN和Dropout\n", 18 | "'''\n", 19 | "keras.backend.set_learning_phase(1)\n", 20 | "kmodel=ResNet50(weights='imagenet')\n", 21 | "preprocessing=(np.array([104,116,123]),1)\n", 22 | "fmodel=foolbox.models.KerasModel(kmodel,bounds=(0,255),preprocessing=preprocessing)\n", 23 | "# get source image and label\n", 24 | "image,label = foolbox.utils.imagenet_example()\n", 25 | "attack=foolbox.attacks.LocalSearchAttack(fmodel)\n", 26 | "adversarial = attack(image[:,:,:,-1],label) # if the attack fails,adversarial\n", 27 | "# will be None and a warning will be printed\n", 28 | "if adversarial is not None:\n", 29 | " adversarial_label=np.argmax(fmodel.predictions(adversarial))\n", 30 | " print('Adversarial label={}, Original label={}'.format(adversarial_label,label))\n", 31 | "else:\n", 32 | " print('Fail to LocalSearchAttack!')" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": null, 38 | "metadata": { 39 | "collapsed": true 40 | }, 41 | "outputs": [], 42 | "source": [ 43 | "%matplotlip inline\n", 44 | "import matplotlip.pyplot as plt\n", 45 | "plt.figure()\n", 46 | "plt.subplot(131)\n", 47 | "plt.title('Original')\n", 48 | "plt.imshow(image/255) # division by 255 to convert [0,255] to [0,1]\n", 49 | "plt.axis('off')\n", 50 | "\n", 51 | "plt.subplot(132)\n", 52 | "plt.title('Adversarial')\n", 53 | "plt.imshow(adversarial[:,:,::-1]/255) #::-1 to convert BGR to RGB\n", 54 | "plt.axis('off')\n", 55 | "\n", 56 | "plt.subplot(133)\n", 57 | "plt.title('Difference')\n", 58 | "difference=adversarial[:,:,::-1]-image\n", 59 | "plt.image(diffenrence/abs(difference).max() *0.2+0.5)\n", 60 | "plt.axis('off')\n", 61 | "plt.show()" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": null, 67 | "metadata": { 68 | "collapsed": true 69 | }, 70 | "outputs": [], 71 | "source": [ 72 | "print(np.where(difference!=0.0))" 73 | ] 74 | } 75 | ], 76 | "metadata": { 77 | "kernelspec": { 78 | "display_name": "Python 3", 79 | "language": "python", 80 | "name": "python3" 81 | }, 82 | "language_info": { 83 | "codemirror_mode": { 84 | "name": "ipython", 85 | "version": 3 86 | }, 87 | "file_extension": ".py", 88 | "mimetype": "text/x-python", 89 | "name": "python", 90 | "nbconvert_exporter": "python", 91 | "pygments_lexer": "ipython3", 92 | "version": "3.6.2" 93 | } 94 | }, 95 | "nbformat": 4, 96 | "nbformat_minor": 2 97 | } 98 | -------------------------------------------------------------------------------- /白盒/Universal/.ipynb_checkpoints/UniversalAttack-checkpoint.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import tensorflow as tf\n", 10 | "import numpy as np\n", 11 | "from tensorflow.examples.tutorials.mnist import input_data\n", 12 | "from tensorflow.python.framework import graph_util\n", 13 | "from tensorflow.python.platform import gfile\n", 14 | "import os\n", 15 | "pb_file_path=\"tensorflow_mnist_graph.pb\" # 模型文件\n", 16 | "mnist=input_data.read_data_sets('MNIST_data/',one_hot=True) # mnist 数据\n", 17 | "# 预测用的会话\n", 18 | "persisted_sess = tf.Session()\n", 19 | "with gfile.FastGFile(pb_file_path,'rb') as f:\n", 20 | " graph_def=tf.GraphDef()\n", 21 | " graph_def.ParseFromString(f.read())\n", 22 | " persisted_sess.graph.as_default()\n", 23 | " tf.import_graph_def(graph_def,name='')\n", 24 | "persisted_sess.graph.get_operations()\n", 25 | "# 记载输入和输出tensor\n", 26 | "persisted_input=persisted_sess.graph.get_tensor_by_name(\"input:0\")\n", 27 | "persisted_keep_prob = persisted_sess.graph.get_tensor_by_name(\"keep_prob:0\")\n", 28 | "persisted_output = persisted_sess.graph.get_tensor_by_name(\"output:0\")" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": null, 34 | "metadata": { 35 | "collapsed": true 36 | }, 37 | "outputs": [], 38 | "source": [ 39 | "print('>> Computing feedforward function...')\n", 40 | "def f(image_inp,keep_prob=1.0):\n", 41 | " return persisted_sess.run(persisted_output, \n", 42 | " feed_dict={persisted_input: image_inp,persisted_keep_prob:keep_prob})\n", 43 | "# 数据已经归一化\n", 44 | "test_x=mnist.test.images\n", 45 | "test_y=mnist.test.labels" 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": null, 51 | "metadata": { 52 | "collapsed": true 53 | }, 54 | "outputs": [], 55 | "source": [ 56 | "# 批量验证测试集的准确率\n", 57 | "from sklearn.metrics import accuracy_score\n", 58 | "y_pred=np.argmax(f(test_x),axis=1)\n", 59 | "y_true=np.argmax(test_y,axis=1)\n", 60 | "print(accuracy_score(y_true,y_pred,normalize=True))\n", 61 | "num_images=test_x.shape[0]\n", 62 | "fooling_rate=float(np.sum(y_pred!=y_true)/float(num_images))\n", 63 | "print('FOOLING RATE = ',fooling_rate)" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": null, 69 | "metadata": { 70 | "collapsed": true 71 | }, 72 | "outputs": [], 73 | "source": [ 74 | "def jacobian(y_flat,x,inds):\n", 75 | " n=10\n", 76 | " loop_vars=[\n", 77 | " tf.constant(0,tf.int32),\n", 78 | " tf.TensorArray(tf.float32,size=n)\n", 79 | " ]\n", 80 | " _,jocabian=tf.while_loop(\n", 81 | " lambda j,_:j> Computing gradient function...')\n", 198 | "def grad_fs(image_inp, indices,keep_prob=1.0): \n", 199 | " return persisted_sess.run(dydx, feed_dict={persisted_input: image_inp, inds: indices,persisted_keep_prob:keep_prob}).squeeze(axis=1)\n", 200 | "\n", 201 | "# Running universal perturbation\n", 202 | "v = universal_perturbation(X, f, grad_fs, delta=0.2,num_classes=10)" 203 | ] 204 | }, 205 | { 206 | "cell_type": "code", 207 | "execution_count": null, 208 | "metadata": { 209 | "collapsed": true 210 | }, 211 | "outputs": [], 212 | "source": [ 213 | "y_pred=np.argmax(f(test_x+v),axis=1)\n", 214 | "y_true=np.argmax(test_y,axis=1)\n", 215 | "\n", 216 | "print(accuracy_score(y_true, y_pred, normalize=True))\n", 217 | "\n", 218 | "num_images=test_x.shape[0]\n", 219 | "\n", 220 | "fooling_rate = float(np.sum(y_pred != y_true) / float(num_images))\n", 221 | "print('FOOLING RATE = ', fooling_rate)" 222 | ] 223 | } 224 | ], 225 | "metadata": { 226 | "kernelspec": { 227 | "display_name": "Python 3", 228 | "language": "python", 229 | "name": "python3" 230 | }, 231 | "language_info": { 232 | "codemirror_mode": { 233 | "name": "ipython", 234 | "version": 3 235 | }, 236 | "file_extension": ".py", 237 | "mimetype": "text/x-python", 238 | "name": "python", 239 | "nbconvert_exporter": "python", 240 | "pygments_lexer": "ipython3", 241 | "version": "3.6.2" 242 | } 243 | }, 244 | "nbformat": 4, 245 | "nbformat_minor": 2 246 | } 247 | -------------------------------------------------------------------------------- /白盒/Universal/MNIST_data/t10k-images-idx3-ubyte: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/白盒/Universal/MNIST_data/t10k-images-idx3-ubyte -------------------------------------------------------------------------------- /白盒/Universal/MNIST_data/t10k-labels-idx1-ubyte: -------------------------------------------------------------------------------- 1 | '                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             -------------------------------------------------------------------------------- /白盒/Universal/MNIST_data/train-images-idx3-ubyte: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/白盒/Universal/MNIST_data/train-images-idx3-ubyte -------------------------------------------------------------------------------- /白盒/Universal/MNIST_data/train-labels-idx1-ubyte: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FenHua/Adversarial-Examples/d8479386e041ce7a73f9cf353b5923ec3f274526/白盒/Universal/MNIST_data/train-labels-idx1-ubyte -------------------------------------------------------------------------------- /白盒/Universal/UniversalAttack.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import tensorflow as tf\n", 10 | "import numpy as np\n", 11 | "from tensorflow.examples.tutorials.mnist import input_data\n", 12 | "from tensorflow.python.framework import graph_util\n", 13 | "from tensorflow.python.platform import gfile\n", 14 | "import os\n", 15 | "pb_file_path=\"tensorflow_mnist_graph.pb\" # 模型文件\n", 16 | "mnist=input_data.read_data_sets('MNIST_data/',one_hot=True) # mnist 数据\n", 17 | "# 预测用的会话\n", 18 | "persisted_sess = tf.Session()\n", 19 | "with gfile.FastGFile(pb_file_path,'rb') as f:\n", 20 | " graph_def=tf.GraphDef()\n", 21 | " graph_def.ParseFromString(f.read())\n", 22 | " persisted_sess.graph.as_default()\n", 23 | " tf.import_graph_def(graph_def,name='')\n", 24 | "persisted_sess.graph.get_operations()\n", 25 | "# 记载输入和输出tensor\n", 26 | "persisted_input=persisted_sess.graph.get_tensor_by_name(\"input:0\")\n", 27 | "persisted_keep_prob = persisted_sess.graph.get_tensor_by_name(\"keep_prob:0\")\n", 28 | "persisted_output = persisted_sess.graph.get_tensor_by_name(\"output:0\")" 29 | ] 30 | }, 31 | { 32 | "cell_type": "code", 33 | "execution_count": null, 34 | "metadata": { 35 | "collapsed": true 36 | }, 37 | "outputs": [], 38 | "source": [ 39 | "print('>> Computing feedforward function...')\n", 40 | "def f(image_inp,keep_prob=1.0):\n", 41 | " return persisted_sess.run(persisted_output, \n", 42 | " feed_dict={persisted_input: image_inp,persisted_keep_prob:keep_prob})\n", 43 | "# 数据已经归一化\n", 44 | "test_x=mnist.test.images\n", 45 | "test_y=mnist.test.labels" 46 | ] 47 | }, 48 | { 49 | "cell_type": "code", 50 | "execution_count": null, 51 | "metadata": { 52 | "collapsed": true 53 | }, 54 | "outputs": [], 55 | "source": [ 56 | "# 批量验证测试集的准确率\n", 57 | "from sklearn.metrics import accuracy_score\n", 58 | "y_pred=np.argmax(f(test_x),axis=1)\n", 59 | "y_true=np.argmax(test_y,axis=1)\n", 60 | "print(accuracy_score(y_true,y_pred,normalize=True))\n", 61 | "num_images=test_x.shape[0]\n", 62 | "fooling_rate=float(np.sum(y_pred!=y_true)/float(num_images))\n", 63 | "print('FOOLING RATE = ',fooling_rate)" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": null, 69 | "metadata": { 70 | "collapsed": true 71 | }, 72 | "outputs": [], 73 | "source": [ 74 | "def jacobian(y_flat,x,inds):\n", 75 | " n=10\n", 76 | " loop_vars=[\n", 77 | " tf.constant(0,tf.int32),\n", 78 | " tf.TensorArray(tf.float32,size=n)\n", 79 | " ]\n", 80 | " _,jocabian=tf.while_loop(\n", 81 | " lambda j,_:j> Computing gradient function...')\n", 198 | "def grad_fs(image_inp, indices,keep_prob=1.0): \n", 199 | " return persisted_sess.run(dydx, feed_dict={persisted_input: image_inp, inds: indices,persisted_keep_prob:keep_prob}).squeeze(axis=1)\n", 200 | "\n", 201 | "# Running universal perturbation\n", 202 | "v = universal_perturbation(X, f, grad_fs, delta=0.2,num_classes=10)" 203 | ] 204 | }, 205 | { 206 | "cell_type": "code", 207 | "execution_count": null, 208 | "metadata": { 209 | "collapsed": true 210 | }, 211 | "outputs": [], 212 | "source": [ 213 | "y_pred=np.argmax(f(test_x+v),axis=1)\n", 214 | "y_true=np.argmax(test_y,axis=1)\n", 215 | "\n", 216 | "print(accuracy_score(y_true, y_pred, normalize=True))\n", 217 | "\n", 218 | "num_images=test_x.shape[0]\n", 219 | "\n", 220 | "fooling_rate = float(np.sum(y_pred != y_true) / float(num_images))\n", 221 | "print('FOOLING RATE = ', fooling_rate)" 222 | ] 223 | } 224 | ], 225 | "metadata": { 226 | "kernelspec": { 227 | "display_name": "Python 3", 228 | "language": "python", 229 | "name": "python3" 230 | }, 231 | "language_info": { 232 | "codemirror_mode": { 233 | "name": "ipython", 234 | "version": 3 235 | }, 236 | "file_extension": ".py", 237 | "mimetype": "text/x-python", 238 | "name": "python", 239 | "nbconvert_exporter": "python", 240 | "pygments_lexer": "ipython3", 241 | "version": "3.6.2" 242 | } 243 | }, 244 | "nbformat": 4, 245 | "nbformat_minor": 2 246 | } 247 | -------------------------------------------------------------------------------- /白盒/UniversalAttack/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | # data 107 | running_images/ 108 | -------------------------------------------------------------------------------- /白盒/UniversalAttack/DeepFool/Python/README.md: -------------------------------------------------------------------------------- 1 | # DeepFool 2 | DeepFool is a simple algorithm to find the minimum adversarial perturbations in deep networks 3 | 4 | ### deepfool.py 5 | 6 | This function implements the algorithm proposed in [[1]](http://arxiv.org/pdf/1511.04599) using PyTorch to find adversarial perturbations. 7 | 8 | __Note__: The final softmax (loss) layer should be removed in order to prevent numerical instabilities. 9 | 10 | The parameters of the function are: 11 | 12 | - `image`: Image of size `HxWx3d` 13 | - `net`: neural network (input: images, output: values of activation **BEFORE** softmax). 14 | - `num_classes`: limits the number of classes to test against, by default = 10. 15 | - `max_iter`: max number of iterations, by default = 50. 16 | 17 | ### test_deepfool.py 18 | 19 | A simple demo which computes the adversarial perturbation for a test image from ImageNet dataset. 20 | 21 | ## Reference 22 | [1] S. Moosavi-Dezfooli, A. Fawzi, P. Frossard: 23 | *DeepFool: a simple and accurate method to fool deep neural networks*. In Computer Vision and Pattern Recognition (CVPR ’16), IEEE, 2016. 24 | -------------------------------------------------------------------------------- /白盒/UniversalAttack/DeepFool/Python/deepfool.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from torch.autograd import Variable 3 | import torch as torch 4 | import copy 5 | from torch.autograd.gradcheck import zero_gradients 6 | 7 | 8 | def deepfool(image, net, device, num_classes=10, overshoot=0.02, max_iter=50): 9 | 10 | """ 11 | :param image: Image of size HxWx3 12 | :param net: network (input: images, output: values of activation **BEFORE** softmax). 13 | :param num_classes: num_classes (limits the number of classes to test against, by default = 10) 14 | :param overshoot: used as a termination criterion to prevent vanishing updates (default = 0.02). 15 | :param max_iter: maximum number of iterations for deepfool (default = 50) 16 | :return: minimal perturbation that fools the classifier, number of iterations that it required, new estimated_label and perturbed image 17 | """ 18 | image = image.to(device) 19 | net = net.to(device) 20 | 21 | f_image = net.forward(image.unsqueeze(0)).detach().cpu().numpy().flatten() 22 | I = (np.array(f_image)).flatten().argsort()[::-1] 23 | 24 | I = I[0:num_classes] 25 | label = I[0] 26 | 27 | input_shape = image.shape 28 | pert_image = image 29 | 30 | w = np.zeros(input_shape) 31 | r_tot = np.zeros(input_shape) 32 | 33 | loop_i = 0 34 | 35 | x = pert_image.unsqueeze(0) 36 | x.requires_grad_() 37 | 38 | fs = net.forward(x) 39 | fs_list = [fs[0,I[k]] for k in range(num_classes)] 40 | k_i = label 41 | 42 | while k_i == label and loop_i < max_iter: 43 | 44 | pert = np.inf 45 | fs[0, I[0]].backward(retain_graph=True) 46 | grad_orig = x.grad.data.cpu().numpy().copy() 47 | 48 | for k in range(1, num_classes): 49 | zero_gradients(x) 50 | 51 | fs[0, I[k]].backward(retain_graph=True) 52 | cur_grad = x.grad.data.cpu().numpy().copy() 53 | 54 | # set new w_k and new f_k 55 | w_k = cur_grad - grad_orig 56 | f_k = (fs[0, I[k]] - fs[0, I[0]]).data.cpu().numpy() 57 | 58 | pert_k = abs(f_k)/np.linalg.norm(w_k.flatten()) 59 | 60 | # determine which w_k to use 61 | if pert_k < pert: 62 | pert = pert_k 63 | w = w_k 64 | 65 | # compute r_i and r_tot 66 | r_i = pert * w / np.linalg.norm(w) 67 | r_tot = np.float32(r_tot + r_i) 68 | 69 | pert_image = image + (1+overshoot)*torch.from_numpy(r_tot).to(device) 70 | 71 | x = pert_image 72 | x.requires_grad_() 73 | fs=net.forward(x) 74 | k_i = np.argmax(fs.data.cpu().numpy().flatten()) 75 | 76 | loop_i += 1 77 | 78 | r_tot = (1+overshoot)*r_tot 79 | 80 | return r_tot, loop_i, label, k_i, pert_image -------------------------------------------------------------------------------- /白盒/UniversalAttack/LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /白盒/UniversalAttack/README.md: -------------------------------------------------------------------------------- 1 | # Universal_Adversarial_Perturbation_pytorch 2 | A PyTorch Implementation of the UAP attack 3 | 4 | [Universal Adversarial Perturbation](https://arxiv.org/pdf/1610.08401.pdf): Moosavi-Dezfooli, Seyed-Mohsen, Alhussein Fawzi, Omar Fawzi, and Pascal Frossard. "Universal adversarial perturbations." arXiv preprint (2017). 5 | 6 | DeepFool implementation adapted from: [LTS4/DeepFool](https://github.com/LTS4/DeepFool/tree/master/Python) 7 | -------------------------------------------------------------------------------- /白盒/UniversalAttack/attack.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "import time\n", 12 | "import random\n", 13 | "import numpy as np\n", 14 | "import torch.nn as nn\n", 15 | "from PIL import Image\n", 16 | "import torchvision.models as models\n", 17 | "import torchvision.transforms as transforms\n", 18 | "from DeepFool.Python.deepfool import deepfool\n", 19 | "from torch.autograd.gradcheck import zero_gradients\n", 20 | "def get_model(device):\n", 21 | " net=models.vgg16(pretrained=True)\n", 22 | " net.eval()\n", 23 | " net=net.to(device)\n", 24 | " return net\n", 25 | "def data_input_init(xi):\n", 26 | " mean = [ 0.485, 0.456, 0.406 ]\n", 27 | " std = [ 0.229, 0.224, 0.225 ]\n", 28 | " transform = transforms.Compose([\n", 29 | " transforms.Resize(256),\n", 30 | " transforms.CenterCrop(224),\n", 31 | " transforms.ToTensor(),\n", 32 | " transforms.Normalize(mean = mean,\n", 33 | " std = std)])\n", 34 | " return (mean,std,transform)\n", 35 | "def proj_lp(v,xi,p):\n", 36 | " # 映射到p阶范式球形上,球的中心是0,半径为xi\n", 37 | " if p==np.inf:\n", 38 | " v=torch.clamp(v,-xi,xi) # 无穷范式\n", 39 | " else:\n", 40 | " v=v*min(1,xi/(torch.norm(v,p)+0.00001))\n", 41 | " return v\n", 42 | "def get_fooling_rate(data_list,v,model,device):\n", 43 | " # data_list 输入图片的路经\n", 44 | " # v: Noise matrix\n", 45 | " # model: 目标网络\n", 46 | " # device: 计算设备\n", 47 | " tf = data_input_init(0)[2]\n", 48 | " num_images = len(data_list)\n", 49 | " fooled=0.0\n", 50 | " for name in tqdm(data_list):\n", 51 | " image = Image.open(name)\n", 52 | " image =tf(image)\n", 53 | " image=image.unsqueeze(0)\n", 54 | " image=image.to(device)\n", 55 | " _,pred = torch.max(model(image),1)\n", 56 | " _,adv_pred = torch.max(model(image+v),1)\n", 57 | " if(pred != adv_pred):\n", 58 | " fooled+=1\n", 59 | " # 计算愚弄成功率\n", 60 | " fooling_rate = fooled/num_images\n", 61 | " print('Fooling Rate = ',fooling_rate)\n", 62 | " for param in model.parameters():\n", 63 | " # 冻结梯度更新\n", 64 | " param.requires_grad = False\n", 65 | " return fooling_rate,model\n", 66 | "def universal_adversarial_perturbation(data_list,model,device,xi=10,\n", 67 | " delta=0.2,max_iter_uni=10,p=np.inf,\n", 68 | " num_classes=10,overshoot=0.02,\n", 69 | " max_iter_df=10,t_p=0.2):\n", 70 | " '''\n", 71 | " data_list: 图像路经\n", 72 | " model:目标模型\n", 73 | " device:计算设备\n", 74 | " xi:控制着p阶范式的扰动程度\n", 75 | " delta: 控制愚弄率,默认80%\n", 76 | " max_iter_uni: 最大迭代次数\n", 77 | " p: 正则化阶数\n", 78 | " num_classes 用于deepfool,限制测试的类别,默认为10\n", 79 | " overshoot:用于deepfool,防止无效更新\n", 80 | " max_iter_df:最大的deepfool的迭代次数\n", 81 | " t_p:用于deepfool,真实的比例,默认为0.2\n", 82 | " 函数返回通用扰动矩阵\n", 83 | " '''\n", 84 | " time_start=time.time()\n", 85 | " mean,std,tf=data_input_init(xi)\n", 86 | " v=torch.zeros(1,3,224,224).to(device)\n", 87 | " v.requires_grad_()\n", 88 | " fooling_rate=0.0\n", 89 | " num_images = len(data_list)\n", 90 | " itr = 0\n", 91 | " while fooling_rate<1-delta and itr 1.0:\n", 33 | " original_img=original_img/255.0\n", 34 | " if adversarial_img.any() > 1.0:\n", 35 | " adversarial_img=adversarial_img/255.0\n", 36 | "\n", 37 | " plt.subplot(131)\n", 38 | " plt.title('Original')\n", 39 | " plt.imshow(original_img)\n", 40 | " plt.axis('off')\n", 41 | "\n", 42 | " plt.subplot(132)\n", 43 | " plt.title('Adversarial')\n", 44 | " plt.imshow(adversarial_img)\n", 45 | " plt.axis('off')\n", 46 | "\n", 47 | " plt.subplot(133)\n", 48 | " plt.title('Adversarial-Original')\n", 49 | " difference = adversarial_img - original_img\n", 50 | " #(-1,1) -> (0,1)\n", 51 | " difference=difference / abs(difference).max()/2.0+0.5\n", 52 | " plt.imshow(difference,cmap=plt.cm.gray)\n", 53 | " plt.axis('off')\n", 54 | " plt.tight_layout()\n", 55 | " plt.show()\n", 56 | "# 获取计算设备\n", 57 | "device=torch.device('cuda'if torch.cuda.is_available() else 'cpu')\n", 58 | "#图像加载以及预处理\n", 59 | "image_path=\"../picture/horse.jpeg\"\n", 60 | "orig = cv2.imread(image_path)[..., ::-1]\n", 61 | "orig = cv2.resize(orig, (224, 224))\n", 62 | "img=orig.copy().astype(np.float32)\n", 63 | "mean = [0.485, 0.456, 0.406]\n", 64 | "std = [0.229, 0.224, 0.225]\n", 65 | "img /= 255.0\n", 66 | "img = (img - mean) / std\n", 67 | "img=img.transpose(2,0,1)\n", 68 | "img=np.expand_dims(img,axis=0)\n", 69 | "img=Variable(torch.from_numpy(img).to(device).float())\n", 70 | "model=models.alexnet(pretrained=True).to(device).eval()\n", 71 | "orig_label=np.argmax(model(img).data.cpu().numpy())\n", 72 | "print('orig_label={}'.format(orig_label))" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": 4, 78 | "metadata": { 79 | "collapsed": true 80 | }, 81 | "outputs": [], 82 | "source": [ 83 | "# Saliency map\n", 84 | "# 此方法为beta参数的简化版本,注重攻击目标贡献大的点\n", 85 | "def saliency_map(F,x,t,mask):\n", 86 | " # F 为模型的输出\n", 87 | " # t 为攻击的类别\n", 88 | " # x 表示输入的图像\n", 89 | " # mask 标记位,记录已经访问的点的坐标\n", 90 | " F[0,t].backward(retain_graph=True)\n", 91 | " derivative=x.grad.data.cpu().numpy().copy()\n", 92 | " alphas=derivative*mask # 预测 对攻击目标的贡献\n", 93 | " betas=-np.ones_like(alphas) # 预测对非攻击目标的贡献\n", 94 | " sal_map=np.abs(alphas)*np.abs(betas)*np.sign(alphas*betas)\n", 95 | " idx=np.argmin(sal_map) # 最佳像素和扰动方向\n", 96 | " idx=np.unravel_index(idx,mask.shape) # 转换成(p1,p2)格式\n", 97 | " pix_sign=np.sign(alphas)[idx]\n", 98 | " return idx,pix_sign" 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": 8, 104 | "metadata": {}, 105 | "outputs": [ 106 | { 107 | "name": "stdout", 108 | "output_type": "stream", 109 | "text": [ 110 | "epoch=0 label=708 loss=10.877062797546387\n", 111 | "idx=(0, 1, 68, 111) over 6.442296981811523\n", 112 | "epoch=1 label=708 loss=10.73783016204834\n", 113 | "idx=(0, 1, 91, 81) over 6.550559997558594\n", 114 | "epoch=2 label=708 loss=10.609870910644531\n", 115 | "epoch=3 label=708 loss=10.493537902832031\n", 116 | "epoch=4 label=708 loss=10.32066535949707\n", 117 | "idx=(0, 1, 119, 92) over 4.274649620056152\n", 118 | "epoch=5 label=708 loss=10.159882545471191\n", 119 | "epoch=6 label=708 loss=10.056227684020996\n", 120 | "epoch=7 label=708 loss=9.946487426757812\n", 121 | "epoch=8 label=708 loss=9.85370922088623\n", 122 | "epoch=9 label=708 loss=9.754996299743652\n", 123 | "epoch=10 label=708 loss=9.689464569091797\n", 124 | "epoch=11 label=708 loss=9.55824089050293\n", 125 | "epoch=12 label=708 loss=9.371283531188965\n", 126 | "epoch=13 label=708 loss=9.216536521911621\n", 127 | "epoch=14 label=708 loss=9.074386596679688\n", 128 | "idx=(0, 1, 101, 162) over 3.1574230194091797\n", 129 | "epoch=15 label=708 loss=8.930526733398438\n", 130 | "epoch=16 label=708 loss=8.847480773925781\n", 131 | "epoch=17 label=708 loss=8.76241683959961\n", 132 | "epoch=18 label=708 loss=8.656790733337402\n", 133 | "epoch=19 label=708 loss=8.589019775390625\n", 134 | "idx=(0, 1, 107, 107) over 4.204621315002441\n", 135 | "epoch=20 label=51 loss=8.585227966308594\n", 136 | "epoch=21 label=51 loss=8.536836624145508\n", 137 | "epoch=22 label=51 loss=8.461435317993164\n", 138 | "epoch=23 label=51 loss=8.410560607910156\n", 139 | "idx=(0, 1, 109, 145) over 4.379692077636719\n", 140 | "epoch=24 label=364 loss=8.418410301208496\n", 141 | "idx=(0, 0, 101, 162) over 3.0404486656188965\n", 142 | "epoch=25 label=364 loss=8.325776100158691\n", 143 | "epoch=26 label=364 loss=8.296793937683105\n", 144 | "epoch=27 label=364 loss=8.281131744384766\n", 145 | "epoch=28 label=364 loss=8.216582298278809\n", 146 | "idx=(0, 0, 98, 136) over 4.53220272064209\n", 147 | "epoch=29 label=364 loss=8.19058609008789\n", 148 | "epoch=30 label=364 loss=8.196134567260742\n", 149 | "epoch=31 label=364 loss=8.22438907623291\n", 150 | "epoch=32 label=364 loss=8.171110153198242\n", 151 | "epoch=33 label=364 loss=8.069096565246582\n", 152 | "epoch=34 label=51 loss=7.974162578582764\n", 153 | "epoch=35 label=51 loss=7.879168510437012\n", 154 | "epoch=36 label=51 loss=7.757537841796875\n", 155 | "epoch=37 label=51 loss=7.719779014587402\n", 156 | "epoch=38 label=51 loss=7.712818145751953\n", 157 | "epoch=39 label=51 loss=7.605422019958496\n", 158 | "epoch=40 label=51 loss=7.512378692626953\n", 159 | "epoch=41 label=51 loss=7.458972930908203\n", 160 | "epoch=42 label=51 loss=7.52679967880249\n", 161 | "epoch=43 label=51 loss=7.419553279876709\n", 162 | "epoch=44 label=51 loss=7.331740856170654\n", 163 | "epoch=45 label=51 loss=7.3014044761657715\n", 164 | "epoch=46 label=51 loss=7.335504055023193\n", 165 | "epoch=47 label=51 loss=7.22821044921875\n", 166 | "epoch=48 label=51 loss=7.142072677612305\n", 167 | "epoch=49 label=51 loss=7.287581920623779\n", 168 | "epoch=50 label=51 loss=7.129010200500488\n", 169 | "idx=(0, 0, 100, 138) over 4.258206844329834\n", 170 | "epoch=51 label=51 loss=7.112462997436523\n", 171 | "idx=(0, 1, 100, 138) over 4.362184524536133\n", 172 | "epoch=52 label=51 loss=7.227566242218018\n", 173 | "epoch=53 label=51 loss=7.08453893661499\n", 174 | "epoch=54 label=51 loss=6.921497821807861\n", 175 | "epoch=55 label=51 loss=6.790563583374023\n", 176 | "epoch=56 label=51 loss=6.680903434753418\n", 177 | "epoch=57 label=51 loss=6.625180721282959\n", 178 | "idx=(0, 0, 109, 145) over 4.275331497192383\n", 179 | "epoch=58 label=51 loss=6.436946392059326\n", 180 | "epoch=59 label=51 loss=6.4111104011535645\n", 181 | "epoch=60 label=51 loss=6.3189005851745605\n", 182 | "epoch=61 label=51 loss=6.194986343383789\n", 183 | "epoch=62 label=51 loss=6.107163429260254\n", 184 | "epoch=63 label=51 loss=6.045999050140381\n", 185 | "epoch=64 label=51 loss=5.987514019012451\n", 186 | "epoch=65 label=51 loss=5.891438961029053\n", 187 | "epoch=66 label=51 loss=5.690794944763184\n", 188 | "epoch=67 label=51 loss=5.518342018127441\n", 189 | "epoch=68 label=51 loss=5.409573554992676\n", 190 | "epoch=69 label=51 loss=5.302094459533691\n", 191 | "epoch=70 label=51 loss=5.208126068115234\n", 192 | "epoch=71 label=51 loss=5.143712997436523\n", 193 | "epoch=72 label=51 loss=5.0477423667907715\n", 194 | "idx=(0, 0, 122, 152) over 4.395205020904541\n", 195 | "epoch=73 label=51 loss=4.998594760894775\n", 196 | "epoch=74 label=51 loss=4.874507904052734\n", 197 | "epoch=75 label=51 loss=4.7626872062683105\n", 198 | "idx=(0, 1, 100, 158) over 3.9802520275115967\n", 199 | "epoch=76 label=51 loss=4.684852123260498\n", 200 | "idx=(0, 0, 100, 158) over 3.8453121185302734\n", 201 | "epoch=77 label=51 loss=4.514315128326416\n", 202 | "epoch=78 label=51 loss=4.472990036010742\n", 203 | "epoch=79 label=51 loss=4.331677436828613\n", 204 | "epoch=80 label=51 loss=4.260552406311035\n", 205 | "epoch=81 label=51 loss=4.0974578857421875\n", 206 | "epoch=82 label=51 loss=4.079051971435547\n", 207 | "epoch=83 label=51 loss=4.008029937744141\n", 208 | "epoch=84 label=51 loss=3.9733781814575195\n", 209 | "epoch=85 label=51 loss=3.9497289657592773\n", 210 | "epoch=86 label=51 loss=3.902484893798828\n", 211 | "epoch=87 label=51 loss=3.817145347595215\n", 212 | "epoch=88 label=51 loss=3.7644271850585938\n", 213 | "epoch=89 label=51 loss=3.697509765625\n", 214 | "epoch=90 label=51 loss=3.604391098022461\n", 215 | "epoch=91 label=51 loss=3.4687490463256836\n", 216 | "epoch=92 label=51 loss=3.427938461303711\n", 217 | "epoch=93 label=51 loss=3.364107131958008\n", 218 | "epoch=94 label=51 loss=3.2636938095092773\n", 219 | "epoch=95 label=51 loss=3.1871204376220703\n", 220 | "epoch=96 label=51 loss=3.1775598526000977\n", 221 | "epoch=97 label=51 loss=3.3098020553588867\n", 222 | "epoch=98 label=51 loss=3.2290725708007812\n", 223 | "epoch=99 label=51 loss=3.158574104309082\n", 224 | "epoch=100 label=51 loss=3.05307674407959\n", 225 | "epoch=101 label=51 loss=2.9604082107543945\n", 226 | "epoch=102 label=51 loss=2.8453025817871094\n", 227 | "epoch=103 label=51 loss=2.7262487411499023\n", 228 | "idx=(0, 0, 103, 136) over 4.480828762054443\n", 229 | "epoch=104 label=51 loss=2.64224910736084\n", 230 | "idx=(0, 0, 104, 122) over 3.87956166267395\n", 231 | "epoch=105 label=51 loss=2.536820411682129\n", 232 | "epoch=106 label=51 loss=2.4196996688842773\n", 233 | "epoch=107 label=51 loss=2.30173397064209\n", 234 | "epoch=108 label=51 loss=2.3065052032470703\n", 235 | "epoch=109 label=51 loss=2.251315116882324\n", 236 | "idx=(0, 1, 100, 144) over 4.327170372009277\n", 237 | "epoch=110 label=51 loss=2.175297737121582\n", 238 | "epoch=111 label=51 loss=2.0631160736083984\n", 239 | "idx=(0, 0, 100, 144) over 4.223957061767578\n", 240 | "epoch=112 label=51 loss=1.9604244232177734\n", 241 | "epoch=113 label=51 loss=1.9469337463378906\n", 242 | "epoch=114 label=51 loss=1.8308420181274414\n", 243 | "epoch=115 label=51 loss=1.7953052520751953\n", 244 | "epoch=116 label=51 loss=1.6912193298339844\n", 245 | "epoch=117 label=51 loss=1.6115522384643555\n", 246 | "idx=(0, 0, 105, 122) over 3.5713160037994385\n", 247 | "epoch=118 label=51 loss=1.5583915710449219\n", 248 | "epoch=119 label=51 loss=1.5074138641357422\n", 249 | "idx=(0, 1, 104, 122) over 4.015266418457031\n", 250 | "epoch=120 label=51 loss=1.4632511138916016\n", 251 | "epoch=121 label=51 loss=1.3992414474487305\n", 252 | "idx=(0, 1, 91, 124) over 3.06988787651062\n", 253 | "epoch=122 label=288 loss=1.3142623901367188\n" 254 | ] 255 | } 256 | ], 257 | "source": [ 258 | "img.requires_grad=True\n", 259 | "for param in model.parameters():\n", 260 | " param.requires_grad=False\n", 261 | "epochs=500\n", 262 | "theta=0.3 # 扰动系数\n", 263 | "target_label=288 #攻击目标\n", 264 | "target=Variable(torch.Tensor([float(target_label)]).to(device).long())\n", 265 | "loss_func=torch.nn.CrossEntropyLoss()\n", 266 | "\n", 267 | "mask=np.ones_like(img.data.cpu().numpy()) # 定义搜索域,修改后的位置置零\n", 268 | "# 定义边界\n", 269 | "max_=3.0\n", 270 | "min_=-3.0\n", 271 | "for epoch in range(epochs):\n", 272 | " output=model(img)\n", 273 | " label=np.argmax(output.data.cpu().numpy())\n", 274 | " loss=loss_func(output,target)\n", 275 | " print('epoch={} label={} loss={}'.format(epoch,label,loss))\n", 276 | " if label==target_label:\n", 277 | " break # 攻击成功\n", 278 | " zero_gradients(img) # 梯度清零\n", 279 | " idx,pix_sign=saliency_map(output,img,target_label,mask)\n", 280 | " # 添加扰动\n", 281 | " img.data[idx]=img.data[idx]+pix_sign*theta*(max_ - min_)\n", 282 | " # 达到极限的点不再参与更新\n", 283 | " if(img.data[idx] <= min_)or(img.data[idx] >= max_):\n", 284 | " print('idx={} over {}'.format(idx,img.data[idx]))\n", 285 | " mask[idx]=0\n", 286 | " img.data.cpu()[idx]=np.clip(img.data.cpu()[idx],min_,max_)" 287 | ] 288 | }, 289 | { 290 | "cell_type": "code", 291 | "execution_count": 11, 292 | "metadata": {}, 293 | "outputs": [ 294 | { 295 | "name": "stdout", 296 | "output_type": "stream", 297 | "text": [ 298 | "(3, 224, 224)\n" 299 | ] 300 | }, 301 | { 302 | "data": { 303 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAagAAACTCAYAAADbeI0aAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3XmYnFWV+PHvrb2qq3pLN+l09pCEJURBiSjgRAUii6MMgjOCOqDiDxR/o4PjMDgDEWYY5VEcZmRNhiiyOArzAwYUhqAYSAJJyEpWOun0vlR1V9e+1/39Uf1eurMnpOlK9/k8Tx5CLW+9VXVyz61773uu0lojhBBClBvbaJ+AEEIIcSCSoIQQQpQlSVBCCCHKkiQoIYQQZUkSlBBCiLIkCUoIIURZkgR1hJRStyqllh7vxx7BsbRSavbxOJY4ckqpa5VSr4/2eRyOUupBpdQ/HeFjX1VKfX2kz2m0yXc3YudwxI89zHFmDLZrjsM99rAPGKuUUtcCNwMnA1Hg/wH/oLUeONDjtdZ3Hemxj+ax4v2nlHoV+CDQoLXOjPLpvCda6xtG+xzeT/LdHZhSSgHfA74BTAGCwBPA7Yf6nI7mHEYj1sblLyil1M3Aj4G/A6qAjwLTgZeVUq4DPH7cJvKxRik1A/g4oIHPjsL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iiXyzFlyhQ2b95MLBYzy3yt0jTpdJqLLrrIzENY5Wt27tzJrFmzTPmaTCZDPp8nHA4TiURMDzkej5u5Bqu4qHWtTDqdZteuXTgc4/rre19IjAgxesbtEJ9VV2337t18+9vfxuVyma24rRI21gWRhUKBfD5v5hoKhQKNjY288cYbZsfUhoYGnE4nM2bMIJfLcemll/KpT31q2Kqq9vZ2KisrSaVStLe309TUREdHB83NzYRCIXNO1uovp9PJhAkTTHFZKK3CWr9+vVliLEaOxIgQo2vcdq+efvppisUi7e3tvPHGG5x88sncd999PP744xSLRRKJBNFolFgsxubNm/F6vUCp0TrvvPOYN2+eqce2du1aMpmMWd11yy23cPrpp/P73/+evr4+otGoGYqxJritMjlQWsFVKBTYtWsXEydONHMIWmtqamro7+8317CsX7/e/F2MLIkRIUbXuPwFpbUmFArhdruZNm0aa9as4b//+79ZtWoVfX19Zg4A4O2338bj8ZjnKqX4y7/8Szo7O3G73WzevJmFCxeajeOuu+466uvref7552ltbcVut1NZWUkmk+Hkk09m1qxZOBwO6urqOPfcc2lpaWHnzp1s377dNDpQKptjVS5wuVz4/X7WrVsnDc/7RGJEiNE3Ln9Bvf766yxYsIBvfetbLFiwgC1btgDgdDpNNeqenh5Wrly531X8X/rSl5g8eTJKKVpaWti7dy9vvvkmhUKB73znO1RVVfHqq6+aSfBEImF2Zd27d6+ZvygWizz22GPmYkyHw8E999wDYFZseb1eKioqiMfjxONxM5kuRp7EiBCjb9z9grK2HOjs7GTatGm888475vYNGzaQSCRwOp2kUim8Xu+whsfaTrumpgaHw8GOHTvo7u5Ga80111xDKpWivr6ejo4OkskkWuthK6m8Xq+pVm1dqDvUT37yE3NtjFV9wDrOtm3b9qsCIFWnR4bEiBDlYVwlKK01d999Nx0dHdx66608+uijvPjii2itWbp0KbW1taxatYpiscjq1auHPfeUU07h0UcfJZPJ0N3dzdq1a9mwYQPhcJh///d/J5lMEgwGuf/++5kxYwaBQICVK1eyZcsWKisrh63+stls1NbW8qUvfWnYawytn2bt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 308 | "metadata": {}, 309 | "output_type": "display_data" 310 | } 311 | ], 312 | "source": [ 313 | "adv=img.data.cpu().numpy()[0]\n", 314 | "print(adv.shape)\n", 315 | "adv = adv.transpose(1, 2, 0)\n", 316 | "adv = (adv * std) + mean\n", 317 | "\n", 318 | "adv = adv * 256.0\n", 319 | "adv = np.clip(adv, 0, 255).astype(np.uint8)\n", 320 | "\n", 321 | "show_images_diff(orig,orig_label,adv,target_label)" 322 | ] 323 | }, 324 | { 325 | "cell_type": "code", 326 | "execution_count": null, 327 | "metadata": { 328 | "collapsed": true 329 | }, 330 | "outputs": [], 331 | "source": [] 332 | } 333 | ], 334 | "metadata": { 335 | "kernelspec": { 336 | "display_name": "Python 3", 337 | "language": "python", 338 | "name": "python3" 339 | }, 340 | "language_info": { 341 | "codemirror_mode": { 342 | "name": "ipython", 343 | "version": 3 344 | }, 345 | "file_extension": ".py", 346 | "mimetype": "text/x-python", 347 | "name": "python", 348 | "nbconvert_exporter": "python", 349 | "pygments_lexer": "ipython3", 350 | "version": "3.6.8" 351 | } 352 | }, 353 | "nbformat": 4, 354 | "nbformat_minor": 2 355 | } 356 | -------------------------------------------------------------------------------- /黑盒/JSMA/JSMA.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 3, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "orig_label=708\n" 13 | ] 14 | } 15 | ], 16 | "source": [ 17 | "# 基于l0范式,JSMA\n", 18 | "import torch\n", 19 | "import torchvision\n", 20 | "from torch.autograd import Variable\n", 21 | "from torch.autograd.gradcheck import zero_gradients\n", 22 | "import torch.nn as nn\n", 23 | "from torchvision import models\n", 24 | "import numpy as np\n", 25 | "import cv2\n", 26 | "#对比展现原始图片和对抗样本图片\n", 27 | "def show_images_diff(original_img,original_label,adversarial_img,adversarial_label):\n", 28 | " import matplotlib.pyplot as plt\n", 29 | " plt.figure()\n", 30 | "\n", 31 | " #归一化\n", 32 | " if original_img.any() > 1.0:\n", 33 | " original_img=original_img/255.0\n", 34 | " if adversarial_img.any() > 1.0:\n", 35 | " adversarial_img=adversarial_img/255.0\n", 36 | "\n", 37 | " plt.subplot(131)\n", 38 | " plt.title('Original')\n", 39 | " plt.imshow(original_img)\n", 40 | " plt.axis('off')\n", 41 | "\n", 42 | " plt.subplot(132)\n", 43 | " plt.title('Adversarial')\n", 44 | " plt.imshow(adversarial_img)\n", 45 | " plt.axis('off')\n", 46 | "\n", 47 | " plt.subplot(133)\n", 48 | " plt.title('Adversarial-Original')\n", 49 | " difference = adversarial_img - original_img\n", 50 | " #(-1,1) -> (0,1)\n", 51 | " difference=difference / abs(difference).max()/2.0+0.5\n", 52 | " plt.imshow(difference,cmap=plt.cm.gray)\n", 53 | " plt.axis('off')\n", 54 | " plt.tight_layout()\n", 55 | " plt.show()\n", 56 | "# 获取计算设备\n", 57 | "device=torch.device('cuda'if torch.cuda.is_available() else 'cpu')\n", 58 | "#图像加载以及预处理\n", 59 | "image_path=\"../picture/horse.jpeg\"\n", 60 | "orig = cv2.imread(image_path)[..., ::-1]\n", 61 | "orig = cv2.resize(orig, (224, 224))\n", 62 | "img=orig.copy().astype(np.float32)\n", 63 | "mean = [0.485, 0.456, 0.406]\n", 64 | "std = [0.229, 0.224, 0.225]\n", 65 | "img /= 255.0\n", 66 | "img = (img - mean) / std\n", 67 | "img=img.transpose(2,0,1)\n", 68 | "img=np.expand_dims(img,axis=0)\n", 69 | "img=Variable(torch.from_numpy(img).to(device).float())\n", 70 | "model=models.alexnet(pretrained=True).to(device).eval()\n", 71 | "orig_label=np.argmax(model(img).data.cpu().numpy())\n", 72 | "print('orig_label={}'.format(orig_label))" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": 4, 78 | "metadata": { 79 | "collapsed": true 80 | }, 81 | "outputs": [], 82 | "source": [ 83 | "# Saliency map\n", 84 | "# 此方法为beta参数的简化版本,注重攻击目标贡献大的点\n", 85 | "def saliency_map(F,x,t,mask):\n", 86 | " # F 为模型的输出\n", 87 | " # t 为攻击的类别\n", 88 | " # x 表示输入的图像\n", 89 | " # mask 标记位,记录已经访问的点的坐标\n", 90 | " F[0,t].backward(retain_graph=True)\n", 91 | " derivative=x.grad.data.cpu().numpy().copy()\n", 92 | " alphas=derivative*mask # 预测 对攻击目标的贡献\n", 93 | " betas=-np.ones_like(alphas) # 预测对非攻击目标的贡献\n", 94 | " sal_map=np.abs(alphas)*np.abs(betas)*np.sign(alphas*betas)\n", 95 | " idx=np.argmin(sal_map) # 最佳像素和扰动方向\n", 96 | " idx=np.unravel_index(idx,mask.shape) # 转换成(p1,p2)格式\n", 97 | " pix_sign=np.sign(alphas)[idx]\n", 98 | " return idx,pix_sign" 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": 8, 104 | "metadata": {}, 105 | "outputs": [ 106 | { 107 | "name": "stdout", 108 | "output_type": "stream", 109 | "text": [ 110 | "epoch=0 label=708 loss=10.877062797546387\n", 111 | "idx=(0, 1, 68, 111) over 6.442296981811523\n", 112 | "epoch=1 label=708 loss=10.73783016204834\n", 113 | "idx=(0, 1, 91, 81) over 6.550559997558594\n", 114 | "epoch=2 label=708 loss=10.609870910644531\n", 115 | "epoch=3 label=708 loss=10.493537902832031\n", 116 | "epoch=4 label=708 loss=10.32066535949707\n", 117 | "idx=(0, 1, 119, 92) over 4.274649620056152\n", 118 | "epoch=5 label=708 loss=10.159882545471191\n", 119 | "epoch=6 label=708 loss=10.056227684020996\n", 120 | "epoch=7 label=708 loss=9.946487426757812\n", 121 | "epoch=8 label=708 loss=9.85370922088623\n", 122 | "epoch=9 label=708 loss=9.754996299743652\n", 123 | "epoch=10 label=708 loss=9.689464569091797\n", 124 | "epoch=11 label=708 loss=9.55824089050293\n", 125 | "epoch=12 label=708 loss=9.371283531188965\n", 126 | "epoch=13 label=708 loss=9.216536521911621\n", 127 | "epoch=14 label=708 loss=9.074386596679688\n", 128 | "idx=(0, 1, 101, 162) over 3.1574230194091797\n", 129 | "epoch=15 label=708 loss=8.930526733398438\n", 130 | "epoch=16 label=708 loss=8.847480773925781\n", 131 | "epoch=17 label=708 loss=8.76241683959961\n", 132 | "epoch=18 label=708 loss=8.656790733337402\n", 133 | "epoch=19 label=708 loss=8.589019775390625\n", 134 | "idx=(0, 1, 107, 107) over 4.204621315002441\n", 135 | "epoch=20 label=51 loss=8.585227966308594\n", 136 | "epoch=21 label=51 loss=8.536836624145508\n", 137 | "epoch=22 label=51 loss=8.461435317993164\n", 138 | "epoch=23 label=51 loss=8.410560607910156\n", 139 | "idx=(0, 1, 109, 145) over 4.379692077636719\n", 140 | "epoch=24 label=364 loss=8.418410301208496\n", 141 | "idx=(0, 0, 101, 162) over 3.0404486656188965\n", 142 | "epoch=25 label=364 loss=8.325776100158691\n", 143 | "epoch=26 label=364 loss=8.296793937683105\n", 144 | "epoch=27 label=364 loss=8.281131744384766\n", 145 | "epoch=28 label=364 loss=8.216582298278809\n", 146 | "idx=(0, 0, 98, 136) over 4.53220272064209\n", 147 | "epoch=29 label=364 loss=8.19058609008789\n", 148 | "epoch=30 label=364 loss=8.196134567260742\n", 149 | "epoch=31 label=364 loss=8.22438907623291\n", 150 | "epoch=32 label=364 loss=8.171110153198242\n", 151 | "epoch=33 label=364 loss=8.069096565246582\n", 152 | "epoch=34 label=51 loss=7.974162578582764\n", 153 | "epoch=35 label=51 loss=7.879168510437012\n", 154 | "epoch=36 label=51 loss=7.757537841796875\n", 155 | "epoch=37 label=51 loss=7.719779014587402\n", 156 | "epoch=38 label=51 loss=7.712818145751953\n", 157 | "epoch=39 label=51 loss=7.605422019958496\n", 158 | "epoch=40 label=51 loss=7.512378692626953\n", 159 | "epoch=41 label=51 loss=7.458972930908203\n", 160 | "epoch=42 label=51 loss=7.52679967880249\n", 161 | "epoch=43 label=51 loss=7.419553279876709\n", 162 | "epoch=44 label=51 loss=7.331740856170654\n", 163 | "epoch=45 label=51 loss=7.3014044761657715\n", 164 | "epoch=46 label=51 loss=7.335504055023193\n", 165 | "epoch=47 label=51 loss=7.22821044921875\n", 166 | "epoch=48 label=51 loss=7.142072677612305\n", 167 | "epoch=49 label=51 loss=7.287581920623779\n", 168 | "epoch=50 label=51 loss=7.129010200500488\n", 169 | "idx=(0, 0, 100, 138) over 4.258206844329834\n", 170 | "epoch=51 label=51 loss=7.112462997436523\n", 171 | "idx=(0, 1, 100, 138) over 4.362184524536133\n", 172 | "epoch=52 label=51 loss=7.227566242218018\n", 173 | "epoch=53 label=51 loss=7.08453893661499\n", 174 | "epoch=54 label=51 loss=6.921497821807861\n", 175 | "epoch=55 label=51 loss=6.790563583374023\n", 176 | "epoch=56 label=51 loss=6.680903434753418\n", 177 | "epoch=57 label=51 loss=6.625180721282959\n", 178 | "idx=(0, 0, 109, 145) over 4.275331497192383\n", 179 | "epoch=58 label=51 loss=6.436946392059326\n", 180 | "epoch=59 label=51 loss=6.4111104011535645\n", 181 | "epoch=60 label=51 loss=6.3189005851745605\n", 182 | "epoch=61 label=51 loss=6.194986343383789\n", 183 | "epoch=62 label=51 loss=6.107163429260254\n", 184 | "epoch=63 label=51 loss=6.045999050140381\n", 185 | "epoch=64 label=51 loss=5.987514019012451\n", 186 | "epoch=65 label=51 loss=5.891438961029053\n", 187 | "epoch=66 label=51 loss=5.690794944763184\n", 188 | "epoch=67 label=51 loss=5.518342018127441\n", 189 | "epoch=68 label=51 loss=5.409573554992676\n", 190 | "epoch=69 label=51 loss=5.302094459533691\n", 191 | "epoch=70 label=51 loss=5.208126068115234\n", 192 | "epoch=71 label=51 loss=5.143712997436523\n", 193 | "epoch=72 label=51 loss=5.0477423667907715\n", 194 | "idx=(0, 0, 122, 152) over 4.395205020904541\n", 195 | "epoch=73 label=51 loss=4.998594760894775\n", 196 | "epoch=74 label=51 loss=4.874507904052734\n", 197 | "epoch=75 label=51 loss=4.7626872062683105\n", 198 | "idx=(0, 1, 100, 158) over 3.9802520275115967\n", 199 | "epoch=76 label=51 loss=4.684852123260498\n", 200 | "idx=(0, 0, 100, 158) over 3.8453121185302734\n", 201 | "epoch=77 label=51 loss=4.514315128326416\n", 202 | "epoch=78 label=51 loss=4.472990036010742\n", 203 | "epoch=79 label=51 loss=4.331677436828613\n", 204 | "epoch=80 label=51 loss=4.260552406311035\n", 205 | "epoch=81 label=51 loss=4.0974578857421875\n", 206 | "epoch=82 label=51 loss=4.079051971435547\n", 207 | "epoch=83 label=51 loss=4.008029937744141\n", 208 | "epoch=84 label=51 loss=3.9733781814575195\n", 209 | "epoch=85 label=51 loss=3.9497289657592773\n", 210 | "epoch=86 label=51 loss=3.902484893798828\n", 211 | "epoch=87 label=51 loss=3.817145347595215\n", 212 | "epoch=88 label=51 loss=3.7644271850585938\n", 213 | "epoch=89 label=51 loss=3.697509765625\n", 214 | "epoch=90 label=51 loss=3.604391098022461\n", 215 | "epoch=91 label=51 loss=3.4687490463256836\n", 216 | "epoch=92 label=51 loss=3.427938461303711\n", 217 | "epoch=93 label=51 loss=3.364107131958008\n", 218 | "epoch=94 label=51 loss=3.2636938095092773\n", 219 | "epoch=95 label=51 loss=3.1871204376220703\n", 220 | "epoch=96 label=51 loss=3.1775598526000977\n", 221 | "epoch=97 label=51 loss=3.3098020553588867\n", 222 | "epoch=98 label=51 loss=3.2290725708007812\n", 223 | "epoch=99 label=51 loss=3.158574104309082\n", 224 | "epoch=100 label=51 loss=3.05307674407959\n", 225 | "epoch=101 label=51 loss=2.9604082107543945\n", 226 | "epoch=102 label=51 loss=2.8453025817871094\n", 227 | "epoch=103 label=51 loss=2.7262487411499023\n", 228 | "idx=(0, 0, 103, 136) over 4.480828762054443\n", 229 | "epoch=104 label=51 loss=2.64224910736084\n", 230 | "idx=(0, 0, 104, 122) over 3.87956166267395\n", 231 | "epoch=105 label=51 loss=2.536820411682129\n", 232 | "epoch=106 label=51 loss=2.4196996688842773\n", 233 | "epoch=107 label=51 loss=2.30173397064209\n", 234 | "epoch=108 label=51 loss=2.3065052032470703\n", 235 | "epoch=109 label=51 loss=2.251315116882324\n", 236 | "idx=(0, 1, 100, 144) over 4.327170372009277\n", 237 | "epoch=110 label=51 loss=2.175297737121582\n", 238 | "epoch=111 label=51 loss=2.0631160736083984\n", 239 | "idx=(0, 0, 100, 144) over 4.223957061767578\n", 240 | "epoch=112 label=51 loss=1.9604244232177734\n", 241 | "epoch=113 label=51 loss=1.9469337463378906\n", 242 | "epoch=114 label=51 loss=1.8308420181274414\n", 243 | "epoch=115 label=51 loss=1.7953052520751953\n", 244 | "epoch=116 label=51 loss=1.6912193298339844\n", 245 | "epoch=117 label=51 loss=1.6115522384643555\n", 246 | "idx=(0, 0, 105, 122) over 3.5713160037994385\n", 247 | "epoch=118 label=51 loss=1.5583915710449219\n", 248 | "epoch=119 label=51 loss=1.5074138641357422\n", 249 | "idx=(0, 1, 104, 122) over 4.015266418457031\n", 250 | "epoch=120 label=51 loss=1.4632511138916016\n", 251 | "epoch=121 label=51 loss=1.3992414474487305\n", 252 | "idx=(0, 1, 91, 124) over 3.06988787651062\n", 253 | "epoch=122 label=288 loss=1.3142623901367188\n" 254 | ] 255 | } 256 | ], 257 | "source": [ 258 | "img.requires_grad=True\n", 259 | "for param in model.parameters():\n", 260 | " param.requires_grad=False\n", 261 | "epochs=500\n", 262 | "theta=0.3 # 扰动系数\n", 263 | "target_label=288 #攻击目标\n", 264 | "target=Variable(torch.Tensor([float(target_label)]).to(device).long())\n", 265 | "loss_func=torch.nn.CrossEntropyLoss()\n", 266 | "\n", 267 | "mask=np.ones_like(img.data.cpu().numpy()) # 定义搜索域,修改后的位置置零\n", 268 | "# 定义边界\n", 269 | "max_=3.0\n", 270 | "min_=-3.0\n", 271 | "for epoch in range(epochs):\n", 272 | " output=model(img)\n", 273 | " label=np.argmax(output.data.cpu().numpy())\n", 274 | " loss=loss_func(output,target)\n", 275 | " print('epoch={} label={} loss={}'.format(epoch,label,loss))\n", 276 | " if label==target_label:\n", 277 | " break # 攻击成功\n", 278 | " zero_gradients(img) # 梯度清零\n", 279 | " idx,pix_sign=saliency_map(output,img,target_label,mask)\n", 280 | " # 添加扰动\n", 281 | " img.data[idx]=img.data[idx]+pix_sign*theta*(max_ - min_)\n", 282 | " # 达到极限的点不再参与更新\n", 283 | " if(img.data[idx] <= min_)or(img.data[idx] >= max_):\n", 284 | " print('idx={} over {}'.format(idx,img.data[idx]))\n", 285 | " mask[idx]=0\n", 286 | " img.data.cpu()[idx]=np.clip(img.data.cpu()[idx],min_,max_)" 287 | ] 288 | }, 289 | { 290 | "cell_type": "code", 291 | "execution_count": 11, 292 | "metadata": {}, 293 | "outputs": [ 294 | { 295 | "name": "stdout", 296 | "output_type": "stream", 297 | "text": [ 298 | "(3, 224, 224)\n" 299 | ] 300 | }, 301 | { 302 | "data": { 303 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAagAAACTCAYAAADbeI0aAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3XmYnFWV+PHvrb2qq3pLN+l09pCEJURBiSjgRAUii6MMgjOCOqDiDxR/o4PjMDgDEWYY5VEcZmRNhiiyOArzAwYUhqAYSAJJyEpWOun0vlR1V9e+1/39Uf1eurMnpOlK9/k8Tx5CLW+9VXVyz61773uu0lojhBBClBvbaJ+AEEIIcSCSoIQQQpQlSVBCCCHKkiQoIYQQZUkSlBBCiLIkCUoIIURZkgR1hJRStyqllh7vxx7BsbRSavbxOJY4ckqpa5VSr4/2eRyOUupBpdQ/HeFjX1VKfX2kz2m0yXc3YudwxI89zHFmDLZrjsM99rAPGKuUUtcCNwMnA1Hg/wH/oLUeONDjtdZ3Hemxj+ax4v2nlHoV+CDQoLXOjPLpvCda6xtG+xzeT/LdHZhSSgHfA74BTAGCwBPA7Yf6nI7mHEYj1sblLyil1M3Aj4G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2dcJ6gVK1aYlVVWiRnr+hHrolmrgaioqGDPnj1m3iiXyzFlyhQ2b95MLBYzy3yt0jTpdJqLLrrIzENY5Wt27tzJrFmzTPmaTCZDPp8nHA4TiURMDzkej5u5Bqu4qHWtTDqdZteuXTgc4/rre19IjAgxesbtEJ9VV2337t18+9vfxuVyma24rRI21gWRhUKBfD5v5hoKhQKNjY288cYbZsfUhoYGnE4nM2bMIJfLcemll/KpT31q2Kqq9vZ2KisrSaVStLe309TUREdHB83NzYRCIXNO1uovp9PJhAkTTHFZKK3CWr9+vVliLEaOxIgQo2vcdq+efvppisUi7e3tvPHGG5x88sncd999PP744xSLRRKJBNFolFgsxubNm/F6vUCp0TrvvPOYN2+eqce2du1aMpmMWd11yy23cPrpp/P73/+evr4+otGoGYqxJritMjlQWsFVKBTYtWsXEydONHMIWmtqamro7+8317CsX7/e/F2MLIkRIUbXuPwFpbUmFArhdruZNm0aa9as4b//+79ZtWoVfX19Zg4A4O2338bj8ZjnKqX4y7/8Szo7O3G73WzevJmFCxeajeOuu+466uvref7552ltbcVut1NZWUkmk+Hkk09m1qxZOBwO6urqOPfcc2lpaWHnzp1s377dNDpQKptjVS5wuVz4/X7WrVsnDc/7RGJEiNE3Ln9Bvf766yxYsIBvfetbLFiwgC1btgDgdDpNNeqenh5Wrly531X8X/rSl5g8eTJKKVpaWti7dy9vvvkmhUKB73znO1RVVfHqq6+aSfBEImF2Zd27d6+ZvygWizz22GPmYkyHw8E999wDYFZseb1eKioqiMfjxONxM5kuRp7EiBCjb9z9grK2HOjs7GTatGm888475vYNGzaQSCRwOp2kUim8Xu+whsfaTrumpgaHw8GOHTvo7u5Ga80111xDKpWivr6ejo4OkskkWuthK6m8Xq+pVm1dqDvUT37yE3NtjFV9wDrOtm3b9qsCIFWnR4bEiBDlYVwlKK01d999Nx0dHdx66608+uijvPjii2itWbp0KbW1taxatYpiscjq1auHPfeUU07h0UcfJZPJ0N3dzdq1a9mwYQPhcJh///d/J5lMEgwGuf/++5kxY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kJggg==\n", 304 | "text/plain": [ 305 | "
" 306 | ] 307 | }, 308 | "metadata": {}, 309 | "output_type": "display_data" 310 | } 311 | ], 312 | "source": [ 313 | "adv=img.data.cpu().numpy()[0]\n", 314 | "print(adv.shape)\n", 315 | "adv = adv.transpose(1, 2, 0)\n", 316 | "adv = (adv * std) + mean\n", 317 | "\n", 318 | "adv = adv * 256.0\n", 319 | "adv = np.clip(adv, 0, 255).astype(np.uint8)\n", 320 | "\n", 321 | "show_images_diff(orig,orig_label,adv,target_label)" 322 | ] 323 | }, 324 | { 325 | "cell_type": "code", 326 | "execution_count": null, 327 | "metadata": { 328 | "collapsed": true 329 | }, 330 | "outputs": [], 331 | "source": [] 332 | } 333 | ], 334 | "metadata": { 335 | "kernelspec": { 336 | "display_name": "Python 3", 337 | "language": "python", 338 | "name": "python3" 339 | }, 340 | "language_info": { 341 | "codemirror_mode": { 342 | "name": "ipython", 343 | "version": 3 344 | }, 345 | "file_extension": ".py", 346 | "mimetype": "text/x-python", 347 | "name": "python", 348 | "nbconvert_exporter": "python", 349 | "pygments_lexer": "ipython3", 350 | "version": "3.6.8" 351 | } 352 | }, 353 | "nbformat": 4, 354 | "nbformat_minor": 2 355 | } 356 | --------------------------------------------------------------------------------