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 details)

Uploaded Python 3

File details

Details for the file pytorch_ood-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pytorch_ood-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for pytorch_ood-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c15558d34a25170a58c052059751a90454daf92b3e31b08c552d673a02f3bb7b
MD5 e8c7014161cdb951d0aef9276405b7cd
BLAKE2b-256 21e8f7a03fa3dc3b95e862ac689fabf1afbf5c91f57ecee71cdd06cee1fa9a23

See more details on using hashes here.

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