Please wait a minute...
浙江大学学报(工学版)  2025, Vol. 59 Issue (6): 1169-1178    DOI: 10.3785/j.issn.1008-973X.2025.06.008
计算机技术     
基于改进RT-DETR的牛仔面料疵点检测算法
梁耕良1(),韩曙光2,*()
1. 浙江理工大学 计算机科学与技术学院(人工智能学院),浙江 杭州 310018
2. 浙江理工大学 理学院,浙江 杭州 310018
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
 全文: PDF(3499 KB)   HTML
摘要:

为了实现牛仔面料微小疵点的快速准确检测,克服已有模型在复杂纹理背景下检测性能不佳的问题,提出基于改进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)    
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 words: fabric defect    defect detection    RT-DETR    partial convolution (PConv)    Deformable Attention    normalized Wasserstein distance (NWD)
收稿日期: 2024-03-30 出版日期: 2025-05-30
CLC:  TS 101.8  
基金资助: 国家自然科学基金资助项目(12471304).
通讯作者: 韩曙光     E-mail: 13959104785@163.com;dawn1024@zstu.edu.cn
作者简介: 梁耕良(2001—),男,硕士生,从事机器视觉研究. orcid.org/0009-0006-9626-4562. E-mail:13959104785@163.com
服务  
把本文推荐给朋友
加入引用管理器
E-mail Alert
作者相关文章  
梁耕良
韩曙光

引用本文:

梁耕良,韩曙光. 基于改进RT-DETR的牛仔面料疵点检测算法[J]. 浙江大学学报(工学版), 2025, 59(6): 1169-1178.

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.

链接本文:

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

图 1  RT-DETR结构示意图
图 2  PConv示意图
图 3  EMA注意力模块结构图
图 4  S2检测层示意图
图 5  IoU对微小和正常尺度物体的敏感度分析
图 6  CCFM模块示意图
图 7  MSFF模块示意图
图 8  MFE模块示意图
图 9  改进的RT-DETR模型
图 10  牛仔布匹缺陷检测样本图示
配置环境配置名称(版本)
操作系统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
表 1  深度学习的实验环境配置
参数含义数值
Images size图像尺度640
batch size批数量4
E迭代次数200
lr学习率0.0001
Momentum动量0.9
Weight_decay权重衰减率0.0001
表 2  深度学习的实验超参数
权重取值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
表 3  损失函数参数设置对比实验
算法$ 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
表 4  单一改进有效性对比实验结果
损失函数$ 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
表 5  损失函数对比实验
图 11  损失函数变化图
检测模型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
表 6  改进模块消融实验结果
图 12  模型热力图可视化
算法模型$ \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
表 7  本研究模型与已有模型的对比实验
图 13  RT-DETR 改进前后的疵点检测结果对比图
模型mAP@0.5/%
破洞污渍
RT-DETR-R1892.993.2
本研究方法97.796.2
表 8  TILDA数据集缺陷检测实验结果
图 14  硅钢带的微观表面缺陷示意图
模型mAP@0.5/%mAP@0.50?0.95/%
RT-DETR-R1890.239.8
本研究方法92.341.5
表 9  硅钢带的微观表面缺陷检测实验
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] 鞠文博,董华军. 基于上下文信息融合与动态采样的主板缺陷检测方法[J]. 浙江大学学报(工学版), 2025, 59(6): 1159-1168.
[2] 梁礼明,龙鹏威,金家新,李仁杰,曾璐. 基于改进YOLOv8s的钢材表面缺陷检测算法[J]. 浙江大学学报(工学版), 2025, 59(3): 512-522.
[3] 杨冰,徐楚阳,姚金良,向学勤. 基于单目RGB图像的三维手部姿态估计方法[J]. 浙江大学学报(工学版), 2025, 59(1): 18-26.
[4] 唐善成,逯建辉,张莹,金子成,赵安新. 修复缺陷嫌疑区域的无监督磁瓦表面缺陷检测[J]. 浙江大学学报(工学版), 2024, 58(4): 718-728.
[5] 刘坤,王丁,王静凯,陈海永,刘卫朋. 基于特征过滤与特征解耦的域泛化模型[J]. 浙江大学学报(工学版), 2024, 58(3): 459-467.
[6] 王安静,袁巨龙,朱勇建,陈聪,吴金津. 基于改进YOLOv8s的鼓形滚子表面缺陷检测算法[J]. 浙江大学学报(工学版), 2024, 58(2): 370-380.
[7] 卞佰成,陈田,吴入军,刘军. 基于改进YOLOv3的印刷电路板缺陷检测算法[J]. 浙江大学学报(工学版), 2023, 57(4): 735-743.
[8] 兰欢,余建波. 基于深度学习三维成型的钢板表面缺陷检测[J]. 浙江大学学报(工学版), 2023, 57(3): 466-476.
[9] 袁天乐,袁巨龙,朱勇建,郑翰辰. 基于改进YOLOv5的推力球轴承表面缺陷检测算法[J]. 浙江大学学报(工学版), 2022, 56(12): 2349-2357.
[10] 赵爽,吴君涛,邱欣晨,王奎华,涂园. 基于水平低应变法的高承台桩缺陷检测研究[J]. 浙江大学学报(工学版), 2021, 55(10): 1867-1876.
[11] 陈杨波,伊国栋,张树有. 基于点云特征对比的曲面翘曲变形检测方法[J]. 浙江大学学报(工学版), 2021, 55(1): 81-88.
[12] 叶刚,李毅波,马逐曦,成杰. 基于ViBe的端到端铝带表面缺陷检测识别方法[J]. 浙江大学学报(工学版), 2020, 54(10): 1906-1914.
[13] 秦钟伟,陈捷,洪荣晶,吴伟伟. 摩擦片表面缺陷的视觉显著性检测算法[J]. 浙江大学学报(工学版), 2019, 53(10): 1883-1891.