Focus Your Distribution: Coarse-to-Fine Non-Contrastive Learning for Anomaly Detection and Localization

Ye Zheng, Xiang Wang, Rui Deng, Tianpeng Bao, Rui Zhao, Liwei Wu

Abstract

Unsupervised anomaly detection in industrial settings requires identifying subtle deviations from normal patterns. This paper presents a novel framework that achieves a highly compact normal data distribution through a two-stage coarse-to-fine alignment process. By integrating image-level alignment with a dense non-contrastive learning pretext task, the model achieves state-of-the-art performance on standard benchmarks without requiring anomalous training samples.

Introduction

In industrial quality control, anomalies such as minute scratches or broken threads are often incredibly subtle. While standard computer vision models excel at semantic differences (e.g., distinguishing a cat from a dog), they struggle with these fine-grained deviations where the anomaly is a small variation from a standard pattern.

Existing unsupervised anomaly detection (AD) methods typically rely on reconstruction errors or feature mapping. However, these often fail to capture local irregularities or depend on synthetic anomalies that do not reflect real-world defects. The authors argue that to effectively detect outliers, one must first ensure the distribution of normal data is as tight and well-aligned as possible.

Methodology

The proposed framework utilizes a two-stage process to learn a compact representation of normal data:

  1. Coarse Alignment Stage:
    • Image-Level Coarse Alignment (ICA): A module similar to a Spatial Transformer Network (STN) learns to rotate and shift images within a batch to a standardized orientation.
  2. Feature-Level Coarse Alignment (FCA): This refines alignment within the neural network's feature maps, ensuring spatial correspondence across different samples.
  3. Fine Alignment Stage (Dense Non-Contrastive Learning): Once aligned, the model employs a dense non-contrastive learning task. Unlike contrastive learning, which separates different classes, this task forces features at corresponding pixel locations across a batch of normal images to be as similar as possible. A stop-gradient strategy is used to prevent representation collapse, ensuring the network learns robust, granular features of "normal" appearance.
The proposed coarse-to-fine alignment framework architecture.

Inference: After training, the distribution of these dense features is modeled using a Multivariate Gaussian. Anomalies are detected by calculating the Mahalanobis distance, measuring the deviation of test pixels from the learned normal mean.

Experimental Setup

The researchers evaluated their model on three key datasets:

  • MVTec AD: The industry standard containing 15 categories of objects and textures.
  • BeanTech AD: A newer industrial dataset with three categories.
  • Disturbed MVTec: A challenging variant created by the authors featuring random brightness, contrast, and rotations to simulate messy, real-world factory environments.

Results and Discussion

The framework achieved new state-of-the-art (SOTA) results across multiple benchmarks. On MVTec AD, it reached an image-level AUC of 97.7% and a pixel-level localization AUC of 98.2%. On BeanTech AD, it outperformed previous methods significantly, achieving 98.1% image-level AUC compared to the previous best of 90.0%.

Visual impact of the Image Coarse Alignment (ICA) module on anomaly localization.

A key insight is that dense feature comparison is only effective when pixels are spatially aligned. As shown in the visual results, the ICA module allows the model to focus on actual defects rather than orientation variance. Mathematically, the non-contrastive learning acts as an implicit mean-shift algorithm, effectively "shrinking" the feature distribution toward the most typical representation, making outliers much easier to identify.

Conclusion

While the model is specialized for structured industrial objects rather than broad semantic outlier detection, its coarse-to-fine approach sets a new benchmark for unsupervised AD. The robustness demonstrated on the "Disturbed MVTec" dataset suggests high potential for real-world deployment. Future work may explore adapting these alignment principles for video anomaly detection, where temporal consistency is critical.

Summary updated

BibTeX
@inproceedings{zheng2022focus,
  author = {Ye Zheng and Xiang Wang and Rui Deng and Tianpeng Bao and Rui Zhao and Liwei Wu},
  title = {{Focus Your Distribution: Coarse-to-Fine Non-Contrastive Learning for Anomaly Detection and Localization}},
  booktitle = {ICME},
  year = {2022},
  doi = {10.1109/icme52920.2022.9859925},
}
Figure