Hard-Normal Example-Aware Template Mutual Matching for Industrial Anomaly Detection

Zixuan Chen, Xiaohua Xie, Lingxiao Yang, Jian-Huang Lai

TL;DR

This paper introduces HETMM, a novel framework for industrial anomaly detection that specifically addresses the challenge of "hard-normal" examples, which are normal but difficult to distinguish from anomalies. HETMM uses an Affine-invariant Template Mutual Matching (ATMM) approach and a Pixel-level Template Selection (PTS) module to create a robust decision boundary, achieving state-of-the-art performance with significantly reduced computational costs.

What Problem Does This Paper Address?

Industrial anomaly detection is crucial for ensuring product quality, but it's a challenging task. Anomalies are rare, making it difficult to collect enough anomalous data for training. Consequently, most methods adopt a one-class classification approach, learning from only normal samples. However, a significant problem arises from "hard-normal" examples – normal samples that are visually similar to anomalies and lie close to the decision boundary. Existing methods, often dominated by "easy-normal" examples, struggle to differentiate these hard-normal samples, leading to high false-positive rates (misclassifying normal as anomalous) and missed detections (failing to detect actual anomalies). This paper aims to tackle this specific challenge by developing a more robust anomaly detection system that can accurately distinguish between hard-normal examples and true anomalies.

Methods

The proposed framework, HETMM, consists of two main novel modules:

  • Affine-invariant Template Mutual Matching (ATMM): This module addresses the limitations of traditional pixel-level and patch-level template matching. ATMM employs a mutual matching strategy across multiple feature layers. It uses both "forward ATM" (comparing query features to template prototypes) and "backward ATM" (comparing template prototypes to query features) to capture complementary information. This bi-directional approach makes it robust to affine transformations and better at distinguishing hard-normal examples from anomalies.
  • Pixel-level Template Selection (PTS): To reduce computational cost and memory usage, PTS is introduced to compress the original template set into a smaller, more efficient one. Unlike methods that only select cluster centers (which tend to miss hard-normal examples), PTS strategically selects both cluster centers (easy-normal examples) and hard-normal examples. This ensures that the compressed template set still effectively represents the original distribution and preserves the decision boundary, crucial for handling hard-normal cases.

Datasets

The authors evaluated their method on several real-world datasets:

  • MVTec AD [8]: A widely used industrial anomaly detection benchmark with 15 categories.
  • Visual Anomaly (VisA) dataset [60]: A large dataset with image- and pixel-level labels for 12 objects.
  • Magnetic Tile Defects (MTD) dataset [25]: A specialized dataset for detecting defects in magnetic tiles under varying illumination.
  • MVTec Logical Constraints Anomaly Detection (MVTec LOCO) [9]: Focuses on distinguishing structural and logical anomalies.
  • MVTec Structural and Logical Anomaly Detection (MVTec SL) [9]: Applies the structural/logical anomaly classification to the MVTec AD dataset.
  • Mini Shanghai Tech Campus (mSTC) [30]: A dataset for detecting abnormal events in videos, posing a long-range spatiotemporal challenge.

Key Insights and Ideas

  • The "Hard-Normal" Problem is Key: The paper highlights that the subtle distinction between hard-normal examples and anomalies is a primary driver of errors in existing methods, not just the rarity of anomalies.
  • Mutual Matching for Robustness: The bi-directional matching in ATMM (forward and backward) is crucial for capturing complementary information that single-direction matching misses, especially for logical anomalies.
  • Hard-Normal Prototypes are Essential for Compression: Simply selecting cluster centers for template compression is insufficient. Including hard-normal examples in the compressed template set is vital for maintaining performance, particularly in preserving the decision boundary.
  • Training-Free and Hot-Update Capability: HETMM's training-free nature and ability to be hot-updated by adding new samples are significant advantages for industrial settings where continuous learning and adaptation are often required.

Key Results

  • State-of-the-Art Performance: HETMM consistently outperforms existing methods across various datasets and metrics, including image-level AUROC, pixel-level AUROC, and PRO (Pre-Region Overlap). For instance, on MVTec AD, the full HETMM achieved 99.8% AUCI and 99.0% AUCP.
  • Significant Speedup: By using the PTS-compressed 60-sheet template set, HETMM achieves competitive performance (e.g., 99.5% AUCI on MVTec AD) while drastically increasing inference speed to 26.1 FPS on a Quadro 8000 RTX GPU, compared to 4.7 FPS for the full template set.
  • Improved Localization: HETMM demonstrates superior anomaly localization, achieving lower false-positive rates and more precise boundaries, as evidenced by high PRO scores.
  • Robustness to Hyperparameters: Sensitivity analysis shows HETMM is robust to various hyperparameter choices, including different backbones and patch sizes.

Limitations and Future Work

  • Performance with Compressed Templates: While the 60-sheet template set offers excellent speed, it shows a slight performance drop compared to the full template set, particularly in detecting some categories where template incompleteness can lead to failure.
  • Backbone Choice: While WResNet101 provided optimal performance, the paper notes that ViT and ConvNeXt-based architectures, while acceptable, struggled with low false-positive rate localization.
  • Future Work: The paper implicitly suggests that further research into optimizing the trade-off between template set size, inference speed, and detection accuracy could be beneficial. The hot-update capability also opens avenues for exploring more advanced incremental learning scenarios.

Summary updated

BibTeX
@article{chen2025hard,
  author = {Zixuan Chen and Xiaohua Xie and Lingxiao Yang and Jian-Huang Lai},
  title = {{Hard-Normal Example-Aware Template Mutual Matching for Industrial Anomaly Detection}},
  journal = {Int. J. Comput. Vis.},
  year = {2025},
  doi = {10.1007/s11263-024-02323-0},
}
Figure