纺织学报 ›› 2023, Vol. 44 ›› Issue (09): 205-212.doi: 10.13475/j.fzxb.20220508801

• 机械与器材 • 上一篇    下一篇

基于轻量化网络和知识蒸馏的纱线状态检测

任国栋, 屠佳佳, 李杨, 邱子安, 史伟民()   

  1. 浙江理工大学 浙江省现代纺织装备技术重点实验室, 浙江 杭州 310018
  • 收稿日期:2022-05-30 修回日期:2022-09-27 出版日期:2023-09-15 发布日期:2023-10-30
  • 通讯作者: 史伟民(1965—),男,教授,博士。主要研究方向为纺织机械自动控制。E-mail:swm@zstu.edu.cn
  • 作者简介:任国栋(1996—),男,硕士生。主要研究方向为智能检测与控制。
  • 基金资助:
    国家重点研发计划资助项目(2017YFB1304000)

Yarn state detection based on lightweight network and knowledge distillation

REN Guodong, TU Jiajia, LI Yang, QIU Zian, SHI Weiming()   

  1. Zhejiang Key Laboratory of Modern Textile Equipment Technology, Zhejiang Sci-Tech University, Hangzhou, Zhejiang 310018, China
  • Received:2022-05-30 Revised:2022-09-27 Published:2023-09-15 Online:2023-10-30

摘要:

为准确识别导纱管内纱线数量与种类,保证纱线打结有序进行,提出一种基于卷积神经网络的纱线分类方法。首先,将采集到的3 500张图片分为训练集2 800张和测试集700 张,再从训练集中划出560张作为验证集;其次采用叠加深度可分离卷积构建轻量化的自搭建学生网络。为克服学生网络准确率低、泛化性能弱等缺陷,采用迁移学习与知识蒸馏的组合训练方式对自搭建网络进行训练,将最终训练得到的学生网络权重进行移动端部署应用。实验结果表明:在PC端上对自搭建学生网络采取组合训练方式有效,在移动端上单根纱线识别概率在70%以上、双根纱线为80%以且纱线检测平均准确率达98.86%。为针织行业有关纱线的检测与识别提供了新思路。

关键词: 纱线状态识别, 轻量化神经网络, 知识蒸馏, 迁移学习, 模型部署, 针织

Abstract:

Objective The knotting machine in the circular weft knitting production line absorbs the yarn at the end of different yarn cylinders through the yarn guide tube, and sends the absorbed yarn to the knotting device to complete the knotting process. Aiming at the problem that it is difficult to detect the multi-state and multi-type yarn absorption in the yarn guide tube of the splitter, a detection scheme based on machine vision was proposed to realize the real-time monitoring of yarn number and color in the yarn guide tube of the knot machine to ensure the reliability of the joint.

Method In order to overcome the limitation of convenional yarn detection, an image classification method based on deep learning was proposed. 3 500 collected images were divided into 2 800 training sets and 700 test sets, and 560 images were separated from the training set as the verification set. Following that, a lightweight self-built student network was constructed by using superposition depth separable convolution. In order to overcome the defects of low accuracy and weak generalization performance of students' network, the combination training method of transfer learning and knowledge distillation was utilized to train the self-built network, and the final trained student network weight was deployed on the mobile terminal.

