Please wait a minute...
Journal of ZheJiang University (Engineering Science)  2025, Vol. 59 Issue (6): 1169-1178    DOI: 10.3785/j.issn.1008-973X.2025.06.008
    
Denim fabric defect detection algorithm based on improved RT-DETR
Gengliang LIANG1(),Shuguang HAN2,*()
1. School of Computer Science and Technology (School of Artificial Intelligence), Zhejiang Sci-Tech University, Hangzhou 310018, China
2. School of Science, Zhejiang Sci-Tech University, Hangzhou 310018, China
Download: HTML     PDF(3499KB) HTML
Export: BibTeX | EndNote (RIS)      

Abstract  

A detection algorithm based on improved RT-DETR was proposed, to achieve rapid and accurate detection of minor defects on surfaces of denim fabrics and to overcome the decline in detection performance of existing models under complex textured backgrounds. First, partial convolution (PConv) was utilized to enhance the model’s ability to recognize key features through the Efficient Multi-Scale Attention mechanism. Second, on the basis of adding the S2 feature detection layer, two feature fusion operations, multi-feature encoding (MFE) and multi-scale feature fusion (MSFF), were introduced to enhance the integration of feature information at different scales, and the Deformable Attention mechanism was employed to better address defect deformation. In terms of loss function, a new loss function was proposed, which could accelerate the network convergence and improve the accuracy of network detection. Tests conducted on the fabric defect dataset from Tianchi Cloud demonstrated that the improved RT-DETR model achieved an average mAP@0.5 of 60%, marking 5.3% improvement over the RT-DETR-R18 model, with a 40.1% reduction in the total number of model parameters. Compared to YOLOv5 and YOLOv8, improvements of 9.5% and 9.9% in mAP@0.5 were observed, respectively. The improved RT-DETR model shows significant enhancements in the positioning accuracy and detection precision of defect detection, meeting the requirements for industrial-scale detection. This model serves as an important reference for the intelligent transformation and development of the textile and apparel industry.



Key wordsfabric defect      defect detection      RT-DETR      partial convolution (PConv)      Deformable Attention      normalized Wasserstein distance (NWD)     
Received: 30 March 2024      Published: 30 May 2025
CLC:  TS 101.8  
Fund:  国家自然科学基金资助项目(12471304).
Corresponding Authors: Shuguang HAN     E-mail: 13959104785@163.com;dawn1024@zstu.edu.cn
Cite this article:

Gengliang LIANG,Shuguang HAN. Denim fabric defect detection algorithm based on improved RT-DETR. Journal of ZheJiang University (Engineering Science), 2025, 59(6): 1169-1178.

URL:

https://www.zjujournals.com/eng/10.3785/j.issn.1008-973X.2025.06.008     OR     https://www.zjujournals.com/eng/Y2025/V59/I6/1169


基于改进RT-DETR的牛仔面料疵点检测算法

为了实现牛仔面料微小疵点的快速准确检测,克服已有模型在复杂纹理背景下检测性能不佳的问题,提出基于改进RT-DETR的检测算法. 采用部分卷积(PConv)结合Efficient Multi-Scale Attention机制增强模型对关键特征的识别能力;在添加S2特征检测层的基础上,提出多特征编码模块(MFE)和多尺度特征融合模块(MSFF)这2个特征融合操作,增强不同尺度的特征信息融合,并使用Deformable Attention注意力机制应对多样的疵点. 在损失函数方面,提出新的联合损失函数,在加快网络收敛的同时,提高网络检测的精度. 在天池云的布匹缺陷数据集上进行实验,结果表明改进RT-DETR模型的平均mAP@0.5为60%,与RT-DETR-R18模型相比,mAP@0.5提升5.3个百分点,模型总参数量下降40.1%;与YOLOv5、YOLOv8相比,mAP@0.5分别提升9.5、9.9个百分点. RT-DETR改进模型在疵点检测的定位准确度与精度上均有显著提升,能满足工业大规模检测要求,对于纺织服装产业的智能化转型具有重要的借鉴作用.


关键词: 面料缺陷,  缺陷检测,  RT-DETR,  部分卷积(PConv),  可变形注意力,  归一化 Wasserstein 距离(NWD) 
Fig.1 Structure diagram of RT-DETR model
Fig.2 Schematic diagram of PConv
Fig.3 Structure diagram of EMA attention module
Fig.4 Schematic diagram of S2 detection layer
Fig.5 IoU sensitivity analysis for tiny- and normal-scale objects
Fig.6 Schematic diagram of CCFM module
Fig.7 Schematic diagram of MSFF module
Fig.8 Schematic diagram of MFE module
Fig.9 Improved RT-DETR model
Fig.10 Denim fabric defect detection sample images
配置环境配置名称(版本)
操作系统Windows10
CPUIntel(R) Xeon(R) Platinum 8255C CPU @ 2.50 GHz
GPURTX 3090(24 GB) ×1
编译器Python 3.8(ubuntu20.04)
深度学习框架PyTorch 1.11.0
加速模块CUDA Toolkit-11.3.1
Tab.1 Experimental environment of deep learning
参数含义数值
Images size图像尺度640
batch size批数量4
E迭代次数200
lr学习率0.0001
Momentum动量0.9
Weight_decay权重衰减率0.0001
Tab.2 Experimental hyperparameters of deep learning
权重取值mAP@0.5/%mAP@0.50?0.95/%
$ {w}_{1}=0.4,{w}_{2}=0.6 $55.325.3
$ {w}_{1}=0.5,{w}_{2}=0.5 $55.625.8
$ {w}_{1}=0.6,{w}_{2}=0.4 $56.025.9
$ {w}_{1}=0.7,{w}_{2}=0.3 $56.326.1
$ {w}_{1}=0.8,{w}_{2}=0.2 $55.925.7
Tab.3 Comparative experiment on parameter setting of loss function
算法$ P $$ R $$ \text{mAP@0.5}\text{/\%} $$ \text{mAP@} \text{0.50?0.95}\text{/\%} $$ {\text{FPS/(}\text{帧}\text{?}\text{s}}^{{-1}}\text{)} $$ {N}_{{\mathrm{p}}}\text{/}{\text{10}}^{\text{7}} $S/MB
RT-DETR-R180.6670.55754.725.157.11.98838.6
R18+PConv(改进模型1)0.6860.58758.327.051.21.67932.8
R18+EMA(改进模型2)0.7030.58357.928.145.21.99838.9
R18+Deformable Attention(改进模型3)0.6970.60858.727.949.31.98838.6
R18+S2+MSFF-MFE(改进模型4)0.7100.58858.628.849.21.50029.1
R18+3个改进点(本研究模型)0.7100.60360.028.637.41.19023.5
Tab.4 Results of single improvement effectiveness comparison experiment
损失函数$ P $$ R $${\mathrm{ mAP}}@0.5/{\text{%}} $$ {\mathrm{mAP}}@ \text{0.50?0.95}/{\text{%}} $
LGIoU0.6870.57557.026.1
LCIoU0.7060.58759.328.1
LEIoU0.7010.58558.727.9
$ {L}_{\text{joint}} $0.7160.59360.328.9
Tab.5 Comparison experiment of loss function
Fig.11 Change of loss function
检测模型PEBlock-EMAMSFF-MFEDeformable Attention$ {L}_{\text{joint}} $$ \text{mAP@0.5}\text{/\%} $$ \text{mAP} \text{@}{0.50-0.95}\text{/\%} $$ {N}_{{\mathrm{p}}}\text{/}{\text{10}}^{\text{7}} $$ {\text{FPS}\text{/(}\text{帧}\text{?}\text{s}}^{{-1}}\text{)} $
Model1$ \times $$ \times $$ \times $$ \times $54.725.11.98857.1
Model3$ \times $$ \times $$ \times $59.228.41.69039.5
Model4$ \times $$ \times $58.728.81.19035.2
Model5$ \times $60.028.61.19037.4
Model6
(本研究模型)
60.328.91.19037.1
Tab.6 Ablation study on enhanced modules
Fig.12 Model heat map visualization
算法模型$ \text{mAP@} \text{0.5}/{\text{%}} $$ \text{mAP@} \text{0.50?0.95}\text{/\%} $$ \text{FPS}\text{/} \text{(}\text{帧}\text{?}{\text{s}}^{{-1}}) $$ {N}_{\rm{p}}\text{/}{\text{10}}^{\text{7}} $
YOLOv5m50.521.162.32.504
YOLOv8m50.121.464.52.584
YOLOv5m-DETR52.723.855.22.490
YOLOv8m-DETR53.2.23.961.22.608
RT-DETR54.725.157.11.988
本研究方法60.328.937.41.190
Tab.7 Comparative experiments of proposed model with existing models
Fig.13 Comparison of defect detection results before and after RT-DETR improvement
模型mAP@0.5/%
破洞污渍
RT-DETR-R1892.993.2
本研究方法97.796.2
Tab.8 Experimental results of defect detection on TILDA dataset
Fig.14 Schematic diagram of microscopic surface defects of silicon steel strip
模型mAP@0.5/%mAP@0.50?0.95/%
RT-DETR-R1890.239.8
本研究方法92.341.5
Tab.9 Microscopic surface defect detection experiment of silicon steel strip
[1]   张缓缓, 马金秀, 景军锋, 等 基于改进的加权中值滤波与K-means聚类的织物缺陷检测[J]. 纺织学报, 2019, 40 (12): 50- 56
ZHANG Huanhuan, MA Jinxiu, JING Junfeng, et al Fabric defect detection method based on improved fast weighted Median filtering and K-means[J]. Journal of Textile Research, 2019, 40 (12): 50- 56
[2]   郑兆伦, 鲁玉军 基于奇异值分解的双算法织物缺陷检测[J]. 纺织学报, 2022, 43 (11): 59- 67
ZHENG Zhaolun, LU Yujun Dual-algorithm for fabric defect detection based on singular value decomposition[J]. Journal of Textile Research, 2022, 43 (11): 59- 67
[3]   周文明, 周建, 潘如如 应用上下文视觉显著性的色织物疵点检测[J]. 纺织学报, 2020, 41 (8): 39- 44
ZHOU Wenming, ZHOU Jian, PAN Ruru Yarn-dyed fabric defect detection based on context visual saliency[J]. Journal of Textile Research, 2020, 41 (8): 39- 44
[4]   闫本超, 潘如如, 周建, 等 基于改进Itti显著模型的织物疵点实时检测[J]. 纺织学报, 2023, 44 (7): 95- 102
YAN Benchao, PAN Ruru, ZHOU Jian, et al Real-time detection of fabric defects based on use of improved Itti salient model[J]. Journal of Textile Research, 2023, 44 (7): 95- 102
[5]   GIRSHICK R. Fast R-CNN [C]// IEEE International Conference on Computer Vision. Santiago: IEEE, 2015: 1440–1448.
[6]   王安静, 袁巨龙, 朱勇建, 等 基于改进YOLOv8s的鼓形滚子表面缺陷检测算法[J]. 浙江大学学报: 工学版, 2024, 58 (2): 370- 380,387
WANG Anjing, YUAN Julong, ZHU Yongjian, et al Drum roller surface defect detection algorithm based on improved YOLOv8s[J]. Journal of Zhejiang University: Engineering Science, 2024, 58 (2): 370- 380,387
[7]   张艳, 孙晶雪, 孙叶美, 等 基于分割注意力与线性变换的轻量化目标检测[J]. 浙江大学学报: 工学版, 2023, 57 (6): 1195- 1204
ZHANG Yan, SUN Jingxue, SUN Yemei, et al Lightweight object detection based on split attention and linear transformation[J]. Journal of Zhejiang University: Engineering Science, 2023, 57 (6): 1195- 1204
[8]   LIU B, WANG H, CAO Z, et al PRC-light YOLO: an efficient lightweight model for fabric defect detection[J]. Applied Sciences, 2024, 14 (2): 938
doi: 10.3390/app14020938
[9]   CARION N, MASSA F, SYNNAEVE G, et al. End-to-end object detection with transformers [C]// European Conference on Computer Vision. Cham: Springer, 2020: 213–229.
[10]   ZHANG H, LI F, LIU S, et al. DINO: detr with improved DeNoising anchor boxes for end-to-end object detection [EB/OL]. (2022-03-07) [2024-02-24]. https://arxiv.org/abs/2203.03605v4.
[11]   ZHAO Y, LV W, XU S, et al. DETRs beat YOLOs on real-time object detection [C]// IEEE/CVF Conference on Computer Vision and Pattern Recognition. Seattle: IEEE, 2024: 16965–16974.
[12]   HOWARD A G, ZHU M, CHEN B, et al. MobileNets: efficient convolutional neural networks for mobile vision applications [EB/OL]. (2017-04-17) [2024-02-26]. https://arxiv.org/abs/1704.04861v1.
[13]   HAN K, WANG Y, TIAN Q, et al. GhostNet: more features from cheap operations [C]// IEEE/CVF Conference on Computer Vision and Pattern Recognition. Seattle: IEEE, 2020: 1580–1589.
[14]   MA N, ZHANG X, ZHENG H T, et al. ShuffleNet V2: practical guidelines for efficient CNN architecture design [C]// European Conference on Computer. Cham: Springer, 2018: 122–138.
[15]   CHEN J, KAO S H, HE H, et al. Run, don’t walk: chasing higher FLOPS for faster neural networks [C]// IEEE/CVF Conference on Computer Vision and Pattern Recognition. Vancouver: IEEE, 2023: 12021–12031.
[16]   OUYANG D, HE S, ZHANG G, et al. Efficient multi-scale attention module with cross-spatial learning [C]// IEEE International Conference on Acoustics, Speech and Signal Processing. Rhodes Island: IEEE, 2023: 1–5.
[17]   ZHU X, SU W, LU L, et al. Deformable DETR: deformable transformers for end-to-end object detection [EB/OL]. (2020-10-08) [2024-02-26]. https://arxiv.org/abs/2010.04159v4.
[18]   WANG J, XU C, YANG W, et al. A normalized Gaussian Wasserstein distance for tiny object detection [EB/OL]. (2021-10-26) [2024-02-26]. https://arxiv.org/abs/2110.13389v2.
[19]   LIU W, LU H, FU H, et al. Learning to upsample by learning to sample [EB/OL]. (2023-8-29) [2024-02-26]. https://arxiv.org/abs/2308.15085v1.
[20]   XU G, LIAO W, ZHANG X, et al Haar wavelet downsampling: a simple but effective downsampling module for semantic segmentation[J]. Pattern Recognition, 2023, 143: 109819
doi: 10.1016/j.patcog.2023.109819
[1] Wenbo JU,Huajun DONG. Motherboard defect detection method based on context information fusion and dynamic sampling[J]. Journal of ZheJiang University (Engineering Science), 2025, 59(6): 1159-1168.
[2] Junyin WANG,Bin WEN,Yanjun SHEN,Jun ZHANG,Zihao WANG. Surface defect detection method for aluminum profiles based on improved YOLOv7-tiny[J]. Journal of ZheJiang University (Engineering Science), 2025, 59(3): 523-534.
[3] Liming LIANG,Pengwei LONG,Jiaxin JIN,Renjie LI,Lu ZENG. Steel surface defect detection algorithm based on improved YOLOv8s[J]. Journal of ZheJiang University (Engineering Science), 2025, 59(3): 512-522.
[4] Bing YANG,Chuyang XU,Jinliang YAO,Xueqin XIANG. 3D hand pose estimation method based on monocular RGB images[J]. Journal of ZheJiang University (Engineering Science), 2025, 59(1): 18-26.
[5] Shancheng TANG,Jianhui LU,Ying ZHANG,Zicheng JIN,Anxin ZHAO. Unsupervised surface defect detection of magnetic tile for repair of suspected area defects[J]. Journal of ZheJiang University (Engineering Science), 2024, 58(4): 718-728.
[6] Kun LIU,Ding WANG,Jingkai WANG,Haiyong CHEN,Weipeng LIU. Feature filtering and feature decoupling based domain generalization model[J]. Journal of ZheJiang University (Engineering Science), 2024, 58(3): 459-467.
[7] Anjing WANG,Julong YUAN,Yongjian ZHU,Cong CHEN,Jinjin WU. Drum roller surface defect detection algorithm based on improved YOLOv8s[J]. Journal of ZheJiang University (Engineering Science), 2024, 58(2): 370-380.
[8] Qing-lin AI,Jing-rui CUI,Bing-hai LV,Tong TONG. Surface defect detection method for bearing drum-shaped rollers based on fusion transformation of defective area[J]. Journal of ZheJiang University (Engineering Science), 2023, 57(5): 1009-1020.
[9] Bai-cheng BIAN,Tian CHEN,Ru-jun WU,Jun LIU. Improved YOLOv3-based defect detection algorithm for printed circuit board[J]. Journal of ZheJiang University (Engineering Science), 2023, 57(4): 735-743.
[10] Huan LAN,Jian-bo YU. Steel surface defect detection based on deep learning 3D reconstruction[J]. Journal of ZheJiang University (Engineering Science), 2023, 57(3): 466-476.
[11] Tian-le YUAN,Ju-long YUAN,Yong-jian ZHU,Han-chen ZHENG. Surface defect detection algorithm of thrust ball bearing based on improved YOLOv5[J]. Journal of ZheJiang University (Engineering Science), 2022, 56(12): 2349-2357.
[12] Shuang ZHAO,Jun-tao WU,Xin-chen QIU,Kui-hua WANG,Yuan TU. Study on defect detection of extended pile shaft under lateral low-strain integrity test[J]. Journal of ZheJiang University (Engineering Science), 2021, 55(10): 1867-1876.
[13] Yang-bo CHEN,Guo-dong YI,Shu-you ZHANG. Surface warpage detection method based on point cloud feature comparison[J]. Journal of ZheJiang University (Engineering Science), 2021, 55(1): 81-88.
[14] Zhong-wei QIN,Jie CHEN,Rong-jing HONG,Wei-wei WU. Visual salience detection algorithm for surface defects of friction sheets[J]. Journal of ZheJiang University (Engineering Science), 2019, 53(10): 1883-1891.