Lightweight corn-weed accurate detection algorithm based on improved YOLOv10s
By improving the backbone and neck structure of the YOLOv10s model and constructing D-PP-HGNet and RCS-OSA modules, the problems of low recognition accuracy and high computational complexity of the corn-weed detection algorithm are solved, realizing lightweight and efficient corn-weed precision detection, which is suitable for automated weed management in smart agriculture.
Patent Information
- Application Number
- CN202511706483.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-20
- Publication Date
- 2026-01-09
AI Technical Summary
Existing corn-weed detection algorithms suffer from low accuracy and high computational complexity, making them difficult to deploy on mobile devices and unable to meet the application requirements of real-time agricultural robots or drone platforms in smart agriculture.
An improved YOLOv10s model is adopted. The backbone is replaced by a lightweight D-PP-HGNet network, and the C2f module in the neck is replaced by an RCS-OSA module. The model structure is optimized to reduce the number of parameters and computational complexity, while improving the feature extraction capability.
It significantly improves the accuracy and efficiency of corn-weed detection, is compatible with edge device deployment, and enables efficient real-time detection in complex farmland environments.
Smart Images

Figure CN121305368A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of computer vision and artificial intelligence, and in particular to a corn- weed precise detection algorithm suitable for automatic weed identification and precise prevention and control scenarios in smart agriculture. BACKGROUND
[0002] With the continuous deepening of smart agriculture, agricultural production methods are undergoing a comprehensive digitalization and intelligentization transformation. In the field of crop production management, precision agriculture, as the core development direction, puts forward higher requirements for intelligent perception and fine management of crops in the field. Among them, corn, as an important food and feed crop in the world, its weed control in the production process has always been a key challenge. Traditional weed control methods mainly rely on large-area chemical agent spraying, which not only causes drug waste and environmental pollution, but also may affect corn growth. Therefore, the development of efficient and precise corn- weed identification and detection technology is an important prerequisite for realizing variable spraying, mechanical weeding and intelligent operation of agricultural robots, and has important significance for promoting green agriculture and sustainable development.
[0003] In recent years, target detection technology based on deep learning has shown great potential in agricultural vision tasks. This kind of method automatically extracts distinguishing features of crops and weeds through convolutional neural networks, overcoming the limitations of traditional image processing methods in complex field environments, such as poor adaptability and reliance on manually designed features. For example, Fan Xiangpeng et al. proposed an improved YOLOv5 structure, which introduced an attention mechanism and a restructured feature extraction module, achieving high detection accuracy in cotton field weed identification; Hu Rui et al. developed a new Multimodule-YOLOv7-L model, which realized the precise classification of the severity of weeds in vegetable rows, providing a reliable basis for precision spraying; Zheng Lu et al. integrated TensorRT technology on the YOLOv8 architecture, increasing the detection speed of the model by nine times, providing significant progress for the development of efficient weed detection systems for practical agricultural applications.
[0004] However, in actual farmland environments, target detection algorithms based on deep learning technology still face many technical bottlenecks in practical applications. First, corn and weeds have strong morphological similarity at the seedling stage, with subtle feature differences, making it difficult for traditional detection models to maintain high classification accuracy. In addition, most existing algorithms have high computational complexity, making it difficult to deploy them to edge computing devices or embedded systems, limiting their application in real-time agricultural robots or unmanned aerial vehicle platforms. Therefore, developing a corn- weed precise detection algorithm that balances detection accuracy and lightweight is of great significance for promoting precision plant protection and automated management in smart agriculture, and is also one of the key technologies that need to be broken through in the current field of agricultural artificial intelligence SUMMARY
[0005] To address the shortcomings of the aforementioned background technology, this invention proposes a lightweight corn-weed precision detection algorithm based on improved YOLOv10s, which solves the technical problems of low recognition accuracy, high computational intensity, and difficulty in deployment on mobile devices in existing algorithms.
[0006] To achieve the above objectives, the technical solution of the present invention is implemented as follows: A lightweight corn-weed precision detection algorithm based on improved YOLOv10s, comprising the following steps: S1: Collect images of corn seedlings and weeds, and construct a cornfield weed dataset; S2: Construct an improved lightweight corn-weed detection model for YOLOv10s, build a lightweight D-PP-HGNet network to replace the original backbone of the YOLOv10s model, and introduce an improved RCS-OSA module in the neck network. S3: The improved lightweight corn-weed detection model of YOLOv10s is trained and evaluated using the cornfield weed dataset. S4: The improved lightweight corn-weed detection model of YOLOv10s, which was trained and evaluated, is used to classify and detect corn seedlings and weeds in the test images.
[0007] Furthermore, the construction method of the D-PP-HGNet lightweight network is as follows: Based on the PP-HGNet framework, depthwise separable convolutions are introduced to replace the standard convolutions of the HG Block in the original framework to obtain the IHG Block, and LDS learnable downsampling layers are added to construct the D-PP-HGNet lightweight network. By introducing depthwise separable convolutions and learnable downsampling layers on the PP-HGNet framework to replace the original YOLOv10s backbone, the network retains the ability to extract low-level detailed features (such as leaf texture) and high-level semantic features (such as crop spatial distribution) while significantly reducing the number of parameters and computational complexity, making it suitable for edge devices.
[0008] Furthermore, in the improved YOLOv10s lightweight corn-weed detection model, the backbone replaced by the D-PP-HGNet lightweight network includes the Stem layer, the first IHG Block, the first LDS layer, the second IHG Block, the second LDS layer, the third IHG Block, the fourth IHG Block, the third LDS layer, the fifth IHG Block, the GAP layer, the SPPF layer, and the PSA layer, which are connected in sequence. Each IHG Block serves as a core feature extraction unit for extracting local detail features; each LDS layer is used to adaptively and dynamically adjust the downsampling ratio based on the input features.
[0009] Furthermore, the processing in the IHG Block is as follows: a first convolutional layer with a kernel size of 3×3 captures complex image features in the input feature map; spatial features are extracted and channels are combined from the output of the first convolutional layer through four cascaded depthwise separable convolutional layers; the output feature map of the first convolutional layer is concatenated with the output feature maps of each depthwise separable convolutional layer; the concatenated feature map is then dimensionality-reduced by a second convolutional layer with a kernel size of 1×1; after feature filtering by the ESE module, the dimensionality-reduced feature map is residually connected to the input feature map to obtain the global description vector.
[0010] Furthermore, in the ESE module, adaptive pooling is first used instead of the traditional global average pooling of SE to extract contextual features. The pooled features are then subjected to 1×1 convolution to reduce the channel dimension and extract the global contextual information of the input features, while fusing information from different channels. Subsequently, the contextual features extracted by the 1×1 convolution are fed into the Sigmoid activation to form channel-level attention weights. Finally, the attention weights are multiplied with the original features channel by channel to enhance important channels and suppress irrelevant channels.
[0011] Furthermore, an improved RCS-OSA module is introduced into the neck network, including replacing the C2f module in the original YOLOv10s neck network with the improved RCS-OSA module. By replacing the C2f module in the neck with the improved RCS-OSA, and integrating channel Shuffle Reparameterization (RCS) and One-Time Aggregation (OSA) techniques, the recognition accuracy of small targets (small weeds), dense targets (clump-forming weeds), and similar targets (corn seedlings and grass weeds) is improved by focusing on the details of weed targets through spatial object attention, while reducing channel redundancy computation.
[0012] Furthermore, the improved RCS-OSA module introduces fusionable convolutional blocks based on the RepVGG reparameterization concept at the short-circuit branches and the end of the original RCS-OSA module.
[0013] Furthermore, the improved RCS-OSA module's processing procedure is as follows: The input feature map is split into a short-circuit branch input feature map and an RCS branch input feature map on an average basis according to the channel dimension. The short-circuit branch input feature map undergoes feature enhancement through a first fusionable convolutional block constructed based on the RepVGG reparameterization concept, outputting a first feature map with the same number of channels. The RCS branch input feature map is processed by a first stacked RCS module, outputting a second feature map. The second feature map is processed by a second stacked RCS module, outputting a third feature map. The first, second, and third feature maps are shuffled through channels and then merged for output. Finally, they undergo deep feature integration and expression enhancement through a second fusionable convolutional block constructed based on the RepVGG reparameterization concept, yielding the output of the RCS-OSA module.
[0014] Furthermore, during the training phase, in the first stacked RCS modules and the second stacked RCS modules, each RCS module is processed in parallel through the first branch, the second branch and the third branch. The first branch directly passes the features, the second branch extracts features through 1×1 convolution, and the third branch extracts features through 3×3 convolution. The outputs of the first branch, the second branch and the third branch are merged and then shuffled through channels to obtain the output of each RCS module. During the inference phase, the first, second, and third branches are merged into a single 3×3 convolution through structural reparameterization.
[0015] Furthermore, the fusionable convolutional block constructed based on the RepVGG reparameterization concept consists of three parallel branches during the training phase. These three branches include a 3×3 convolution + BatchNorm main branch, a 1×1 convolution + BatchNorm auxiliary branch, and an Identity branch activated when the input and output channels are the same and the stride is 1. The outputs of the three parallel branches are summed element-wise and then activated by ReLU. During the inference phase, the convolutions in the main branch, auxiliary branch, and Identity branch are fused into a single convolution with a 3×3 kernel through reparameterization.
[0016] The beneficial effects of this invention are: This invention employs an improved YOLOv10s model, optimizing both the backbone and neck components. A lightweight network, called DwconvHigh Performance GPU Net (D-PP-HGNet), is built upon the high-performance GPU network (PP-HGNet) framework to replace the backbone module. Furthermore, an improved Reduced ChannelSpatial Object Attention (RCS-OSA) module replaces the C2f module in the neck, reducing the number of parameters and improving the model's detection accuracy. This significantly enhances the model's target detection efficiency and performance for different types of weeds in complex farmland environments, facilitating automated weed management in cornfields. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is the original YOLOv10s model structure diagram.
[0019] Figure 2 This is a structural diagram of the improved YOLOv10s model of the present invention.
[0020] Figure 3 This is a structural diagram of the improved Hierarchical Gradient Block (IHG Block) module.
[0021] Figure 4 This is a structural diagram of the ESE module of the present invention.
[0022] Figure 5 This is a structural diagram of the improved RCS-OSA of the present invention.
[0023] Figure 6 This is a flowchart of the method of the present invention. Detailed Implementation
[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0025] This invention addresses the pain points of existing corn-weed detection algorithms, such as low accuracy and bulky, difficult-to-deploy models. With lightweight design and high precision as its core objectives, it constructs a precise corn-weed detection solution based on the YOLOv10s model. The overall logic is as follows: First, a large-scale cornfield weed-specific dataset covering multiple scenarios is built to solve the fundamental problem of poor data generalization leading to inaccurate model identification. Then, based on the YOLOv10s model, the C2f modules of the backbone and neck parts of the model are optimized. A lightweight network called Dwconv PaddlePaddleHigh Performance GPU Net (D-PP-HGNet) was built on the high-performance GPU network PaddlePaddle High Performance GPU Net (PP-HGNet) framework. This lightweight network replaced the backbone module, and the C2f module in the neck was replaced with ReducedChannelSpatial Object Attention (RCS-OSA). By replacing redundant modules with a lightweight network, the feature extraction capability was enhanced while reducing the number of parameters and computational cost. Finally, the feasibility of the model in accurately detecting corn seedlings / weeds and deploying edge devices in complex farmland environments was verified through training and evaluation on a dataset. Ultimately, the dual goals of efficient corn-weed differentiation and lightweight real-time inference were achieved.
[0026] A lightweight corn-weed precision detection algorithm based on improved YOLOv10s, such as Figure 6 As shown, the steps include: S1: Collect images of corn seedlings and weeds, and construct a cornfield weed dataset.
[0027] In this embodiment of the application, firstly, image acquisition is performed: when acquiring images of corn seedlings and weeds, a high-definition camera is used to acquire images of corn seedlings and their associated weeds in the field. Images are taken at different times, in the morning (6:00-8:00, noon 12:00-14:00, evening 18:00-20:00), under various weather conditions (sunny, cloudy, light rain), and on different terrains (flat land, gentle slope, depression), to ensure that the actual farmland is covered with light, humidity, and differences in crop posture.
[0028] Secondly, image preprocessing was performed: images were selectively cropped, blurry, overexposed / underexposed images were removed, and clear images were retained. Then, the retained images were cropped into regions of interest (ROIs) (size 640×640 pixels), retaining only the core region containing corn seedlings and weeds, and removing large areas of bare soil, stones, and other irrelevant backgrounds. This ensured that each image closely reflected the characteristics of the field crops and weeds, constructing a high-quality dataset of 3000 corn seedling and weed images. The quality of the dataset is crucial. For weed recognition models, the quality of the data directly determines the performance of the model, not only directly affecting the accuracy of the algorithm, but also significantly improving its performance during the improvement process.
[0029] Furthermore, dataset annotation and partitioning were performed: a cornfield weed dataset was constructed to improve the training of the YOLOv10s model. Based on the constructed high-quality image dataset, each image was labeled using LabelImg, with the labeled categories divided into three types: corn seedlings, grassy weeds, and broadleaf weeds. Different colored bounding boxes were used to draw and identify corn seedlings and different types of weeds. The labeled images were divided into training, validation, and test sets in a 4:1:1 ratio, thus constructing a cornfield weed dataset for improving the training, validation, and testing of the YOLOv10s model.
[0030] S2: Construct an improved lightweight corn-weed detection model for YOLOv10s. Based on the PP-HGNet framework, introduce depthwise separable convolutions to replace the standard convolutions in the HG Block of the original framework, and add learnable downsampling layers (LDS) to construct a lightweight D-PP-HGNet network to replace the original backbone of the YOLOv10s model. Replace the C2f module of the original neck network of the YOLOv10s model with the RCS-OSA module. For example... Figure 1 The image shown is the original YOLOv10s model. Figure 2 This is the improved YOLOv10s model of the present invention.
[0031] In this embodiment, the backbone of the original model is replaced with an improved D-PP-HGNet lightweight network. It uses a hierarchical method to extract target features, enabling the network to effectively learn and integrate features at both low and high abstraction levels. This allows it to capture subtle texture differences between corn seedlings and weeds in complex farmland environments, as well as understand the global spatial distribution patterns of crops. This helps the model adapt to the detection tasks of weeds of different sizes and shapes. A learnable downsampling layer is introduced, which can dynamically downsample according to the characteristics of the input data, thereby reducing the spatial dimension of the feature map and alleviating the computational burden.
[0032] Specifically, the improved D-PP-HGNet lightweight network consists of a Stem layer, a first IHGBlock, a first LDS layer, a second IHG Block, a second LDS layer, a third IHG Block, a fourth IHG Block, a third LDS layer, a fifth IHG Block, a GAP layer, a SPPF layer, and a PSA layer connected sequentially. The Stem layer is used for initial feature extraction and dimensionality reduction, reducing subsequent computation. Each IHG Block serves as a core feature extraction unit, extracting local detail features. Each LDS layer adaptively and dynamically adjusts the downsampling ratio based on input features, reducing computational burden while preserving key features. The GAP layer performs global averaging on the feature map output from the fifth HG Block, improving the model's robustness to spatial transformations. The SPPF layer performs multi-scale pooling on the output vector of the GAP layer, fusing features at different scales to improve the detection capability for weeds of varying sizes. The PSA layer weights the output features of the SPPF layer, strengthening the feature weights of key target regions (such as weed leaf tips) and suppressing background interference from soil, dead leaves, etc.
[0033] In this embodiment, the core component of the high-performance network PaddlePaddle High Performance GPU Net (PP-HGNet), the Hierarchical Gradient Block (HG Block), is improved by introducing Depthwise Separable Convolution to replace the original standard convolution. This decomposition decomposes the standard convolution into two independent steps. This ingenious decomposition design maintains sufficient representational power while achieving extreme efficiency optimization, significantly reducing the number of model parameters and computational complexity, offering significant advantages in mobile and edge computing devices.
[0034] Specifically, such as Figure 3As shown, the processing in the IHG Block is as follows: A first convolutional layer with a kernel size of 3×3 captures complex image features from the input feature map. Since the first convolutional layer is crucial for extracting low-level information, it remains unchanged. Spatial feature extraction and channel combination are performed on the output of the first convolutional layer through four cascaded depthwise separable convolutional layers. This decomposes a complex joint task into two simpler independent tasks, avoiding a large amount of repetitive and redundant computation, and greatly improving the problem of increased computational demands caused by the extensive use of 3×3 convolutions. The output feature map of the first convolutional layer and the output feature maps of each depthwise separable convolutional layer are concatenated. The concatenated feature map is then dimensionality-reduced by a second convolutional layer with a kernel size of 1×1, reducing the number of parameters and computational cost in subsequent calculations. The dimensionality-reduced feature map is then processed by the ESE module, where global average feature filtering is performed, and a residual connection is made with the input feature map to obtain the global description vector.
[0035] like Figure 4 As shown, the ESE module first uses adaptive pooling instead of the traditional global average pooling in SE to extract contextual features. Adaptive pooling does not require manually specifying the pooling kernel size and can automatically adjust the output size according to needs, capturing global information in the channel dimension. The pooled features are then subjected to 1×1 convolution to reduce the channel dimension, extracting global contextual information of the input features and fusing information from different channels. Subsequently, the contextual features extracted by the 1×1 convolution are fed into a sigmoid activation to form channel-level attention weights, measuring the importance of each channel feature. Finally, these weights are multiplied with the original features channel by channel to strengthen important channels and suppress irrelevant channels, thereby completing the channel recalibration of features with extremely low computational cost.
[0036] An improved RCS-OSA module is introduced into the neck network, including replacing the C2f module in the original YOLOv10s neck network with the improved RCS-OSA module. The RCS component employs a multi-branch structure during training, combining channel segmentation and channel shuffling operations to enrich feature learning and maintain inter-channel information interaction. The OSA component acquires multi-scale receptive field features by concatenating multiple convolutional layers and performs a single aggregation at the end of the module, avoiding the efficiency bottleneck caused by dense connections. The RCS-OSA module significantly reduces computational complexity and memory usage by reducing redundant computation in the channel dimension, while maintaining multi-scale feature extraction capabilities. Its spatial object attention mechanism can accurately focus on the detailed features of weed targets, effectively distinguishing different weed categories with similar morphologies and enhancing the detection capabilities for small targets and densely distributed weeds. In complex farmland environments, the RCS-OSA module can effectively suppress background interference and improve the feature discrimination between weeds and crops.
[0037] The improved RCS-OSA module introduces a fusionable convolutional block based on the RepVGG reparameterization concept at the short-circuit branch and end of the original RCS-OSA module. The RepVGG fusionable convolutional block (RepVGG Block) consists of three branches during the training phase: a 3×3 convolution + BatchNorm main branch, a 1×1 convolution + BatchNorm auxiliary branch, and an Identity branch activated when the input and output channels are the same and the stride is 1. The outputs of these three branches are element-wise summed after convolution and then activated by ReLU. During the inference phase, reparameterization is used to mathematically fuse the main branch, auxiliary branch, and Identity branch into a single 3×3 convolutional kernel, achieving an efficient structure of multiple branches for training and a single branch for inference, combining expressiveness and inference speed.
[0038] Introducing a fusionable convolutional block based on the RepVGG heavy parameter concept can significantly improve feature learning capabilities during training, while fusing all branches into a lightweight 3×3 convolution during inference, thereby improving accuracy and speed without increasing the number of parameters.
[0039] like Figure 5As shown, the improved RCS-OSA module's processing procedure is as follows: The input feature map is split into a short-circuit branch input feature map and an RCS branch input feature map on an average basis according to the channel dimension. The short-circuit branch input feature map is enhanced by the first fusionable convolutional block constructed based on the RepVGG reparameterization idea. During the training phase, this module uses a multi-branch convolutional structure to achieve feature enrichment and weak multi-scale modeling, while maintaining feature stability using identity branches. During the inference phase, it is fused into a single convolution through reparameterization, thus significantly improving the feature representation capability of the short-circuit branch without increasing inference overhead. To enhance the extraction capability of multi-scale features, a first feature map with the same number of channels is output. The RCS branch input feature map is processed by the first stacked RCS module to output a second feature map. The second feature map is processed by the second stacked RCS module to output a third feature map. The first, second, and third feature maps are shuffled by channel and then merged for output (OSA). Finally, the OSA-fused features are further enhanced through a second fusionable convolutional block constructed based on the RepVGG reparameterization idea, performing deep feature integration and representation enhancement. Leveraging RepVGG's highly parameterized multi-branch structure, this module performs multi-scale spatial modeling, channel reshaping, and feature enhancement during training. During inference, these features are fused into a single convolution to maintain lightweight computation, significantly improving the consistency of fused feature representation and detection effectiveness. Enhanced efficiency in feature extraction and information utilization allows the module to achieve stronger representational capabilities while maintaining a low computational load, resulting in the output of the RCS-OSA module.
[0040] During the training phase, in both the first and second stacked RCS modules (in this embodiment, both the first and second stacked RCS modules use two layers of stacked RCS units, i.e., n = 2). This configuration, after introducing RepVGG reparameterized fusionable convolutional blocks, achieves better feature representation and detection performance while maintaining controllable computational load. Each RCS module is processed in parallel through a first branch, a second branch, and a third branch. The first branch directly passes features, the second branch extracts features through 1×1 convolutions, and the third branch extracts features through 3×3 convolutions. The outputs of the first, second, and third branches are merged and then shuffled through channels to obtain the output of each RCS module. The output of each RCS module serves as the input for subsequent RCS modules.
[0041] During the inference phase, the first, second, and third branches are merged into a single 3×3 convolution through structural reparameterization.
[0042] S3: The improved lightweight corn-weed detection model of YOLOv10s is trained and evaluated using the cornfield weed dataset.
[0043] Training environment and parameter settings: Hardware environment: CPU is Intel(R) Core(TM) i5-14600K; GPU is NVIDIA GeForce RTX 4060 Ti (16GB VRAM); Software environment: Operating system is Ubuntu 20.04, programming language is Python 3.9, deep learning framework is PyTorch 2.0.1; Training parameters: learning rate is set to 0.01, batch size is 16, training epochs are 200, loss function is CIoU Loss, and the optimizer is SGD (momentum coefficient 0.9, weight decay 0.0005).
[0044] Model training process: The improved YOLOv10s model consists of four parts: input, backbone network, neck network, and detection head. The training process is as follows: The input corn-weed RGB image is preprocessed and then fed into the backbone network.
[0045] The backbone network processing consists of several layers. Layer 0 is the Stem layer, the initial preprocessing layer that extracts features from the original input data and performs channel dimensionality reduction to reduce subsequent computation. Layers 1, 3, 5, 6, and 8 are HG Block layers, which process data hierarchically through multiple short-circuit connections, providing powerful, efficient, and stable feature learning capabilities. Layers 2, 4, and 7 are LDS learnable downsampling layers, performing downsampling to reduce the spatial dimension of the feature map, reducing computational load and potentially increasing the receptive field of subsequent layers. Layer 9 is the GAP (Global Average Pooling) layer, which uses the GAP layer to reduce the spatial dimension of the feature map to the minimum value per feature. Figure 1 The first vector helps improve the network's robustness to spatial transformations of the input data; the 10th layer is the SPPF layer, used to improve the model's ability to detect targets at different scales in the feature map; the 11th layer is the improved PSA layer, used to enhance the model's attention to key regions in the feature map.
[0046] Subsequently, the feature maps enter the neck network. Layers 12 and 15 are upsampling layers, which enhance the spatial resolution of the input feature maps, thereby expanding the deep and abstract semantic information spatially and providing a basis for size matching for subsequent cross-layer feature fusion. Layers 13, 16, 19, and 22 are concat layers, which concatenate feature maps from different layers along the channel dimension. Layers 14, 17, and 20 are RCS-OSA layers, which serve as the core of feature processing and transformation, efficiently processing the composite features generated by the concatenation and extracting and fusing multi-scale features more efficiently than the C2f layer. Layer 22 is the C2fCIB layer, which transforms the feature map formed by the upsampling and concatenation operations into a new feature map with specific channels, realizing feature fusion at different scales and obtaining stronger feature representation capabilities. Layer 18 is a convolutional layer, which reduces the spatial dimension of the feature map while maintaining the number of channels. Layer 21 is the SCDown layer, which has fewer parameters than the convolutional layer and can reduce the spatial dimension of the feature map more efficiently while keeping the number of channels constant.
[0047] Finally, the feature maps are fed into the 24th layer of the detection layer, which transforms the feature maps extracted from the 17th, 20th, and 23rd layers of the network into the final detection result, including the location of the target.
[0048] The trained lightweight corn-weed detection model was tested using a test set. The improved YOLOv10s target detection model was used to detect different types of weeds in cornfields.
[0049] The trained model was evaluated using a test set. Evaluation metrics included mean accuracy (mAP), number of parameters, computational cost (FLOPs), and inference speed (FPS). The model was compared with the original YOLOv10s, YOLOv8s, YOLOv7s, and YOLOv5s models. The results are shown in the table below. Evaluation results show that the improved YOLOv10s model proposed in this study exhibits significant performance improvements in several aspects compared to the original YOLOv10s model. Firstly, in terms of accuracy (mAP), the improved YOLOv10s achieves an mAP value of 95.8%, a 6.3 percentage point increase compared to the original YOLOv10s' 89.5%, demonstrating a significant improvement in object detection accuracy through our improved method. This improvement effectively enhances the model's detection capabilities in complex scenes, particularly in multi-class object detection tasks. Secondly, the improved model also optimizes parameter count and computational complexity. The number of model parameters is reduced from 7.5M in the original YOLOv10s to 5.4M, and the computational cost (FLOPs) is reduced from 16.8G to 6.5G, showing a significant improvement in computational efficiency. These optimizations allow the improved YOLOv10s to maintain high accuracy while reducing its dependence on computational resources, making it more suitable for deployment on low-power devices. Furthermore, the improved inference speed gives the model a greater advantage in applications with high real-time requirements, with FPS increasing from 98 to 130, demonstrating the improved model's rapid response capability. S4: The improved lightweight corn-weed detection model of YOLOv10s, completed through training and evaluation, is used to classify and detect corn seedling and weed images.
[0050] Compared to existing YOLO models (such as YOLOv5s, YOLOv8s, and YOLOv9s), the improved YOLOv10s model proposed in this study demonstrates superior performance across multiple performance metrics. Specifically, the improved YOLOv10s achieves an mAP of 95.8%, leading all compared models, especially compared to YOLOv5s (84.5%) and YOLOv9s (87.6%), showing a significant improvement in accuracy and demonstrating a greatly enhanced object detection capability on complex datasets. Regarding computational resources, despite the significant improvement in accuracy, the improved YOLOv10s has only 5.4M parameters, a substantial reduction compared to YOLOv8s (11.2M) and YOLOv9s (8.5M), allowing the model to operate efficiently in environments with lower computational resources. Meanwhile, the improved YOLOv10s has a computational cost (FLOPs) of 6.5G, significantly lower than YOLOv8s' 21.5G, reducing the computational burden during model inference and helping to accelerate inference speed and lower deployment costs. In terms of inference speed, the improved YOLOv10s achieves 130 FPS, significantly exceeding YOLOv5s (115 FPS) and YOLOv9s (85 FPS), indicating that this model has a stronger advantage in real-time detection tasks, especially in applications with high computational efficiency requirements. Overall, the improved YOLOv10s not only performs excellently in terms of accuracy, computational efficiency, and inference speed, but also possesses strong application potential, enabling more efficient and accurate detection.
[0051] The significant advantage of this invention lies in its meticulous design and deep optimization of a lightweight YOLOv10 model compared to existing technologies, aiming to significantly improve the model's computational efficiency and real-time processing capabilities. First, by transforming the original backbone network into D-PP-HGNet, this invention greatly reduces the model's computational complexity while improving detection accuracy. Second, this invention incorporates RCS-OSA to more efficiently extract and fuse multi-scale features, significantly enhancing the model's ability to accurately identify corn seedlings and weeds in complex farmland environments. Furthermore, to verify the effectiveness and practicality of this invention, a dataset specifically designed for cornfield weeds was constructed, and comprehensive model training and performance evaluation were performed on it. In summary, this invention achieves effective detection results while improving the model's application on edge computing devices.
[0052] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A lightweight corn-weed precision detection algorithm based on improved YOLOv10s, characterized in that, The steps are as follows: S1: Collect images of corn seedlings and weeds, and construct a cornfield weed dataset; S2: Construct an improved lightweight corn-weed detection model for YOLOv10s, build a lightweight D-PP-HGNet network to replace the original backbone of the YOLOv10s model, and introduce an improved RCS-OSA module in the neck network. S3: The improved lightweight corn-weed detection model of YOLOv10s is trained and evaluated using the cornfield weed dataset. S4: The improved lightweight corn-weed detection model of YOLOv10s, which was trained and evaluated, is used to classify and detect corn seedlings and weeds in the test images.
2. The lightweight corn-weed precision detection algorithm based on improved YOLOv10s according to claim 1, characterized in that, The construction method of the D-PP-HGNet lightweight network is as follows: on the basis of the PP-HGNet framework, depthwise separable convolution is introduced to replace the standard convolution of HG Block in the original framework to obtain IHG Block, and LDS learnable downsampling layer is added to construct the D-PP-HGNet lightweight network.
3. The lightweight corn-weed precision detection algorithm based on improved YOLOv10s according to claim 2, characterized in that, The backbone of the improved YOLOv10s lightweight corn-weed detection model, replaced by the D-PP-HGNet lightweight network, includes the following layers connected in sequence: Stem layer, first IHG Block, first LDS layer, second IHG Block, second LDS layer, third IHG Block, fourth IHG Block, third LDS layer, fifth IHG Block, GAP layer, SPPF layer, and PSA layer. Each IHG Block serves as a core feature extraction unit for extracting local detail features; each LDS layer is used to adaptively and dynamically adjust the downsampling ratio based on the input features.
4. The lightweight corn-weed precision detection algorithm based on improved YOLOv10s according to claim 3, characterized in that, The processing in IHG Block is as follows: a first convolutional layer with a kernel size of 3×3 captures complex image features in the input feature map. Spatial features are extracted and channels are combined from the output of the first convolutional layer through four cascaded depthwise separable convolutional layers. The output feature map of the first convolutional layer is concatenated with the output feature maps of each depthwise separable convolutional layer. The concatenated feature map is then dimensionality-reduced by a second convolutional layer with a kernel size of 1×1. After feature filtering by the ESE module, the dimensionality-reduced feature map is residually connected to the input feature map to obtain the global description vector.
5. The lightweight corn-weed precision detection algorithm based on improved YOLOv10s according to claim 4, characterized in that, In the ESE module, adaptive pooling is used to replace the global average pooling of traditional SE to extract contextual features. The pooled features are then reduced in dimensionality by 1×1 convolution to extract global contextual information of the input features, while information from different channels is fused. The contextual features extracted by the 1×1 convolution are then fed into the Sigmoid activation to form channel-level attention weights. Finally, the attention weights are multiplied with the original features channel by channel to enhance important channels and suppress irrelevant channels.
6. The lightweight corn-weed precision detection algorithm based on improved YOLOv10s according to any one of claims 1-5, characterized in that, An improved RCS-OSA module is introduced into the neck network, including replacing the C2f module in the original YOLOv10s neck network with the improved RCS-OSA module.
7. The lightweight corn-weed precision detection algorithm based on improved YOLOv10s according to claim 6, characterized in that, The improved RCS-OSA module introduces fusionable convolutional blocks based on the RepVGG reparameterization concept at the short-circuit branches and the end of the original RCS-OSA module.
8. The lightweight corn-weed precision detection algorithm based on improved YOLOv10s according to claim 7, characterized in that, The improved RCS-OSA module processes the following: The input feature map is split into a short-circuit branch input feature map and an RCS branch input feature map, each channel in turn. The short-circuit branch input feature map undergoes feature enhancement through a first fusionable convolutional block built on the RepVGG reparameterization concept, resulting in a first feature map with the same number of output channels. The RCS branch input feature map is processed by a first stacked RCS module, resulting in a second feature map. The second feature map is then processed by a second stacked RCS module, resulting in a third feature map. The first, second, and third feature maps are shuffled through channels and then merged. Finally, they undergo deep feature integration and expression enhancement through a second fusionable convolutional block built on the RepVGG reparameterization concept, yielding the output of the RCS-OSA module.
9. The lightweight corn-weed precision detection algorithm based on improved YOLOv10s according to claim 8, characterized in that, During the training phase, in the first stacked RCS modules and the second stacked RCS modules, each RCS module is processed in parallel through the first branch, the second branch and the third branch. The first branch directly passes the features, the second branch extracts features through 1×1 convolution, and the third branch extracts features through 3×3 convolution. The outputs of the first branch, the second branch and the third branch are merged and then shuffled through channels to obtain the output of each RCS module. During the inference phase, the first, second, and third branches are merged into a single 3×3 convolution through structural reparameterization.
10. The lightweight corn-weed precision detection algorithm based on improved YOLOv10s according to any one of claims 7 to 9, characterized in that, The fusionable convolutional block constructed based on the RepVGG reparameterization concept consists of three parallel branches during the training phase. These branches include a 3×3 convolution + BatchNorm main branch, a 1×1 convolution + BatchNorm auxiliary branch, and an Identity branch activated when the input and output channels are the same and the stride is 1. The outputs of the three parallel branches are summed element-wise and then activated by ReLU. During the inference phase, the convolutions in the main branch, auxiliary branch, and Identity branch are fused into a single 3×3 convolution kernel through reparameterization.
