针对玉米田间环境下幼苗与杂草检测实时性不足、识别模型结构复杂、识别精度欠佳及移动端部署困难等问题,提出一种基于改进YOLOv5s的玉米田间杂草检测方法。通过嵌入轻量化的GhostNetV3模块减少模型的计算量和参数量,提升运行速率以适配移动端部署要求;在主干特征提取网络中引入CA(Coordinate attention)注意力机制,通过空间维度特征强化提升有效特征表达能力,在强化特征提取能力的同时,抑制无关信息干扰,进而提升模型的检测精度;引入高效交并比损失函数EIoU (Efficient intersection over union)替代模型传统的GIoU (Generalized intersection over union),通过改进边界框回归策略提升目标定位精度、收敛效率和回归精度;采用数据增强技术拓展训练样本的多样性,有效解决样本数据不足和复杂背景干扰问题,进一步提升模型的鲁棒性。试验结果表明,该方法在玉米田杂草检测任务中性能显著提升,相比基准模型,精确率、召回率和平均精度分别提高3.7%、7.7%和3.4%,达到95.9%、85.8%、88.6%,浮点运算量、参数量和模型大小分别减少了54.3%、53.9%、50%,在保证检测精度的前提下实现了模型的轻量化与高效性。
Abstract
To address the challenges of insufficient real-time performance, complex model structures, low detection accuracy, and difficulties in mobile deployment for seedling and weed detection in maize fields, this study proposes an improved YOLOv5s-based weed detection method. A lightweight GhostNetV3 module was embedded to reduce computational cost and parameter size to accelerate inference speed and meet mobile deployment requirements. A coordinate attention (CA) mechanism was introduced into the backbone feature extraction network to enhance the representation of effective features by strengthening spatial information while suppressing irrelevant interference, thus improving detection accuracy. Furthermore, the efficient intersection over union (EIoU) loss was adopted to replace the traditional generalized intersection over union (GIoU) loss, improving bounding box regression precision, convergence efficiency, and localization accuracy. Data augmentation techniques were also applied to increase the diversity of training samples, effectively alleviating the problems of insufficient data and complex background interference, and enhancing model robustness. Experimental results demonstrate that the proposed method significantly improves the performance in maize field weed detection. Compared with the baseline YOLOv5s model, the precision, recall, and mean average precision of the proposed method increased by 3.7%, 7.7%, and 3.4%, and reached 95.9%, 85.8%, and 88.6%, respectively. Its floating-point operations, parameter size, and model size were reduced by 54.3%, 53.9%, and 50%. These results indicate that the proposed method achieves both lightweight and high efficiency while maintaining detection accuracy.
式中:为第c个通道在第h行的水平池化结果;为第c个通道在第w列的垂直池化结果;表示第c个通道、第h行、第i列的特征值;表示第c个通道、第j行、第w列的特征值。。随后,将这2个一维特征向量拼接起来,并通过一个卷积层进行降维,得到特征向量,其中r为降维因子。将特征向量 f 沿着水平和垂直方向拆分为2个特征向量和,分别通过2个卷积层进行升维,得到和,然后对和应用sigmoid函数得到注意力权重图和:
3)采用EIoU替代传统边界框回归方法,通过引入几何约束与中心点距离优化机制,该方案显著提升了目标定位的准确性,同时加快了模型训练收敛速度,改进后的损失函数通过动态调整长宽比权重,有效缓解了多尺度目标的检测偏差问题,尤其在复杂背景和小目标场景下表现出更强的鲁棒性。该优化方案不仅增强了模型在实际检测任务中的表现,实现了检测精度与推理效率的协同提升,还兼顾了模型的轻量化设计,使其更适用于资源受限的移动端设备Jetson Orin Nano super部署,满足了对高效性与精确性的双重要求。
LiuM C, GaoT T, MaZ X, SongZ H, LiF D, YanY F. Target detection model of corn weeds in field environment based on MSRCR algorithm and YOLOv4-tiny[J]. Transactions of the Chinese Society for Agricultural Machinery, 2022, 53(2): 246-255, 335 (in Chinese)
[3]
MhlangaB, ChauhanB S, ThierfelderC. Weed management in maize using crop competition: A review[J]. Crop Protection, 2016, 88: 28-36
[4]
KumarP, RawalS, PooniaT M, PuniaR, ChoudharyK, Anu, Monika. Effect of weed management on growth and yield of maize grown under different tillage systems[J]. Journal of Experimental Agriculture International, 2025, 47(2): 296-301
LiuS N, ZhuJ Y, ZhengS J, WangD F, WangB, ZhangJ J, ZhouX G. Effects of different cultivation density on occurrence of weeds and yield of maize[J]. Journal of Weed Science, 2016, 34(2): 53-57 (in Chinese)
YangJ Z, GongG S, ZhangM, ChenH B, WangX G, YangC P. Effects of different planting cultivation density and cultivars of maize on occurrence of weed and yield[J]. Ecology and Environmental Sciences, 2011, 20(S1): 1037-1041 (in Chinese)
[9]
MishchenkoY, ButenkoA, HotvianskaA, ОTsyuk, SologubI, BondarenkoO, PryshedkoN, MikulinaM, RyzhenkoA, SevydovO. The impact of organic farming methods on weed infestation in corn crops and soil improvement[J]. Journal of Ecological Engineering, 2025, 26(3): 77-85
[10]
AliA, AhmedS, LaghariG M, LaghariA H, SoomroA A, JabeenN. Effect of maize ( Zea mays ) and soybean ( Glycine max) cropping systems on weed infestation and resource use efficiency [J]. Agronomy, 2024, 14(12): 2801
ZhangY, ZhuY G, WuL F, GuD D, YangC H. Research status and prospect of weeding devices between seedlings at home and abroad[J]. Agricultural Machinery Using & Maintenance, 2024(4): 62-65 (in Chinese)
KanL M, ZhaoS X, GaoS N, GuoY, ZhouY N. Research status and prospect of corn weeder[J]. Agricultural Machinery Using & Maintenance, 2024(4): 73-76 (in Chinese)
LiX J. Main problems and management strategies of weeds in agricultural fields in China in recent years[J]. Plant Protection, 2018, 44(5): 77-84 (in Chinese)
ZhaoH, CaoY H, YueY J, WangH J. Field weed recognition based on improved DenseNet[J]. Transactions of the Chinese Society of Agricultural Engineering, 2021, 37(18): 136-142 (in Chinese)
[21]
WangA C, ZhangW, WeiX H. A review on weed detection using ground-based machine vision and image processing techniques[J]. Computers and Electronics in Agriculture, 2019, 158: 226-240
WangC, WuX H, LiZ W. Recognition of maize and weed based on multi-scale hierarchical features extracted by convolutional neural network[J]. Transactions of the Chinese Society of Agricultural Engineering, 2018, 34(5): 144-151 (in Chinese)
LiuW, XuL M, XingJ J, ShiL N, GaoZ M, YuanQ C. Research status of mechanical intra-row weed control in row crops[J]. Journal of Agricultural Mechanization Research, 2017, 39(1): 243-250 (in Chinese)
FangH M, NiuM M, XueX Y, JiC Y. Effects of mechanical-chemical synergistic weeding on weed control in maize field[J]. Transactions of the Chinese Society of Agricultural Engineering, 2022, 38(6): 44-51 (in Chinese)
ZhangS C, XueX Y, SunT, TianZ W, WuJ W, ZhouQ Q. Study on weed control of plant protection UAV and effect evaluation in rape filed[J]. Journal of Chinese Agricultural Mechanization, 2019, 40(9): 48-53, 59 (in Chinese)
QiL, LiuC, JiangY. Present status and intelligent development prospects of mechanical weeding technology and equipment for rice[J]. Journal of South China Agricultural University, 2020, 41(6): 29-36 (in Chinese)
ZhangL A, TangK, ZhaoY J, WangX Y, YuD Z, LuX J, WangX. Optimization of leg structure parameter of quadruped laser weeding robot[J]. Transactions of the Chinese Society of Agricultural Engineering, 2020, 36(2): 7-15 (in Chinese)
[34]
BauerM V, MarxC, BauerF V, FluryD M, RipkenT, StreitB. Thermal weed control technologies for conservation agriculture: A review[J]. Weed Research, 2020, 60(4): 241-250
[35]
张帅. 我国主要农作物田杂草防控技术[J]. 杂草学报, 2020, 38(2): 50-55
[36]
ZhangS. Weed control techniques in farmland of China[J]. Journal of Weed Science, 2020, 38(2): 50-55 (in Chinese)
[37]
HamudaE, Mc GinleyB, GlavinM, JonesE. Automatic crop detection under field conditions using the HSV colour space and morphological operations[J]. Computers and Electronics in Agriculture, 2017, 133: 97-107
[38]
XiongY, GeY Y, LiangY L, BlackmoreS. Development of a prototype robot and fast path-planning algorithm for static laser weeding[J]. Computers and Electronics in Agriculture, 2017, 142: 494-503
[39]
SabziS, Abbaspour-GilandehY, ArribasJ I. An automatic visible-range video weed detection, segmentation and classification prototype in potato field [J]. Heliyon, 2020, 6(5): e03685
[40]
PunithavathiR, Delphin Carolina RaniA, SughashiniK R, KurangiC, NirmalaM, Farhana Thariq AhmedH, BalamuruganS P. Computer vision and deep learning-enabled weed detection model for precision agriculture[J]. Computer Systems Science and Engineering, 2023, 44(3): 2759-2774
SunJ, HeX F, TanW J, WuX H, ShenJ F, LuH. Recognition of crop seedling and weed recognition based on dilated convolution and global pooling in CNN[J]. Transactions of the Chinese Society of Agricultural Engineering, 2018, 34(11): 159-165 (in Chinese)
PengM X, XiaJ F, PengH. Efficient recognition of cotton and weed in field based on Faster R-CNN by integrating FPN[J]. Transactions of the Chinese Society of Agricultural Engineering, 2019, 35(20): 202-209 (in Chinese)
KangJ, LiuG, GuoG F. Weed detection based on multi-scale fusion module and feature enhancement[J]. Transactions of the Chinese Society for Agricultural Machinery, 2022, 53(4): 254-260 (in Chinese)
QuanL Z, XiaF L, JiangW, LiH L, LiH D, LouZ X, LiC W. Research on recognition of maize seedlings and weeds in maize mield based on YOLO v4 convolutional neural network[J]. Journal of Northeast Agricultural University, 2021, 52(7): 89-98 (in Chinese)