Home

Awesome

[ICLR-2024] Neuron Activation Coverage: Rethinking Out-of-distribution Detection and Generalization

This is the official PyTorch implementation of our NAC-UE: https://arxiv.org/abs/2306.02879. In this updated version, we re-evaluated NAC-UE on OpenOOD v1.5 without modifying the core method. It still outperforms 21 SoTA OOD detection methods across three benchmarks!

Please see the source code for NAC-ME in the folder domainbed, which is tailored for generalization tasks.

Usage

Our experimental settings carefully align with OpenOOD v1.5. We provide details for utilized benchmarks and models below. For more information, please refer to https://github.com/Jingkang50/OpenOOD.

We provide the required packages in environment.yml, you can simply run the following command to create the environment:

conda env create -f environment.yml;
pip install libmr==0.1.9

1. OOD benchmark Preparation

To download all required InD and OOD datasets, you can use the downloading script provided by OpenOOD. Specifically, please run:

bash scripts/download/download.sh 

2. Pre-trained Model Preparation

We employ ResNet-18 pretrained by OpenOOD v1.5. For ResNet-50 and Vit-b-16, we utilize the pretrained models provided by Pytorch. You can download checkpoints using the following links:

These checkpoints can be also be downloaded with the downloading script.

3. OOD Detection Evaluation

3.1 Split training data for sanity check

We utilize a subset of the InD training set for a sanity check to verify if the OOD detection method is overfitted. Please run the following command to split the training data (default: 1000 training images for sanity check):

bash scripts/split_train.sh 1000

3.2 Evaluation on CIFAR-10 / CIFAR-100 / ImageNet-1k

We provide all scripts to reproduce our results in here.

Note that aps denotes the automatic paramter search, cross indicates the models are pretrained using cross entropy loss.

Also, if you want to reproduce the baselines results (e.g., ReAct) using this repository, you can run the following command:

bash scripts/ood/react/cifar10_test_ood_react.sh;
bash scripts/ood/react/cifar100_test_ood_react.sh;
bash scripts/ood/react/imagenet_test_ood_react.sh

4. OOD Detection Evaluation with Faster Parameter Search

Here, we provide a faster way to implement NAC-UE for OOD detection.

OOD Detection Results

NAC-UC achieves SoTA performance on the 3 OOD benchmarks, CIFAR-10, CIFAR100, and ImageNet. For instance, you can check the results on CIFAR-10 below.

results

Citation

If you find our codebase useful, please cite our paper:

@inproceedings{liu2024neuron,
 title={Neuron Activation Coverage: Rethinking Out-of-distribution Detection and Generalization},
 author={Yibing Liu and Chris XING TIAN and Haoliang Li and Lei Ma and Shiqi Wang},
 booktitle={ICLR},
 year={2024},
}

Credits

This codebase is developed using OpenOOD (version as of September 10, 2023). We extend our sincere gratitude for their generosity in providing this valuable resource.