Skip to content

Latest commit

 

History

History
93 lines (50 loc) · 3.29 KB

README.md

File metadata and controls

93 lines (50 loc) · 3.29 KB

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.

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

  • ID dataset

    • Download ImageNet-1k dataset from the official Website. Put the dataset in the folder data/imagenet.
  • 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, and data/Textures, respectively.

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