This repo contains the sample code of our proposed DivOE in our paper: Diversified Outlier Exposure for Out-of-Distribution Detection via Informative Extrapolation (NeurIPS 2023).
Required Packages
The following packages are required to be installed:
All of our experiments are conducted on NVIDIA GeForce RTX451 3090 GPUs with Python 3.7, PyTorch 1.12 and Torchvision 0.13
Pretrained Models
For CIFAR-10/CIFAR-100, pretrained WRN models are provided in folder
./CIFAR/snapshots/
For ImageNet, we used the pre-trained ResNet-50 provided by Pytorch.
Datasets
Please download the datasets in folder
./data/
1. CIFAR-10/100 as ID dataset
Auxiliary OOD Dataset
Test OOD Datasets
2. ImageNet as ID dataset
Auxiliary OOD Dataset
We employ the ImageNet-21K-P dataset as the auxiliary OOD dataset, which makes invalid classes cleansing and image resizing compared with the original ImageNet-21K
Test OOD Datasets
We employed iNaturalist, SUN, Places365, and Texture, following the same experiment settings as MOS. To download these four test OOD datasets, one could follow the instructions in the code repository of MOS.
Fine-tuning and Testing
run MSP score training and testing for cifar10 WRN
bash run.sh oe_tune 0
run MSP score training and testing for cifar100 WRN
bash run.sh oe_tune 1
run MSP score training and testing for ImageNet ResNet-50
bash run.sh oe_tune 2
run DivOE with MSP score for extrapolation on cifar10 WRN with the following hyperparameters