Anomaly detection is demanding for industrial quality assurance and cost reduction, which is still a challenging problem in practice, due to limited availability of anomalies for model training. This work presents a new self-supervised method based on optimal discrete codebook to address defect(anomaly) segmentation on textile fabric. To suppress the generalization of reconstructing anomalous images, an optimal discrete codebook is learned to encode the abnormal feature into a normal one through latent discrete quantization. Moreover, to improve the discriminative power for subtle abnormal regions, the self-supervised segmentation model is presented by combining multi-layer abnormal features instead of reconstruction error. By using the solid color fabric dataset and the denim dataset for validation, the image-level AUROC reaches 100% and 98.8%, respectively; the pixel-level AUROC reaches 96.7% and 94.1%, respectively. The experimental results demonstrate that the proposed method outperforms state-of-the-art self-supervised algorithms in terms of both running time and localization accuracy for fabric defects, which makes it especially suitable for fabric defect segmentation tasks.
Qi Kankan, Pan Ruru, Zhou Jian
. Self-Supervised Fabric Defect Segmentation Based on Optimal Discrete Codebook[J]. Journal of Shanghai Jiaotong University(Science), 2026
, 31(4)
: 950
-959
.
DOI: 10.1007/s12204-025-2795-7
[1] LIU J X, PAN R R, ZHOU J. Unsupervised fabric defect detection based on under-complete dictionary reconstruction [J/OL]. Journal of Shanghai Jiao Tong University, 2023 (in Chinese). https://doi.org/10.16183/j.cnki.jsjtu.2023.205
[2] WEI B, HAO K R, GAO L, et al. Detecting textile micro-defects: A novel and efficient method based on visual gain mechanism [J]. Information Sciences, 2020, 541: 60-74.
[3] HAN T F, SHI P F. The texture defect detection based on multi-level wavelet transform and co-occurrence matrix [J]. Journal of Shanghai Jiao Tong University, 2006, 40(3): 425-430 (in Chinese).
[4] ZHOU J, WANG J. Unsupervised fabric defect segmentation using local patch approximation [J]. The Journal of the Textile Institute, 2016, 107(6): 800-809.
[5] LI C, LI J, LI Y F, et al. Fabric defect detection in textile manufacturing: A survey of the state of the art [J]. Security and Communication Networks, 2021, 2021: 9948808.
[6] LIU J H, WANG C Y, SU H, et al. Multistage GAN for fabric defect detection [J]. IEEE Transactions on Image Processing, 2019, 29: 3388-3400.
[7] WANG X B, FANG W J, XIANG S. Fabric defect detection based on anchor-free network [J]. Measurement Science and Technology, 2023, 34(12): 125402.
[8] KOULALI I, ESKIL M T. Unsupervised textile defect detection using convolutional neural networks [J]. Applied Soft Computing, 2021, 113: 107913.
[9] THOMINE S, SNOUSSI H. Distillation-based fabric anomaly detection [J]. Textile Research Journal, 2024, 94(5/6): 552-565.
[10] ZHANG H W, LIU S B, WANG C, et al. Color-patterned fabric defect detection algorithm based on triplet attention multi-scale U-shape denoising convolutional auto-encoder [J]. The Journal of Supercomputing, 2024, 80(4): 4451-4476.
[11] YU Z Q, XU Y, WANG Y F, et al. Unsupervised fabric defect detection based on multiscale image reconstruction and structural similarity assessment [J]. Coloration Technology, 2024, 140(6): 827-842.
[12] HOJJATI H, HO T K K, ARMANFARD N. Self-supervised anomaly detection in computer vision and beyond: A survey and outlook [DB/OL]. (2022-05-10). https://arxiv.org/abs/2205.05173
[13] WANG W C, AHN E, FENG D G, et al. A review of predictive and contrastive self-supervised learning for medical images [J]. Machine Intelligence Research, 2023, 20(4): 483-513.
[14] ZHANG H W, CHEN X W, LU S, et al. A contrastive learning-based attention generative adversarial network for defect detection in colour-patterned fabric [J]. Coloration Technology, 2023, 139(3): 248-264.
[15] ZAVRTANIK V, KRISTAN M, SKOČAJ D. Reconstruction by inpainting for visual anomaly detection [J]. Pattern Recognition, 2021, 112: 107706.
[16] SHENG S Y, JING J F, JIAO X T, et al. MÆIDM: Multi-scale anomaly embedding inpainting and discrimination for surface anomaly detection [J]. Machine Vision and Applications, 2023, 34(4): 66.
[17] ZAVRTANIK V, KRISTAN M, SKOČAJ D. DRÆM–A discriminatively trained reconstruction embedding for surface anomaly detection [C]//2021 IEEE/CVF International Conference on Computer Vision. Montreal: IEEE, 2021: 8310-8319.
[18] SCHLÜTER H M, TAN J, HOU B, et al. Natural Synthetic Anomalies for Self-supervised Anomaly Detection and Localization [M]// Computer Vision – ECCV 2022. Cham: Springer, 2022: 474-489.
[19] VAN DEN OORD A, VINYALS O. Neural discrete representation learning [C]// 31st Conference on Neural Information Processing Systems. Long Beach: NIPS, 2017: 1-10.
[20] RAZAVI A, VAN DEN OORD A, VINYALS O. Generating diverse high-fidelity images with VQ-VAE-2 [C]// 33rd Conference on Neural Information Processing Systems. Vancouver: NIPS, 2019: 1-11.
[21] ZHANG C K, FENG S Z, WANG X, et al. ZJU-leaper: A benchmark dataset for fabric defect detection and a comparative study [J]. IEEE Transactions on Artificial Intelligence, 2020, 1(3): 219-232.
[22] TIEN T D, NGUYEN A T, TRAN N H, et al. Revisiting reverse distillation for anomaly detection [C]//2023 IEEE/CVF Conference on Computer Vision and Pattern Recognition. Vancouver: IEEE, 2023: 24511-24520.
[23] ROTH K, PEMULA L, ZEPEDA J, et al. Towards total recall in industrial anomaly detection [C]//2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition. New Orleans: IEEE, 2022: 14298-14308.
[24] LEI J R, HU X B, WANG Y, et al. PyramidFlow: High-resolution defect contrastive localization using pyramid normalizing flow [C]//2023 IEEE/CVF Conference on Computer Vision and Pattern Recognition. Vancouver: IEEE, 2023: 14143-14152.
[25] DENG H Q, LI X Y. Anomaly detection via reverse distillation from one-class embedding [C]//2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition. New Orleans: IEEE, 2022: 9727-9736.
[26] XIE X, HUANG Y H, NING W Y, et al. RDAD: A reconstructive and discriminative anomaly detection model based on transformer [J]. International Journal of Intelligent Systems, 2022, 37(11): 8928-8946.