In response to the complex diversity of surface defects in plywood veneers and the difficulties in feature extraction, as well as the large number of parameters and computational costs of deep learning-based defect detection algorithms, which makes effective application on devices with lower computing power challenging, a detection model for surface defects (live knots, dead knots, holes, cracks, and notches) in veneers based on an improved YOLOv8n is constructed. To enhance the detection accuracy and lightweight performance of the model, improvements are made to the plywood veneer surface defect detection model. First, a new efficient attention mechanism (coordinate attention, CA) is adopted, which can enhance the accuracy of feature extraction and the network's spatial information perception ability while avoiding excessive computational burden; secondly, a novel structure based on partial convolution (PConv) is proposed——CSPPC (CSP(coross stage partial) pyramid convolution), it to improve computational efficiency and the fusion capability of multi-scale features; finally, an improved weighted intersection over union loss function——WIoUv3, it is introduced, which enhances the model's localization accuracy and robustness. Experimental results show that the improved YOLOv8 model (CP-YOLOv8) performs excellently in the task of detecting surface defects in plywood veneers, achieving an average precision mean (mAP) of 93.8%, an increase of 0.9% over the original model, while reducing the model's floating-point operations (GFLOPs) and parameter count to 7.2 G and 2.58 M, respectively, a reduction of 0.9 G and 0.42 M, which can fully meet practical application needs and provide an efficient, accurate, and lightweight solution for quality inspection of plywood veneers.
在目标检测任务中,定位框的精确性直接决定了检测性能。传统的交并比(intersection over union,IoU)、广义交并比(generalized intersection over union,GIoU)、距离交并比(distance intersection over union,DIoU)和完整交并比(complete intersection over union,CIoU)损失函数对目标边界框的精确拟合能力仍存在局限。本研究引入了改进的加权交并比(WIoU)损失函数,其结合了IoU度量、边界框的中心偏移以及形状差异,提出了一种动态非单调机制,能有效应对目标大小及形状差异的挑战,同时优化边界框的匹配度和收敛性。WIoUv1(Wise-IoUv1,式中记为)提出了一种基于注意力机制的预测框损失计算方法。随后,WIoUv2()和WIoUv3()在此基础上进一步引入了聚焦系数,使得该方法更加适应复杂样本的学习需求。Wise-IoU的数学公式演变过程如下所示。
试验的操作系统为Windows11,CPU为Intel Core i9-13900F@2.10 GHz。GPU为NVDIAGe Force RTX4070 (8 GB),运行内存为32 GB。Pytorch版本为1.13.0,Python版本为3.9,CUDA版本为12.1,相机选用MVS03260GC。
参数设置:图片大小设置为640×640像素,训练轮次为300,批量大小为16,学习率为0.01。
3.2 评价指标
试验采用了精确率(precision,式中记为P)、召回率(Recall,式中记为R)以及平均精度均值(mean average precision,mAP,式中记为mAP),平均精度(average precision,AP,式中记为AP),包括mAP@50,浮点运算次数GFLOPs,模型参数量(parameters),相关计算公式为
LIMW H, BONABM B, CHUAK H.An aggressively pruned CNN model with visual attention for near real-time wood defects detection on embedded processors[J].IEEE Access,2023,11:36834-36848.
[2]
XIEY H, WANGJ C.Study on the identification of the wood surface defects based on texture features[J].Optik-International Journal for Light and Electron Optics,2015,126(19):2231-2235.
CHENGD, CHENGG, WANGX.Real-time detection method of wood defects based on deep learning[C]//2022 IEEE 8th International Conference on Computer and Communications (ICCC),09-12 December,2022,Chengdu,China,IEEE,2022:2192-2197.
[7]
REDMONJ, DIVVALAS, GIRSHICKR,et al.You only look once:Unified,real-time object detection[C]//2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR),12 December 2016,Las Vegas,NV,USA.IEEE,2016:779-788.
[8]
YUANW.Accuracy comparison of YOLOv7 and YOLOv4 regarding image annotation quality for apple flower bud classification[J].AgriEngineering,2023,5(1):413-424.
[9]
ROSSG.Fast R-CNN[C]//2015 IEEE International Conference on Computer Vision (ICCV),07-13 December 2015,Santiago,Chile.IEEE,2015:1440-1448.
[10]
RENS Q, HEK M, GIRSHICKR,et al.Faster R-CNN:Towards real-time object detection with region proposal networks[J].IEEE Transactions on Pattern Analysis and Machine Intelligence,2017,39(6):1137-1149.
[11]
LIUZ F, LIUX H, LIC L,et al.Fabric defect detection based on faster R-CNN[C]// 9th International Conference on Graphic and Image Processing,14-16 October 2017,Qingdao,China.2018:55-63.
[12]
HANS, JIANGX, WUZ.An Improved YOLOv5 algorithm for wood defect detection based on attention[J].IEEE Access,2023,11:71800-71810.
[13]
LID, XIEW, WANGB,et al.Data augmentation and layered deformable mask R-CNN-Based detection of wood defects[J].IEEE Access,2021,9:108162-108174.
[14]
XIAB, LUOH, SHIS.Improved faster R-CNN based surface defect detection algorithm for plates[J].Computational Intelligence and Neuroscience,2022,2022:3248722.
JIAH N, XUH D, WANGL H,et al.Quantitative identification of surface defects in wood paneling based on improved YOLOv5[J].Journal of Beijing Forestry University,2023,45(4):147-155.
ZHUH, ZHOUS H, ZENGY L,et al.Detection model of wood surface defects based on improved YOLOv5s[J].Chinese Journal of Wood Science and Technology,2023,37(2):8-15.