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).
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
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.
Please download the datasets in folder
./data/
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
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.
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
bash run.sh MSP_DivOE 0 0.5 0.05 0.25 5
run DivOE with MSP score for extrapolation on cifar100 WRN with the following hyperparameters
bash run.sh MSP_DivOE 1 0.5 0.05 0.25 5
run DivOE with MSP score for extrapolation on ImageNet ResNet-50 with the following hyperparameters
bash run.sh MSP_DivOE 2 0.5 0.05 0.25 5
Our method achieves the following average performance on all test OOD datasets:
CIFAR-10 | CIFAR-10 | CIFAR-100 | CIFAR-100 | ImageNet | ImageNet | |
---|---|---|---|---|---|---|
FPR95 | AUROC | FPR95 | AUROC | FPR95 | AUROC | |
OE | 13.76 | 97.53 | 27.67 | 91.89 | 61.94 | 81.58 |
DivOE | 11.66 | 97.82 | 24.80 | 92.91 | 60.12 | 81.96 |
If you find our paper and repo useful, please cite our paper:
@inproceedings{zhu2023diversified,
title ={Diversified Outlier Exposure for Out-of-Distribution Detection via Informative Extrapolation},
author ={Jianing Zhu, Geng Yu, Jiangchao Yao, Tongliang Liu, Gang Niu, Masashi Sugiyama, Bo Han},
booktitle ={Thirty-seventh Conference on Neural Information Processing Systems},
year ={2023}
}