Introduction:
Recent studies have addressed the concern of detecting and rejecting the out-of-distribution (OOD) samples as a major challenge in the safe deployment of deep learning (DL) models. It is desired that the DL model should only be confident about the in-distribution (ID) data which reinforces the driving principle of the OOD detection. In this work, we propose a simple yet effective generalized OOD detection method independent of out-of-distribution
datasets. Our approach relies on self-supervised feature learning of the training samples, where the embeddings lie on a compact low-dimensional space. Motivated by the recent studies that show self-supervised adversarial contrastive learning helps robustifying the model, we empirically show that a pre-trained model with selfsupervised contrastive learning yields a better model for uni-dimensional feature learning in the latent space. The method proposed in this work, referred to as RODD, outperforms SOTA detection performance on extensive suite of benchmark datasets on OOD detection tasks.
Overall architecture of the proposed OOD detection method. (a) In the first step, self-supervised adversarial contrastive learning is performed.(b) Secondly, the encoder is fine-tuned by freezing the weights of the penultimate layer. (c) Thirdly, we calculate the first singular vectors of each class using their features. (d) The final step is the OOD detection where uncertainty score is estimated using cosine similarity between the feature vector of the test sample and first singular vectors of each ID class.
CIFAR-10 and CIFAR-100 are in-distribution datasets which will be automatically downloaded during training
Create a folder 'data' in the root 'RODD' folder
Download following OOD datasets in the 'data' folder.
Places
Textures (Download the entire dataset)
All other OOD Datasets such as ImageNetc, ImageNetr, LSUNr, LSUNc, iSUN and SVHN can be downloaded from Google Drive
Python 3.9 cuda 11.2 torch 1.8.1 torchvision 0.9.1 numpy 1.20.1 sklearn 0.24.1
python pretrain.py --dataset cifar10
python pretrain.py --dataset cifar100
python fine_tune.py --dataset cifar10
python fine_tune.py --dataset cifar100
python extract_features.py in-dataset cifar10
python evaluate_original.py
python extract_features.py in-dataset cifar100
python evaluate_original.py
@INPROCEEDINGS{9857016,
author={Khalid, Umar and Esmaeili, Ashkan and Karim, Nazmul and Rahnavard, Nazanin},
booktitle={2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW)},
title={RODD: A Self-Supervised Approach for Robust Out-of-Distribution Detection},
year={2022},
volume={},
number={},
pages={163-170},
doi={10.1109/CVPRW56347.2022.00028}}