This is the source code for paper [Discriminability-Driven Channel Selection for Out-of-Distribution Detection] by Yue Yuan, Rundong He, YiCong Dong, Zhongyi Han and Yilong Yin.
In this work, we propose propose a new test-time OOD detection method called DDCS, which adaptively selects channels with high class discrimination to improve out-of-distribution detection performance
Please download ImageNet-1k and place the training data and validation data in
./datasets/id_data/ILSVRC-2012/train
and ./datasets/id_data/ILSVRC-2012/val
, respectively.
We have curated 4 OOD datasets from iNaturalist, SUN, Places, and Textures, and de-duplicated concepts overlapped with ImageNet-1k.
For iNaturalist, SUN, and Places, we have sampled 10,000 images from the selected concepts for each dataset, which can be download via the following links:
wget http://pages.cs.wisc.edu/~huangrui/imagenet_ood_dataset/iNaturalist.tar.gz
wget http://pages.cs.wisc.edu/~huangrui/imagenet_ood_dataset/SUN.tar.gz
wget http://pages.cs.wisc.edu/~huangrui/imagenet_ood_dataset/Places.tar.gz
For Textures, we use the entire dataset, which can be downloaded from their original website.
Please put all downloaded OOD datasets into ./datasets/ood_data/
.
The model we used in the paper is the pre-trained MobileNet-V2 provided by Pytorch. The download process will start upon running.
To get activations on the penultimate layer, please run:
python get_activation.py
To get ID discriminative score for each channel, please run:
python ID_mean.py
python ID_val.py
python DDscore.py
To reproduce our results, please run:
python eval.py