This repository contains a Jupyter Notebook that demonstrates an anomaly detection model available in anomalib
: PaDiM A Patch Distribution Modeling Framework for Anomaly Detection in MVTec dataset. This method is implemented using the anomalib library in Python.
Detecting anomalies in images is a popular application of anomaly detection. In this tutorial, we will go over a popular dataset known as the "MVTec Anomaly Detection" dataset. MVTec is a dataset for benchmarking anomaly detection methods with a focus on industrial inspection.
Here are some features of the dataset:
- Contains over 5000 high-resolution images.
- Images are divided into fifteen distinct object and texture categories such as bottle, cable, carpet, wood, leather and pill.
- Each category consists of two sets: training images (defect-free) and test images (with defects and without defects).
Some example of the MVTec dataset:
Anomalib is a deep learning library for developing and deploying state-of-the-art anomaly detection algorithms for benchmarking on both public and private datasets.
- The largest public collection of ready-to-use deep learning anomaly detection algorithms and benchmark datasets.
- Provides a set of tools that facilitate the development and implementation of Anomaly Detection models.
- Focus on image-based anomaly detection or anomalous pixel regions within images in a dataset.
Currently, there are 13 anomaly detection models available in anomalib
library. Namely,
- Patch-based algorithm relying on pre-trained CNN feature extractor.
- Breaks image into patches, extracts embeddings using different layers.
- Concatenates activation vectors for diverse semantic levels.
- Encodes fine-grained and global contexts in embeddings.
- Reduces dimensions of embedding vectors to mitigate redundancy.
- Generates multivariate Gaussian distribution for each patch embedding.
- Distribution calculated across entire training batch.
- Inference uses Mahalanobis distance to score test image patches.
- Uses inverse of covariance matrix from training for Mahalanobis distance.
- Anomaly map formed from Mahalanobis distance scores.
- Higher scores in anomaly map indicate anomalous regions.