Skip to content

berkerdemirel/ORA-OOD-Detection-with-Relative-Angles

Repository files navigation

ORA: Out-of-Distribution Detection with Relative Angles

This repository contains the official implementation for the paper "Out-of-Distribution Detection with Relative Angles" (NeurIPS 2025).

Our work introduces ORA, a novel method for Out-of-Distribution (OOD) detection that leverages the concept of relative angles in the feature space. By analyzing the angular displacement of a test sample with respect to class prototypes, ORA provides a robust and effective signal for distinguishing in-distribution (ID) data from OOD data.

Workflow

The project is structured into two main stages: feature extraction and OOD detection.

1. Feature Extraction

First, you need to extract and cache the features from the backbone models. This is done using feat_extract_all.py for ImageNet-based models and feat_extract_cifar.py for CIFAR-based models. These scripts will save the feature representations, logits, and labels to disk, which allows for faster experimentation in the next stage.

2. OOD Detection

Once the features are cached, you can run the OOD detection experiments. The main scripts for this are:

  • run_imagenet_unified.py: For experiments on ImageNet and its variants.
  • run_cifar.py: For experiments on CIFAR-10.

These scripts load the pre-computed features and apply various OOD detection methods to evaluate their performance.

Supported Components

Backbone Models

The following backbone architectures are supported:

  • resnet18
  • resnet18-supcon
  • resnet50
  • resnet50-supcon
  • vit
  • mobile
  • convnext
  • convnextpre
  • swin
  • swinpre
  • deit
  • deitpre
  • densenet
  • eva
  • clip

OOD Datasets

The following OOD datasets are supported for evaluation against ImageNet:

  • iNaturalist (inat)
  • SUN (sun50)
  • Places (places50)
  • Describable Textures Dataset (dtd)

OOD Detection Methods

This repository includes implementations for several OOD detection methods, including our proposed method, ORA. Implementations can be seen in utils/ood_methods.py

Setup

The download.sh script is provided to download the necessary pretrained models (e.g., ResNets with SupCon loss) and the OOD datasets required to run the experiments.

Citation

If you find this work useful, please consider citing our paper:

@misc{demirel2025outofdistributiondetectionrelativeangles,
      title={Out-of-Distribution Detection with Relative Angles}, 
      author={Berker Demirel and Marco Fumero and Francesco Locatello},
      year={2025},
      eprint={2410.04525},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/2410.04525}, 
}

Acknowledgements

Feature extraction and metric computations are adapted from the official repository for the fDBD paper. We thank the authors for making their code public.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •