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:
- SPADE (Cohen et al. 2021) – knn in z-space and distance to feature maps
- PaDiM* (Defard et al. 2020) – distance to multivariate Gaussian of feature maps
- PatchCore (Roth et al. 2021) – knn distance to avgpooled feature maps
* 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