Giter Site home page Giter Site logo

adversarial_training_imagenet's Introduction

adversarial_training_imagenet

This repository contains the code for ARES-Bench (A Comprehensive Study on Robustness of Image Classification Models: Benchmarking and Rethinking), a Python library for adversarial machine learning research focusing on benchmarking adversarial robustness on image classification correctly and comprehensively.

Installation

  • Install CUDA 11.3 with cuDNN 8 following the official installation guide of CUDA and cuDNN.

  • Setup conda environment:

# Create environment
conda create -n RobustBench python=3.9 -y
conda activate RobustBench

# Install requirements
conda install pytorch=1.12.1 torchvision=0.13.1 cudatoolkit=11.3 -c pytorch -y

# Clone RobustBench
git clone https://github.com/thu-ml/adversarial_training_imagenet.git

# Install other requirements
pip install -r requirements.txt

The requirements.txt includes its dependencies.

Files in the folder

  • adv/: PyTorch implementation of Attack methods.
  • ares_attack_torch/: PyTorch implementation of Attack methods from ARES.
  • model/: PyTorch implementation of models and a model zoo.
  • src_ckpt/: Storage for checkpoints downloaded.
  • src_data/: Storage for datasets.
  • test_out/: Output directory for model training and testing.
  • train_configs/: Training configs for adversarial training.

Example to run the codes

ARES-Bench provides command line interface to run benchmarks. For example, you can train a robust model of ResNet50 with corresponding configuration:

python -m torch.distributed.launch --nproc_per_node=<num-of-gpus-to-use> adversarial_training.py --configs=./train_configs/resnet50.yaml

There are 5 eval_***.py files in the folder that evaluate the adversarial robustness benchmarks on ImageNet and its variants. For example, if you want to evaluate the robustness of ResNet50 on ImageNet-C dataset, you can run the following command line:

python -m torch.distributed.launch --nproc_per_node=<num-of-gpus-to-use> eval_ood.py --model_name=resnet50_normal --imagenet_c_path=<imagenet-c-path>

Citing ARES-Bench

@article{liu2023comprehensive,
  title={A Comprehensive Study on Robustness of Image Classification Models: Benchmarking and Rethinking},
  author={Liu, Chang and Dong, Yinpeng and Xiang, Wenzhao and Yang, Xiao and Su, Hang and Zhu, Jun and Chen, Yuefeng and He, Yuan and Xue, Hui and Zheng, Shibao},
  journal={arXiv preprint arXiv:2302.14301},
  year={2023}
}

adversarial_training_imagenet's People

Contributors

dongyp13 avatar sunrise6513 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.