This project is for the paper "A Simple Unified Framework for Detecting Out-of-Distribution Samples and Adversarial Attacks". Some codes are from odin-pytorch, LID, and adversarial_image_defenses.
It is tested under Ubuntu Linux 16.04.1 and Python 3.6 environment, and requries Pytorch package to be installed:
- Pytorch: Only GPU version is available.
- scipy
- scikit-learn
We use download links of two out-of-distributin datasets from odin-pytorch:
Please place them to ./data/
.
We provide six pre-trained neural networks (1) three DenseNets trained on CIFAR-10, CIFAR-100 and SVHN, where models trained on CIFAR-10 and CIFAR-100 are from odin-pytorch, and (2) three ResNets trained on CIFAR-10, CIFAR-100 and SVHN.
- DenseNet on CIFAR-10 / DenseNet on CIFAR-100 / DenseNet on SVHN
- ResNet on CIFAR-10 / ResNet on CIFAR-100 / ResNet on SVHN
Please place them to ./pre_trained/
.
# model: ResNet, in-distribution: CIFAR-10, gpu: 0
python OOD_Baseline_and_ODIN.py --dataset cifar10 --net_type resnet --gpu 0
# model: ResNet, in-distribution: CIFAR-10, gpu: 0
python OOD_Generate_Mahalanobis.py --dataset cifar10 --net_type resnet --gpu 0
# model: ResNet
python OOD_Regression_Mahalanobis.py --net_type resnet
# model: ResNet, in-distribution: CIFAR-10, adversarial attack: FGSM gpu: 0
python ADV_Samples.py --dataset cifar10 --net_type resnet --adv_type FGSM --gpu 0
# model: ResNet, in-distribution: CIFAR-10, adversarial attack: FGSM gpu: 0
python ADV_Generate_LID_Mahalanobis.py --dataset cifar10 --net_type resnet --adv_type FGSM --gpu 0
# model: ResNet
python ADV_Regression.py --net_type resnet