Skip to main content

PyTorch Out-of-Distribution Detection

Project description

PyTorch Out-of-Distribution Detection

Python Code style: black

Python library to accelerate research in fields related to Out-of-Distribution Detection, Open-Set Recognition, Novelty Detection, Confidence Estimation and Anomaly Detection based on Deep Neural Networks (with PyTorch).

This library implements

  • Objective Functions
  • OOD Detection Methods
  • Datasets used in academic literature
  • Neural Network Architectures used in academic literature, as well as pretrained weights
  • Useful Utilities

It is provided with the aim to speed up research and to facilitate reproducibility.

Installation

pip install pytorch-ood

Optional Dependencies

For OpenMax, you will have to install libmr, which is currently broken. You will have to install cython and libmr afterwards manually.

Quick Start

Load model pre-trained with energy regularization, and predict on some dataset data_loader using Energy-based outlier scores.

from pytorch_ood.model import WideResNet
from pytorch_ood import NegativeEnergy
from pytorch_ood.metrics import OODMetrics

model = WideResNet.from_pretrained("er-cifar10-tune").eval().cuda()
detector = NegativeEnergy(model)

metrics = OODMetrics()

for x, y in data_loader:
    metrics.update(detector(x.cuda()), y)

print(metrics.compute())

Implemented Methods

Method Reference
OpenMax
ODIN
Mahalanobis
Monte Carlo Dropout
Softmax Thresholding Baseline
Energy Based OOD Detection
Objectosphere
Outlier Exposure
Deep SVDD

Roadmap

  • add additional OOD methods
  • add more datasets, e.g. for audio and video
  • implement additional tests
  • migrate to DataPipes

Contributing

We encourage everyone to contribute to this project by adding implementations of OOD Detection methods, datasets etc, or check the existing implementations for bugs.

License

The code is licensed under Apache 2.0. We have taken care to make sure any third party code included or adapted has compatible (permissive) licenses such as MIT, BSD, etc. The legal implications of using pre-trained models in commercial services are, to our knowledge, not fully understood.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pytorch_ood-0.0.2-py3-none-any.whl (18.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page