Home

Awesome

Ensemble of Self Supervised Leave-out Classifiers

This is an unofficial pytorch implementation of Out-of-Distribution Detection Using an Ensemble of Self Supervised Leave-out Classifiers.

Requirements

Preparation

Download five out-of-distributin datasets provided by ODIN:

Here is an example code of downloading Tiny-ImageNet (crop) dataset. In the root directory, run

mkdir data
cd data
wget https://www.dropbox.com/s/avgm2u562itwpkl/Imagenet.tar.gz
tar -xvzf Imagenet.tar.gz
cd ..

Usage

Pre-trained Models

We provide download links of four types of pre-trained models.

Each type of models contains 5 models for 5-fold. Here is an example code of downloading DenseNet-BC trained on CIFAR-10. In the root directory, run

mkdir checkpoints
cd checkpoints
wget https://www.dropbox.com/s/mo2xay9rpfk8emu/cifar10_dense.tar.gz
tar -xvzf cifar10_dense.tar.gz
cd ..

Train single model (Optional)

Train DenseNet on the first fold of CIFAR-10.

python train.py -c checkpoints/cifar10_fold_1_dense_checkpoint --fold 1

Trained model will be saved at checkpoints/cifar10_fold_1_dense_checkpoint.

Train all models (Optional)

python train_all.py

This script will train models of DenseNet/WideResNet on 5-fold CIFAR-10/100 which results in 20 models. Trained model will be saved at checkpoints.

Test

Use 5-fold ensemble and ODIN to detect OOD samples. For example, to test DenseNet-BC trained on CIFAR-10 where TinyImageNet (crop) is the out-of-distribution dataset, please run

python test.py --in-dataset cifar10 --out-dataset Imagenet --magnitud 0.002

The temperature is set as 1000, and perturbation magnitude is set as 0.002.

Note: Please choose arguments according to the following.

args

Results

All values are percentages. ↑ indicates larger value is better, and ↓ indicates lower value is better. Each value cell is in "Paper/Our Implementation" format.

DenseNet on CIFAR-10

OOD DatasetFPR at 95% TPR ↓Detection Error ↓AUROC ↑AUPR In ↑AUPR Out ↑
Tiny-ImageNet (crop)1.23 / 1.482.63 / 2.7999.65 / 99.6699.68 / 99.6799.64 / 99.66
Tiny-ImageNet (resize)2.93 / 2.583.84 / 3.6399.34 / 99.4599.37 / 99.4899.32 / 99.46
LSUN (crop)3.42 / 3.704.12 / 4.3299.25 / 99.2799.29 / 99.3299.24 / 99.26
LSUN (resize)0.77 / 1.582.1 / 2.6999.75 / 99.6799.77 / 99.6899.73 / 99.68

DenseNet on CIFAR-100

OOD DatasetFPR at 95% TPR ↓Detection Error ↓AUROC ↑AUPR In ↑AUPR Out ↑
Tiny-ImageNet (crop)8.29 / 4.786.27 / 4.8698.43 / 99.0098.58 / 99.0598.3 / 99.00
Tiny-ImageNet (resize)20.52 / 12.099.98 / 7.6396.27 / 97.8096.66 / 98.0195.82 / 97.66
LSUN (crop)14.69 / 11.678.46 / 7.5897.37 / 97.8797.62 / 98.0097.18 / 97.81
LSUN (resize)16.23 / 9.308.77 / 6.4497.03 / 98.2197.37 / 98.4296.6 / 97.96

WideResNet on CIFAR-10

OOD DatasetFPR at 95% TPR ↓Detection Error ↓AUROC ↑AUPR In ↑AUPR Out ↑
Tiny-ImageNet (crop)0.82 / 2.082.24 / 3.4899.75 / 99.5599.77 / 99.5799.75 / 99.54
Tiny-ImageNet (resize)2.94 / 4.293.83 / 4.6299.36 / 99.1599.4 / 99.1799.36 / 99.17
LSUN (crop)1.93 / 4.653.24 / 4.7199.55 / 99.0799.57 / 99.1799.55 / 99.02
LSUN (resize)0.88 / 3.252.52 / 3.9299.7 / 99.3999.72 / 99.3799.68 / 99.43

WideResNet on CIFAR-100

OOD DatasetFPR at 95% TPR ↓Detection Error ↓AUROC ↑AUPR In ↑AUPR Out ↑
Tiny-ImageNet (crop)9.17 / 8.756.67 / 6.5198.22 / 98.3098.39 / 98.4898.07 / 98.11
Tiny-ImageNet (resize)24.53 / 21.0911.64 / 10.0095.18 / 96.1395.5 / 96.6394.78 / 95.27
LSUN (crop)14.22 / 15.558.2 / 8.5197.38 / 97.2597.62 / 97.4997.16 / 97.09
LSUN (resize)16.53 / 15.169.14 / 7.9596.77 / 97.1997.03 / 97.6496.41 / 96.35

References