Anomaly Multi-classification in Industrial Scenarios: Transferring Few-shot Learning to a New Task

Jie Liu, Yao Wu, Xiaotong Luo, Zongze WuarXiv 2024 · arXiv · OpenReview

TL;DR

This paper introduces a new challenge: anomaly multi-classification in industrial settings, where not only detecting but also categorizing defects is crucial. They propose a novel framework that combines anomaly detection (PatchCore) with few-shot learning techniques, enhanced by a synthetic data generation method and contrastive learning, to effectively classify rare industrial defects.

What Problem Does This Paper Address?

In industrial production, identifying defective items is critical. However, simply detecting an anomaly isn't always enough; classifying the type of anomaly is often necessary for targeted repairs and quality control. The challenge lies in the scarcity of labeled defect data, making traditional supervised multi-classification methods infeasible. While anomaly detection methods exist, and few-shot learning addresses limited data scenarios, applying few-shot learning to the multi-classification of industrial anomalies is an underexplored area. This paper aims to bridge this gap by proposing a new task and a robust methodology for it.

Methods

The authors introduce a multi-stage approach:

  • Anomaly Detection Foundation: They leverage PatchCore, a state-of-the-art anomaly detection method that uses local image features and a memory bank of normal samples to identify anomalies.
  • Residual Representation: Instead of using raw features from PatchCore, they extract "residual representations" by comparing anomalous patch features to their nearest neighbors in the normal feature memory bank. This highlights the anomalous regions more effectively.
  • Few-Shot Multi-Classification Baseline: They build a baseline classifier inspired by RelationNet, a popular few-shot learning architecture. This baseline takes the residual features as input.
  • Synthetic Data Generation: To overcome the lack of diverse defect samples for training, they propose a data generation method. This involves creating "pseudo classes" by merging textures from the DTD dataset with generated masks, allowing the model to learn generalizable defect discrimination before fine-tuning on real, limited defect data.
  • Contrastive Learning Enhancement: To further improve the classification performance, they incorporate contrastive learning. This involves using a contrastive loss (InfoNCE) to learn more discriminative feature representations from the support and query sets, leading to better separation of anomaly classes.

Datasets

  • MVTec AD: A widely used dataset for industrial anomaly detection, containing 15 object categories with various defect types.
  • MVTec 3D AD: A 3D extension of the MVTec AD dataset.
  • DTD (Describable Textures Dataset): Used for generating synthetic defect data.

Key Insights and Ideas

  • Anomaly Multi-classification as a New Frontier: The paper clearly articulates the need for classifying anomaly types, not just detecting their presence, in industrial settings. This reframes the problem beyond traditional binary anomaly detection.
  • Residual Features are Key: Using the difference between anomalous features and their nearest normal counterparts (residual representation) significantly boosts classification performance compared to using raw features. This suggests that focusing on the "deviation" is more informative for classification.
  • Synthetic Data Bridges the Gap: Generating synthetic defect data with pseudo-classes is crucial for pre-training models. This allows them to learn generalizable defect discrimination, which is then fine-tuned on scarce real-world defect data, effectively transferring few-shot learning to industrial scenarios.
  • Contrastive Learning for Better Separation: Applying contrastive learning to the few-shot classification task leads to more distinct feature clusters for different anomaly types, improving accuracy.

Key Results

  • The proposed method, combining PatchCore, residual representations, synthetic data pre-training, and contrastive learning, significantly outperforms a direct classification approach (fine-tuning ResNet) and a vanilla RelationNet baseline.
  • On the MVTec AD dataset, the contrastive classifier with pretraining achieved an average accuracy of 41.07% ±1.29% in the four-shot scenario, a substantial improvement over direct classification (23.345%) and the vanilla baseline (18.461%).
  • The effectiveness of residual representations was demonstrated, showing better performance than using raw features.
  • The synthetic data generation method proved beneficial for pre-training, especially in two-shot, three-shot, and five-shot scenarios.

Limitations and Future Work

  • Data Generation Limitations: The authors note that their data generation method shows significant room for improvement, particularly when dealing with only four samples, indicating potential issues with generalization or robustness in extreme few-shot scenarios.
  • Accuracy in Some Categories: Despite improvements, the classification accuracy for some defect categories remains at the level of random guessing, highlighting the inherent difficulty of the task.
  • Future Directions: The authors suggest exploring metric-based or optimization-based few-shot learning methods for industrial data. They also mention that their approach can be easily embedded into other anomaly detection algorithms like Padim and SPADE. Further research into more sophisticated data generation techniques is also warranted.

Summary updated

Abstract

In industrial scenarios, it is crucial not only to identify anomalous items but also to classify the type of anomaly. However, research on anomaly multi-classification remains largely unexplored. This paper proposes a novel and valuable research task called anomaly multi-classification. Given the challenges in applying few-shot learning to this task, due to limited training data and unique characteristics of anomaly images, we introduce a baseline model that combines RelationNet and PatchCore. We propose a data generation method that creates pseudo classes and a corresponding proxy task, aiming to bridge the gap in transferring few-shot learning to industrial scenarios. Furthermore, we utilize contrastive learning to improve the vanilla baseline, achieving much better performance than directly fine-tune a ResNet. Experiments conducted on MvTec AD and MvTec3D AD demonstrate that our approach shows superior performance in this novel task.
BibTeX
@misc{liu2024anomaly,
  author = {Jie Liu and Yao Wu and Xiaotong Luo and Zongze Wu},
  title = {{Anomaly Multi-classification in Industrial Scenarios: Transferring Few-shot Learning to a New Task}},
  year = {2024},
  eprint = {2406.05645},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.05645},
}
Figure