Skip to content

Repository files navigation

Adaptive Spatial–Frequency Guidance for Transferable Adversarial Evaluation of Robust Visual Classifiers

Official PyTorch implementation of ASFG, a cross-domain adversarial optimization framework designed for evaluating robustness of visual classifiers under spatial-gradient smoothing conditions.


Prerequisites & Environment Setup

This codebase has been tested on NVIDIA RTX 4090, Ubuntu 22.04, Python 3.10, PyTorch 2.1.

Create environment:

conda create -n asfg_env python=3.10 -y
conda activate asfg_env
Install PyTorch:

pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121

Install dependencies:

pip install robustbench numpy scipy tqdm pandas matplotlib pyyaml pillow

---

## Dataset Preparation

ImageNet-1K:
Download official validation set and place under:

./datasets/imagenet_val_1k

TinyImageNet:
Download dataset and place under:

./datasets/tiny-imagenet-200

Images are resized to 224×224 before evaluation.

Directory structure:

.
├── datasets/
│   ├── imagenet_val_1k/
│   └── tiny-imagenet-200/
├── attacks/
├── tools/
├── analysis/
├── scripts/
├── configs/
├── run_experiments.py
├── run_transfer_matrix.py
├── run_ablation_study.py
└── requirements.txt

---

## Quick Start

Run main attack:

python run_experiments.py --config configs/imagenet.yaml

Run transfer evaluation:

python run_transfer_matrix.py --config configs/imagenet.yaml

Run ablation study:

python run_ablation_study.py --config configs/imagenet.yaml

---

## Evaluation Protocol

All experiments follow l∞ threat model:

epsilon = {0.008, 0.012, 0.016, 0.020, 0.025, 0.030, 0.040}
steps = 20
alpha_std = 2 * epsilon / steps
alpha_asfg = max(epsilon / 6, 2 * alpha_std)

White-box: full gradient access on source model  
Black-box: transfer-based evaluation (no queries)


## Models & Weight Accessibility

- Engstrom2019Robust (ResNet-50)
- Salman2020Do_R50 (ResNet-50)
- Liu2023Comprehensive (ConvNeXt-B)

**Note on Checkpoints:** To ensure absolute protocol transparency, all pretrained robust visual architectures are automatically pulled from official public endpoints via the `RobustBench` API upon script initialization. Local manual weight configuration is completely bypassed to prevent checkpoint tampering.

---

## Reproducibility & Figure/Table Mapping

To systematically audit the empirical validations presented in the manuscript, map the script entrypoints to their corresponding target deliverables as formalized below:

- **Table 1 (Threat Model Specifications)** → Verified analytically inside `Section 4.1.1` and structurally encoded within `configs/*.yaml`.
- **Table 2 (ImageNet-1K Core Evaluation)** → Execute `python run_experiments.py --config configs/imagenet.yaml` (Outputs ASR values and PSNR logs).
- **Table 3 (Tiny-ImageNet Evaluation)** → Execute `python run_experiments.py --config configs/tiny_imagenet.yaml` (Tracks cross-scale metrics under resized $224\times224$ space).
- **Table 4 (Cross-Architecture Black-Box Transfer Matrix)** → Execute `python run_transfer_matrix.py` (Calculates CNN-to-ViT generalized metrics).
- **Table 5 & Figure 7 (Computational Overhead & Optimization Trajectories)** → Execute `python run_ablation_study.py` (Profiles absolute runtimes and exports chronological directional cosine similarity alignment statistics).
- **Figure 8, 9, & 10 (Visual and Spectral Disentanglement Analysis)** → Handled via native parsing tools localized inside the `./analysis/` directory.---
---

## Output Structure

All execution metrics, visual patches, and raw array artifacts are cataloged under the `./results/` repository according to the following hierarchical architecture:

./results/
├── imagenet/
│   ├── asr_summary.csv        # Evaluated quantitative metrics for Table 2
│   ├── transfer_matrix.npy    # Cross-architecture raw array for Table 4
│   └── trajectory_logs/       # Step-by-step cos_theta curves for Figure 7
├── tiny_imagenet/
│   └── asr_summary.csv        # Cross-scale metrics for Table 3
└── visual_ablations/
    ├── dft_spectra/           # 2D power spectrum snapshots for Figure 9
    └── roi_patches/           # Magnified perceptual samples for Figure 8 & 10
---

## Random Seed

All experiments use fixed seed = 42

---

## Citation

If you use this code, please cite:

@article{ASFG2026,
  title={Adaptive Spatial–Frequency Guidance for Transferable Adversarial Evaluation of Robust Visual Classifiers},
  year={2026}
}

About

Adaptive Spatial-Frequency Guidance for Transferable Adversarial Evaluation of Robust Visual Classifiers

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages