kkirchheim/pytorch-ood

👽 Out-of-Distribution Detection with PyTorch

What it solves

Deep learning models often fail silently when presented with data that is significantly different from their training set (Out-of-Distribution or OOD data). This library provides a standardized toolkit to detect when a model is encountering such "unknown" inputs, helping to prevent unreliable predictions in production environments.

How it works

The library implements a wide range of academic OOD detection algorithms that analyze a model's internal states—such as softmax probabilities, energy scores, or feature activations—to determine if an input is likely an outlier. It provides a consistent interface for these detectors, allowing users to swap between different methods, evaluate them against standard benchmarks, and integrate them into existing PyTorch workflows.

Who it’s for

This project is designed for machine learning researchers and engineers who need to evaluate model robustness, implement uncertainty estimation, or build systems that can safely reject inputs that fall outside the model's training distribution.

Highlights

  • Extensive collection of state-of-the-art OOD detection algorithms (e.g., Energy-Based, ODIN, Mahalanobis, ReAct, ViM).
  • Built-in support for common OOD benchmarks like OpenOOD.
  • Compatible with popular frameworks like PyTorch Lightning and segmentation-models-pytorch.
  • Includes pre-trained model weights and utilities for data augmentation and custom loss functions.
  • Standardized API for evaluating and comparing different detection strategies.

Related

  • Project
  • Project
  • Project
  • Project
  • Project