Trustworthy-AI-Group/TransferAttack
TransferAttack is a pytorch framework to boost the adversarial transferability for image classification.
TransferAttack – A PyTorch Toolkit for Transferable Adversarial Attacks
What it does
TransferAttack is a research‑oriented Python library built on PyTorch that lets you generate and evaluate transferable adversarial examples for image‑classification models (CNNs, Vision Transformers, etc.). Transferable attacks are crafted on one model but remain effective against other, unseen models – a key way to probe the robustness of deep vision systems.
Key features
- Benchmark suite – a curated collection of > 80 published untargeted attacks, grouped by technique (gradient‑based, input‑transformation, advanced objectives). The README lists each method with a short description and a citation.
- Plug‑and‑play model interface – you can load common ImageNet‑compatible models (e.g., ResNet‑50, ViT) and run any of the attacks with a single command‑line flag (
--attack mifgsm --model=resnet50). - Evaluation mode – after generating adversarial images,
--evalruns a standardized transferability test across a set of pre‑trained models. - Reproducible dataset – the framework ships with a small 1,000‑image ImageNet‑style PNG set; download links are provided (Google Drive / Hugging Face).
- Extensible – the code is organized so new attacks can be added by inheriting a base attack class and implementing the gradient‑update rule.
Typical workflow
# install dependencies
pip install -r requirements.txt
# generate adversarial images with MI‑FGSM on a ResNet‑50
python main.py \
--input_dir ./data \
--output_dir adv_data/mifgsm/resnet50 \
--attack mifgsm \
--model=resnet50
# evaluate transfer success on other models
python main.py \
--input_dir ./data \
--output_dir adv_data/mifgsm/resnet50 \
--eval
The same pattern works for any of the listed attacks (e.g., --attack dim, --attack tap).
Why it matters
- Provides a single, consistent environment for reproducing dozens of recent adversarial‑transfer papers, which otherwise each come with their own code bases.
- Helps researchers quickly test how a new defense or model architecture stands up to a broad spectrum of attacks.
- The accompanying survey paper (arXiv:2602.23117) and a curated bibliography give context for the field.
Getting started
- Clone the repo and install the required Python ≥ 3.6, PyTorch ≥ 1.12.1, torchvision, and
timm. - Download the provided 1k‑image dataset.
- Run
main.pywith the desired attack and model flags. - Inspect the generated adversarial PNGs in
adv_data/or use the built‑in evaluation to see transfer rates.
Citation If you use the code or the benchmark in a publication, cite the associated arXiv paper (2026).
All details above are taken directly from the repository’s README; no additional features are inferred.
Related
- Project
- Project
- Project
- Project