Table of Contents
Fetching ...

Out-of-Distribution Detection with Relative Angles

Berker Demirel, Marco Fumero, Francesco Locatello

TL;DR

This work introduces ORA, a post-hoc out-of-distribution detection score based on the maximum relative angle $\theta$ between a centered feature $\mathbf{z}-\boldsymbol{\mu}_{ID}$ and its projection onto the decision boundary, computed relative to the in-distribution mean $\boldsymbol{\mu}_{ID}$. By centering in-distribution statistics and focusing on angular relationships rather than Euclidean distances, ORA achieves translation- and scale-invariant discrimination between ID and OOD data, and can combine scores across diverse models through simple summation. Extensive experiments on ImageNet with nine backbones, as well as CLIP-based setups and contrastive representations, show ORA achieves state-of-the-art or near-state-of-the-art performance in FPR95 and AUROC, and benefits from model ensembling and activation-shaping techniques. Ablation studies confirm the importance of centering at $\boldsymbol{\mu}_{ID}$ and maximizing over the furthest class angle, and the method demonstrates strong performance gains on both large-scale benchmarks and resource-constrained settings. Overall, ORA provides a robust, hyperparameter-free, and broadly compatible approach to OOD detection with practical implications for deploying reliable AI systems.

Abstract

Deep learning systems deployed in real-world applications often encounter data that is different from their in-distribution (ID). A reliable model should ideally abstain from making decisions in this out-of-distribution (OOD) setting. Existing state-of-the-art methods primarily focus on feature distances, such as k-th nearest neighbors and distances to decision boundaries, either overlooking or ineffectively using in-distribution statistics. In this work, we propose a novel angle-based metric for OOD detection that is computed relative to the in-distribution structure. We demonstrate that the angles between feature representations and decision boundaries, viewed from the mean of in-distribution features, serve as an effective discriminative factor between ID and OOD data. We evaluate our method on nine ImageNet-pretrained models. Our approach achieves the lowest FPR in 5 out of 9 ImageNet models, obtains the best average FPR overall, and consistently ranking among the top 3 across all evaluated models. Furthermore, we highlight the benefits of contrastive representations by showing strong performance with ResNet SCL and CLIP architectures. Finally, we demonstrate that the scale-invariant nature of our score enables an ensemble strategy via simple score summation. Code is available at https://github.com/berkerdemirel/ORA-OOD-Detection-with-Relative-Angles.

Out-of-Distribution Detection with Relative Angles

TL;DR

This work introduces ORA, a post-hoc out-of-distribution detection score based on the maximum relative angle between a centered feature and its projection onto the decision boundary, computed relative to the in-distribution mean . By centering in-distribution statistics and focusing on angular relationships rather than Euclidean distances, ORA achieves translation- and scale-invariant discrimination between ID and OOD data, and can combine scores across diverse models through simple summation. Extensive experiments on ImageNet with nine backbones, as well as CLIP-based setups and contrastive representations, show ORA achieves state-of-the-art or near-state-of-the-art performance in FPR95 and AUROC, and benefits from model ensembling and activation-shaping techniques. Ablation studies confirm the importance of centering at and maximizing over the furthest class angle, and the method demonstrates strong performance gains on both large-scale benchmarks and resource-constrained settings. Overall, ORA provides a robust, hyperparameter-free, and broadly compatible approach to OOD detection with practical implications for deploying reliable AI systems.

Abstract

Deep learning systems deployed in real-world applications often encounter data that is different from their in-distribution (ID). A reliable model should ideally abstain from making decisions in this out-of-distribution (OOD) setting. Existing state-of-the-art methods primarily focus on feature distances, such as k-th nearest neighbors and distances to decision boundaries, either overlooking or ineffectively using in-distribution statistics. In this work, we propose a novel angle-based metric for OOD detection that is computed relative to the in-distribution structure. We demonstrate that the angles between feature representations and decision boundaries, viewed from the mean of in-distribution features, serve as an effective discriminative factor between ID and OOD data. We evaluate our method on nine ImageNet-pretrained models. Our approach achieves the lowest FPR in 5 out of 9 ImageNet models, obtains the best average FPR overall, and consistently ranking among the top 3 across all evaluated models. Furthermore, we highlight the benefits of contrastive representations by showing strong performance with ResNet SCL and CLIP architectures. Finally, we demonstrate that the scale-invariant nature of our score enables an ensemble strategy via simple score summation. Code is available at https://github.com/berkerdemirel/ORA-OOD-Detection-with-Relative-Angles.
Paper Structure (40 sections, 16 equations, 6 figures, 21 tables, 1 algorithm)

This paper contains 40 sections, 16 equations, 6 figures, 21 tables, 1 algorithm.

Figures (6)

  • Figure 1: Geometric visualization of ORA for in-distribution (left) and out-of-distribution (right) cases. ORA focuses on the angular distance between the feature representation and the decision boundary, from the perspective of the in-distribution mean. The angle $\theta$ serves as the distinguishing factor between ID and OOD samples, with $\theta_{\text{ID}} > \theta_{\text{OOD}}$.
  • Figure 2: Histogram of ID (CIFAR-10) and OOD (Texture) samples with respect to the sine of the angle formed with the vector $\mathbf{z} - \bm{\mu}_{\text{ID}}$. This empirically shows that $\sin{(\alpha)}$ is not highly informative for distinguishing ID from OOD.
  • Figure 3: Comparison of the score histograms on Imagenet (ID) and inaturalistinatvan2018inaturalist(OOD) of the best individual model (left) with the model ensemble (right). Model ensemble improves the ID and OOD separation.
  • Figure 4: Score distributions of ID and OOD datasets in CIFAR-10 OOD Benchmark.
  • Figure 5: Score distributions of ID and OOD datasets in ImageNet OOD Benchmark.
  • ...and 1 more figures