Domain-Generalized Textured Surface Anomaly Detection

Shang-Fu Chen, Yu-Min Liu, Chia-Ching Lin, Trista Pei-Chun Chen, Yu-Chiang Frank Wang

TL;DR

This paper introduces a novel domain-generalized anomaly detection framework for textured surfaces. It tackles the challenge of detecting anomalies in unseen domains with minimal normal data by employing a meta-learning approach that learns to compare image patches across multiple source domains, enabling both image-level detection and patch-level localization.

What Problem Does This Paper Address?

Traditional anomaly detection methods, particularly those relying on reconstruction-based approaches like autoencoders, typically require a substantial amount of normal data from the specific domain of interest to train effectively. However, in real-world industrial quality control scenarios, obtaining such comprehensive training data for every new product or surface type is often impractical. Furthermore, anomaly detection models trained on one domain often fail to generalize to unseen domains with different visual characteristics. This paper addresses the critical challenge of domain-generalized textured surface anomaly detection, where the goal is to build a model that can reliably detect anomalies in a new, unseen textured surface domain, even when only a small amount of normal data is available for reference during testing.

Methods

The proposed framework, named MVTec-AD, is built upon a meta-learning approach that learns to compare image pairs. It consists of three main components:

  • Feature Extractor: This component uses a bi-directional feature pyramid network (BiFPN) to extract multi-scale features from both the query image (potentially containing anomalies) and reference images (known to be normal). This multi-scale representation is crucial for capturing both general surface characteristics and fine-grained defect details.
  • Co-attention Module: This novel module learns to compare query and reference image patches by mapping them into a shared latent space and calculating their cosine similarity. This generates a co-attention matrix that reflects patch-level similarity. This mechanism is key to guiding the anomaly detection process and enabling patch-level localization, even with only image-level labels during training.
  • Meta-Comparer: This module utilizes the features extracted and the guidance from the co-attention module to learn a "learn-to-compare" strategy. By training on multiple source domains, it learns to identify deviations from normality in a domain-agnostic manner. The meta-comparer outputs anomaly scores for both the entire image and individual patches.

The framework employs three loss functions:

  1. Classification Loss (Lcls): For image-level anomaly detection, based on the maximum anomaly score across patches.
  2. Attention Loss (Latt): To encourage similarity between normal query-reference patch pairs and dissimilarity for abnormal ones, leveraging the co-attention mechanism.
  3. Patch-level Anomaly Ranking Loss (Lrank): To refine patch-level anomaly detection by comparing anomaly scores of patch pairs, guided by their co-attention scores.

Datasets

The paper evaluates its approach on two datasets:

  • MVTec-AD: A comprehensive dataset for unsupervised anomaly detection, specifically focusing on the texture categories (Carpet, Grid, Leather, Tile, Wood) for this work. The experiments utilize a leave-one-domain-out cross-validation strategy, where one texture is held out as the target domain, and the remaining four are used as source domains for training.
  • BTAD: Used for cross-dataset experiments to further validate the domain-generalized anomaly detection capabilities.

Key Insights and Ideas

  • Meta-learning for comparison is key: The core idea is that learning how to compare normal and potentially abnormal patches across diverse domains is more effective for generalization than learning a direct mapping to anomaly scores within a single domain.
  • Patch-level co-attention with image-level labels: The paper demonstrates that it's possible to achieve patch-level anomaly localization using only image-level labels during training, by cleverly using co-attention to infer patch-wise deviations.
  • Robustness to limited target data: The proposed method shows significantly better performance than existing anomaly detection methods when the amount of normal data in the target domain is limited (e.g., 10% of available normal images). This is because the target domain data is used as references, not for training the core model.
  • Domain generalization benefits from "learn-to-compare": Modifying existing domain generalization methods to incorporate a "learn-to-compare" mechanism (similar to the proposed approach) significantly improves their performance, highlighting the value of this paradigm.

Key Results

  • Superior performance on MVTec-AD: The proposed method consistently outperforms state-of-the-art anomaly detection and domain generalization approaches on the MVTec-AD texture dataset, achieving high average image-level AUC scores.
  • Effective anomaly localization: The model successfully localizes abnormal regions in textured surfaces, as visualized in Figure 5, even when only image-level labels were available during training.
  • Robustness to varying reference data: Performance degradation is minimal even with a small percentage (e.g., 10%) of normal reference images in the target domain, a significant advantage over traditional methods.
  • Outperforms DG methods: The proposed method shows a substantial margin over existing domain generalization approaches, particularly when they are adapted to a learn-to-compare setting.

Limitations and Future Work

  • Domain difference impact: The paper acknowledges that performance drops are expected when the target domain's data distribution significantly deviates from the source domains, as indicated by FID scores (Table 2). The Grid texture, with its high FID score, consistently presents a challenge for generalization.
  • Future work could explore:
    • Investigating methods to mitigate the performance drop when target domain distributions are highly dissimilar.
  • Extending the framework to other types of textured surfaces or more complex industrial defect scenarios.
  • Exploring more sophisticated meta-learning strategies or attention mechanisms for even greater generalization capabilities.

Summary updated

BibTeX
@inproceedings{chen2022domain,
  author = {Shang-Fu Chen and Yu-Min Liu and Chia-Ching Lin and Trista Pei-Chun Chen and Yu-Chiang Frank Wang},
  title = {{Domain-Generalized Textured Surface Anomaly Detection}},
  booktitle = {ICME},
  year = {2022},
  url = {https://openreview.net/forum?id=KCwJRHx5X4Q},
}
Figure