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.
