tfds-defect-detection

A tensorflow dataset builder for semantic defect segmentation datasets like MVTEC and VisA. Includes options to generate synthetic anomalies

https://github.com/thetoby9944/tfds_defect_detection

Science Score: 39.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.0%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

A tensorflow dataset builder for semantic defect segmentation datasets like MVTEC and VisA. Includes options to generate synthetic anomalies

Basic Info
  • Host: GitHub
  • Owner: thetoby9944
  • License: agpl-3.0
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 22.2 MB
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created over 3 years ago · Last pushed over 3 years ago
Metadata Files
Readme License Citation

README.rst

.. figure:: tfds_defect_detection/assets/images/logo.png
   :align: center
   :alt:
   :scale: 50 %


.. image:: https://readthedocs.org/projects/tfds-defect-detection/badge/?version=latest
    :target: https://tfds-defect-detection.readthedocs.io/en/latest/README.html
    :alt: Documentation Status
.. image:: https://img.shields.io/pypi/v/tfds_defect_detection
   :target: https://pypi.org/project/tfds-defect-detection/
.. image:: https://img.shields.io/pypi/pyversions/tfds_defect_detection
   :alt: PyPI - Python Version

========================================
TensorFlow Datasets for Defect Detection
========================================

To directly jump into the code look at the sample notebook

.. class:: center

|Open in Colab|

.. |Open in Colab| image:: https://img.shields.io/badge/Open%20In-Colab-orange?style=for-the-badge&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAUCAYAAACaq43EAAAACXBIWXMAAAdiAAAHYgE4epnbAAAEg2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSfvu78nIGlkPSdXNU0wTXB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6g7PWIT+PeSznxtTHEM5OUtCV06QLqxUAJwdjuLWMdsGBZEzpiVdkfkfodOPwQgKJiAAAAAASUVORK5CYII=
   :target: https://colab.research.google.com/drive/1_0diKQAHBX2q8iCEI7bmv0TnnmaWZR1M?usp=sharing

.. admonition:: Features

    - tensorflow.data.Dataset builder for defect segmentation
    - Comes with unsupervised / self-supervised SotA datasets
    - Artificial defect generator
    - Evaluation data with hand labelled images

Provides a tf.data.Dataset loader for
------------------------------------------


+----------+------------------+-----------------------------------------------------------+
| Dataset  | Licence          | Copyright                                                 |
+==========+==================+===========================================================+
| MVTEC    | CC BY-NC-SA 4.0  | MVTEC.com, All rights reserved                            |
+----------+------------------+-----------------------------------------------------------+
| VisA     | CC BY 4.0        | Amazon.com, Inc. or its affiliates. All Rights Reserved.  |
+----------+------------------+-----------------------------------------------------------+

Dataset Links

MVTEC: https://www.mvtec.com/company/research/datasets/mvtec-ad
VisA: https://github.com/amazon-science/spot-diff


Install
-------

Create a new python=3.9 env and install `tfds_defect_detection` from pip

.. code-block:: bash

    pip install tfds_defect_detection



Examples
-----------

.. code-block:: python

    import tfds_defect_detection as tfd
    tfd.load()




Usage
-----------

All parmeters

.. code-block:: python

    import tfds_defect_detection as tfd
    impor albumentations as A

    ds = tfd.load(
        names = ("mvtec", "visa"),
        data_dir=Path("."),
        pairing_mode = "result_with_contrastive_pair",  # "result_only", "result_with_original"
        create_artificial_anomalies=True,
        validation_split=0.2,
        subset_mode = "training",                       # "validation", "test", "holdout", None
        drop_masks=False,
        width=256,
        height=256,
        repeat=True,
        anomaly_size = None,

        global_transform=A.Compose([
          A.RandomBrightnessContrast(),
          A.HueSaturationValue(),
        ]),

        process_deviation=A.Compose([
          A.ShiftScaleRotate(
            shift_limit=0.01,
            scale_limit=0.0,
            rotate_limit=1.5,
            p=1
          ),
          A.Blur(blur_limit=3),
          A.RandomBrightnessContrast(),
          A.RandomGamma(),
          A.HueSaturationValue(),
        ]),

        anomaly_composition=A.Compose([
          A.RandomRotate90(),
          A.Transpose(),
          A.ShiftScaleRotate(
            shift_limit=0.0625,
            scale_limit=0.50,
            rotate_limit=45, p=1
          ),
          A.RandomGamma(),
          A.OpticalDistortion(),
          A.GridDistortion(),
          A.RandomContrast(0.5, p=1),
        ]),

        batch_size=9,
        seed=123,
        shuffle=True,
        peek=True,
        image_validation=False,
        delete_tmp=True,
        crop_to_aspect_ratio=True
    )


