Skip to content

NeurIPS22 "RankFeat: Rank-1 Feature Removal for Out-of-distribution Detection" and T-PAMI Extension

Notifications You must be signed in to change notification settings

KingJamesSong/RankFeat

Repository files navigation

RankFeat

NeurIPS22 paper "RankFeat: Rank-1 Feature Removal for Out-of-distribution Detection"

ID/OOD Dataset Preparation

In-Distribution (ID) dataset. Please download ImageNet-1k and use its validation set as the ID set.

Out-of-Distribution (OOD) dataset. For the used OOD datasets (iNaturalist, SUN, Places, and Textures), please download them from 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
wget https://www.robots.ox.ac.uk/~vgg/data/dtd/download/dtd-r1.0.1.tar.gz

For the large-scale Species dataset, please download the four subsets (Protozoa, Microorganisms, Plants, and Mollusks) from the official link.

Pre-trained Model Preparation

For SqueezeNet, it is already available in the Pytorch library. For BiT-S ResNetv2-101 and T2T-ViT-24, one can download the BiT-S ResNetv2-101 and T2T-ViT by the following links:

wget http://pages.cs.wisc.edu/~huangrui/finetuned_model/BiT-S-R101x1-flat-finetune.pth.tar
wget https://github.com/yitu-opensource/T2T-ViT/releases/download/main/82.6_T2T_ViTt_24.pth.tar

For more BiT pre-trained models, one can also refer to BiT-S pre-trained families.

Usage

Check train_resnetv2.sh, train_squeezenet.sh, and train_t2tvit.sh in the scripts folder for the specific usages on each architectures.

Besides our proposed RankFeat, the previous post hoc methods are also implemented here, including MSP, ODIN, Energy, Mahalanobis, GradNorm, and ReAct.

OOD Evaluation Results

Citation

If you think the code is helpful to your research, please consider citing our paper:

@inproceedings{song2022rankfeat,
  title={RankFeat: Rank-1 Feature Removal for Out-of-distribution Detection},
  author={Song, Yue and Sebe, Nicu and Wang, Wei},
  booktitle={NeurIPS},
  year={2022}
}

The code is built based on MOS and GradNorm. If you have any questions or suggestions, please feel free to contact me via yue.song@unitn.it.

About

NeurIPS22 "RankFeat: Rank-1 Feature Removal for Out-of-distribution Detection" and T-PAMI Extension

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published