2026

Mahalanobis PatchCore: Covariance-Aware and Streaming-Compatible Industrial Anomaly Detection

Covariance-aware, bounded-memory PatchCore research submitted to Applied Soft Computing, with an anomalib implementation released in v2.7.0.

PreprintSubmitted to ASOC

Authors

Affiliations

Correspondence

niccolo.ferrari@unife.it

Abstract

Industrial visual anomaly detection is usually one-class: normal images are abundant, while defects are rare, heterogeneous, and often unavailable during system design. PatchCore-style retrieval suits this setting because it scores test images from a memory bank of normal patch features, but the standard Euclidean geometry ignores feature correlations and its offline construction materialises the full patch pool before subsampling. We introduce Mahalanobis PatchCore, a covariance-aware, streaming-compatible extension of PatchCore. Its artificial intelligence contribution is a retrieval detector that estimates a regularised covariance model in reduced feature space and whitens embeddings, so Euclidean nearest-neighbour search after transformation implements Mahalanobis retrieval. A bounded-memory, re-iterable training pipeline builds the memory bank without storing all normal patches at once, using incremental dimensionality reduction, online covariance estimation, and streaming aggregation. The engineering application is automated industrial inspection, where visual anomaly detection must remain accurate under practical memory limits. We evaluate the method on a public 15-category industrial anomaly-detection benchmark and three industrial datasets covering blow-fill-seal strip-ampoule meniscus inspection, amber-glass-ampoule bottom inspection, and lyophilised-cake vial inspection. Mahalanobis PatchCore preserves most offline PatchCore image-level performance on the public benchmark while reducing peak memory from 5.41 to 2.78 GiB, and improves the selected industrial mean image area under the receiver operating characteristic curve from 0.981 to 0.986.

Keywords

Mahalanobis DistanceEmbedding SimilarityBounded-Memory TrainingComputer VisionIndustrial AutomationOut-of-Distribution Anomaly Detection

Current research and implementation

The manuscript is submitted to Applied Soft Computing; journal acceptance has not been announced. Its bounded-memory training makes repeated passes over a normal training dataset. It does not claim continual adaptation during inspection. On MVTec AD, the reviewed manuscript compares mean image AUROC of 0.989 for streaming MH-PatchCore with 0.991 for the offline PatchCore reference, while reducing peak memory from 5.41 to 2.78 GiB. On the selected industrial datasets, MH-PatchCore improves mean image AUROC from 0.981 for the Euclidean streaming control to 0.986. The offline reference remains stronger there, at 0.996. These are results for the reported experiments, not general deployment guarantees.

Niccolò contributed the standalone MH-PatchCore model to anomalib. The implementation is included in anomalib library v2.7.0; its contribution and release are linked above. The public arXiv link retains its own version history.