Abstract
Unsupervised Anomaly Detection (UAD) often struggles with the semantic gap between general pre-training and specialized target domains. ReContrast addresses this by enabling end-to-end optimization of encoders and decoders through a contrastive reconstruction framework. By incorporating stop-gradients, global cosine similarity, and cross-reconstruction, ReContrast prevents pattern collapse on normal-only data. It achieves state-of-the-art performance, including a record-breaking 99.5% AUROC on the MVTec AD benchmark.
Introduction
State-of-the-art UAD methods typically rely on frozen feature extractors pre-trained on ImageNet. However, these encoders often fail to capture domain-specific nuances in industrial or medical imaging, leading to a significant semantic gap. Fine-tuning these encoders on normal-only target data usually results in "pattern collapse," where the model learns trivial shortcuts and fails to distinguish anomalies. ReContrast overcomes this limitation by framing feature reconstruction as a contrastive learning task, allowing for stable, domain-specific encoder adaptation.
Methodology
ReContrast introduces several key innovations to stabilize end-to-end training and bridge the domain gap:
- Contrastive Reconstruction with Stop-Gradients: Inspired by self-supervised learning (e.g., SimSiam), ReContrast uses a stop-gradient operation on the encoder during reconstruction. This prevents the encoder from collapsing its output to match the decoder, fostering mutual reinforcement.
- Global Cosine Similarity: Instead of point-by-point feature comparison, ReContrast flattens 2D feature maps into global vectors. This global context stabilizes the loss landscape and improves generalization.
- Augmentation-Free Contrastive Pairs: To avoid augmentations that might mimic defects, ReContrast uses two "views" of the same image: one from a frozen pre-trained encoder and one from a trainable domain-specific encoder. The decoder then performs cross-reconstruction between these views.
- Hard-Normal Mining: The loss function prioritizes "hard" normal regions (complex edges) over "easy" regions (plain backgrounds), widening the error gap between normal and anomalous structures.
Experimental Results
ReContrast was evaluated across five benchmarks spanning industrial (MVTec AD, VisA) and medical (OCT2017, APTOS, ISIC2018) domains.
- MVTec AD: Achieved a record-breaking image-level AUROC of 99.5%, effectively halving the error rate compared to previous leaders like PatchCore (99.1%).
- Medical Imaging: On the APTOS dataset, ReContrast reached 97.51% AUROC, outperforming specialized medical UAD methods such as GANomaly and f-AnoGAN.
- Efficiency: The ResNet18-based ReContrast outperforms much larger WideResNet50 models from previous generations, demonstrating high computational efficiency.
Discussion and Conclusion
ReContrast demonstrates that encoder adaptation is essential for capturing domain-specific textures and structures. By framing reconstruction as a contrastive task, the model avoids trivial identity mappings. While highly effective for structural anomalies like scratches or lesions, future work is needed to address "logical" anomalies (e.g., missing components in an assembly) and further stabilize the optimization process against occasional loss spikes during training.
Summary updated