This is a PyTorch implementation of DPATCH. Please refer to the paper https://arxiv.org/abs/1806.02299
-
Please install PyTorch following the instuctions on the official website. The version here should be 0.4.0
conda install pytorch torchvision -c pytorch
-
The yolo codes are referred to https://github.com/longcw/yolo2-pytorch. Download the pretrained yolo model yolo-voc.weights.h5
-
Download the dataset VOCdevkit
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.tar wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tar wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCdevkit_08-Jun-2007.tar
-
Extract all of these tars into one directory named
VOCdevkit
tar xvf VOCtrainval_06-Nov-2007.tar tar xvf VOCtest_06-Nov-2007.tar tar xvf VOCdevkit_08-Jun-2007.tar
-
It should have this basic structure
$VOCdevkit/ # development kit $VOCdevkit/VOCcode/ # VOC utility code $VOCdevkit/VOC2007 # image sets, annotations, etc. # ... and several other directories ...
-
Since the program loading the data in
DPatch/data
by default, you can set the data path as following.cd DPatch mkdir data cd data ln -s $VOCdevkit VOCdevkit2007
The trained DPATCH are saved in trained_patch/${target_class}/
bash python train.py
Download a trained DPATCH https://drive.google.com/open?id=1_G5xXWIJWNGuss4KZbBQ9pMvuthmL_wc , or you can test your trained DPatch and set the path in cfgs/config.py (Line 102)
bash python test.py –-attack untargeted python test.py –-attack targeted
The demo pictures are saved in demo/patch, the detection results are saved in demo/
bash python demo.py