This is the official repository of Private FGSM (P-FGSM), a work published as Scene privacy protection on Proc. of IEEE Int. Conf. on Acoustics, Speech and Signal Processing (ICASSP), Brighton, UK, May 12-17, 2019.
Original Image | Adversarial image |
---|---|
![]() |
![]() |
Church (confidence: 82.6%) | Zen Garden (confidence: 99.2%) |
- Conda
- Python 2.7
- Numpy
- PyTorch
- Torchvision
- Opencv-python
- Tqdm
The code has been tested on Ubuntu 18.04 and MacOs 10.14.4.
Install miniconda: https://docs.conda.io/en/latest/miniconda.html Create conda environment for Python 2.7
conda create -n pfgsm python=2.7
Activate conda environment:
source activate pfgsm
Install requirements
pip install -r requirements.txt
Only if using MacOs:
export PATH="<pathToMiniconda>/bin:$PATH"
brew install wget
Create a folder with the images that you want to create their adversarials in <pathToImages>
Generate adversarial images executing:
python p-fgsm.py --model=<model> --path=<pathToImages>
For example:
python p-fgsm.py --model=resnet50 --path=./images
In the publication ResNet50 is used. However, other models can also be used: ResNet18, and AlexNet. The pre-trained models will download automatically on the first execution of the code.
- New adversarial folder inside the location of the input images with the generated adversarial images.
<pathToImages>/adversialimages/<imageName>.png
- log.txt file in the following order of columns (format):
- image name
- number of iterations to converge
- original class
- original class probability
- final class
- final class probability
- target class
- target class probability
If you use our code, please cite the following publication:
@InProceedings{Li2019,
Title = {Scene Privacy Protection},
Author = {C. Y. Li and A. S. Shamsabadi and R. Sanchez-Matilla and R. Mazzon and A. Cavallaro},
Booktitle = {Proc. IEEE Int. Conf. on Acoustics, Speech and Signal Processing},
Year = {2019},
Address = {Brighton, UK},
Month = May
}
The content of this project itself is licensed under the Creative Commons Non-Commercial (CC BY-NC).