Official implementation of ICCV2023 paper WDiscOOD: Out-of-Distribution Detection via Whitened Linear Discriminant Analysis by Yiye Chen, Yunzhi Lin, Ruinian Xu, Patricio A. Vela. It achieves state-of-the-art performance on multiple benchmarks.
The code is developed under the Ubuntu 20.04 and Python 3.9 environment. Please install the packages following the instructions below:
-
Install the Pytorch.
Following the instructions from the official website. The code is developed and tested with the Pytorch 1.11.0
-
Install the rest.
pip install -r requirements.txt
-
ID dataset
- Download ImageNet-1k dataset from the official Website. Put the dataset in the folder
data/imagenet
.
- Download ImageNet-1k dataset from the official Website. Put the dataset in the folder
-
OOD dataset
- OpenImage-O: Follow the instruction from ViM. Put the dataset in the folder
data/openimaeg_o
- ImageNet-O: Follow the official guidance. Put the dataset in
data/imagenet_o
- iNaturalist, SUN, Places, Textures: Follow the instruction from MOS. Put them in
data/inaturalist
,data/Places
,data/Textures
, anddata/Textures
, respectively.
- OpenImage-O: Follow the instruction from ViM. Put the dataset in the folder
-
ResNet-50 on ImageNet. No external download required. Will use the released model by Pytorch.
-
ResNet-Supcon on ImageNet. Download from KNN-OOD, and place in
./pretrained_models/ImageNet
-
CLIP model. Install the API following CLIP repo
bash experiments/feat_imgNet.sh {resnet50|vit_b|resnet50_clip|resnet50_supcon}
bash experiments/WDiscOOD_final.sh {resnet50|vit_b|resnet50_clip|resnet50_supcon}
For classifier settings, test with:
bash experiments/run_baselines_clf_final.sh {resnet50|vit_b} {MSP|Energy|MahaVanilla|KNN|VIM|Residual|ReAct|ODIN}
For stand-alone visual encoders:
bash experiments/run_baselines_enc_final.sh {resnet50_supcon|resnet50_clip} {MahaVanilla|KNN}
Part of the code is modified from ViM, MOS, and KNN-OOD repo.
If you find WDiscOOD helpful in your research or application, please consider citing our paper:
@article{chen2023wdiscood,
title={WDiscOOD: Out-of-Distribution Detection via Whitened Linear Discriminative Analysis},
author={Chen, Yiye and Lin, Yunzhi and Xu, Ruinian and Vela, Patricio A},
journal={International Conference on Computer Vision (ICCV)},
year={2023}
}