Results Experimental results showed that the teacher network using transfer learning had a verification set accuracy of more than 92% after the first round, and the convergence speed of the loss curve was also significantly accelerated (Fig. 9). When the student network was trained by knowledge distillation, the setting of loss weight α and distillation temperature T had no rule on the verification accuracy of the network. Compared with the student network verification accuracy of 95.7% before distillation, it was improved in general (Tab. 3). When the loss weight α was set to 0.2 and the distillation temperature T was set to 3, the best effect was achieved, and the top-1 accuracy on the verification set reached 99.57%. Comparative experiments of model reasoning were conducted on student network, teacher network and typical lightweight network before and after distillation (Tab. 4). The accuracy of the student network, which was originally 96.00% accurate on the test set, was improved to 99.28% after distillation. In addition, compared with the current typical lightweight model, the self-built lightweight student network had fewer parameters and less computation, which indirectly improved the forward reasoning time of the model. When the trained self-built network was deployed on the embedded terminal for actual test, the probability of a single yarn was higher than 70% (Fig. 11), while the probability of a double yarn was higher than 80%. The actual yarn detection accuracy rate was 98.86% after repeated experimental test on the yarn (Tab. 5). The difference in test accuracy between PC and embedded terminal was observed. The analysis showed that the PC side test was in the form of pictures taken before, while the embedded side test was in the form of actual video stream. On the other hand, the precision of weight parameters may be lost during the process of model quantization acceleration and deployment.

Conclusion The analysis result shows that, on the one hand, the PC side test is in the form of pictures taken before, while the embedded side test is in the form of actual video stream. On the other hand, the precision of weight parameters may be lost during the process of model quantization acceleration and deployment. It can be seen from the above yarn testing results that it meets the practical application needs and lays a solid foundation for promoting the application and popularization of the later knotting machine. In addition, the current yarn detection device is suitable for the knotting machine, but only it is necessary to optimize and upgrade the hardware and algorithm, useful in many occasions relating to yarn detection. Its lightweight size and low cost are undoubtedly progressed with commercial promotion value and significance.

Key words: yarn recognition, lightweight neural network, knowledge distillation, transfer learning, deployment model, knitting

中图分类号: 

  • TP391.41

图1

纱架与打结机示意图"

图2

纱线检测流程示意图"

图3

纱线检测装置"

图4

纱线检测板卡功能模块图"

图5

纱线样本集可视化"

图6

数据增强变化"

图7

学生网络结构示意图"

表1

学生网络结构参数"

类型 卷积核尺寸/步长 输入尺寸
标准卷积 3×3/2 224×224×3
深度可分离卷积块 3×3/2,1×1 112×112×32
深度可分离卷积块 3×3/2,1×1 56×56×64
深度可分离卷积块 3×3/2,1×1 28×28×64
深度可分离卷积块 3×3/2,1×1 14×14×128
深度可分离卷积块 3×3,1×1 7×7×256
池化层 7×7 7×7×512
全连接层 512×7 1×1×512
Softmax 分类输出 1×1×7

图8

整体训练与部署流程图"

表2

实验参数设置"

参数名称 参数值
模型输入尺寸 224×224×3
交叉熵损失函数 Categorical_crossentropy
优化器 Adam
分类器 Softmax
迭代次数 100
批大小 32
学习率 0.000 1

图9

迁移学习下的验证集准确率以及训练损失"

表3

参数T和α对Top-1验证准确率的影响"

T 验证集Top-1准确率/%
α=0.1 α=0.2 α=0.3 α=0.4
1 99.04 99.21 99.21 97.96
3 99.21 99.57 97.61 98.68
5 97.72 97.61 99.21 99.57
7 98.68 97.96 99.04 97.96
10 99.04 99.21 99.39 97.68

图10

知识蒸馏下的验证准确率与训练损失"

表4

网络模型推理性能对比"

模型 准确率/
%
参数量
106
运算量
106
内存大小/
MB
时间/ms
CPU GPU
老师网络
(ResNet34)
99.89 21.29 3 670 37.61 63.99 7.46
学生网络 96.00 0.19 34.44 10.12 8.11 1.73
KD+学生
网络
99.28 0.19 34.44 10.12 8.12 1.77
MobileNet_
V3_Small
99.16 1.53 58.80 50.39 22.07 7.33
ShuffleNet_
V2_x0.5
99.27 1.37 43.65 11.24 26.97 9.35

图11

纱线检测效果图"

表5

嵌入式端检测准确率"

