Home

Awesome

WDiscOOD: Out-of-Distribution Detection via Whitened Linear Discriminant Analysis

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.

<img src="./demo_figs/wdiscood_performance.png" width="600">

Preliminaries

The code is developed under the Ubuntu 20.04 and Python 3.9 environment. Please install the packages following the instructions below:

  1. Install the Pytorch.

    Following the instructions from the official website. The code is developed and tested with the Pytorch 1.11.0

  2. Install the rest.

    pip install -r requirements.txt
    

Dataset Preparation

Pretrained Models

  1. ResNet-50 on ImageNet. No external download required. Will use the released model by Pytorch.

  2. ResNet-Supcon on ImageNet. Download from KNN-OOD, and place in ./pretrained_models/ImageNet

  3. CLIP model. Install the API following CLIP repo

Run experiments

Extract features

bash experiments/feat_imgNet.sh {resnet50|vit_b|resnet50_clip|resnet50_supcon}

Test WDiscOOD

bash experiments/WDiscOOD_final.sh {resnet50|vit_b|resnet50_clip|resnet50_supcon}

Test baselines

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}

Acknowledgement

Part of the code is modified from ViM, MOS, and KNN-OOD repo.

Citation

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}
}