Abstract:In the anomaly detection of industrial surfaces, due to the unknown and irregular nature of the abnormalities, it is difficult and costly to manually label abnormal samples, and the supervised deep learning algorithms have limitations in the task of anomaly detection on the surface of industrial products. To address the above problems, an unsupervised surface anomaly detection algorithm based on contrastive learning generative adversarial network (CLGAN) is proposed. Firstly, the CLGAN model based on unsupervised learning algorithm is established. Secondly, contrastive learning is used to strengthen the positive and negative sample constraints of the potential feature space, maximizing the mutual information between the corresponding patches of the input and output images, enhancing the differentiation of positive and negative sample feature vectors, and further improving the ability of the model to reconstruct abnormal sample images. Then, in the detection stage, the trained model is used to obtain the anomaly-free reconstruction image of the industrial product to be tested, and the residual image between the sample to be measured and its corresponding reconstructed image is calculated. Finally, combined with the double threshold segmentation method and mathematical morphology processing, the rapid detection and accurate location of abnormal areas on the surface of industrial products are realized. Experimental results on the public dataset MVTec AD demonstrate that the proposed algorithm has a better recognition effect and stronger generalization ability compared with other unsupervised deep learning model algorithms.