Skip to content
/ anodet Public

Anomaly detection on images using features from pretrained neural networks.

License

Notifications You must be signed in to change notification settings

OpenAOI/anodet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

anodet

A set of functions and classes for performing anomaly detection in images using features from pretrained neural networks.

The package includes functions and classes for extracting, modifying and comparing features. It also includes unofficial implementations of PaDiM and PatchCore.

Some code has been borrowed and/or inspired by other repositories, see code reference below.

See wiki for documentation.

Example result with padim on image from MVTEC dataset

Installation

Clone the repository

git clone https://github.com/OpenAOI/anodet.git

Install the package

cd anodet
python -m pip install -r requirements.txt
python -m pip install .

Usage example

# Prepare a dataloader and fit a model to the data
dataloader = DataLoader(...)
padim = anodet.Padim() 
padim.fit(dataloader)

# Prepare some test images and make predictions
batch = ...
image_scores, score_map = padim.predict(batch) 

See notebooks for in depth examples.

Development setup

Install

Install the package in editable mode

python -m pip install --editable [PATH TO REPOSITORY]

Tests

Install packages for testing

python -m pip install pytest pytest-mypy pytest-flake8

Run tests

cd [PATH TO REPOSITORY]
pytest --mypy --flake8

For configuration of pytest, mypy and flake8 edit setup.cfg.

Creating docs

Install pydoc-markdown

python -m pip install pydoc-markdown

Clone docs repository

git clone https://github.com/OpenAOI/anodet.wiki.git

Run script

cd anodet.wiki
python generate_docs.py --source-path=[PATH TO REPOSITORY] --package-name="anodet" --save-path=.

Code Reference

PaDiM: https://arxiv.org/abs/2011.08785

PatchCore: https://arxiv.org/abs/2106.08265

Some parts used in patch_core.py : https://github.com/hcw-00/PatchCore_anomaly_detection

Code in directory sampling_methods : https://github.com/google/active-learning

concatenate_two_layers function in feature_extraction.py : https://github.com/xiahaifeng1995/PaDiM-Anomaly-Detection-Localization-master

pytorch_cov function in utils.py : pytorch/pytorch#19037

About

Anomaly detection on images using features from pretrained neural networks.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published