1.College of Computer and Control Engineering,Northeast Forestry University,Harbin 150040,China
2.College of Mechanical and Electrical Engineering,Northeast Forestry University,Harbin 150040,China
Show less
文章历史+
Received
Accepted
Published
2024-12-09
Issue Date
2025-07-16
PDF (5078K)
摘要
为解决目标检测算法在木材表面缺陷检测中容易出现漏检及检测精度不足的问题,提出一种改进的YOLOv8模型(YOLOv8-CBW,C、B、W分别为CondSiLU、BiFPN、Wise-IoU的缩写),并构建包含多种木材缺陷的自制数据集。通过对原有的YOLOv8算法进行优化,将条件卷积(conditional convolution,CondConv)与SiLU (sigmoid-weighted linear unit)结合后形成CondSiLU模块替代传统卷积模块,提升特征提取的灵活性;引入双向特征金字塔网络(bidirectional feature pyramid network,BiFPN),增强模型多尺度特征融合能力;并用Wise-IoU (weighted intersection over union)损失函数替代CIoU (complete intersection over union),提高模型对低质量样本的适应性和泛化性能。试验结果表明,改进后的YOLOv8-CBW模型与YOLOv8模型相比,mAP50 (即IoU (交并比)阈值为0.50时的平均精度均值)和mAP50-95 (是指IoU (交并比)阈值在0.50~0.95时的平均精度均值)分别提高了3.7%和3.9%,且在复杂木材缺陷检测任务中表现出更高的精度和稳定性。研究结果为木材缺陷检测任务提供新思路,并具有良好的实际应用前景。
Abstract
To solve the problem that the target detection algorithm is prone to leakage and lacks detection accuracy in detecting wood surface defects, this paper proposes an improved YOLOv8 model (YOLOv8-CBW, C, B and W are abbreviations for CondSiLU, BiFPN and Wise-IoU) and constructs a self-made dataset containing various wood defects. By optimizing the original YOLOv8 algorithm and combining CondConv (conditional convolution) with SiLU (sigmoid-weighted linear unit) to form the CondSiLU module instead of the traditional convolution module, the flexibility of feature extraction is improved; the bidirectional feature pyramid network (BiFPN) is introduced to enhance the multi-scale feature fusion capability; and the Wise-IoU (weighted intersection over union) loss function replaces the CIoU (complete intersection over union) to improve the adaptability and generalization performance of the model to low-quality samples. The experimental results show that the improved YOLOv8-CBW model improves the mAP50 (mean average precision at IoU threshold 0.50) and mAP50-95(mean average precision over IoU thresholds from 0.50 to 0.95) by 3.7% and 3.9%, respectively, compared with the YOLOv8 model, and it shows higher precision and stability in complex wood defect detection tasks. The research in this paper provides new ideas for wood defect detection tasks and has good practical application prospects.
针对在木材表面缺陷检测中,缺陷的尺度变化较大。ConvModule模块卷积层中的固定卷积核,在处理多尺度特征时很容易丢失一些细节或过于关注某个尺度的信息[9]。鉴于ConvModule卷积层的这种问题,本研究在CondConv模块的基础上设计出了CondSiLU(conditional convolution with SiLU Activation)模块来代替YOLOv8模型里的ConvModule模块。CondConv模块通过引入条件参数(根据输入特征动态生成的卷积核),来替代传统卷积中的固定卷积核。上一层模块的输出结果,同时作为本模块的输入,通过计算权重函数计算不同卷积核的权重,从而对每一个输入生成专属的卷积核组合。结果通过组合的卷积核对输入的数据进行卷积得到[10]。最后再进行归一化处理和激活函数即可得到CondConv模块的输出结果。CondConv模块使用的是ReLU(rectified linear unit)激活函数[11],虽然可以解决梯度消失的问题,但是当输入结果为负时,其产生的梯度为零。而SiLU(sigmoid-weighted linear unit)函数在输入为负时,SiLU的输出结果也可以非负,因此使用SiLU函数代替ReLU函数可以提高模块反向传播阶段的性能。本研究使用SiLU函数来作为CondConv模块的激活函数,设计了新的CondSiLU卷积模块。由于CondConv模块原本针对木材表面缺陷这类特征尺度变化大的场景要比普通卷积具有更好的适用性,并且本研究设计的CondSiLU模块由于激活函数的修改,增强了其反向传播性能,因此该模块适用于木材表面这类复杂的缺陷识别任务,能够提升木材缺陷检测模型的整体性能。改进后的CondConv模块结构如图2所示。
在以上数据的基础上,本研究又从捷克的奥斯特拉发理工大学[20]在2022年更新的大规模木材表面缺陷图像的公开数据集中,选择了592张图像。为了验证采集环境和设备差异对模型性能的影响,将数据集按采集来源分为2组:手机拍摄数据集和公开数据集,分别训练和测试改进后的YOLOv8-CBW模型。试验结果表明,2组数据集的平均精度(mean average precision,mAP)指标差异在1.5%以内,说明设备或环境带来的差异对模型性能影响较小,这进一步验证了本研究数据集的一致性和模型的泛化能力。经过测试发现,由于原始数据集的样本量较小,在检测模型的训练过程中会出现模型过拟合的问题。为了避免过拟合问题,对原始数据进行了数据增强,增强手段包括对原始数据进行旋转、高亮以及裁切。增强后的数据集共包含8 194张图像。将数据集按照8∶1∶1划分为训练集、验证集、测试集。本研究的数据集具有的细节见表2。数据集包含的缺陷类型:活结、死结、带有缝隙的结、树髓、裂缝、腐烂,如图5所示。
2.3 评价指标
为了公正评估所提模型在木材缺陷检测中的表现,本研究试验部分采用的性能指标包括精确率(precision,)、召回率(recall,)、平均精度均值(mean average precision,,式中记为mAP)以及模型的计算量(GFLOPs)。评价指标计算公式为
TIANM H, DUL, WANGF,et al.Forecast and analysis of the timber production capacity of China's forest resources[J].China Forest Products Industry,2022,59(4):57-63.
HANC Y, PANGJ Y, SUNY X,et al.Study and manufacture of anti-cracking agent for functional wood based on EVA[J].Forest Engineering,2023,39(6):95-100,108.
JIG K, WANGR, PENGS F.Person re-identification method based on attention mechanism and CondConv[J].Journal of Beijing University of Aeronautics and Astronautics,2024,50(2):655-662.
YUP P, LINY H, LAIY F,et al.Dense log end face detection method using the hybrid of BiFPN and YOLOv5s[J].Journal of Forestry Engineering,2023,8(1):126-134.
CUIT, HANT, HUANGY R.Road surface disease detection method in low light scenarios[J/OL].Journal of Chongqing Technology and Business University (Natural Science Edition),1-11 [2024-12-11].
ZHUH, ZHOUS Y, 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.
CHENC, XUEW J, DONGP X,et al.Intelligent evaluation method based on attention mechanism and improved dynamic ReLU for power transmission and transformation engineering drawings[J].Journal of Shenyang University of Technology,2024,46(6):772-778.
BIANY L.Research and application of wood surface defect detection based on CornerNe[J].Electronic Technology and Software Engineering,2021(18):208-210.
CHENZ W, DIAOH K, YUANY,et al.Siamese network object tracking algorithm based on graph network and IoU-aware[J].Control and Decision,2024,39(9):2867-2875.
DONGH X, PANJ R, DONGF N,et al.Research on bounding box regression loss function based on YOLOv5s model[J].Modern Electronics Technique,2024,47(3):179-186.
ZHANGX Z, ZHAID Y, CHENJ.Research on wood defect image recognition and segmentation model based on deep reinforcement learning[J].Electronic Measurement Technology,2020,43(17):80-86.