pytorch-ood


Namepytorch-ood JSON
Version 0.1.9 PyPI version JSON
download
home_pagehttps://github.com/kkirchheim/pytorch-ood
SummaryA Library for Out-of-Distribution Detection with PyTorch
upload_time2024-06-19 10:40:07
maintainerNone
docs_urlNone
authorKonstantin Kirchheim
requires_python>=3.8
licenseApache 2.0
keywords ood pytorch out-of-distribution detection
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            PyTorch Out-of-Distribution Detection
****************************************

|docs| |version| |license| |python-version| |downloads|


.. |docs| image:: https://img.shields.io/badge/docs-online-blue?style=for-the-badge
   :target: https://pytorch-ood.readthedocs.io/en/latest/
   :alt: Documentation
.. |version| image:: https://img.shields.io/pypi/v/pytorch-ood?color=light&style=for-the-badge
   :target: https://pypi.org/project/pytorch-ood/
   :alt: License
.. |license| image:: https://img.shields.io/pypi/l/pytorch-ood?style=for-the-badge
   :target: https://gitlab.com/kkirchheim/pytorch-ood/-/blob/master/LICENSE
   :alt: License
.. |python-version| image:: https://img.shields.io/badge/-Python 3.8+-blue?logo=python&logoColor=white&style=for-the-badge
   :target: https://www.python.org/
   :alt: Python
.. |downloads| image:: https://img.shields.io/pypi/dm/pytorch-ood?style=for-the-badge
   :target: https://pepy.tech/project/pytorch-ood
   :alt: Downloads

-----

.. image:: docs/_static/pytorch-ood-logo.jpg
   :align: center
   :width: 100%
   :alt: pytorch-ood-logo

-----


Out-of-Distribution (OOD) Detection with Deep Neural Networks based on PyTorch.

The library provides:

- Out-of-Distribution Detection Methods
- Loss Functions
- Datasets
- Neural Network Architectures as well as pretrained weights
- Useful Utilities

and is designed such that it should be compatible with frameworks
like `pytorch-lightning <https://www.pytorchlightning.ai>`_ and
`pytorch-segmentation-models <https://github.com/qubvel/segmentation_models.pytorch>`_.
The library also covers some methods from closely related fields such as Open-Set Recognition, Novelty Detection,
Confidence Estimation and Anomaly Detection.



📚  Documentation
^^^^^^^^^^^^^^^^^^^
The documentation is available `here <https://pytorch-ood.readthedocs.io/en/latest/>`_.

**NOTE**: An important convention adopted in ``pytorch-ood`` is that **OOD detectors predict outlier scores**
that should be larger for outliers than for inliers.
If you notice that the scores predicted by a detector do not match the formulas in the corresponding publication,
it may be possible that we multiplied the scores by negative one to comply with this convention.

