Skip to content

Shulammiteya/andp-diffusion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ANDP: Adversarial Noise–Driven Diffusion Purification

A diffusion-based adversarial purification method trained with adversarial noise.

Table of Contents
  1. Overview
  2. Environment Setup
  3. Datasets & Pre-trained Models
  4. Configuration
  5. Running Experiments
  6. Results & Logs
  7. License & Acknowledgements

Overview

ANDP (Adversarial Noise–Driven Diffusion Purification) is designed to:

  • Remove adversarial perturbations from images using diffusion models trained with adversarial noise, which improves robustness against unseen attacks.
  • Support multiple datasets and classifiers.
  • Provide a modular experiment pipeline for ablation studies, hyperparameter sweeps, and cross-classifier evaluation.

Environment Setup

  • System requirements:

    Component Specification
    OS Linux (Ubuntu recommended)
    GPU NVIDIA GeForce RTX 4090
    NVIDIA Driver 535.183.01
    CUDA 12.2
    Python 3.9 recommended (3.10 may work with caution)
  • Create environment:

    conda create -n andp-env python=3.9
    conda activate andp-env
    pip install -r requirements.txt

Datasets & Pre-trained Models

  • Supported datasets:
  • Training and evaluation scripts automatically detect datasets at the default locations.
  • Pre-trained classifier are stored under pretrained_models/.

Configuration

  • Configuration files are defined in YAML format and located under configs/ (e.g., cifar10.yaml, imagenet.yaml).
  • Each configuration file specifies global settings, dataset and model parameters, and experiment-specific options for training, evaluation, and adversarial purification.

Running Experiments

  • Experiment scripts

    Script Purpose
    scripts/run.sh Unified entry point for a single experiment (training & evaluation)
    scripts/exp_baseline.sh Phase 0: baseline experiments
    scripts/exp_mode_selection.sh Phase 1: mix-noise mode selection experiments
    scripts/exp_lambda_sweep.sh Phase 2: lambda sweep experiments
    scripts/exp_exposure_ablation.sh Phase 3: exposure ablation studies
    scripts/exp_batch.sh Phase 4: multi-seed & cross-dataset & cross-classifier evaluation

    Notes:
    Each experiment script calls run.sh with the corresponding parameters.
    Scripts are designed to allow batch runs for reproducibility.

  • Single experiment example:

    bash scripts/run.sh \
      --train --test \
      --dataset cifar10 \
      --classifier wrn-28-10 \
      --seed 33 \
      --mix-mode convex_energy \
      --lambda-sched sinusoid \
      --exposure full
  • Batch experiment example (multi-seed / multi-dataset / multi-classifier):

    bash scripts/exp_batch.sh

Results & Logs

  • Logs are saved under logs/ with timestamped folders.

  • Output results are saved under results/<dataset>/<timestamp>_<classifier>_<seed>/.

    Example structure:

    .
    ├── logs/
    │   ├── 20251217_060925_cifar10_wrn-28-10_33/
    │   └── ...
    └── results/
        ├── cifar10/
        │   ├── 20251217_060925_wrn-28-10_33/
        │   └── ...
        └── imagenet/
            ├── 20251218_080319_rn-50_33/
            └── ...
    

License & Acknowledgements

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements / References:

Please note that while this code is MIT-licensed, some referenced projects may have their own licenses.

About

Diffusion-based adversarial purification framework with configurable noise mixing and evaluation on CIFAR-10 and ImageNet.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors