Field weed detection method and system based on improved YOLO model and medium
Patent Information
- Application Number
- CN202611169280.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-04
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2046-08-04
AI Technical Summary
传统的机器学习方法,如支持向量机(SVM)、随机森林(RF)和k-最近邻(k-NN),利用颜色、纹理、形状和植被指数等人工特征进行杂草分类,虽然这些方法在一定程度上取得了成功,但存在明显的局限性:SVM在高维特征空间中表现良好,但参数调优困难且可扩展性差;随机森林模型可以处理噪声和不平衡数据集,但难以应对复杂的杂草-作物相互作用;k-NN算法计算成本高、可解释性差,并且对距离度量选择敏感
[0045]本发明提供基于改进型YOLO模型的田间杂草检测方法、系统及介质,基于传统YOLO模型进行网络结构上的改进,通过嵌入细粒度通道注意力机制、使用轻量级分组卷积替换部分颈部网络、应用增强型E-NWD损失函数,以及使用移动倒置瓶颈卷积结构改进检测头,得到性能优化的改进型YOLO-FENG检测模型对目标田间区域的图像数据进行杂草检测,减少环境和设备振动对成像的干扰,此外,改进型YOLO-FENG检测模型在检测严重模糊目标方面表现出卓越的能力。
Smart Images

Figure CN122676422B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer image processing, and more specifically to a method, system, and medium for detecting field weeds based on an improved YOLO model. Background Technology
[0002] Traditional agricultural practices typically involve uniformly spraying herbicides across the entire field, which is not only wasteful but also raises a range of safety concerns. In contrast, real-time monitoring technology can significantly reduce herbicide usage, helping to delay the development of herbicide resistance in weeds. Furthermore, with less chemicals entering the soil, the toxic effects on beneficial organisms, such as soil microbial communities and earthworms, are minimized, contributing to the maintenance of healthy soil fertility and ecological balance.
[0003] As intelligent weed detection technology gradually becomes a key driver of precision agriculture, it enables precise weed management in specific locations by accurately identifying the location and type of weeds, effectively reducing the amount of herbicide used. Intelligent weeding equipment, such as intelligent walking mechanisms equipped with lasers, high-voltage electricity, or robotic arms, relies on high-precision weed identification technology to perform precise control operations. Therefore, weed detection research is of significant value.
[0004] With advancements in computer vision and artificial intelligence, weed detection technology has evolved from traditional image processing based on manual features to intelligent recognition based on deep learning. This has significantly improved the accuracy and efficiency of weed identification, providing technical support for the sustainable development of modern agriculture. Existing weed detection technologies are primarily based on image processing techniques, achieving weed identification from four perspectives: preprocessing, segmentation, feature extraction, and classification. In the image preprocessing stage, techniques such as median filtering are mainly used to remove image noise. In the segmentation stage, color features of color images are utilized to segment green plants and soil backgrounds, commonly using segmentation methods based on the RGB color model and the HIS color model. In the feature extraction stage, analysis is mainly conducted from three perspectives: color, shape, and texture. Traditional machine learning methods, such as Support Vector Machines (SVM), Random Forests (RF), and k-Nearest Neighbors (k-NN), utilize artificial features like color, texture, shape, and vegetation indices for weed classification. While these methods have achieved some success, they also have significant limitations: SVM performs well in high-dimensional feature spaces, but parameter tuning is difficult and scalability is poor; Random Forest models can handle noisy and imbalanced datasets, but struggle with complex weed-crop interactions; and k-NN algorithms are computationally expensive, have poor interpretability, and are sensitive to the choice of distance metric. More importantly, these traditional methods perform poorly in real-world environments with shadows, occlusion, and visually similar weed species, failing to effectively detect weeds and making it difficult to solve real-time detection problems.
[0005] The emergence of deep learning has fundamentally changed this situation. With the application of RCNN, YOLO series object detection frameworks, and Transformer models to weed identification, multi-level features can achieve efficient automatic identification in complex agricultural environments. Currently, in feature selection, one approach employs an encapsulated feature selection method that embeds the SVM classification algorithm into the Ant Colony Optimization (ACO) feature selection process. By defining an evaluation function, the maximum classification accuracy of the SVM algorithm guides the feature selection operation to obtain the optimal feature vector and classifier hyperparameters. This method can reduce the dimensionality of plant leaf morphological features, significantly compressing the feature space and reducing the input dimensionality and learning complexity of the classifier. Another approach leverages the advantages of DS evidence theory, combining incomplete and uncertain information, by using SVM classification results based on color, shape, and texture features as independent evidence. The posterior probability of the SVM is introduced to construct a Basic Trust Assignment Function (BPA), and DS evidence combination rules are used for evidence fusion. Experimental results show that the accuracy and stability of the multi-feature decision fusion identification method surpass those of weed identification methods based on single features.
[0006] Despite significant advancements in weed detection using deep learning, most models trained on controlled environments or small datasets struggle to handle the diverse challenges of real-world farmland, including drastic variations in weed species, growth stages, and lighting conditions. Small sample sizes, limited species diversity, and uniform growth stages result in weak model generalization capabilities, and deployment bottlenecks restrict practical application effectiveness. Actual detection performance is also limited by equipment vibration, travel speed, and computational resources; vibration interference can cause image blurring, impacting image quality. Summary of the Invention
[0007] The technical problem this invention aims to solve is that, in practical agricultural applications, most traditional weed detection models, trained on controlled environments or small datasets, struggle to cope with the diverse challenges of vibration interference and computational resource limitations in real farmland, affecting detection accuracy and efficiency. This invention aims to provide a field weed detection method, system, and medium based on an improved YOLO model. It improves the network structure of the traditional YOLO model by embedding a fine-grained channel attention mechanism, replacing part of the neck network with lightweight grouped convolutions, applying an enhanced E-NWD loss function, and improving the detection head using a moving inverted bottleneck convolution structure. This results in a performance-optimized improved YOLO-FENG detection model that detects weeds in image data of target field areas, reducing the interference of environmental and equipment vibrations on imaging. Furthermore, the improved YOLO-FENG detection model demonstrates superior ability to detect severely blurred targets.
[0008] This invention is achieved through the following technical solution:
[0009] This invention provides a field weed detection method based on an improved YOLO model, the method comprising:
[0010] Collect image data of the target field area and preprocess the image data;
[0011] The preprocessed image data is input into the constructed improved YOLO-FENG detection model for weed detection;
[0012] The improved YOLO-FENG detection model includes a backbone network, a neck network, and a detection head. The backbone network incorporates a fine-grained channel attention mechanism to capture the interaction between global and local information at different granularity levels. The neck network incorporates lightweight grouped convolutions for grouping operations and channel shuffling. The loss function used to train the improved YOLO-FENG detection model is an enhanced E-NWD loss function, which is based on the Wasserstein distance loss function but incorporates multi-scale geometric constraints, dynamic temperature control, and boundary distance sensing terms.
[0013] Output the weed detection results.
[0014] A further optimized solution is that the preprocessing method includes:
[0015] First, the image data is scaled, flipped, rotated, and stitched. Then, the image data is enhanced using a Gaussian blur method with a standard deviation of 1.
[0016] A further optimization scheme is that the backbone network is used to perform the following processing on the preprocessed image data:
[0017] The original feature map is extracted based on the preprocessed image data;
[0018] Shallow spatial features and high-level semantic features are extracted from the original feature map respectively;
[0019] Based on the fine-grained channel attention mechanism, the high-level semantic features are first subjected to global average pooling to obtain the channel global features, while retaining the original features of the high-level semantic features. Then, the channel covariance matrix is constructed to capture the dependency between the channel global features and local features. Channel attention weights are generated based on the channel covariance matrix, and the high-level semantic features are recalibrated based on the channel attention weights.
[0020] The recalibrated high-level semantic features and shallow spatial features are combined by channel concatenation and convolution to obtain multi-scale enhanced features.
[0021] A further optimization scheme involves using the neck network to propagate weed category semantic features via a top-down path and weed location detail features via a bottom-up path based on multi-scale enhanced features. The neck network employs a Slim Neck lightweight architecture, and all standard convolutional layers in the neck network are replaced with grouped convolutional layers. During feature propagation, all intermediate convolutional operations are performed by the grouped convolutional layers.
[0022] A further optimization scheme is to embed a moving inverted bottleneck convolutional structure at the head or tail of the detection head. The moving inverted bottleneck convolutional structure includes an expansion layer, a depthwise separable convolutional layer, and a compression layer. The expansion layer is used for feature upscaling. The depthwise separable convolutional layer is used for channel-wise spatial feature extraction. The compression layer is used for feature downscaling.
[0023] A further optimization scheme is proposed, in which the enhanced E-NWD loss function L is expressed as: ; in, Represents multi-scale geometric constraints. For boundary distance sensing terms, This is a dynamic temperature control item.
[0024] A further optimization scheme is as follows: the multi-scale geometric constraint term is used to constrain the position between the center of the predicted box and the center of the ground truth box; the boundary distance sensing term is used to constrain the boundary position of the predicted box; and the dynamic temperature control term is used to constrain the temperature of targets of different sizes.
[0025] A further optimization scheme is as follows: the multi-scale geometric constraint term Represented as: ;
[0026] Where Δx and Δy represent the differences in x and y coordinates between the center of the predicted bounding box and the center of the ground truth bounding box; α represents the center distance weighting factor; and These represent the width and height of the prediction box, respectively; These represent the width and height of the actual bounding box, respectively.
[0027] The boundary distance sensing item Represented as:
[0028] ;
[0029] ;
[0030] ;
[0031] ;
[0032] ;
[0033] in, This indicates the offset between the left boundary of the predicted bounding box and the left boundary of the ground truth bounding box; This indicates the offset of the predicted bounding box from the right boundary of the ground truth bounding box; This indicates the offset between the predicted bounding box and the top boundary of the ground truth bounding box; This indicates the offset between the predicted bounding box and the lower boundary of the ground truth bounding box; , This indicates the coordinates of the top-left corner of the prediction box; , This indicates the coordinates of the bottom right corner of the prediction box; , Represents the coordinates of the top-left corner of the true bounding box; , Represents the coordinates of the bottom right corner of the true bounding box; This represents the boundary distance weighting factor; in this embodiment, it is set to 0.3.
[0034] The dynamic temperature control item Represented as:
[0035] ;
[0036] ;
[0037] ;
[0038] in, Indicates the base temperature; Indicates the size factor; Indicates the aspect ratio factor; Indicates the aspect ratio of the prediction box; This represents the aspect ratio of the actual bounding box.
[0039] This solution also provides a field weed detection method system based on an improved YOLO model, used to implement the aforementioned field weed detection method based on an improved YOLO model. The system includes:
[0040] The acquisition module is used to acquire image data of the target field area and preprocess the image data;
[0041] The detection module is used to input preprocessed image data into the pre-constructed improved YOLO-FENG detection model for weed detection. The improved YOLO-FENG detection model includes a backbone network, a neck network, and a detection head. The backbone network introduces a fine-grained channel attention mechanism to capture the interaction between global and local information at different granularity levels. The neck network introduces lightweight grouped convolution for grouping operations and channel shuffling. The loss function used to train the improved YOLO-FENG detection model is the enhanced E-NWD loss function, which is based on the Wasserstein distance loss function and incorporates multi-scale geometric constraint terms, dynamic temperature control terms, and boundary distance sensing terms.
[0042] The output module is used to output the weed detection results.
[0043] This solution also provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, can implement the field weed detection method based on the improved YOLO model described above.
[0044] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0045] This invention provides a field weed detection method, system, and medium based on an improved YOLO model. It improves the network structure of the traditional YOLO model by embedding a fine-grained channel attention mechanism, replacing part of the neck network with lightweight grouped convolutions, applying an enhanced E-NWD loss function, and improving the detection head using a moving inverted bottleneck convolution structure. This results in a performance-optimized improved YOLO-FENG detection model for weed detection in target field areas, reducing interference from environmental and equipment vibrations on imaging. Furthermore, the improved YOLO-FENG detection model demonstrates superior ability to detect severely blurred targets. Attached Figure Description
[0046] To more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be considered as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort. In the drawings:
[0047] Figure 1 This is a schematic diagram of the process for a field weed detection method based on the improved YOLO model.
[0048] Figure 2 A schematic diagram of the network architecture of the improved YOLO-FENG detection model;
[0049] Figure 3 This is a diagram showing a comparison of detection results between the baseline model and the improved YOLO-FENG detection model.
[0050] Figure 4 A schematic diagram comparing the detection performance of the YOLOv11n model and the improved YOLO-FENG detection model under different Gaussian blur effects;
[0051] Figure 5 This is a schematic diagram comparing the decay rate of the detection performance index of the YOLOv11n model and the improved YOLO-FENG detection model under different Gaussian blur effects.
[0052] Figure 6 This is a schematic diagram of a field weed detection system based on the improved YOLO model. Detailed Implementation
[0053] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the embodiments and accompanying drawings. The illustrative embodiments and descriptions of the present invention are only used to explain the present invention and are not intended to limit the present invention.
[0054] In practical agricultural applications, most traditional models are trained on controlled environments or small datasets, making it difficult to cope with the diverse challenges of vibration interference and computational resource limitations in real farmland, which affects detection accuracy and speed. In view of this, this solution provides the following embodiments to solve the above-mentioned technical problems.
[0055] Example 1 This embodiment provides a field weed detection method based on an improved YOLO model, such as... Figure 1 As shown, the method includes:
[0056] Step 1: Collect image data of the target field area and preprocess the image data;
[0057] In step one, the preprocessing methods include:
[0058] First, the image data is scaled, flipped, rotated, and stitched. Then, the image data is enhanced using a Gaussian blur method with a standard deviation of 1.
[0059] Step 2: Input the preprocessed image data into the constructed improved YOLO-FENG detection model for weed detection;
[0060] In step two, the improved YOLO-FENG detection model includes a backbone network, a neck network, and a detection head;
[0061] A fine-grained channel attention mechanism is introduced into the backbone network to capture the interaction between global and local information at different granularity levels; specifically, the backbone network performs the following processing on the preprocessed image data:
[0062] S21, Extract the original feature map based on the preprocessed image data;
[0063] S22, extract shallow spatial features and high-level semantic features from the original feature map respectively;
[0064] S23, based on the fine-grained channel attention mechanism, firstly, global average pooling is performed on the high-level semantic features to obtain the channel global features, while retaining the original features of the high-level semantic features. Then, the channel covariance matrix is constructed to capture the dependency between the channel global features and local features. Channel attention weights are generated according to the channel covariance matrix, and the high-level semantic features are recalibrated based on the channel attention weights.
[0065] S24, the recalibrated high-level semantic features and shallow spatial features are combined by channel concatenation and convolution to obtain multi-scale enhanced features.
[0066] In step two, lightweight grouped convolutions are introduced into the neck network for grouping operations and channel shuffling; the neck network is used to transmit weed category semantic features from a top-down path and weed location detail features from a bottom-up path based on multi-scale enhanced features.
[0067] Specifically, the neck network uses a Slim Neck lightweight architecture, and all standard convolutional layers in the neck network are replaced with grouped convolutional layers (GSConv layers). During feature propagation, all intermediate convolutional operations are performed by the grouped convolutional layers.
[0068] In step two, a moving inverted bottleneck convolutional structure is embedded in the head or tail of the detection head. The moving inverted bottleneck convolutional structure includes an expansion layer, a depthwise separable convolutional layer, and a compression layer. The expansion layer is used for feature upscaling. The depthwise separable convolutional layer is used for channel-wise spatial feature extraction. The compression layer is used for feature downscaling.
[0069] In step two, the loss function for training the improved YOLO-FENG detection model is the enhanced E-NWD loss function, which is based on the Wasserstein distance loss function and introduces multi-scale geometric constraint terms, dynamic temperature control terms, and boundary distance sensing terms.
[0070] Specifically, the enhanced E-NWD loss function L is expressed as: ;
[0071] in, Represents multi-scale geometric constraints. For boundary distance sensing terms, The dynamic temperature control term is used to constrain the position between the center of the predicted bounding box and the center of the ground truth bounding box. The boundary distance sensing term is used to constrain the boundary position of the predicted bounding box. The dynamic temperature control term is used to constrain the temperature of targets of different sizes.
[0072] Multiscale geometric constraints Represented as: ;
[0073] Where Δx and Δy represent the differences in x and y coordinates between the center of the predicted bounding box and the center of the ground truth bounding box; α represents the center distance weighting factor; and These represent the width and height of the prediction box, respectively; These represent the width and height of the actual bounding box, respectively.
[0074] Boundary distance sensing item Represented as:
[0075] ;
[0076] ;
[0077] ;
[0078] ;
[0079] ;
[0080] in, This indicates the offset between the left boundary of the predicted bounding box and the left boundary of the ground truth bounding box; This indicates the offset of the predicted bounding box from the right boundary of the ground truth bounding box; This indicates the offset between the predicted bounding box and the top boundary of the ground truth bounding box; This indicates the offset between the predicted bounding box and the lower boundary of the ground truth bounding box; , This indicates the coordinates of the top-left corner of the prediction box; , This indicates the coordinates of the bottom right corner of the prediction box; , Represents the coordinates of the top-left corner of the true bounding box; , Represents the coordinates of the bottom right corner of the true bounding box; This represents the boundary distance weighting factor; in this embodiment, it is set to 0.3.
[0081] Dynamic temperature control item Represented as:
[0082] ;
[0083] ;
[0084] ;
[0085] in, Indicates the base temperature; Indicates the size factor; Indicates the aspect ratio factor; Indicates the aspect ratio of the prediction box; This represents the aspect ratio of the actual bounding box.
[0086] Step 3: Output the weed detection results.
[0087] Example 2 This embodiment provides some key processes for constructing an improved YOLO-FENG detection model. For the training dataset of the improved YOLO-FENG detection model, existing weed datasets often do not match the weed populations of specific target areas. To address this issue, the training dataset constructed in this embodiment is based on actual farmland surveys, aiming to include as many weed types as possible to enhance the model's generalization ability. During the peak weed growth period from June to September, multiple locations were randomly selected in major grain-producing areas for observation, and common weed species were recorded. After screening, 11 of the most common weed species in farmland were identified: sorrel, watercress, goosegrass, small clover, plantain, Kentucky bluegrass, purslane, tricolor amaranth, sow thistle, and chickweed.
[0088] A training dataset was established based on the aforementioned 11 weed species. Initial images were sourced from the CWD30 dataset, the Plant Image Database of China (PPBC), and field collections. Image enhancement and other preprocessing techniques were applied to the initial images to improve the model's generalization ability. These preprocessing techniques included scaling, flipping, rotating, and stitching. Gaussian blur with a standard deviation of 1 was introduced as an image enhancement method. The training dataset contains 8690 images of the 11 weed species, as detailed in Table 1. The training dataset was randomly divided into a training set (80%, 6952 images), a validation set (10%, 869 images), and a test set (10%, 869 images). All partitions were performed stratified by species to ensure balanced representativeness.
[0089] Table 1 Weed Species
[0090] The training dataset was manually labeled using LabelImg software, and the labeled files were saved in YOLO format. Each image was manually labeled by the same person, so there was no problem of misalignment between the original bounding box and the target due to rotation and scaling.
[0091] This embodiment first uses the traditional YOLOv11n model as the base model and trains it on the training dataset. The traditional YOLOv11n model uses the C3k2 module instead of the core component C2f module in YOLOv8. The C3k2 module adopts a two-branch design: one branch uses 3×3 convolutions to capture local features, and the other branch uses 1×1 convolutions for channel interaction, fusing multi-scale feature representations through residual connections. After the SPPF layer, the C2PSA module is introduced. The C2PSA module integrates a pyramid slicing attention mechanism, combining channel and spatial information to effectively optimize the feature map of the previous layer, improving the model's ability in multi-scale feature processing, enhancing global modeling capabilities, and reducing computational complexity. In addition, the traditional YOLOv11n model employs a multi-stage enhancement strategy, including four-image mosaicking, image mixing, object copy-paste, and HSV color space enhancement, to improve the model's generalization ability, especially for small object detection. The loss function integrates CIoU bounding box loss, binary cross-entropy classification loss, and the crucial DFL loss. The DFL loss transforms bounding box regression into a classification problem, enabling the traditional YOLOv11n model to learn the distribution of bounding box positions, thereby improving localization accuracy, especially for objects with blurred boundaries.
[0092] The training hardware platform was an NVIDIA GeForce RTX 4090D GPU, and the software environment was a Windows 11 operating system equipped with CUDA 12.9 and CUDNN 8.9.0. All models were trained in batches of 16, for a total of 150 epochs (no significant improvement was observed beyond this number). The input image resolution was 640×640, and the SGD optimizer was used (momentum = 0.937, initial learning rate l). r0 =0.01, final learning rate l rf =0.01), with a random seed of 0. Four-image stitching enhancement was disabled for the last 10 cycles, and early stopping was triggered if there was no improvement for 50 consecutive cycles. The results showed that the YOLOv11n model achieved a precision of 82.3%, a recall of 75.3%, an mAP50 of 81.1%, an mAP50-95 of 56.2%, and an inference speed of 8.9 milliseconds / frame.
[0093] Although the baseline YOLOv11n model performs well, it exhibits limitations, particularly in its inability to accurately detect targets under severely blurred conditions (simulating lens shake or defocusing during device movement).
[0094] Building upon this foundation, this approach improves upon the traditional YOLOv11n model by designing a lightweight object detection network. It optimizes the balance between accuracy and speed by combining lightweight grouped convolutions (GSConv) with a Slim Neck structure. Lightweight grouped convolutions introduce grouping operations and channel shuffling into standard convolutions, significantly reducing computational complexity while enhancing feature representation. The Slim Neck structure further reduces the number of parameters and computational cost by simplifying the number of layers and channels in the neck network. This fusion mechanism significantly improves inference efficiency while maintaining high detection accuracy, making it suitable for deployment on mobile or edge devices.
[0095] The normalized Wasserstein distance loss function models bounding boxes as 2D Gaussian distributions and measures the similarity of bounding boxes by calculating the Wasserstein distance between these distributions. This loss is robust to small targets and can alleviate the gradient vanishing problem that occurs with traditional IoU loss when the target scale varies greatly or the overlap is minimal. However, its original form mainly focuses on the overall distribution difference, lacking fine-grained constraints on the geometry (center, shape, orientation) of the bounding boxes, and has limited adaptability to densely overlapping target scenes such as weeds. Therefore, this embodiment proposes an enhanced Wasserstein loss function, the core improvement of which is as follows:
[0096] First, a gradient-friendly center alignment term (multi-scale geometric constraint term) is introduced into the Wasserstein loss function. The center alignment term injects size information directly into the geometric constraints by dividing the absolute offset between the center of the predicted box and the center of the ground truth box by the sum of their width and height. This ensures that the penalty is consistent regardless of the target size, as long as the center proportion offset is the same, thus achieving cross-scale center alignment and enabling the loss function to have multi-scale processing capabilities.
[0097] Secondly, a dynamic temperature coefficient (dynamic temperature control term) is introduced into the Wasserstein loss function. The base temperature is set to 6.4 based on experience, and is adaptively adjusted according to the minimum size of the target and the difference in aspect ratio. For small targets or cases with significant shape differences, this enhances the model's discriminative power and ensures gradient smoothness, making the optimization more adaptive.
[0098] Finally, a boundary distance-aware term is introduced into the Wasserstein loss function. The alignment error of the four boundaries is explicitly calculated and weighted and normalized using the boundary sensitivity coefficient δ relative to the scale of the minimum bounding rectangle. This enhances the supervision of local boundary alignment, which is particularly beneficial for accurately locating partially overlapping or adjacent targets.
[0099] The improved YOLOv11n model is lightweight. The design of lightweight grouped convolution (GSConv) and Slim Neck structure reduces the number of parameters. The fine-grained channel attention mechanism in the backbone network enhances the feature representation (similar to the dehazing effect), and the enhanced Wasserstein loss function improves the detection accuracy of small targets.
[0100] Furthermore, the detection head in this scheme embeds a moving inverted bottleneck convolutional structure (MBConv) at its head or tail. This MBConv structure includes an expansion layer, a depthwise separable convolutional layer, and a compression layer. The expansion layer is used for feature dimensionality upscaling, the depthwise separable convolutional layer is used for channel-by-channel spatial feature extraction, and the compression layer is used for feature dimensionality reduction. The detection head follows the inverted residual principle: first, a 1×1 convolution expands the channel dimension of the feature map to enhance representational power; then, depthwise separable convolutions are used in this expanded high-dimensional space to extract spatial features, significantly reducing the number of parameters and computational cost; finally, a 1×1 convolution performs projection compression, forming a narrow-wide-narrow hourglass structure. Compared to standard convolutions, this design decouples spatial and channel correlations, thereby achieving superior computational efficiency.
[0101] The network architecture of the improved YOLO-FENG detection model is as follows: Figure 2 As shown, the backbone network specifically includes 5 convolutional layers, 4 C3k2-FCA feature extraction modules, a fast spatial pyramid pooling layer, and a parallel spatial attention convolutional module. The convolutional layers and C3k2-FCA feature extraction modules are alternately connected. The neck network includes 2 upsampling layers, 4 feature splicing layers, and 4 GSConv cross-stage modules. The head network consists of 3 MBConv detection heads. To address the issue of missed detections caused by overlapping and blurred boundaries between weeds and crop leaves, the backbone network embeds a C3k2-FCA feature extraction module. The C3k2-FCA feature extraction module divides the field image feature map into two branches. Branch one preserves shallow spatial details, which is crucial for identifying the fine textures and contours of weeds. Branch two extracts high-level semantic features to capture the overall morphological information of weeds.
[0102] A fine-grained channel attention mechanism is applied to the features of branch two: First, global average pooling is performed on the feature map to obtain a global channel description, while preserving the original features to maintain spatial details. Then, a channel covariance matrix is constructed to capture the high-order dependencies between the global weed region response and local leaf edge texture, small patches, and other patterns. This process avoids the loss of small weed spatial information caused by global pooling in traditional SE attention and eliminates redundant cross-correlation calculations between local and global features. Based on the covariance matrix, channel attention weights are generated through one-dimensional convolution to recalibrate the features of branch two, strengthening channels related to weed serrated edges, specific color variations, and blurred boundary gradients, while suppressing channels related to background interference such as soil, stubble, and shadows. The recalibrated features are then concatenated and integrated with the features of branch one through channel convolution to output multi-scale enhanced features.
[0103] The neck network replaces all standard convolutions with GSConv cross-stage modules. These GSConv cross-stage modules decompose standard convolutions into a hybrid operation of grouped convolutions and depthwise separable convolutions, reducing computation by approximately 30%-40% while maintaining sufficient inter-channel information interaction. For weed detection, the GSConv cross-stage modules preserve the discriminative power of multi-scale weeds (especially small targets), avoiding the smoothing away of key textures due to excessive lightweighting. The neck network employs a SlimNeck architecture, eliminating redundant feature transmission paths. Multi-scale enhanced features output from the backbone network (containing information on large and small weeds) enter the Slim Neck architecture, transmitting weed category semantics via a top-down path and weed location details via a bottom-up path. All intermediate convolutional operations are performed by the GSConv cross-stage modules, ensuring effective fusion of global contours and local edge information of weeds despite a significant reduction in parameters.
[0104] To address the issues of large parameter count and fixed receptive field in traditional detection heads, which make it difficult to adapt to the diverse morphologies of weeds, the head network introduces the MBConv structure as the detection head. The MBConv detection head includes an extension layer for feature upscaling using 1x1 convolutions, a depthwise separable convolutional layer for channel-wise spatial feature extraction, and a compression layer for feature downscaling using 1x1 convolutions. It also works with a squeeze excitation (SE) module for channel attention adjustment to form inverse residual connections.
[0105] For the fused features at each level of the neck output, 1×1 convolutions are first used to increase dimensionality and enrich the weed feature representation. Then, depthwise separable convolutions are used to expand the receptive field without introducing excessive computation, capturing the global structure of different weed morphologies. The channel responses are then recalibrated through a built-in squeeze excitation (SE) module. This mechanism can further identify and suppress channels corresponding to residual farmland background (such as plastic film reflection and dry soil texture) in the fused features, highlighting the unique color and morphological combinations of different weed categories. Finally, 1×1 convolutional dimensionality reduction compression layers are used to regress the bounding boxes and category probabilities of the weed targets.
[0106] To verify the effectiveness of the improved YOLO-FENG detection model, simulation experiments were conducted using the aforementioned training dataset under the same experimental settings. This embodiment compares the improved YOLO-FENG detection model with the baseline model and other common YOLO versions. All experiments were repeated three times and the average value was taken. The comparative analysis focuses on the YOLO series (v9t, v10n, v11n, 6n) because these models have established the dominant benchmark for real-time object detection on resource-constrained devices, which aligns with the goal of field deployment. It was ensured that all baseline models (YOLOv11n, YOLOv10n, YOLOv9t, YOLO26n) and the improved YOLO-FENG detection model were trained and evaluated using the same process to ensure a fair comparison. The detection metric results of the baseline model and the improved YOLO-FENG detection model are compared as follows: Figure 3 As shown in Table 2, Figure 3 The horizontal axis represents the number of training iterations, and the vertical axis represents the accuracy of the detection metric.
[0107] Table 2 Comparison of test result indicators
[0108]
[0109] The improved YOLO-FENG detection model outperforms the baseline models (YOLOv11n, YOLOv10n, YOLOv9t, YOLO26n) across all key metrics: precision (89.0%), recall (79.9%), mAP50 (84.2%), and mAP50-95 (59.6%). In particular, compared to YOLOv11n, the improved YOLO-FENG detection model demonstrates a 6.7 percentage point improvement in precision, a 4.6 percentage point improvement in recall, a 3.2 percentage point improvement in mAP50, and a 3.4 percentage point improvement in mAP50-95, showcasing a comprehensive performance enhancement. Furthermore, the improved YOLO-FENG detection model achieves lower GFLOPs and faster inference speed than the baseline, confirming that the lightweight design successfully balances detection performance and speed.
[0110] This embodiment also compares the lightweight grouped convolution (GSConv) and Slim Neck structure fusion mechanism with other mechanisms (MFM mechanism, SBA mechanism, DySample mechanism), and the results are shown in Table 3.
[0111] Table 3 Comparison of results from different feature fusion mechanisms
[0112] The results show that the proposed fusion mechanism performs best. To evaluate the robustness of the model, Gaussian blurring effects with standard deviations of 2, 4, and 6 were applied to the test set, and the corresponding detection performance indicators were obtained through inference. A comparison of the detection performance indicators of the YOLOv11n model and the improved YOLO-FENG detection model under different Gaussian blurring effects is shown in the figure below. Figure 4 As shown in the figure, the horizontal axis represents the standard deviation of Gaussian blur, and the vertical axis represents the accuracy of various performance indicators. The diagram illustrates the comparison of the attenuation rate of the detection performance indicators of the YOLOv11n model and the improved YOLO-FENG detection model under different Gaussian blur effects. Figure 5 As shown in the figure, the horizontal axis represents the standard deviation of the Gaussian blur, and the vertical axis represents the degree of attenuation. With the increase of blur intensity in the test set, the performance of the baseline model shows a sharp decline. Specifically, when the standard deviation increases from 4 to 6, precision, recall, mAP50, and mAP50-95 decrease by 15%, 19%, 20%, and 21%, respectively. In contrast, the improved YOLO-FENG detection model not only achieves higher absolute performance across all metrics but also exhibits a more gradual performance decline, reflecting its stronger robustness.
[0113] This embodiment utilizes a Jetson Orin Nano edge device (with 1024 CUDA cores, 8 GB of memory, and 67 TOPS of computing power) for inference on the test set images. At an image resolution of 640×640 pixels, the device's single-frame inference time is 49.2 milliseconds, equivalent to approximately 20.3 FPS, meeting the requirements for real-time detection. Gaussian blurs with standard deviations of 2, 4, and 6 were applied to the test set images, creating three degraded datasets. Inference was performed on these datasets using the YOLOv11n model and the improved YOLO-FENG detection model. The YOLOv11n model exhibited significant performance degradation when detecting highly blurred targets, leading to a large number of false negatives and false positives. In contrast, the YOLO-FENG detection model maintained good detection performance even with increased blur intensity. This is attributed to the YOLO-FENG detection model's ability to assign higher weights to more critical feature channels, highlighting key information, enhancing image details and contrast, and effectively preserving and fusing channel and spatial information. It excels at capturing small or key features in complex backgrounds, achieving efficient feature extraction with low computational cost. Therefore, the optimized model shows significant improvement and ultimately achieves accurate recognition in challenging blurred images.
[0114] To verify the contribution of each proposed improvement, an ablation study was conducted using the YOLOv11n model as a baseline. Under the same experimental conditions, modules were added sequentially to various modalities (fine-grained channel attention mechanism FCAttention, enhanced Wasserstein loss E-NWD Loss, lightweight grouped convolutional and Slim Neck structure fusion mechanism GSConv+Slim, and moving inverted bottleneck convolutional structure detection head MBConv). The results are shown in Table 4, where "√" indicates that the module is included, and "×" indicates that the module is not included.
[0115] Table 4 Ablation Experiment Results
[0116] Mode 2, integrating a fine-grained channel attention mechanism and an enhanced Wasserstein loss function, improved recall, mAP50, and mAP50-95 by 4.0, 3.7, and 2.3 percentage points, respectively, but increased inference time to 9.5 milliseconds / frame. Mode 3, incorporating a lightweight grouped convolutional structure fusion mechanism with a Slim Neck structure, improved precision by 4.6 percentage points while reducing inference time to 8.5 milliseconds / frame. Subsequently, Mode 4, employing a moving inverted bottleneck convolutional structure detector head, not only further improved precision and recall but also reduced model complexity and shortened inference time to 7.9 milliseconds / frame. These successive enhancements demonstrated a significant synergistic effect, ultimately enabling the improved YOLO-FENG detection model to achieve optimal overall performance.
[0117] This embodiment investigated weed species in the middle and lower reaches of the Yangtze River and identified 11 common species. A dataset was constructed using image enhancement techniques, including blurring. The dataset was trained using the YOLOv11n model, achieving 82.3% precision, 75.3% recall, 81.1% mAP50, 56.2% mAP50-95, and an inference speed of 8.9 ms / frame. To improve performance, particularly for detecting blurred targets, an improved YOLO-FENG detection model was developed. This model achieved 89.0% precision, 79.9% recall, 84.3% mAP50, and 59.6% mAP50-95 by embedding a fine-grained channel attention mechanism (FCA) into the YOLOv11n model architecture, replacing part of the neck network with lightweight grouped convolutions to reduce model complexity, applying an enhanced E-NWD loss function, and improving the detection head using a moving inverted bottleneck convolution structure. Compared to the baseline model, precision, recall, mAP50, and mAP50-95 were improved by 6.7, 4.6, 3.2, and 3.4 percentage points, respectively. Notably, these performance improvements were achieved while maintaining a fast inference speed of 7.9 ms / frame. The results demonstrate that the improved YOLO-FENG detection model performs well in handling image blur caused by device shake or lens defocus, making it suitable for integration into accurate field weed detection systems under complex conditions.
[0118] Example 3 This embodiment provides a field weed detection system based on an improved YOLO model, used to implement the field weed detection method based on an improved YOLO model described in Embodiment 1, such as... Figure 6 As shown, the system includes:
[0119] The acquisition module is used to acquire image data of the target field area and preprocess the image data;
[0120] The detection module is used to input preprocessed image data into the pre-constructed improved YOLO-FENG detection model for weed detection. The improved YOLO-FENG detection model includes a backbone network, a neck network, and a detection head. The backbone network introduces a fine-grained channel attention mechanism to capture the interaction between global and local information at different granularity levels. The neck network introduces lightweight grouped convolution for grouping operations and channel shuffling. The loss function used to train the improved YOLO-FENG detection model is the enhanced E-NWD loss function, which is based on the Wasserstein distance loss function and incorporates multi-scale geometric constraint terms, dynamic temperature control terms, and boundary distance sensing terms.
[0121] The output module is used to output the weed detection results.
[0122] Example 4 This embodiment provides a computer-readable medium storing a computer program, which, when executed by a processor, implements the field weed detection method based on the improved YOLO model as described in Embodiment 1; specifically, it includes the following steps:
[0123] Step 1: Collect image data of the target field area and preprocess the image data;
[0124] Step two: Input the preprocessed image data into the constructed improved YOLO-FENG detection model for weed detection; the improved YOLO-FENG detection model includes a backbone network, a neck network, and a detection head; the backbone network introduces a fine-grained channel attention mechanism to capture the interaction between global and local information at different granularity levels; the neck network introduces lightweight grouped convolution for grouping operations and channel mixing; the loss function used to train the improved YOLO-FENG detection model is the enhanced E-NWD loss function, which is based on the Wasserstein distance loss function and introduces multi-scale geometric constraint terms, dynamic temperature control terms, and boundary distance sensing terms;
[0125] Step 3 is used to output the weed detection results.
[0126] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A field weed detection method based on an improved YOLO model, characterized in that, The method includes: Collect image data of the target field area and preprocess the image data; The preprocessed image data is input into the constructed improved YOLO-FENG detection model for weed detection; The improved YOLO-FENG detection model includes a backbone network, a neck network, and a detection head. The backbone network incorporates a fine-grained channel attention mechanism to capture the interaction between global and local information at different granularity levels. The neck network incorporates lightweight grouped convolutions for grouping operations and channel shuffling. The loss function used to train the improved YOLO-FENG detection model is an enhanced E-NWD loss function, which is based on the Wasserstein distance loss function but incorporates multi-scale geometric constraints, dynamic temperature control, and boundary distance sensing terms. The enhanced E-NWD loss function L is expressed as: ; in, Represents multi-scale geometric constraints. For boundary distance sensing terms, This is a dynamic temperature control item; The multi-scale geometric constraint term is used to constrain the position between the center of the predicted box and the center of the ground truth box. The boundary distance sensing term is used to constrain the boundary position of the prediction box; The dynamic temperature control term is used to constrain the temperature of targets of different sizes; The multi-scale geometric constraint terms Represented as: ; Where, Δ x and Δ y Indicates the center of the predicted bounding box and the center of the ground truth bounding box. x Coordinate difference sum y Coordinate difference; α Indicates the center distance weighting factor; and These represent the width and height of the prediction box, respectively; These represent the width and height of the actual bounding box, respectively. The boundary distance sensing item Represented as: ; ; ; ; ; in, This indicates the offset between the left boundary of the predicted bounding box and the left boundary of the ground truth bounding box; This indicates the offset of the predicted bounding box from the right boundary of the ground truth bounding box; This indicates the offset between the predicted bounding box and the top boundary of the ground truth bounding box; This indicates the offset between the predicted bounding box and the lower boundary of the ground truth bounding box; , This indicates the coordinates of the top-left corner of the prediction box; , This indicates the coordinates of the bottom right corner of the prediction box; , Represents the coordinates of the top-left corner of the true bounding box; , Represents the coordinates of the bottom right corner of the true bounding box; Indicates the boundary distance weighting factor; The dynamic temperature control item Represented as: ; ; ; in, Indicates the base temperature; min (#, *) indicates that the smaller of # and * is taken; Indicates the size factor; Indicates the aspect ratio factor; Indicates the aspect ratio of the prediction box; The aspect ratio of the actual bounding box Output the weed detection results.
2. The field weed detection method based on the improved YOLO model according to claim 1, characterized in that, The preprocessing method includes: Image enhancement processing is performed on image data based on the Gaussian blur method with a standard deviation of 1.
3. The field weed detection method based on the improved YOLO model according to claim 1, characterized in that, The backbone network is used to perform the following processing on the preprocessed image data: The original feature map is extracted based on the preprocessed image data; Shallow spatial features and high-level semantic features are extracted from the original feature map respectively; Based on the fine-grained channel attention mechanism, the high-level semantic features are first subjected to global average pooling to obtain the channel global features, while retaining the original features of the high-level semantic features. Then, the channel covariance matrix is constructed to capture the dependency between the channel global features and local features. Channel attention weights are generated based on the channel covariance matrix, and the high-level semantic features are recalibrated based on the channel attention weights. The recalibrated high-level semantic features and shallow spatial features are combined by channel concatenation and convolution to obtain multi-scale enhanced features.
4. The field weed detection method based on the improved YOLO model according to claim 3, characterized in that, The neck network is used to transmit semantic features of weed category from top to bottom and detailed features of weed location from bottom to top based on multi-scale enhanced features. The neck network is a Slim Neck lightweight architecture, and all standard convolutional layers in the neck network are replaced with grouped convolutional layers. All intermediate convolutional operations in the feature transmission process are completed by the grouped convolutional layers.
5. The field weed detection method based on the improved YOLO model according to claim 1, characterized in that, The head or tail of the detection head is embedded with a moving inverted bottleneck convolutional structure, which includes an expansion layer, a depthwise separable convolutional layer, and a compression layer. The expansion layer is used for feature upscaling; the depthwise separable convolutional layer is used for channel-wise spatial feature extraction; and the compression layer is used for feature downscaling.
6. A field weed detection method system based on an improved YOLO model, characterized in that, The system is used to implement the field weed detection method based on the improved YOLO model as described in any one of claims 1-5, the system comprising: The acquisition module is used to acquire image data of the target field area and preprocess the image data; The detection module is used to input preprocessed image data into the pre-constructed improved YOLO-FENG detection model for weed detection. The improved YOLO-FENG detection model includes a backbone network, a neck network, and a detection head. The backbone network introduces a fine-grained channel attention mechanism to capture the interaction between global and local information at different granularity levels. The neck network introduces lightweight grouped convolution for grouping operations and channel shuffling. The loss function used to train the improved YOLO-FENG detection model is the enhanced E-NWD loss function, which is based on the Wasserstein distance loss function and incorporates multi-scale geometric constraint terms, dynamic temperature control terms, and boundary distance sensing terms. The output module is used to output the weed detection results.
7. A computer-readable medium having a computer program stored thereon, characterized in that, The computer program, when executed by a processor, can implement the field weed detection method based on the improved YOLO model as described in any one of claims 1-5.