.. figure:: tfds_defect_detection/assets/images/example.png
   :align: center
   :alt:
   :scale: 50 %



Docs
----

FOR API Reference see

https://tfds-defect-detection.readthedocs.io/en/latest/autoapi/tfds_defect_detection/index.html


Cite
----


If this project helped you during your work:
Until a publication is available, please cite as

Tobias Schiele. (2022). TFDS DD - Datasets for Defect Detection. https://github.com/thetoby9944/tfds_defect_detection.


.. code-block:: latex

   @misc{Schiele2019,
       author = {Tobias Schiele},
       title = {TFDS DD - Datasets for Defect Detection},
       year = {2022},
       publisher = {GitHub},
       journal = {GitHub repository},
       howpublished = {\url{https://github.com/thetoby9944/tfds_defect_detection}},
   }


If you use one of the datasets, include these citations:


MVTEC
~~~~~~

Paul Bergmann, Kilian Batzner, Michael Fauser, David Sattlegger, Carsten Steger: The MVTec Anomaly Detection Dataset: A Comprehensive Real-World Dataset for Unsupervised Anomaly Detection; in: International Journal of Computer Vision 129(4):1038-1059, 2021, DOI: 10.1007/s11263-020-01400-4.

Paul Bergmann, Michael Fauser, David Sattlegger, Carsten Steger: MVTec AD  A Comprehensive Real-World Dataset for Unsupervised Anomaly Detection; in: IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 9584-9592, 2019, DOI: 10.1109/CVPR.2019.00982.

VisA
~~~~~

.. code-block:: latex

   @article{zou2022spot,
     title={SPot-the-Difference Self-Supervised Pre-training for Anomaly Detection and Segmentation},
     author={Zou, Yang and Jeong, Jongheon and Pemula, Latha and Zhang, Dongqing and Dabeer, Onkar},
     journal={arXiv preprint arXiv:2207.14315},
     year={2022}
   }

Owner

  • Name: Tobias
  • Login: thetoby9944
  • Kind: user

GitHub Events

Total
Last Year

Committers

Last synced: over 3 years ago

All Time
  • Total Commits: 25
  • Total Committers: 1
  • Avg Commits per committer: 25.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
thetoby9944 t****y@w****e 25

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 3 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
  • Total maintainers: 1
pypi.org: tfds-defect-detection

TensorFlow Datasets for Defect Detection

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 3 Last month
Rankings
Dependent packages count: 6.6%
Forks count: 30.5%
Dependent repos count: 30.6%
Stargazers count: 32.3%
Average: 33.8%
Downloads: 69.1%
Maintainers (1)
Last synced: 11 months ago

Dependencies

docs/requirements.txt pypi
  • pydata-sphinx-theme *
  • recommonmark *
  • sphinx *
  • sphinx-autoapi *
  • sphinx-autobuild *
  • sphinx-bootstrap-theme *
  • sphinx-markdown-tables *
  • sphinxcontrib-bibtex *
  • sphinxcontrib-httpdomain *
requirements.txt pypi
  • albumentations *
  • matplotlib *
  • opencv-python-headless *
  • polygenerator *
  • pydantic *
  • scikit-image *
  • tensorflow *
  • tqdm *