⏳ Quick Start
^^^^^^^^^^^^^^^^^
Load model pre-trained on CIFAR-10 with the Energy-Bounded Learning Loss [#EnergyBasedOOD]_, and predict on some dataset ``data_loader`` using
Energy-based Out-of-Distribution Detection [#EnergyBasedOOD]_, calculating the common OOD detection metrics:

.. code-block:: python

    from pytorch_ood.model import WideResNet
    from pytorch_ood.detector import EnergyBased
    from pytorch_ood.utils import OODMetrics

    # Create Neural Network
    model = WideResNet(num_classes=10, pretrained="er-cifar10-tune").eval().cuda()

    # Create detector
    detector = EnergyBased(model)

    # Evaluate
    metrics = OODMetrics()

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

    print(metrics.compute())


You can find more examples in the `documentation <https://pytorch-ood.readthedocs.io/en/latest/auto_examples/benchmarks/>`_.

🛠 ️️Installation
^^^^^^^^^^^^^^^^^
The package can be installed via PyPI:

.. code-block:: shell

   pip install pytorch-ood



**Dependencies**


* ``torch``
* ``torchvision``
* ``scipy``
* ``torchmetrics``


**Optional Dependencies**

* ``scikit-learn`` for ViM
* ``gdown`` to download some datasets and model weights
* ``pandas`` for the `examples <https://pytorch-ood.readthedocs.io/en/latest/auto_examples/index.html>`_.
* ``segmentation-models-pytorch`` to run the examples for anomaly segmentation


📦 Implemented
^^^^^^^^^^^^^^^

**Detectors**:

+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+
| Detector                    | Description                                                                                    | Year | Ref                |
+=============================+================================================================================================+======+====================+
| OpenMax                     | Implementation of the OpenMax Layer as proposed in the paper *Towards Open Set Deep Networks*. | 2016 | [#OpenMax]_        |
+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+
| Monte Carlo Dropout         | Implements Monte Carlo Dropout.                                                                | 2016 | [#MonteCarloDrop]_ |
+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+
| Maximum Softmax Probability | Implements the Softmax Baseline for OOD and Error detection.                                   | 2017 | [#Softmax]_        |
+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+
| ODIN                        | ODIN is a preprocessing method for inputs that aims to increase the discriminability of        | 2018 | [#ODIN]_           |
|                             | the softmax outputs for In- and Out-of-Distribution data.                                      |      |                    |
+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+
| Mahalanobis                 | Implements the Mahalanobis Method.                                                             | 2018 | [#Mahalanobis]_    |
+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+
| Energy-Based OOD Detection  | Implements the Energy Score of *Energy-based Out-of-distribution Detection*.                   | 2020 | [#EnergyBasedOOD]_ |
+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+
| Entropy                     | Uses entropy to detect OOD inputs.                                                             | 2021 | [#MaxEntropy]_     |
+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+
| Maximum Logit               | Implements the MaxLogit method.                                                                | 2022 | [#StreeHaz]_       |
+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+
| KL-Matching                 | Implements the KL-Matching method for Multi-Class classification.                              | 2022 | [#StreeHaz]_       |
+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+
| ViM                         | Implements Virtual Logit Matching.                                                             | 2022 | [#ViM]_            |
+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+

**Objective Functions**:

+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+
| Objective Function         | Description                                                                                      | Year | Ref                |
+============================+==================================================================================================+======+====================+
| Objectosphere              | Implementation of the paper *Reducing Network Agnostophobia*.                                    | 2016 | [#Objectosphere]_  |
+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+
| Center Loss                | Generalized version of the *Center Loss* from the Paper *A Discriminative Feature Learning       | 2016 | [#CenterLoss]_     |
|                            | Approach for Deep Face Recognition*.                                                             |      |                    |
+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+
| Outlier Exposure           | Implementation of the paper *Deep Anomaly Detection With Outlier Exposure*.                      | 2018 | [#OE]_             |
+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+
| Deep SVDD                  | Implementation of the Deep Support Vector Data Description from the paper *Deep One-Class        | 2018 | [#SVDD]_           |
|                            | Classification*.                                                                                 |      |                    |
+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+
| Energy Regularization      | Adds a regularization term to the cross-entropy that aims to increase the energy gap between IN  | 2020 | [#EnergyBasedOOD]_ |
|                            | and OOD samples.                                                                                 |      |                    |
+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+
| CAC Loss                   | Class Anchor Clustering Loss from *Class Anchor Clustering: a Distance-based Loss for Training   | 2021 | [#CACLoss]_        |
|                            | Open Set Classifiers*                                                                            |      |                    |
+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+
| Entropy Maximization       | Entropy maximization and meta classification for OOD in semantic segmentation                    | 2021 | [#MaxEntropy]_     |
+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+
| II Loss                    | Implementation of II Loss function from *Learning a neural network-based representation for      | 2022 | [#IILoss]_         |
|                            | open set recognition*.                                                                           |      |                    |
+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+
| MCHAD Loss                 | Implementation of the MCHAD Loss friom the paper *Multi Class Hypersphere Anomaly Detection*.    | 2022 | [#MCHAD]_          |
+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+


**Image Datasets**:

+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+
| Dataset               | Description                                                                                                     | Year | Ref           |
+=======================+=================================================================================================================+======+===============+
| TinyImages            | The TinyImages dataset is often used as auxiliary OOD training data. However, use is discouraged.               | 2012 | [#TinyImgs]_  |
+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+
| Textures              | Textures dataset, also known as DTD, often used as OOD Examples.                                                | 2013 | [#Textures]_  |
+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+
| FoolingImages         | OOD Images Generated to fool certain Deep Neural Networks.                                                      | 2014 | [#FImages]_   |
+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+
| TinyImages300k        | A cleaned version of the TinyImages Dataset with 300.000 images, often used as auxiliary OOD training data.     | 2018 | [#OE]_        |
+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+
| MNIST-C               | Corrupted version of the MNIST.                                                                                 | 2019 | [#MnistC]_    |
+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+
| CIFAR10-C             | Corrupted version of the CIFAR 10.                                                                              | 2019 | [#Cifar10]_   |
+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+
| CIFAR100-C            | Corrupted version of the CIFAR 100.                                                                             | 2019 | [#Cifar10]_   |
+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+
| ImageNet-C            | Corrupted version of the ImageNet.                                                                              | 2019 | [#Cifar10]_   |
+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+
| ImageNet - A, O, R    | Different Outlier Variants for the ImageNet.                                                                    | 2019 | [#ImageNets]_ |
+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+
| MVTech-AD             | MVTech Anomaly Segmentation Dataset                                                                             | 2021 | [#MVTech]_    |
+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+
| StreetHazards         | Anomaly Segmentation Dataset                                                                                    | 2022 | [#StreeHaz]_  |
+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+
| PixMix                | PixMix image augmentation method                                                                                | 2022 | [#PixMix]_    |
+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+


**Text Datasets**:

+-------------+---------------------------------------------------------------------------------------------------------------------------+------+-----------------+
| Dataset     | Description                                                                                                               | Year | Ref             |
+=============+===========================================================================================================================+======+=================+
| Multi30k    | Multi-30k dataset, as used by Hendrycks et al. in the OOD baseline paper.                                                 | 2016 | [#Multi30k]_    |
+-------------+---------------------------------------------------------------------------------------------------------------------------+------+-----------------+
| WikiText2   | Texts from the wikipedia often used as auxiliary OOD training data.                                                       | 2016 | [#WikiText2]_   |
+-------------+---------------------------------------------------------------------------------------------------------------------------+------+-----------------+
| WikiText103 | Texts from the wikipedia often used as auxiliary OOD training data.                                                       | 2016 | [#WikiText2]_   |
+-------------+---------------------------------------------------------------------------------------------------------------------------+------+-----------------+
| NewsGroup20 | Textx from different newsgroups, as used by Hendrycks et al. in the OOD baseline paper.                                   |      |                 |
+-------------+---------------------------------------------------------------------------------------------------------------------------+------+-----------------+




🤝  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.


📝 Citing
^^^^^^^^^^

``pytorch-ood`` was presented at a CVPR Workshop in 2022.
If you use it in a scientific publication, please consider citing::

    @InProceedings{kirchheim2022pytorch,
        author    = {Kirchheim, Konstantin and Filax, Marco and Ortmeier, Frank},
        title     = {PyTorch-OOD: A Library for Out-of-Distribution Detection Based on PyTorch},
        booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops},
        month     = {June},
        year      = {2022},
        pages     = {4351-4360}
    }

🛡️ ️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.

----

🔗 References
^^^^^^^^^^^^^^

.. [#OpenMax]  Bendale, A., & Boult, T. E. (2016). Towards open set deep networks. CVPR.

.. [#ODIN] Liang, S., Li, Y., & Srikant, R. (2017). Enhancing the reliability of out-of-distribution image detection in neural networks. ICLR.

.. [#Mahalanobis] Lee, K., Lee, K., Lee, H., & Shin, J. (2018). A simple unified framework for detecting out-of-distribution samples and adversarial attacks. NeurIPS.

.. [#MonteCarloDrop] Gal, Y., & Ghahramani, Z. (2016). Dropout as a bayesian approximation: Representing model uncertainty in deep learning. ICML.

.. [#Softmax] Hendrycks, D., & Gimpel, K. (2016). A baseline for detecting misclassified and out-of-distribution examples in neural networks. ICLR.

.. [#EnergyBasedOOD] Liu, W., Wang, X., Owens, J., & Li, Y. (2020). Energy-based out-of-distribution detection. NeurIPS.

.. [#Objectosphere] Dhamija, A. R., Günther, M., & Boult, T. (2018). Reducing network agnostophobia. NeurIPS.

.. [#OE] Hendrycks, D., Mazeika, M., & Dietterich, T. (2018). Deep anomaly detection with outlier exposure. ICLR.

.. [#SVDD] Ruff, L.,  et al. (2018). Deep one-class classification. ICML.

.. [#IILoss] Hassen, M., & Chan, P. K. (2020). Learning a neural-network-based representation for open set recognition. SDM.

.. [#CACLoss] Miller, D., Sunderhauf, N., Milford, M., & Dayoub, F. (2021). Class anchor clustering: A loss for distance-based open set recognition. WACV.

.. [#CenterLoss] Wen, Y., Zhang, K., Li, Z., & Qiao, Y. (2016). A discriminative feature learning approach for deep face recognition. ECCV.

.. [#Cifar10] Hendrycks, D., & Dietterich, T. (2019). Benchmarking neural network robustness to common corruptions and perturbations. ICLR.

.. [#FImages] Nguyen, A., Yosinski, J., & Clune, J. (2015). Deep neural networks are easily fooled: High confidence predictions for unrecognizable images. CVPR.

.. [#ImageNets] Hendrycks, D., Zhao, K., Basart, S., Steinhardt, J., & Song, D. (2021). Natural adversarial examples. CVPR.

.. [#MnistC] Mu, N., & Gilmer, J. (2019). MNIST-C: A robustness benchmark for computer vision. ICLR Workshop.

.. [#StreeHaz] Hendrycks, D., Basart, S., Mazeika, M., Mostajabi, M., Steinhardt, J., & Song, D. (2022). Scaling out-of-distribution detection for real-world settings. ICML.

.. [#Textures] Cimpoi, M., Maji, S., Kokkinos, I., Mohamed, S., & Vedaldi, A. (2014). Describing textures in the wild. CVPR.

.. [#TinyImgs] Torralba, A., Fergus, R., & Freeman, W. T. (2007). 80 million tiny images: a large dataset for non-parametric object and scene recognition. IEEE Transactions on Pattern Analysis and Machine Learning.

.. [#Multi30k] Elliott, D., Frank, S., Sima'an, K., & Specia, L. (2016). Multi30k: Multilingual english-german image descriptions. Proceedings of the 5th Workshop on Vision and Language.

.. [#WikiText2] Merity, S., Xiong, C., Bradbury, J., & Socher, R. (2016). Pointer sentinel mixture models. `ArXiv <https://arxiv.org/abs/1609.07843>`_

.. [#MVTech] Bergmann, P., Batzner, K., et al. (2021) The MVTec Anomaly Detection Dataset: A Comprehensive Real-World Dataset for Unsupervised Anomaly Detection. IJCV.

.. [#MCHAD] Kirchheim, K., Filax, M., Ortmeier, F. (2022) Multi Class Hypersphere Anomaly Detection. ICPR

.. [#ViM] Wang, H., Li, Z., Feng, L., Zhang, W. (2022) ViM: Out-Of-Distribution with Virtual-logit Matching. CVPR

.. [#PixMix] Hendrycks, D, Zou, A,  et al. (2022) PixMix: Dreamlike Pictures Comprehensively Improve Safety Measures. CVPR

.. [#MaxEntropy] Chan R,  et al. (2021) Entropy maximization and meta classification for out-of-distribution detection in semantic segmentation. CVPR

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kkirchheim/pytorch-ood",
    "name": "pytorch-ood",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "OOD, PyTorch, Out-of-Distribution Detection",
    "author": "Konstantin Kirchheim",
    "author_email": null,
    "download_url": null,
    "platform": null,
    "description": "PyTorch Out-of-Distribution Detection\n****************************************\n\n|docs| |version| |license| |python-version| |downloads|\n\n\n.. |docs| image:: https://img.shields.io/badge/docs-online-blue?style=for-the-badge\n   :target: https://pytorch-ood.readthedocs.io/en/latest/\n   :alt: Documentation\n.. |version| image:: https://img.shields.io/pypi/v/pytorch-ood?color=light&style=for-the-badge\n   :target: https://pypi.org/project/pytorch-ood/\n   :alt: License\n.. |license| image:: https://img.shields.io/pypi/l/pytorch-ood?style=for-the-badge\n   :target: https://gitlab.com/kkirchheim/pytorch-ood/-/blob/master/LICENSE\n   :alt: License\n.. |python-version| image:: https://img.shields.io/badge/-Python 3.8+-blue?logo=python&logoColor=white&style=for-the-badge\n   :target: https://www.python.org/\n   :alt: Python\n.. |downloads| image:: https://img.shields.io/pypi/dm/pytorch-ood?style=for-the-badge\n   :target: https://pepy.tech/project/pytorch-ood\n   :alt: Downloads\n\n-----\n\n.. image:: docs/_static/pytorch-ood-logo.jpg\n   :align: center\n   :width: 100%\n   :alt: pytorch-ood-logo\n\n-----\n\n\nOut-of-Distribution (OOD) Detection with Deep Neural Networks based on PyTorch.\n\nThe library provides:\n\n- Out-of-Distribution Detection Methods\n- Loss Functions\n- Datasets\n- Neural Network Architectures as well as pretrained weights\n- Useful Utilities\n\nand is designed such that it should be compatible with frameworks\nlike `pytorch-lightning <https://www.pytorchlightning.ai>`_ and\n`pytorch-segmentation-models <https://github.com/qubvel/segmentation_models.pytorch>`_.\nThe library also covers some methods from closely related fields such as Open-Set Recognition, Novelty Detection,\nConfidence Estimation and Anomaly Detection.\n\n\n\n\ud83d\udcda  Documentation\n^^^^^^^^^^^^^^^^^^^\nThe documentation is available `here <https://pytorch-ood.readthedocs.io/en/latest/>`_.\n\n**NOTE**: An important convention adopted in ``pytorch-ood`` is that **OOD detectors predict outlier scores**\nthat should be larger for outliers than for inliers.\nIf you notice that the scores predicted by a detector do not match the formulas in the corresponding publication,\nit may be possible that we multiplied the scores by negative one to comply with this convention.\n\n\u23f3 Quick Start\n^^^^^^^^^^^^^^^^^\nLoad model pre-trained on CIFAR-10 with the Energy-Bounded Learning Loss [#EnergyBasedOOD]_, and predict on some dataset ``data_loader`` using\nEnergy-based Out-of-Distribution Detection [#EnergyBasedOOD]_, calculating the common OOD detection metrics:\n\n.. code-block:: python\n\n    from pytorch_ood.model import WideResNet\n    from pytorch_ood.detector import EnergyBased\n    from pytorch_ood.utils import OODMetrics\n\n    # Create Neural Network\n    model = WideResNet(num_classes=10, pretrained=\"er-cifar10-tune\").eval().cuda()\n\n    # Create detector\n    detector = EnergyBased(model)\n\n    # Evaluate\n    metrics = OODMetrics()\n\n    for x, y in data_loader:\n        metrics.update(detector(x.cuda()), y)\n\n    print(metrics.compute())\n\n\nYou can find more examples in the `documentation <https://pytorch-ood.readthedocs.io/en/latest/auto_examples/benchmarks/>`_.\n\n\ud83d\udee0 \ufe0f\ufe0fInstallation\n^^^^^^^^^^^^^^^^^\nThe package can be installed via PyPI:\n\n.. code-block:: shell\n\n   pip install pytorch-ood\n\n\n\n**Dependencies**\n\n\n* ``torch``\n* ``torchvision``\n* ``scipy``\n* ``torchmetrics``\n\n\n**Optional Dependencies**\n\n* ``scikit-learn`` for ViM\n* ``gdown`` to download some datasets and model weights\n* ``pandas`` for the `examples <https://pytorch-ood.readthedocs.io/en/latest/auto_examples/index.html>`_.\n* ``segmentation-models-pytorch`` to run the examples for anomaly segmentation\n\n\n\ud83d\udce6 Implemented\n^^^^^^^^^^^^^^^\n\n**Detectors**:\n\n+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+\n| Detector                    | Description                                                                                    | Year | Ref                |\n+=============================+================================================================================================+======+====================+\n| OpenMax                     | Implementation of the OpenMax Layer as proposed in the paper *Towards Open Set Deep Networks*. | 2016 | [#OpenMax]_        |\n+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+\n| Monte Carlo Dropout         | Implements Monte Carlo Dropout.                                                                | 2016 | [#MonteCarloDrop]_ |\n+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+\n| Maximum Softmax Probability | Implements the Softmax Baseline for OOD and Error detection.                                   | 2017 | [#Softmax]_        |\n+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+\n| ODIN                        | ODIN is a preprocessing method for inputs that aims to increase the discriminability of        | 2018 | [#ODIN]_           |\n|                             | the softmax outputs for In- and Out-of-Distribution data.                                      |      |                    |\n+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+\n| Mahalanobis                 | Implements the Mahalanobis Method.                                                             | 2018 | [#Mahalanobis]_    |\n+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+\n| Energy-Based OOD Detection  | Implements the Energy Score of *Energy-based Out-of-distribution Detection*.                   | 2020 | [#EnergyBasedOOD]_ |\n+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+\n| Entropy                     | Uses entropy to detect OOD inputs.                                                             | 2021 | [#MaxEntropy]_     |\n+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+\n| Maximum Logit               | Implements the MaxLogit method.                                                                | 2022 | [#StreeHaz]_       |\n+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+\n| KL-Matching                 | Implements the KL-Matching method for Multi-Class classification.                              | 2022 | [#StreeHaz]_       |\n+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+\n| ViM                         | Implements Virtual Logit Matching.                                                             | 2022 | [#ViM]_            |\n+-----------------------------+------------------------------------------------------------------------------------------------+------+--------------------+\n\n**Objective Functions**:\n\n+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+\n| Objective Function         | Description                                                                                      | Year | Ref                |\n+============================+==================================================================================================+======+====================+\n| Objectosphere              | Implementation of the paper *Reducing Network Agnostophobia*.                                    | 2016 | [#Objectosphere]_  |\n+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+\n| Center Loss                | Generalized version of the *Center Loss* from the Paper *A Discriminative Feature Learning       | 2016 | [#CenterLoss]_     |\n|                            | Approach for Deep Face Recognition*.                                                             |      |                    |\n+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+\n| Outlier Exposure           | Implementation of the paper *Deep Anomaly Detection With Outlier Exposure*.                      | 2018 | [#OE]_             |\n+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+\n| Deep SVDD                  | Implementation of the Deep Support Vector Data Description from the paper *Deep One-Class        | 2018 | [#SVDD]_           |\n|                            | Classification*.                                                                                 |      |                    |\n+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+\n| Energy Regularization      | Adds a regularization term to the cross-entropy that aims to increase the energy gap between IN  | 2020 | [#EnergyBasedOOD]_ |\n|                            | and OOD samples.                                                                                 |      |                    |\n+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+\n| CAC Loss                   | Class Anchor Clustering Loss from *Class Anchor Clustering: a Distance-based Loss for Training   | 2021 | [#CACLoss]_        |\n|                            | Open Set Classifiers*                                                                            |      |                    |\n+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+\n| Entropy Maximization       | Entropy maximization and meta classification for OOD in semantic segmentation                    | 2021 | [#MaxEntropy]_     |\n+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+\n| II Loss                    | Implementation of II Loss function from *Learning a neural network-based representation for      | 2022 | [#IILoss]_         |\n|                            | open set recognition*.                                                                           |      |                    |\n+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+\n| MCHAD Loss                 | Implementation of the MCHAD Loss friom the paper *Multi Class Hypersphere Anomaly Detection*.    | 2022 | [#MCHAD]_          |\n+----------------------------+--------------------------------------------------------------------------------------------------+------+--------------------+\n\n\n**Image Datasets**:\n\n+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+\n| Dataset               | Description                                                                                                     | Year | Ref           |\n+=======================+=================================================================================================================+======+===============+\n| TinyImages            | The TinyImages dataset is often used as auxiliary OOD training data. However, use is discouraged.               | 2012 | [#TinyImgs]_  |\n+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+\n| Textures              | Textures dataset, also known as DTD, often used as OOD Examples.                                                | 2013 | [#Textures]_  |\n+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+\n| FoolingImages         | OOD Images Generated to fool certain Deep Neural Networks.                                                      | 2014 | [#FImages]_   |\n+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+\n| TinyImages300k        | A cleaned version of the TinyImages Dataset with 300.000 images, often used as auxiliary OOD training data.     | 2018 | [#OE]_        |\n+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+\n| MNIST-C               | Corrupted version of the MNIST.                                                                                 | 2019 | [#MnistC]_    |\n+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+\n| CIFAR10-C             | Corrupted version of the CIFAR 10.                                                                              | 2019 | [#Cifar10]_   |\n+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+\n| CIFAR100-C            | Corrupted version of the CIFAR 100.                                                                             | 2019 | [#Cifar10]_   |\n+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+\n| ImageNet-C            | Corrupted version of the ImageNet.                                                                              | 2019 | [#Cifar10]_   |\n+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+\n| ImageNet - A, O, R    | Different Outlier Variants for the ImageNet.                                                                    | 2019 | [#ImageNets]_ |\n+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+\n| MVTech-AD             | MVTech Anomaly Segmentation Dataset                                                                             | 2021 | [#MVTech]_    |\n+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+\n| StreetHazards         | Anomaly Segmentation Dataset                                                                                    | 2022 | [#StreeHaz]_  |\n+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+\n| PixMix                | PixMix image augmentation method                                                                                | 2022 | [#PixMix]_    |\n+-----------------------+-----------------------------------------------------------------------------------------------------------------+------+---------------+\n\n\n**Text Datasets**:\n\n+-------------+---------------------------------------------------------------------------------------------------------------------------+------+-----------------+\n| Dataset     | Description                                                                                                               | Year | Ref             |\n+=============+===========================================================================================================================+======+=================+\n| Multi30k    | Multi-30k dataset, as used by Hendrycks et al. in the OOD baseline paper.                                                 | 2016 | [#Multi30k]_    |\n+-------------+---------------------------------------------------------------------------------------------------------------------------+------+-----------------+\n| WikiText2   | Texts from the wikipedia often used as auxiliary OOD training data.                                                       | 2016 | [#WikiText2]_   |\n+-------------+---------------------------------------------------------------------------------------------------------------------------+------+-----------------+\n| WikiText103 | Texts from the wikipedia often used as auxiliary OOD training data.                                                       | 2016 | [#WikiText2]_   |\n+-------------+---------------------------------------------------------------------------------------------------------------------------+------+-----------------+\n| NewsGroup20 | Textx from different newsgroups, as used by Hendrycks et al. in the OOD baseline paper.                                   |      |                 |\n+-------------+---------------------------------------------------------------------------------------------------------------------------+------+-----------------+\n\n\n\n\n\ud83e\udd1d  Contributing\n^^^^^^^^^^^^^^^^^\nWe encourage everyone to contribute to this project by adding implementations of OOD Detection methods, datasets etc,\nor check the existing implementations for bugs.\n\n\n\ud83d\udcdd Citing\n^^^^^^^^^^\n\n``pytorch-ood`` was presented at a CVPR Workshop in 2022.\nIf you use it in a scientific publication, please consider citing::\n\n    @InProceedings{kirchheim2022pytorch,\n        author    = {Kirchheim, Konstantin and Filax, Marco and Ortmeier, Frank},\n        title     = {PyTorch-OOD: A Library for Out-of-Distribution Detection Based on PyTorch},\n        booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops},\n        month     = {June},\n        year      = {2022},\n        pages     = {4351-4360}\n    }\n\n\ud83d\udee1\ufe0f \ufe0fLicense\n^^^^^^^^^^^\n\nThe 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.\nThe legal implications of using pre-trained models in commercial services are, to our knowledge, not fully understood.\n\n----\n\n\ud83d\udd17 References\n^^^^^^^^^^^^^^\n\n.. [#OpenMax]  Bendale, A., & Boult, T. E. (2016). Towards open set deep networks. CVPR.\n\n.. [#ODIN] Liang, S., Li, Y., & Srikant, R. (2017). Enhancing the reliability of out-of-distribution image detection in neural networks. ICLR.\n\n.. [#Mahalanobis] Lee, K., Lee, K., Lee, H., & Shin, J. (2018). A simple unified framework for detecting out-of-distribution samples and adversarial attacks. NeurIPS.\n\n.. [#MonteCarloDrop] Gal, Y., & Ghahramani, Z. (2016). Dropout as a bayesian approximation: Representing model uncertainty in deep learning. ICML.\n\n.. [#Softmax] Hendrycks, D., & Gimpel, K. (2016). A baseline for detecting misclassified and out-of-distribution examples in neural networks. ICLR.\n\n.. [#EnergyBasedOOD] Liu, W., Wang, X., Owens, J., & Li, Y. (2020). Energy-based out-of-distribution detection. NeurIPS.\n\n.. [#Objectosphere] Dhamija, A. R., G\u00fcnther, M., & Boult, T. (2018). Reducing network agnostophobia. NeurIPS.\n\n.. [#OE] Hendrycks, D., Mazeika, M., & Dietterich, T. (2018). Deep anomaly detection with outlier exposure. ICLR.\n\n.. [#SVDD] Ruff, L.,  et al. (2018). Deep one-class classification. ICML.\n\n.. [#IILoss] Hassen, M., & Chan, P. K. (2020). Learning a neural-network-based representation for open set recognition. SDM.\n\n.. [#CACLoss] Miller, D., Sunderhauf, N., Milford, M., & Dayoub, F. (2021). Class anchor clustering: A loss for distance-based open set recognition. WACV.\n\n.. [#CenterLoss] Wen, Y., Zhang, K., Li, Z., & Qiao, Y. (2016). A discriminative feature learning approach for deep face recognition. ECCV.\n\n.. [#Cifar10] Hendrycks, D., & Dietterich, T. (2019). Benchmarking neural network robustness to common corruptions and perturbations. ICLR.\n\n.. [#FImages] Nguyen, A., Yosinski, J., & Clune, J. (2015). Deep neural networks are easily fooled: High confidence predictions for unrecognizable images. CVPR.\n\n.. [#ImageNets] Hendrycks, D., Zhao, K., Basart, S., Steinhardt, J., & Song, D. (2021). Natural adversarial examples. CVPR.\n\n.. [#MnistC] Mu, N., & Gilmer, J. (2019). MNIST-C: A robustness benchmark for computer vision. ICLR Workshop.\n\n.. [#StreeHaz] Hendrycks, D., Basart, S., Mazeika, M., Mostajabi, M., Steinhardt, J., & Song, D. (2022). Scaling out-of-distribution detection for real-world settings. ICML.\n\n.. [#Textures] Cimpoi, M., Maji, S., Kokkinos, I., Mohamed, S., & Vedaldi, A. (2014). Describing textures in the wild. CVPR.\n\n.. [#TinyImgs] Torralba, A., Fergus, R., & Freeman, W. T. (2007). 80 million tiny images: a large dataset for non-parametric object and scene recognition. IEEE Transactions on Pattern Analysis and Machine Learning.\n\n.. [#Multi30k] Elliott, D., Frank, S., Sima'an, K., & Specia, L. (2016). Multi30k: Multilingual english-german image descriptions. Proceedings of the 5th Workshop on Vision and Language.\n\n.. [#WikiText2] Merity, S., Xiong, C., Bradbury, J., & Socher, R. (2016). Pointer sentinel mixture models. `ArXiv <https://arxiv.org/abs/1609.07843>`_\n\n.. [#MVTech] Bergmann, P., Batzner, K., et al. (2021) The MVTec Anomaly Detection Dataset: A Comprehensive Real-World Dataset for Unsupervised Anomaly Detection. IJCV.\n\n.. [#MCHAD] Kirchheim, K., Filax, M., Ortmeier, F. (2022) Multi Class Hypersphere Anomaly Detection. ICPR\n\n.. [#ViM] Wang, H., Li, Z., Feng, L., Zhang, W. (2022) ViM: Out-Of-Distribution with Virtual-logit Matching. CVPR\n\n.. [#PixMix] Hendrycks, D, Zou, A,  et al. (2022) PixMix: Dreamlike Pictures Comprehensively Improve Safety Measures. CVPR\n\n.. [#MaxEntropy] Chan R,  et al. (2021) Entropy maximization and meta classification for out-of-distribution detection in semantic segmentation. CVPR\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "A Library for Out-of-Distribution Detection with PyTorch",
    "version": "0.1.9",
    "project_urls": {
        "Bug Tracker": "https://github.com/kkirchheim/pytorch-ood/issues",
        "Homepage": "https://github.com/kkirchheim/pytorch-ood",
        "repository": "https://github.com/kkirchheim/pytorch-ood"
    },
    "split_keywords": [
        "ood",
        " pytorch",
        " out-of-distribution detection"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "685798eca21598bb729d128adc4156de2789ebfca550bfee8af931acd67bdd99",
                "md5": "9ed7948c58b125747ad79f6b24ad4236",
                "sha256": "9ae195ff093d104b9bba2d9c134850025019e286e4fd1f9f99540acd0831b6d9"
            },
            "downloads": -1,
            "filename": "pytorch_ood-0.1.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9ed7948c58b125747ad79f6b24ad4236",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 130411,
            "upload_time": "2024-06-19T10:40:07",
            "upload_time_iso_8601": "2024-06-19T10:40:07.403365Z",
            "url": "https://files.pythonhosted.org/packages/68/57/98eca21598bb729d128adc4156de2789ebfca550bfee8af931acd67bdd99/pytorch_ood-0.1.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-19 10:40:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kkirchheim",
    "github_project": "pytorch-ood",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pytorch-ood"
}
        
Elapsed time: 1.54221s