Skip to main content
QUICK REVIEW

[Paper Review] OODformer: Out-Of-Distribution Detection Transformer

Rajat Koner, Poulami Sinhamahapatra|arXiv (Cornell University)|Jul 19, 2021
Adversarial Robustness in Machine LearningComputer Science14 citations
TL;DR

OODformer proposes a novel out-of-distribution (OOD) detection method using Vision Transformers (ViT) to exploit global image context and attention-based feature correlation for improved OOD generalization. By leveraging class-conditioned similarity of ViT's [class] token embeddings and confidence scores, it achieves state-of-the-art performance on CIFAR-10/-100 and ImageNet30 without requiring negative sampling or fine-tuning on OOD data.

ABSTRACT

A serious problem in image classification is that a trained model might perform well for input data that originates from the same distribution as the data available for model training, but performs much worse for out-of-distribution (OOD) samples. In real-world safety-critical applications, in particular, it is important to be aware if a new data point is OOD. To date, OOD detection is typically addressed using either confidence scores, auto-encoder based reconstruction, or by contrastive learning. However, the global image context has not yet been explored to discriminate the non-local objectness between in-distribution and OOD samples. This paper proposes a first-of-its-kind OOD detection architecture named OODformer that leverages the contextualization capabilities of the transformer. Incorporating the trans\-former as the principal feature extractor allows us to exploit the object concepts and their discriminate attributes along with their co-occurrence via visual attention. Using the contextualised embedding, we demonstrate OOD detection using both class-conditioned latent space similarity and a network confidence score. Our approach shows improved generalizability across various datasets. We have achieved a new state-of-the-art result on CIFAR-10/-100 and ImageNet30.

Motivation & Objective

  • To address the critical challenge of detecting out-of-distribution (OOD) samples in safety-critical vision applications where model performance degrades significantly.
  • To explore the potential of Vision Transformers (ViT) in capturing global image context and object attribute co-occurrence for improved OOD detection.
  • To develop a method that generalizes across datasets without relying on negative sampling, contrastive loss, or fine-tuning on OOD data.
  • To demonstrate that self-attention mechanisms in ViT inherently learn semantically compact representations suitable for OOD detection.

Proposed method

  • Train a Vision Transformer (ViT) on in-distribution (ID) data using standard cross-entropy loss for supervised classification.
  • Extract the [class] token embedding from the final layer of the ViT as a global, contextualized representation of the input image.
  • Compute class-conditioned distance metrics (e.g., cosine, Mahalanobis, Euclidean) between the ID embedding and the mean embedding of each class for OOD detection.
  • Use the softmax confidence score from the classification head as a second OOD detection signal.
  • Evaluate OOD detection performance using standard metrics like AUROC on multiple benchmark datasets.
  • Compare the ViT-based OODformer against ResNet baselines, including both randomly initialized and ImageNet-pretrained models, with and without image upscaling.

Experimental results

Research questions

  • RQ1Can Vision Transformers (ViT) effectively detect out-of-distribution samples without explicit contrastive loss or negative sampling?
  • RQ2Does the global context and multi-head self-attention mechanism in ViT improve OOD generalization compared to CNNs?
  • RQ3How does the choice of distance metric (cosine, Euclidean, Mahalanobis) affect OOD detection performance in the ViT embedding space?
  • RQ4Can a simple, confidence-based and embedding-based OOD detection method outperform existing state-of-the-art approaches?

Key findings

  • OODformer achieves a new state-of-the-art AUROC of 94.4 on CIFAR-100, significantly outperforming the best ResNet-101 baseline (87.8 AUROC).
  • DeiT-Tiny-16, a lightweight ViT variant, achieves 94.4 AUROC on CIFAR-100, surpassing larger ResNet models despite its smaller size and lower parameter count.
  • Pre-trained ViT and DeiT variants consistently outperform ImageNet-pretrained ResNets, even after image upscaling and fine-tuning, indicating the superiority of ViT’s inductive bias for OOD detection.
  • The Mahalanobis distance metric slightly outperforms cosine and Euclidean distances, likely due to its use of both class mean and covariance information.
  • OODformer demonstrates robustness to distance metric choice, with performance varying by only ±2% across different metrics, indicating stability.
  • The performance gap between ViT and ResNet widens with increased model capacity, suggesting ViT’s attention mechanism better captures discriminative, context-aware representations for OOD detection.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.