Industrial knn-based anomaly detection for images

Industrial KNN-based Anomaly Detection

Industrial knn-based anomaly detection for images. Visit streamlit link to check out the demo.

This repo aims to reproduce the results of the following KNN-based anomaly detection methods:

  1. SPADE (Cohen et al. 2021) – knn in z-space and distance to feature maps
    schematic_spade
  2. PaDiM* (Defard et al. 2020) – distance to multivariate Gaussian of feature maps
    schematic_padim
  3. PatchCore (Roth et al. 2021) – knn distance to avgpooled feature maps
    schematic_patchcore

* actually does not have any knn mechanism, but shares many things implementation-wise.


Install

$ pipenv install -r requirements.txt

Note: I used torch cu11 wheels.

Usage

CLI:

$ python indad/run.py METHOD [--dataset DATASET]

Results can be found under ./results/.

Code example:

from indad.model import SPADE

 

 

 

To finish reading, please visit source site