Source-linked AI summary
Anomalib: A Deep Learning Library for Anomaly Detection
Samet Akcay, Dick Ameln, Ashwin Vaidya, Barath Lakshmanan, Nilesh Ahuja, Utku Genc
TL;DR
Anomaly detection often lacks representative anomalous samples, while existing libraries provide limited support for comparing recent deep learning techniques. Anomalib addresses this gap with a unified, modular library for developing, benchmarking, and deploying anomaly detection models across the machine learning lifecycle.
Problem
Anomaly detection commonly relies on normal samples because representative anomalous samples are scarce, while existing libraries limit unified comparison of recent deep learning techniques.
Method
Anomalib combines anomaly detection algorithms, modular plug-and-play components, benchmarking and hyperparameter tools, preprocessing support, and model training, inference, and deployment workflows.
Results
Anomalib provides a unified library of components and tools for anomaly detection research and production.
Takeaways & Limitations
The library supports reproducible comparison, addition of datasets and algorithms, and deployment of anomaly detection models from data to real-time use.
Abstract
from arXiv · showhide
This paper introduces anomalib, a novel library for unsupervised anomaly detection and localization. With reproducibility and modularity in mind, this open-source library provides algorithms from the literature and a set of tools to design custom anomaly detection algorithms via a plug-and-play approach. Anomalib comprises state-of-the-art anomaly detection algorithms that achieve top performance on the benchmarks and that can be used off-the-shelf. In addition, the library provides components to design custom algorithms that could be tailored towards specific needs. Additional tools, including experiment trackers, visualizers, and hyper-parameter optimizers, make it simple to design and implement anomaly detection models. The library also supports OpenVINO model optimization and quantization for real-time deployment. Overall, anomalib is an extensive library for the design, implementation, and deployment of unsupervised anomaly detection models from data to the edge.
1. INTRODUCTION
Anomalib addresses the lack of a unified unsupervised anomaly-detection library by combining recent deep-learning techniques, benchmark models, and modular tools for research and production.
- The growing number of anomaly-detection publications and techniques creates a need for a unified library for benchmarking algorithms.
- Existing libraries often focus on single algorithms, omit performance optimizations, or lack deep-learning techniques, limiting out-of-the-box comparisons.
- Anomalib provides state-of-the-art models for benchmarking on public and custom datasets.
- Its modular components support designing new anomaly-detection algorithms through a plug-and-play approach.
- The library unifies components and tools for anomaly-detection research and production, including interfaces supporting local or edge deployment.
2. DESIGN PRINCIPLES
Anomalib is organized around reproducibility, extensibility, modularity, and real-time performance to support the anomaly-detection workflow from data through deployment.
- Reproducibility guides implementations toward matching results reported in original publications on public and custom benchmark datasets.
- Extensibility lets developers add new algorithms with minimal effort through interfaces compatible with training and inference entrypoints.
- Modularity provides reusable plug-and-play components for creating algorithms, reducing implementation effort and accelerating prototyping.
- Real-time performance is supported through GPU or CPU deployment using PyTorch and OpenVINO options.
- Together, these principles cover the model lifecycle from data to deployment, including reproducible results, added datasets and algorithms, and real-time deployment.
3. ANOMALIB
Anomalib organizes dataset handling, preprocessing, anomaly models, post-processing, optimization, inference, and utility modules into a data-to-deployment workflow. It supports both ready-to-use algorithms and modular construction of custom anomaly detection systems.
- Data and preprocessing: Anomalib supports image and video datasets, with current video processing operating at the frame level because existing models target images.Supported image datasets include CIFAR-10, MVTec, BTAD, and Kolektor; ShanghaiTec is supported for video.
- Data and preprocessing: Tiling preserves the size of small anomalous regions and can reduce detail loss caused by resizing high-resolution images.The library can optionally divide images into non-overlapping or overlapping tiles before model input.
- Models and components: Anomalib combines state-of-the-art density estimation, reconstruction, and knowledge distillation models with modular components for custom algorithms.The components can be assembled into models using operations such as CNN feature extraction and Coreset Sampling.
- Post-processing: Anomalib normalizes anomaly scores to [0,1] using validation-set values by default and provides configurable or disableable thresholding and normalization.Adaptive thresholding optimizes the threshold using validation-set F1 scores.
- Deployment and utilities: OpenVINO and NNCF support inference optimization and quantization, while utilities provide visualization, timing, compression, and GPU-enabled AUROC, F1, and PRO metrics.The library can display inference results or save predicted anomaly scores to the file system.
4. LIBRARY TOOLS
Anomalib provides configurable command-line workflows for training, testing, inference, benchmarking, and hyperparameter optimization, alongside a Python API for flexible experimentation and custom model use.
- Command Line Interface: Ready-to-use scripts support training, testing, inference, model export, benchmarking, and hyperparameter optimization for PyTorch and OpenVINO models.The entrypoints expose command-line settings for datasets, models, and hyperparameters, while HPO sweeps are configured through a YAML file.
- Python API: The Python API lets users configure datasets, models, and trainers directly, illustrated by training and testing PatchCore on the MVTec bottle category.The example uses an MVTec data module, PatchCore with a ResNet-18 backbone, and a PyTorch Lightning trainer.
- Visualization: Visualization tools produce exemplary outputs for inspecting anomaly detection results.Visualization results and model files can be saved to a user-specified file-system location.
5. BENCHMARKS
Anomalib’s benchmarking tool compares image-level and pixel-level AUROC across implemented models and MVTec categories, supporting comparative evaluation across datasets and models.
- Benchmarking: Image-level and pixel-level AUROC scores are benchmarked and averaged across MVTec categories for the public models implemented in anomalib.The experiments demonstrate comparative studies between different models and dataset categories using anomalib’s benchmarking tool.
6. CONCLUSIONS
The paper presents anomalib as an open-source library for training, benchmarking, deploying, and developing deep-learning anomaly detection models. It emphasizes reproducible comparison and continued community-driven expansion.
- Conclusion: Anomalib provides tools for quick and reproducible comparison of anomaly detection models on arbitrary datasets.The paper releases the library as an open-source package intended to incorporate updated state-of-the-art techniques and community contributions.
- Future work: Future work plans to extend anomalib to audio, video, and three-dimensional data.The paper identifies these domains as targets for future library expansion.