Unsupervised fabric defect detection algorithm based on vector quantization and feature distance - Wei, Qiyu; Zhang, Lei; Zhan, Zhu; Li, Liqing; Wang, Jun (Textile research journal, 2025)
Fabric defect detection is an indispensable step in textile fabric production, and many deep-learning-based methods have been proposed. However, existing supervised methods are limited by the lack of annotated datasets, and unsupervised anomaly detection methods still fail to meet the requirements of practical applications. To address these issues, a novel unsupervised dual-scale method based on feature distance, called DSFD, is proposed. First, leveraging the periodic characteristics of fabric textures, a method for obtaining feature templates of image patches and a method for calculating anomaly scores of image patches are proposed based on a vector quantized variational autoencoder (VQ-VAE). Second, to address the issue that codebook vectors cannot be effectively activated using Euclidean distance-based quantization mechanism during model training and testing, a cosine similarity-based quantization mechanism is proposed. Ablation experiments demonstrate its effectiveness in improving defect detection performance. Finally, to enhance the robustness of the model when applied to different types of fabric images, a dual-scale method is proposed. The proposed method was compared with five state-of-the-art anomaly detection methods on three open-source datasets, achieving superior defect detection performance. It demonstrated a performance improvement of 2.1% in image-level defect detection and 1.3% in pixel-level segmentation in terms of area under the curve scores.