ReConPatch : Contrastive Patch Representation Learning for Industrial Anomaly Detection

Jeeho Hyun, Sangyun Kim, Giyoung Jeon, Seung Hwan Kim, Kyunghoon Bae, Byung Jun Kang

In the world of automated manufacturing, spotting a hairline crack or a misaligned component is a high-stakes game of "one of these things is not like the other." Industrial Anomaly Detection (AD) is challenging because, in a well-run factory, defects are rare. We have plenty of examples of "normal," but almost no examples of "broken."

A new paper from LG AI Research, ReConPatch, introduces a clever way to bridge the gap between general-purpose AI and the specific needs of the factory floor.

TL;DR

ReConPatch achieves state-of-the-art performance in industrial anomaly detection by using contrastive representation learning to adapt pre-trained features to specific industrial datasets. By using "contextual similarity" as a pseudo-label, it learns to group similar normal features together more effectively than previous methods, reaching a record 99.72% AUROC on the MVTec AD benchmark.

What Problem Does This Paper Address?

Most modern anomaly detection systems don't start from scratch; they use "features" extracted from deep learning models pre-trained on massive datasets like ImageNet. While these models are great at recognizing cats and cars, they suffer from distribution shift when applied to industrial parts like transistors or leather textures.

Existing solutions usually try to "distill" these features or use heavy data augmentation (rotating and flipping images) to teach the model what's normal. However, handcrafted augmentations can be finicky—what works for a round bottle might not work for a woven fabric. The authors identified a need for a method that adapts to the target data automatically and builds a more "separable" representation space where anomalies clearly stand out from the norm.

Methods

ReConPatch builds on the popular PatchCore framework but adds a sophisticated training step. Here’s the breakdown:

  1. Patch-Level Features: The model extracts local feature vectors (patches) from a pre-trained CNN.
  2. Linear Modulation: Instead of retraining the whole massive network, ReConPatch trains a simple linear layer ($f$) to transform these features into a "target-oriented" space.
  3. Contrastive Learning with Pseudo-labels: This is the "secret sauce." Since there are no labels, the authors use two metrics to decide which patches should be "pulled together" in the feature space:
  4. Pairwise Similarity: How close are two patches in terms of raw distance?
  5. Contextual Similarity: Do these two patches share the same "friends" (nearest neighbors)? This helps the model understand the broader structure of the object.
  6. Relaxed Contrastive Loss: The model uses these similarities as "soft" labels to train the linear layer, ensuring that similar normal patches cluster tightly together while dissimilar ones are pushed apart.
  7. EMA Updates: To keep training stable, they use an Exponential Moving Average (EMA) to update the similarity-calculating network, preventing the model from "chasing its own tail" during training.

Datasets

The researchers evaluated ReConPatch on two primary industrial benchmarks:

  • MVTec AD: The industry standard, containing 15 categories ranging from "Bottle" to "Zipper," with both texture and object-based defects.
  • BTAD (Bean Tech Anomaly Detection): A challenging dataset featuring three industrial products with real-world defects.

Key Insights and Ideas

  • Context is King: The most important "aha moment" is that raw distance between features isn't enough. By looking at the contextual neighborhood (who a patch's neighbors are), the model can distinguish between patches that look similar but belong to different parts of a "normal" distribution.
  • Efficiency via Linear Layers: You don't need to fine-tune a billion parameters. A well-trained linear transformation is enough to "reconfigure" the feature space for a specific industrial task, making the method practical and less prone to overfitting.
  • Robustness to Augmentation: Unlike many competitors, ReConPatch doesn't fall apart when you stop using handcrafted data augmentations. In fact, it significantly outperformed PatchCore in scenarios where data was limited or augmentations were poorly suited to the task.

Key Results

ReConPatch set new high-water marks for the field:

  • MVTec AD: Achieved an image-level detection AUROC of 99.72% (Ensemble) and 99.56% (Single model), outperforming previous leaders like CFA and PatchCore.
  • BTAD: Achieved a state-of-the-art 95.8% AUROC.
  • Discriminability: The authors used a metric called $d'$ (d-prime) to show that ReConPatch creates a much wider "gap" between the scores of normal and abnormal samples compared to previous methods, leading to fewer false positives.

Limitations and Future Work

While ReConPatch is a powerhouse for detecting that an anomaly exists (image-level), its localization (pixel-level segmentation) performance, while excellent, is sometimes slightly behind specialized "refinement" networks. The authors addressed this in the supplementary material by proposing an additional refinement network, but the base model's primary strength remains its highly discriminative feature space.

Future work could involve exploring how to incorporate the correlations between neighboring patches directly into the training loss to further improve the precision of defect localization.

Reference: Hyun, J., et al. "ReConPatch: Contrastive Patch Representation Learning for Industrial Anomaly Detection." arXiv:2305.16713v3, 2024.

Summary updated

BibTeX
@inproceedings{hyun2024reconpatch,
  author = {Jeeho Hyun and Sangyun Kim and Giyoung Jeon and Seung Hwan Kim and Kyunghoon Bae and Byung Jun Kang},
  title = {{ReConPatch : Contrastive Patch Representation Learning for Industrial Anomaly Detection}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2024},
  url = {https://openreview.net/forum?id=6CK8COOdzU},
}

Loading related content...

Figure