类别 测试数量/张 正确数量/张 准确率/%
无纱 50 50 100
黑色普通单根 50 49 98
黑色普通双跟 50 50 100
白色毛羽单根 50 49 98
白色毛羽双根 50 50 100
白色竹节单根 50 48 96
白色竹节双根 50 50 100
总计 350 346 98.86
[1] 马海鹏. 针织圆纬机自动化和信息化关键技术研究[D]. 杭州: 浙江理工大学, 2017: 5-7.
MA Haipeng. Key Technology Research on automation and informatization of circular knitting machine[D]. Hangzhou: Zhejiang Sci-Tech University, 2017: 5-7.
[2] 赵文锐, 贺秋森, 张婧怡, 等. 纱线打结拓扑结构的稳定性研究[J]. 棉纺织技术, 2021, 49(8): 22-25.
ZHAO Wenrui, HE Qiusen, ZHANG Jingyi, et al. Study on the stability of yarn knotting Topology[J]. Cotton Textile Technology, 2021, 49(8): 22-25.
[3] 景慎全. 中国色纺纱行业的技术进步和发展趋势[J]. 纺织导报, 2020, 919(6): 22-27.
JING Shenquan. Technical progress and development trend of China's color spinning yarn industry[J]. China Textile Leader, 2019, 919(6): 22-27.
[4] 王萌萌, 刘成霞. 基于卷积神经网络的织物缝纫平整度客观评价[J]. 毛纺科技, 2020, 48(5): 87-91.
WANG Mengmeng, LIU Chengxia. Objective evaluation of fabric sewing smoothness based on convolutional neural network[J]. Wool Textile Technology, 2020, 48(5): 87-91.
[5] 吴震宇, 陈琳荣, 李子军, 等. 接触式纱线张力传感器动态测量模型[J]. 纺织学报, 2013, 34(8): 138-142.
WU Zhenyu, CHEN Linrong, LI Zijun, et al. Contactyarn tension sensor dynamic measurement model[J]. Journal of Textile Research, 2013, 34(8): 138-142.
[6] 章钰娟, 彭来湖, 徐郁山, 等. 非接触式纱线状态检测技术研究[J]. 现代纺织技术, 2022, 30(1): 101-108.
ZHANG Yujuan, PENG Laihu, XU Yushan, et al. Non-contact yarn state detection technology research[J]. Journal of Modern Textile Technology, 2022, 30 (1): 101-108.
[7] 李东洁, 郭帅, 杨柳. 基于改进图像阈值分割算法的纱线疵点检测[J]. 纺织学报, 2021, 42(3): 82-88.
LI Dongjie, GUO Shuai, YANG Liu. Yarn defect detection based on improved image threshold segmentation algorithm[J]. Journal of Textile Research, 2021, 42(3): 82-88.
[8] 张缓缓, 赵妍, 景军锋, 等. 基于亚像素边缘检测的纱线条干均匀度测量[J]. 纺织学报, 2020, 41(5): 45-49.
ZHANG Huanhuan, ZHAO Yan, JING Junfeng, et al. Yarn evenness measurement based on sub-pixel edge detection[J]. Journal of Textile Research, 2020, 41(5): 45-49.
[9] 马珂, 严凯, 张缓缓, 等. 基于贝叶斯阈值的纱线毛羽检测方法研究[J]. 棉纺织技术, 2021, 49(4):11-15.
MA Ke, YAN Kai, ZHANG Huanhuan, et al. Research on yarn hairiness detection method based on bayesian threshold[J]. Cotton Textile Technology, 2021, 49(4): 11-15.
[10] ZHANG X, ZHOU X, LIN M, et al. Shufflenet: an extremely efficient convolutional neural network for mobile devices[C]// Proceedings of the IEEE conference on computer vision and pattern recognition. 2018: 6848-6856.
[11] Chollet F. Xception: deep learning with depthwise separable convolutions[C]// Proceedings of the IEEE conference on computer vision and pattern recognition. 2017: 1251-1258.
[12] 董萍, 卫梦华, 时雷, 郭伟. 迁移学习在玉米叶片病害识别中的研究与应用[J]. 中国农机化学报, 2022, 43(3): 146-152.
DONG Ping, WEI Menghua, SHI Lei, et al. Migration study in research and application of corn leaf disease recognition[J]. Journal of Chinese Agricultural Mechanization, the Lancet, 2022, 43(3): 146-152.
[13] 黄震华, 杨顺志, 林威, 等. 知识蒸馏研究综述[J]. 计算机学报, 2022, 45(3): 624-653.
HUANG Zhenhua, YANG Shunzhi, LIN Wei, et al. A review of knowledge distillation[J]. Chinese Journal of Computers, 2022, 45(3): 624-653.
[1] 李玉贤, 巫晓雯, 吴光军, 丛洪莲. 针织毛衫版片的参数化设计模型与实现[J]. 纺织学报, 2023, 44(09): 168-174.
[2] 丁雪婷, 王建萍, 潘婷, 姚晓凤, 袁鲁宁. 仿蜻蜓翅膀结构的冬季针织面料研发及其性能[J]. 纺织学报, 2023, 44(09): 75-83.
[3] 李露红, 赵博宇, 丛洪莲. 复合结构经编针织电容式传感器设计及其性能[J]. 纺织学报, 2023, 44(08): 88-95.
[4] 孙园园, 张琦, 张燕婷, 左露娇, 丁宁宇. 三维通孔结构三色三贾卡提花间隔鞋材的研发[J]. 纺织学报, 2023, 44(07): 110-115.
[5] 王开, 王瑾, 牛丽, 陈超余, 马丕波. 棉/不锈钢丝包芯纱针织电路制备及其导电稳定性能[J]. 纺织学报, 2023, 44(07): 64-71.
[6] 俞旭良, 丛洪莲, 孙菲, 董智佳. 仿猪笼草口缘结构功能针织物的设计与应用[J]. 纺织学报, 2023, 44(07): 72-78.
[7] 史伟民, 简强, 李建强, 汝欣, 彭来湖. 基于非线性扩散和多特征融合的提花针织物疵点检测[J]. 纺织学报, 2023, 44(07): 86-94.
[8] 徐瑞东, 刘红, 王航, 朱士凤, 曲丽君, 田明伟. 离子型水凝胶复合织物构筑及其应变传感性能[J]. 纺织学报, 2023, 44(06): 137-143.
[9] 苏旭中, 梁巧敏, 王汇锋, 张娣, 崔益怀. 棉/生物基弹性聚酯纤维混纺针织物的服用性能[J]. 纺织学报, 2023, 44(05): 119-124.
[10] 李玉贤, 丛洪莲, 吴光军. 针织立体构型产品的全成形工艺设计[J]. 纺织学报, 2023, 44(05): 132-138.
[11] 颜丙义, 侯金, 黄启煜, 杨汉城, 田进, 杨春勇. 典型传统服饰图像的在线识别系统[J]. 纺织学报, 2023, 44(05): 184-190.
[12] 宋洁, 蔡涛, 郑福尔, 郑环达, 郑来久. 涤纶针织鞋材超临界CO2无水染色性能[J]. 纺织学报, 2023, 44(05): 46-53.
[13] 彭来湖, 罗昌, 戴宁, 胡旭东, 牛冲. 动态恒张力氨纶输送控制研究[J]. 纺织学报, 2023, 44(04): 194-203.
[14] 尹昂, 丛洪莲. 经编单向导湿织物设计与结构优化[J]. 纺织学报, 2023, 44(04): 86-91.
[15] 牛丽, 刘青, 陈超余, 蒋高明, 马丕波. 仿生鳞片针织结构自供能传感织物的制备及其性能[J]. 纺织学报, 2023, 44(02): 135-142.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!