ToCoAD: Two-Stage Contrastive Learning for Industrial Anomaly Detection

Yun Liang,Zhiguang Hu,Junjie Huang,Donglin Di,Anyang Su,Lei Fan
2024-07-01
Abstract:Current unsupervised anomaly detection approaches perform well on public datasets but struggle with specific anomaly types due to the domain gap between pre-trained feature extractors and target-specific domains. To tackle this issue, this paper presents a two-stage training strategy, called \textbf{ToCoAD}. In the first stage, a discriminative network is trained by using synthetic anomalies in a self-supervised learning manner. This network is then utilized in the second stage to provide a negative feature guide, aiding in the training of the feature extractor through bootstrap contrastive learning. This approach enables the model to progressively learn the distribution of anomalies specific to industrial datasets, effectively enhancing its generalizability to various types of anomalies. Extensive experiments are conducted to demonstrate the effectiveness of our proposed two-stage training strategy, and our model produces competitive performance, achieving pixel-level AUROC scores of 98.21\%, 98.43\% and 97.70\% on MVTec AD, VisA and BTAD respectively.
Computer Vision and Pattern Recognition
What problem does this paper attempt to address?
The paper primarily addresses a key issue in industrial anomaly detection: how to train a model that can effectively detect and locate various types of anomalies when only normal samples are available. Specifically, current unsupervised anomaly detection methods perform well on public datasets but face challenges in detecting specific types of anomalies, mainly due to the domain gap between pre-trained feature extractors and the target-specific domain (e.g., industrial images). To overcome this challenge, the paper proposes a two-stage training strategy called ToCoAD (Two-Stage Contrastive Learning for Industrial Anomaly Detection). The core ideas of this strategy are as follows: 1. **First Stage**: Train a discriminative network by synthesizing anomalies. This stage uses self-supervised learning by injecting synthetic anomalies (e.g., using Perlin noise) into normal images to train a discriminative network to roughly locate these anomalous regions. 2. **Second Stage**: Fine-tune the feature extractor using guided contrastive learning. In this stage, the discriminative network trained in the first stage is used to provide negative sample guidance, assisting the contrastive learning network in further optimizing the feature extractor. In this way, the model can gradually learn the anomaly distribution specific to the industrial dataset, thereby improving its generalization ability to different types of anomalies. Through this two-stage approach, ToCoAD can effectively train a model capable of accurately identifying multiple types of anomalies without any anomaly samples. Experimental results show that ToCoAD achieves highly competitive performance on several popular datasets, particularly in pixel-level anomaly detection, with its AUROC scores significantly higher than existing methods. In summary, the main contribution of this research is the proposal of a novel two-stage training strategy aimed at addressing the domain gap issue in industrial anomaly detection and improving the model's generalization performance through contrastive learning.