Home

Awesome

Diffusion Denoising Process for Perceptron Bias in Out-of-distribution Detection

This repo is the official PyTorch implementation for the paper Diffusion Denoising Process for Perceptron Bias in Out-of-distribution Detection

by Luping Liu, Yi Ren, Xize Cheng, Zhou Zhao (Zhejiang University).

What does this work do?

In this work, we provide a new perceptron bias assumption that the discriminator models are more sensitive to some subareas to explain the overconfidence problem. Our detection methods combine the discriminator and generation models, which uses a ResNet to extract features and the diffusion denoising process of a diffusion model (with classifier-free guidance) to reduce overconfidence areas. Our methods get competitive OOD detection results with SOTA methods.

algorithm

Code structure

How to run the code

Dependencies

Run the following to install necessary python packages for our code.

pip install -r requirements.txt

Usage

Train the diffusion models through main.py.

python main.py --runner training --config config/ddim_cifar10_cond.yml --train_path temp/train/base_multi
torchrun --nproc_per_node 2 main.py --runner training --config config/ddim_cifar10_cond.yml --train_path temp/train/base_multi

Evaluate the diffusion models through main.py.

python main.py --runner fid --method PNDM4 --sample_step 50 --device cuda --config config/ddim_cifar10_cond.yml \
  --image_path temp/sample --model_path temp/models/ddim/ema_cifar10.ckpt

Generate samples for OOD detection through main.py.

python main.py --runner detection --config config/32_cifar10_cond.yml --method DDIM --sample_step 50 \
  --model_path temp/model/ddim_cifar10_cond.ckpt --disc_path temp/model/res18_cifar10_disc.ckpt --repeat_size 4

Compute OOD detection results through detect.py.

python detect/ood_detect.py --id_name cifar10 --space logit  --repeat_size 4

Datasets & checkpoints

All datasets, precalculated statistics for FID and checkpoints of models are provided in this Onedrive.

References

If you find the code useful for your research, please consider citing:

@misc{liu2022diffusion,
      title={Diffusion Denoising Process for Perceptron Bias in Out-of-distribution Detection}, 
      author={Luping Liu and Yi Ren and Xize Cheng and Zhou Zhao},
      year={2022},
      eprint={2211.11255},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

This work is built upon some previous papers which might also interest you: