facebookarchive / adversarial_image_defenses Goto Github PK
View Code? Open in Web Editor NEWCountering Adversarial Image using Input Transformations.
License: Other
Countering Adversarial Image using Input Transformations.
License: Other
faiss with openblas on Ubuntu 16.
From gdb it seems to segfault on a dynamic cast.
gdb outputs:
==============================GENERATING QUILTING PATCHES AND INDICES==============================
| Input args are:
Namespace(batchsize=256, data_params={'IMAGE_SIZE': 224, 'IMAGE_SCALE_SIZE': 256}, data_root='/tmp/adverarial_dataset', defenses=None, device='gpu', imagenet_dir='/home/ssnl/anaconda3/lib/python3.6/site-packages/adversarial/lib/../test/images', index_file='/tmp/tmp.faiss', model='resnet50', models_root='/tmp/adverarial_dataset', normalize=False, num_patches=1000000, patches_file='/tmp/tmp.pickle', pca_dims=64, pixel_drop_rate=0.5, preprocessed_data=False, pretrained=False, quantize_depth=8, quilting_index_root='/tmp/adverarial_dataset', quilting_neighbors=1, quilting_patch_root='/tmp/adverarial_dataset', quilting_patch_size=5, quilting_random_stitch=False, tar_dir='/tmp/adverarial_dataset/imagenet_transformed_tarred', tar_index_dir='/tmp/adverarial_dataset/imagenet_transformed_tarred_index', tar_prefix='tmp/imagenet_transformed', tvm_method='bregman', tvm_weight=0.03)
| set up image loader...
/home/ssnl/anaconda3/lib/python3.6/site-packages/torchvision/transforms/transforms.py:397: UserWarning: The use of the transforms.RandomSizedCrop transform is deprecated, please use transforms.RandomResizedCrop instead.
"please use transforms.RandomResizedCrop instead.")
| Loading data from /home/ssnl/anaconda3/lib/python3.6/site-packages/adversarial/lib/../test/images/train
| gather image patches...
| training faiss index...#############################################################################################################################################################################################################################################################################################|
| writing faiss index to /tmp/adverarial_dataset/index_5.faiss
Thread 1 "python" received signal SIGSEGV, Segmentation fault.
__cxxabiv1::__dynamic_cast (src_ptr=src_ptr@entry=0x555601f4fb90, src_type=0x7fff8f336b90 <typeinfo for faiss::VectorTransform>, dst_type=dst_type@entry=0x7fff8f336ba0 <typeinfo for faiss::LinearTransform>, src2dst=src2dst@entry=0)
at /opt/conda/conda-bld/compilers_linux-64_1505664199673/work/.build/src/gcc-7.2.0/libstdc++-v3/libsupc++/dyncast.cc:68
68 /opt/conda/conda-bld/compilers_linux-64_1505664199673/work/.build/src/gcc-7.2.0/libstdc++-v3/libsupc++/dyncast.cc: No such file or directory.
cc @taesung89
I installed Faiss and other packages followed instruction, but I got these errors when I try to run the demo. My environment is pytorch 0.4 and python 3.6.
Traceback (most recent call last):
File "adversarial/examples/demo.py", line 17, in
from adversarial.gen_transformed_images import generate_transformed_images
File "/home/shangqian/anaconda3/lib/python3.6/site-packages/adversarial/gen_transformed_images.py", line 14, in
from lib.defenses import get_defense
File "/home/shangqian/anaconda3/lib/python3.6/site-packages/adversarial/lib/defenses.py", line 20, in
from lib.transformations.quilting_fast import quilting
File "/home/shangqian/anaconda3/lib/python3.6/site-packages/adversarial/lib/transformations/quilting_fast.py", line 17, in
QUILTING_LIB = ctypes.cdll.LoadLibrary(os.path.join(os.path.dirname(file), "libquilting.so"))
File "/home/shangqian/anaconda3/lib/python3.6/ctypes/init.py", line 426, in LoadLibrary
return self._dlltype(name)
File "/home/shangqian/anaconda3/lib/python3.6/ctypes/init.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: /home/shangqian/anaconda3/lib/python3.6/site-packages/adversarial/lib/transformations/libquilting.so: cannot open shared object file: No such file or directory
In setup.py, the link in line 65 is no longer working. Please change it to MAXFLOW_URL = "http://mouse.cs.uwaterloo.ca/code/maxflow-v3.01.zip" instead.
Hi,
Any insights that you can share on this error? Attaching the complete output when I do "pip install .".
My current environment:
Python: 2.7
(FB_env) nisha@xxx:/adversarial_image_defenses$ python -c "import faiss"
(FB_env) nisha@xxx:/adversarial_image_defenses$ python -c "import torch; print(torch.version)"
0.4.0
(FB_env) nisha@xxx:/adversarial_image_defenses$ python -c "import torchvision; print(torchvision.version)"
0.2.1
(FB_env) nisha@xxx:/adversarial_image_defenses$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85
(FB_env) nisha@toymaker:/adversarial_image_defenses$ cython --version
Cython version 0.28.2
So mode needs to be set to FGSMode.LOGIT, if I want to use the logits? If mode is 'None', the cross-entropy loss is used, if mode is 'FGSMode.CARLINI', the output is updated, then the FGSMode.LOGIT loss is used.
Not entirely sure what's going on. If I wanted to use the logits, and use the xent loss, what mode should I set?
It is stated that: the attack has been 'modified with TV minimization, random cropping, and random pixel dropping'. What does this mean? No description was given on this in the paper. With what hyperparameter setting can all modifications be turned off?
Furthermore, with the modifications turned off, is the implementation here equivalent to Carlini's original formulation? Doesn't seem to be the case, for one, the 'binary_search_steps' hyperparameter is missing. If it isn't, can you please explain what the formulation is here? Also, can a formulation equivalent to the original C&W attack be added to the repository? The original formulation has been validated to be a very successful attack, so I feel it, without modification, should be included in this repository.
A Tensorflow implemenation of the C&W L2 attack is provided in the 'carlini/nn_robust_attacks' repository and in Tensorflow's Cleverhans repository.
In the code above, we have 'if not preprocessed:and in
load_adversarialwe have
preprocessed=args.preprocessed_data` :
But args.preprocessed_data
is used for images that already have transformations/defenses applied (using your terminology, transformations and defenses are synonymous correct?), not when adversaries are already applied.
But how you are using "preprocessed" in _load_adversarial_helper implies you are speaking about if attacks have been preprocessed.
I think this might be a bug.
Thank you very much for providing ImageNet models trained on quilting and TVM. Were the hyperparameters for the transformations the same as presented in the paper?
"We fixed the hyperparameters of our defenses in all experiments: specifically, we set pixel dropout
probability p= 0.5 and the regularization parameter of the total variation minimizer λTV = 0.03. We
use a quilting patch size of 5×5 and a database of 1, 000, 000 patches that were randomly selected
from the ImageNet training set."
If not, what were the hyperparameters?
All dependencies have been installed, including Faiss, as per instructions, however when running the demo script, the following error is triggered. What is meant by 'check build script'?
async is a reserved word in Python 3.7 so cuda is deprecating the function parameter async in favor of non_blocking.
flake8 testing of https://github.com/facebookresearch/adversarial_image_defenses on Python 3.7.0
$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
./adversarial/lib/adversary.py:64:34: E999 SyntaxError: invalid syntax
target = target.cuda(async=True)
^
./adversarial/lib/convnet.py:63:44: E999 SyntaxError: invalid syntax
targets = targets.cuda(async=True)
^
2 E999 SyntaxError: invalid syntax
2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.