Awesome
Detecting Out-of-distribution Data through In-distribution Class Prior
This is the source code for our paper: Detecting Out-of-distribution Data through In-distribution Class Prior by Xue Jiang, Feng Liu, Zhen Fang, Hong Chen, Tongliang Liu, Feng Zheng, and Bo Han. Code is modified from GradNorm.
Usage
1. Install
conda create -n class_prior python=3.8
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
pip install scikit-learn
2. Dataset Preparation
In-distribution dataset
Please download ImageNet-1k and place the training data (not necessary) and validation data in
./dataset/id_data/imagenet_train
and ./dataset/id_data/imagenet_val
, respectively.
The meta file for ImageNet-LT-a8 is in ./meta
.
Out-of-distribution dataset
Following MOS, we use the following 4 OOD datasets for evaluation: iNaturalist, SUN, Places, and Textures.
Please refer to MOS, download OOD datasets and put them into ./dataset/ood_data/
.
3. Pre-trained Model Preparation
We use mmclassification to train ResNet101 on ImageNet-LT-a8 dataset.
Put the downloaded model in ./checkpoints/
.
4. OOD Detection Evaluation
To reproduce our results, please run:
bash ./run.sh
Citation
If you find our codebase useful, please cite our work:
@inproceedings{jiang2023detecting,
title={Detecting Out-of-distribution Data through In-distribution Class Prior},
author={Xue Jiang and Feng Liu and Zhen Fang and Hong Chen and Tongliang Liu and Feng Zheng and Bo Han},
booktitle = {ICML},
year = {2023}
}