This is the PyTorch code of the SAAT paper, which has been accepted by IEEE TIFS.
The code has been tested on PyTorch 1.10. To install the dependencies, run
pip install -r requirements.txt
For example, training a deep hashing model with 32 code length on the NUS-WIDE dataset.
python hashing.py --train --bit 32 --dataset NUS-WIDE
After training, the well-trained models will be saved to checkpoint
folder. We can evaluate its retrieval performance through MAP metric.
python hashing.py --test --bit 32 --dataset NUS-WIDE
The following code performs adversarial attack against the well-trained model.
attack_method
: name of adversarial attack algorithm, e.g., mainstay (our proposed mainstay codes-based semantic-aware attack).
python attack.py --bit 32 --dataset NUS-WIDE --attack_method mainstay
The following code performs adversarial training for the pre-trained model to alleviate the effects caused by adversarial perturbations.
adv_method
: name of adversarial training algorithm, e.g., saat (the proposed semantic-aware adversarial training).
python defense.py --bit 32 --dataset NUS-WIDE --adv_method saat
Then, we again verify the robustness of the model trained with adversarial training.
adv
: load model after adversarial training.attack_method
: name of adversarial attack algorithm.adv_method
: name of adversarial training algorithm.
python attack.py --bit 32 --dataset NUS-WIDE --attack_method mainstay --adv --adv_method saat
If you find this work is useful, please cite the following:
@ARTICLE{10189878,
author={Yuan, Xu and Zhang, Zheng and Wang, Xunguang and Wu, Lin},
journal={IEEE Transactions on Information Forensics and Security},
title={Semantic-Aware Adversarial Training for Reliable Deep Hashing Retrieval},
year={2023},
volume={18},
number={},
pages={4681-4694},
doi={10.1109/TIFS.2023.3297791}}