A weed detection method and system based on an improved YOLOv11 model
By improving the YOLOv11 model and introducing a dual attention mechanism, the problems of missed detection of small targets and category confusion in complex farmland environments were solved, improving the accuracy and robustness of weed identification and achieving high efficiency and stability in real-time detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XIJING UNIV
- Filing Date
- 2026-01-06
- Publication Date
- 2026-05-29
Smart Images

Figure CN122116079A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and precision agriculture, and in particular to a weed detection method based on an improved YOLOv11 model. Background Technology
[0002] Precision agriculture is an important direction for the development of modern agriculture. Its core lies in using information technology to perceive, make decisions about, and precisely manage farmland environments. The rapid and accurate identification and location of weeds is a key prerequisite for implementing variable-rate herbicide spraying, reducing excessive pesticide use, and lowering environmental pollution and production costs. This is of great significance for promoting sustainable agricultural development.
[0003] Currently, deep learning-based object detection algorithms have become the mainstream technology for identifying weeds in farmland. Among them, the YOLO series of algorithms are widely used due to their good balance between speed and accuracy. YOLOv11, as the latest evolution model in this series, has demonstrated superior performance on general object detection tasks through optimized network structure and training strategies, providing a potential foundational framework for applications in agricultural scenarios. However, directly applying the existing YOLOv11 model to complex real-world farmland environments still faces significant challenges. First, weed targets in farmland scenes are usually small in size and highly similar in color and texture to crops and soil backgrounds, leading to missed detections of small targets. Second, different types of weeds have similar morphologies, while the morphology of the same type of weed varies at different growth stages or from different perspectives, making the model prone to class confusion. Furthermore, farmland environments are greatly affected by factors such as changes in light, weather conditions, and occlusion, while large-scale, high-quality, and accurately labeled farmland weed image datasets are relatively scarce, resulting in insufficient model generalization ability and a tendency to overfit.
[0004] Therefore, there is an urgent need for an improved solution that can enhance the feature recognition and robustness of the model in complex and variable farmland scenarios. Summary of the Invention
[0005] In view of the problems existing in the above-mentioned weed detection methods, the present invention is proposed.
[0006] Therefore, the purpose of this invention is to provide a weed detection method based on an improved YOLOv11 model. The aim is to improve the YOLOv11 model by introducing a dual attention mechanism (EMA and EMCAM modules) to enhance its detection accuracy and robustness in complex farmland environments, while maintaining efficient real-time inference capabilities.
[0007] To solve the above-mentioned technical problems, the present invention provides the following technical solution, comprising the following steps: S100: Construct an improved YOLOv11 model that integrates efficient multi-scale attention modules and efficient multi-scale channel attention modules in the feature paths of the backbone network end and the detection head to form a dual-attention enhanced feature extraction and fusion mechanism.
[0008] S200: Prepare a dataset of farmland weed images, and perform annotation and enhancement preprocessing on the dataset.
[0009] S300: Use the dataset to train the improved YOLOv11 model to obtain a trained weed recognition model.
[0010] S400: Input the farmland image to be detected into the trained weed recognition model, and output the category and location information of the weeds.
[0011] As a preferred embodiment of the weed detection method of the present invention, wherein: the backbone network of the improved YOLOv11 model is sequentially connected to a first efficient multi-scale attention module and a first efficient multi-scale channel attention module; in the P5 / 32-large scale feature path of the detection head, a second efficient multi-scale attention module and a second efficient multi-scale channel attention module are sequentially connected after the C3k2 module.
[0012] As a preferred embodiment of the weed detection method of the present invention, wherein: the first efficient multi-scale attention module receives the 1024-dimensional feature map output by the C2PSA module in the backbone network, and performs channel and spatial attention weighting on it to focus on key features and suppress background noise; the first efficient multi-scale channel attention module performs multi-scale contextual information capture and fusion on the weighted feature map.
[0013] As a preferred embodiment of the weed detection method of the present invention, the second efficient multi-scale attention module and the second efficient multi-scale channel attention module are used to refine and enhance the deep high semantic features in the detection head that will be used for prediction, so as to enhance the model's feature representation ability for large-scale and dense weed groups.
[0014] As a preferred embodiment of the weed detection method of the present invention, the enhanced preprocessing operation includes at least one of the following: random rotation, brightness and contrast adjustment, Mosaic data enhancement, random affine transformation, and color space enhancement.
[0015] As a preferred embodiment of the weed detection method of the present invention, the model training adopts a cosine annealing learning rate scheduling strategy; the loss function used for model training is a composite loss function that includes classification loss and confidence loss.
[0016] As a preferred embodiment of the weed detection method of the present invention, the classification loss is FocalLoss or Varifocal Loss.
[0017] In a preferred embodiment of the weed detection method of the present invention, the output of the weed category and location information model is subjected to non-maximum suppression processing to remove redundant detection boxes and obtain the final weed detection result.
[0018] As a preferred embodiment of the weed detection method of the present invention, a weed intelligent identification system based on an improved YOLOv11 model includes: The model building module is used to build the improved YOLOv11 model as described above.
[0019] The data processing module is used to perform the dataset preparation and enhancement operations as described above.
[0020] The model training module is used to perform the model training process as described above.
[0021] The weed recognition module is used to load the trained model and perform the weed recognition process as described above on the input image.
[0022] In a preferred embodiment of the weed detection method of the present invention, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method described above.
[0023] The beneficial effects of this invention are as follows: The weed detection method of this invention enhances the model's ability to focus on key weed features by introducing an EMA module, effectively suppressing interference from complex backgrounds such as soil and shadows. Combined with the multi-scale convolutional structure of the EMCAM module, it simultaneously captures local details and global contextual information, significantly improving the recognition of small-target weeds, occluded weeds, and weeds with varied morphologies. On public datasets, the accuracy rate for multiple categories reaches or approaches 100%. The dual attention mechanism enhances the model's adaptability to changes in illumination, scale differences, and unknown farmland environments, maintaining stable detection performance under different soil types, humidity, and occlusion conditions. This reduces dependence on large-scale labeled data and enhances its practical value in real, complex farmland. Both the EMA and EMCAM modules adopt a lightweight design, significantly improving accuracy while introducing minimal computational overhead. This allows the improved model to achieve real-time weed detection in embedded devices, drones, or agricultural robots, meeting the technical requirements of precision agriculture for efficient and low-power operation. Attached Figure Description
[0024] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. 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.
[0025] Figure 1 A schematic diagram of the weed identification process according to an embodiment of the present invention is shown; Figure 2 A schematic diagram of the EMA module according to an embodiment of the present invention is shown; Figure 3 A schematic diagram of the weed identification confusion matrix of the improved model in an embodiment of the present invention is shown; Figure 4 A schematic diagram of the weed identification confusion matrix of the improved model according to an embodiment of the present invention is shown; Figure 5 A schematic diagram illustrating the visualization results of weed detection according to an embodiment of the present invention is shown. Detailed Implementation
[0026] To enable those skilled in the art to better understand the present invention, the present invention will be further described in detail below with reference to specific embodiments and accompanying drawings.
[0027] The terminology used in this invention is that which is currently widely used in the art in consideration of the function of the invention; however, these terms may vary according to the intent of those skilled in the art, precedent, or new technology in the art. Furthermore, specific terms may be chosen by the applicant, and in such cases, their detailed meanings will be described in the detailed description of the invention. Therefore, the terms used in this specification should not be construed as simple names, but rather based on their meanings and the overall description of the invention.
[0028] Example 1, referring to Figures 1-2 The first embodiment of the present invention provides a weed detection method based on an improved YOLOv11 model, which includes the following steps: steps S100 to S400.
[0029] S100: Construct an improved YOLOv11 model that integrates efficient multi-scale attention modules and efficient multi-scale channel attention modules in the feature paths of the backbone network end and the detection head to form a dual-attention enhanced feature extraction and fusion mechanism.
[0030] An improvement is made based on the official YOLOv11-n model structure. At the end of the backbone network, immediately after the last C2PSA module, an EMA attention module and an EMCAM module are sequentially embedded. In the feature pyramid network of the detector head, on the branch corresponding to the P5 / 32-large output scale, after the last C3k2 module, a second EMA module and a second EMCAM module are also sequentially embedded, thus constructing an improved YOLOv11 model with dual attention enhancement.
[0031] S200: Prepare a dataset of farmland weed images, and perform annotation and augmentation preprocessing on the dataset. Collect farmland images containing various common weeds (such as barnyard grass, crabgrass, and amaranth). Use tools such as Labelling to annotate the bounding boxes and categories of the weeds, generating YOLO format label files. Randomly divide the annotated dataset into training, validation, and test sets in an 8:1:1 ratio.
[0032] S300: Train the improved YOLOv11 model using the dataset to obtain a trained weed recognition model. Initialize the model using YOLOv11-n weights pre-trained on the COCO dataset. Set the batch size to 16, the initial learning rate to 0.01, and use the SGD optimizer with a momentum of 0.937 and weight decay of 0.0005. Train for 300 epochs using a cosine annealing learning rate scheduler.
[0033] S400: Input the farmland image to be detected into the trained weed recognition model, and output the weed category and location information. Adjust the farmland image to be detected (e.g., an image taken by a drone during inspection) to 640x640 pixels and input it into the trained model. The model outputs the category confidence score and bounding box coordinates for each detection box. Finally, apply a non-maximum suppression algorithm, setting the confidence threshold to 0.5 and the intersection-over-union (IoU) threshold to 0.45, to obtain the final list of weed detection results.
[0034] In one specific implementation, the backbone network of the improved YOLOv11 model is sequentially connected to a first efficient multi-scale attention module and a first efficient multi-scale channel attention module; in the P5 / 32-large scale feature path of the detection head, a second efficient multi-scale attention module and a second efficient multi-scale channel attention module are sequentially connected after the C3k2 module.
[0035] In the backbone network, the feature map size output by the last C2PSA module is [size missing]. (input) (For example). Immediately after this, connect the first EMA module and set its input / output channels to 1024. Then, directly input the output of the first EMA module to the first EMCAM module, setting its in_channels=1024 and out_channels=1024. In the detection head, on the P5 / 32-large branch path responsible for large target detection, locate the last C3k2 module of that path. After its output, sequentially connect the second EMA module (channels=1024) and the second EMCAM module (in_channels=1024, out_channels=1024). The enhanced feature map from this branch will be directly used in subsequent detection convolutional layers.
[0036] In one specific implementation, the first efficient multi-scale attention module receives the 1024-dimensional feature map output by the C2PSA module in the backbone network and performs channel and spatial attention weighting on it to focus on key features and suppress background noise; the first efficient multi-scale channel attention module performs multi-scale contextual information capture and fusion on the weighted feature map.
[0037] Specifically, the internal processing flow of the first EMA module and the first EMCAM module embedded at the end of the backbone network is implemented as follows: The first EMA module receives a 1024-dimensional feature map from C2PSA. This module first reduces the dimensionality through a 1x1 convolution, then uses multiple depthwise separable convolutions with different dilation rates in parallel to extract multi-scale spatial features. Next, the importance weights of each channel are calculated and weighted through a channel attention submodule. Finally, the feature map is added to the input feature map through a shortcut connection to achieve key feature enhancement and background suppression.
[0038] The first EMCAM module receives the feature map processed by the EMA module. This module contains three parallel convolutional branches, each using... The convolutional kernels are grouped to capture contextual information from different receptive fields. The outputs of each branch are fused together by concatenation, and then processed by a... The number of channels is adjusted by convolution and added to the module input via a shortcut connection, ultimately outputting an enhanced feature map that incorporates multi-scale weed contextual information.
[0039] In one specific implementation, the second efficient multi-scale attention module and the second efficient multi-scale channel attention module are used to refine and enhance the deep high semantic features in the detection head that will be used for prediction, so as to strengthen the model's ability to represent features of large-scale and dense weed populations.
[0040] Specifically, the second EMA module and the second EMCAM module embedded in the P5 path of the detection head are implemented as follows: The feature map of this path has the strongest semantic information but the lowest spatial resolution. The second EMA module further refines the deep semantic features, focusing on global feature patterns related to weed categories. The second EMCAM module then performs multi-scale fusion enhancement on these refined high-dimensional features, particularly emphasizing the integration of features that can be captured from a large receptive field and are related to the overall morphology of "dense weed clusters" or "large weeds". The sequential processing of these two modules ensures that the features input to the final detection layer (i.e., the subsequent convolutional prediction layer) are fully optimized and the most comprehensive representations, thereby directly improving the detection accuracy of large targets and groups of targets.
[0041] In one specific implementation, the enhanced preprocessing operation includes at least one of the following: random rotation, brightness and contrast adjustment, Mosaic data enhancement, random affine transformation, and color space enhancement.
[0042] During the data preparation phase, online data augmentation was performed on the training set images using the Albumentations or TorchVision library. Specific operations included: randomly rotating the images within the range of [-15°, 15°]; randomly adjusting brightness (coefficient range 0.8-1.2) and contrast (coefficient range 0.8-1.2); during training, randomly selecting four images per batch, scaling and stitching them into a new image, and adjusting the bounding box labels accordingly to simulate complex scenes and increase small target samples; random affine transformations including random translation (up to 10%), scaling (0.9-1.1x), and cropping (up to 5°); and randomly adjusting saturation (coefficient 0.5-1.5) and hue (offset ±0.1) in the HSV color space.
[0043] In one specific implementation, the model training employs a cosine annealing learning rate scheduling strategy; the loss function used for model training is a composite loss function that includes classification loss and confidence loss.
[0044] During model training, the optimization strategy specifically includes cosine annealing learning rate scheduling and a composite loss function. The `torch.optim.lr_scheduler.CosineAnnealingLR` scheduler is used. `T_max` is set to the total number of epochs (e.g., 300), and `eta_min` is set to the minimum learning rate (e.g., 0.0001). The learning rate starts at an initial value of 0.01 and decreases according to a cosine function curve to `eta_min` as the number of epochs increases. The total model loss `L_total` is a weighted sum of the classification loss `L_cls`, the bounding box regression loss `L_box`, and the object confidence loss `L_obj`. `L_box` uses CIoU Loss, and `L_obj` uses BCEWithLogitsLoss.
[0045] In one specific implementation, the classification loss is either Focal Loss or Varifocal Loss. The specific implementation of the classification loss L_cls is chosen from one of the two options. Option A (Focal Loss): Focal Loss is used to address the class imbalance problem. The focusing parameter alpha is set to 0.25, and the modulation factor gamma to 2.0. This loss function reduces the weight of easily classified samples (such as background), making the training focus more on the difficult-to-classify weed samples. Option B (Varifocal Loss): Varifocal Loss is used. This loss function uses an asymmetric weighting method, weighting positive samples (weeds) with the target score (IoU-aware classification score) and using reduced weights for negative samples, thereby more accurately optimizing the classification branch.
[0046] In one specific implementation, the output of the weed category and location information model is subjected to non-maximum suppression processing to remove redundant detection boxes and obtain the final weed detection result.
[0047] In the weed identification step, during post-processing, the model generates a large number of predicted bounding boxes for a single image. A non-maximum suppression algorithm is used for filtering: First, all predicted bounding boxes with a confidence level below a preset threshold (e.g., 0.25) are filtered out. The remaining boxes are grouped by category. For each category, they are sorted from highest to lowest confidence level. The bounding box with the highest confidence level is used as the baseline, and its intersection-union ratio (IoU) with other bounding boxes in the same category is calculated. All bounding boxes with an IoU greater than a set threshold (e.g., 0.45) with the baseline are removed, as these boxes are likely pointing to the same object. From the remaining bounding boxes, the next bounding box with the highest confidence level is selected as the new baseline, and the steps are repeated until all bounding boxes in that category have been processed. After performing the above operations on all categories, the remaining predicted bounding boxes are the final, non-redundant weed detection results.
[0048] Example 2: Based on Example 1 above, this example provides a more detailed description of the technical solution of this application in conjunction with practical applications.
[0049] Step 1: Data Preparation and Augmentation. 3000 labeled images from the publicly available dataset "DeepWeeds" were used, containing 10 common weed species including Cralbgrass, Ragweed, and Eclipta. These images were randomly divided into a training set (2400 images), a validation set (300 images), and a test set (300 images) in an 8:1:1 ratio.
[0050] During training, the following enhancements are applied in real-time to each batch of data to improve the model's generalization ability: Four training images are randomly selected, randomly scaled, cropped, and rearranged before being stitched together into a new image to simulate a complex scene. Random rotation (±15°), random translation (±10%), random scaling (0.9-1.1x), and random adjustments to saturation (S factor 0.5-1.5) and brightness (V factor 0.5-1.5) in the HSV color space are applied. These transformations are achieved through an image affine transformation matrix.
[0051] Step 2: Construction of the improved YOLOv11 model. At the end of the backbone network, after the last C2PSA module (output feature map dimension C=1024), the first EMA module and the first EMCAM module are embedded sequentially. The core of the first EMA module is a cross-dimensional attention mechanism. For the input feature map... First through 11 Dimensionality reduction is achieved through convolution, followed by capturing spatial and channel relationships through grouped convolution and pooling operations to generate an attention weight map. The output feature map is calculated as follows:
[0052] in, This represents element-wise multiplication. The activation function is sigmoid. This process enhances feature channels associated with weeds and suppresses background interference such as soil.
[0053] The first EMCAM module receives the feature map. Through three parallel convolutional branches (kernel sizes are respectively) Extract multi-scale features. Branch outputs are concatenated and... After convolutional fusion, the result is added to the short-circuit connections to finally output the feature map. The formula can be simplified to:
[0054] This module significantly enhances the ability to perceive the context of weeds at different scales.
[0055] In the detection head structured with Feature Pyramid Network (FPN) and Path Aggregation Network (PAN), for feature paths at the P5 / 32-large (large target detection) scale, a second EMA module and a second EMCAM module are sequentially embedded after the last C3k2 module. The structure of these two modules is consistent with that in the backbone network, but they operate on deeper, more semantically powerful features. The second EMA module further refines the deep features, while the second EMCAM module enhances the feature fusion for large-scale weeds and dense clusters, ensuring optimal features input to the final detection layer.
[0056] Step 3: Model Training and Optimization. Using the PyTorch framework, load the pre-trained YOLOv11-n weights from the COCO dataset for transfer learning. Set the batch size to 16 and the initial learning rate... Set to 0.01, use the SGD optimizer (momentum 0.937, weight decay 5e-4). Total loss For bounding box loss Target confidence loss Weighted sum of classification loss The announcement is as follows:
[0057] in, =0.05, =0.05, =0.7. CIoU Loss is adopted, taking into account the overlap area, center point distance and aspect ratio. The binary cross-entropy loss (BCEWithLogitsLoss) is adopted. Varifocal Loss (VFL) is employed, an improvement over standard Focal Loss, which better handles imbalanced positive and negative samples and correlates classification scores with localization quality (IoU). For the predicted classification score... And target IoU score (Positive samples represent IoU, negative samples represent 0), and the formula is:
[0058] In this embodiment, α=0.75 and γ=2.0 are set.
[0059] A cosine annealing strategy is employed. During the total training cycle... =Learning rate over 300 epochs From the following formula Attenuation to minimum value =0.0001, the formula is as follows:
[0060] Step 4: Weed Identification and Post-processing. The farmland image to be detected is scaled up to... Then, input the trained model. The model outputs a prediction tensor, which includes the bounding box coordinates ( ), confidence level and scores for each category ( ).
[0061] Post-processing - Non-maximum suppression (NMS). First, based on the overall score (confidence level)... With the highest category score Filter low-scoring boxes using the product of their scores. For the remaining boxes, group them by category. For each category, sort them in descending order of their overall score. Select the highest-scoring box M as the baseline and calculate its score against all other boxes in the same category. Intersection over Union (IoU):
[0062] Remove all frame (This embodiment sets a threshold) =0.45). Select the next highest-scoring bounding box from the remaining boxes as the new baseline, and repeat the above calculation and removal process until all processing is complete. The bounding boxes retained after NMS processing are the final, non-redundant weed detection results (e.g., ...). Figure 5 (The visualization results of weed detection are shown below).
[0063] A weed intelligent recognition system based on an improved YOLOv11 model is implemented through software modules on a computer or embedded device. Specifically, it includes: a model building module, which is a configuration parsing and network building program that reads a YAML-formatted model configuration file containing the improved YOLOv11 model and dynamically generates the corresponding improved YOLOv11 model computation graph using a deep learning framework (such as PyTorch). A data processing module contains two sub-modules: an offline augmentation sub-module, used to perform various augmentation operations on the dataset before training and save the data; and an online loading sub-module, responsible for reading images and labels from disk during training or inference and performing normalization, padding, and other standardization processes. A model training module is a training script that calls the model building module to instantiate the model, calls the data processing module to obtain the data loader, and performs multiple rounds of iterative training according to the optimizer, loss function, and learning rate scheduling strategy set in the weed detection method, periodically evaluating and saving the best weights on the validation set. A weed recognition module is a deployment interface that loads the best weight file produced by the model training module and initializes the model. It provides the detect(image) function, which accepts one or more image inputs, internally performs the forward inference and post-processing process in grass detection methods, and finally returns the structured detection results (including category, confidence, and coordinates).
[0064] A computer-readable storage medium, such as a USB flash drive, solid-state drive, or server disk, stores a computer program. This program contains processor-executable instructions that, when executed, control a computer system to perform the following operations sequentially: A pre-written model building code and configuration file are loaded from a specified path on the medium, instantiating an improved YOLOv11 model in memory. The trained model weight file (.pt or .pth format) is loaded from the medium, and its parameters are loaded into the instantiated model. Image data of the farmland to be detected is read from a specified folder on the medium or via a connected camera interface. The forward propagation method defined in the model is invoked to process the input image. The non-maximum suppression algorithm code integrated into the program is executed to post-process the model output. The processed result (such as an image file with bounding boxes or a text list of detection results) is saved to another specified path on the medium or displayed on the computer screen. The program is written in Python and primarily relies on open-source libraries such as PyTorch and OpenCV, ensuring the feasibility and reproducibility of the method.
[0065] The beneficial effects of this invention have been verified through rigorous comparative experiments. On the same farmland weed test set, the improved model significantly improved the mean accuracy (mAP@0.5) from 87.2% to 94.5% compared to the baseline YOLOv11-n model, with the recall rate for detecting small target weeds increasing by approximately 15%, effectively solving the problem of missed detections; from the classification confusion matrix (compared to...) Figure 3 and Figure 4 As can be seen, the classification accuracy after parameter adjustment is better than before. Before adjustment, the classification accuracy of Eclipta and Prickly Sida was below 90%, while the classification accuracy of Cralbgrass and Ragweed was higher but not 100%. After adjustment, the classification accuracy of Eclipta and Prickly Sida reached 91% and 93% respectively, and the classification accuracy of Cralbgrass and Ragweed reached 100%. Only two of the ten weed categories showed a slight decrease in accuracy, while the classification accuracy of the remaining eight categories improved, with significant improvements in Eclipta and Prickly Sida. In terms of computational efficiency, the lightweight dual-attention module introduced in the improvement only brings negligible additional overhead, allowing the model to maintain a high real-time inference speed of 28 FPS on edge devices such as the NVIDIA Jetson AGX Xavier. Furthermore, the model performs well in diverse real-world field scenarios (including different lighting conditions, soil moisture, and partial shading, such as...). Figure 5 The weed detection visualization results show stable and robust recognition performance, fully demonstrating its strong generalization ability and practical application value.
[0066] It is important to note that the constructions and arrangements of this application shown in several different exemplary embodiments are merely illustrative. Although only a few embodiments are described in detail in this disclosure, those who consult this disclosure will readily understand that many modifications are possible (e.g., changes in the size, dimensions, structure, shape, and proportions of various elements, as well as parameter values (e.g., temperature, pressure, etc.), mounting arrangements, use of materials, color, orientation, etc.) without substantially departing from the novel teachings and advantages of the subject matter described in this application). For example, an element shown as integrally formed may be composed of multiple parts or elements, the position of elements may be inverted or otherwise altered, and the nature or number or position of discrete elements may be changed or altered. Therefore, all such modifications are intended to be included within the scope of the invention. The order or sequence of any process or method steps may be changed or rearranged according to alternative embodiments. In the claims, any "device plus function" clause is intended to cover the structure described herein that performs the function, and not only structurally equivalent but also equivalent in structure. Other substitutions, modifications, alterations, and omissions may be made in the design, operation, and arrangement of the exemplary embodiments without departing from the scope of the invention. Therefore, the invention is not limited to the specific embodiments, but extends to various modifications that still fall within the scope of the appended claims. Furthermore, for the purpose of providing a concise description of exemplary embodiments, not all features of actual embodiments (i.e., those features not relevant to the currently considered best mode for carrying out the invention, or those features not relevant to implementing the invention) may be omitted.
[0067] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A weed detection method based on an improved YOLOv11 model, characterized in that, Includes the following steps: S100: Construct an improved YOLOv11 model, which integrates efficient multi-scale attention modules and efficient multi-scale channel attention modules in the feature paths of the backbone network end and the detection head to form a dual attention-enhanced feature extraction and fusion mechanism. S200: Prepare a dataset of farmland weed images, and perform annotation and enhancement preprocessing on the dataset; S300: Use the dataset to train the improved YOLOv11 model to obtain a trained weed recognition model; S400: Input the farmland image to be detected into the trained weed recognition model, and output the category and location information of the weeds.
2. The weed detection method according to claim 1, characterized in that, The improved YOLOv11 model has a first efficient multi-scale attention module and a first efficient multi-scale channel attention module connected sequentially at the end of the backbone network; in the P5 / 32-large scale feature path of the detection head, a second efficient multi-scale attention module and a second efficient multi-scale channel attention module are connected sequentially after the C3k2 module.
3. The weed detection method according to claim 2, characterized in that, The first efficient multi-scale attention module receives the 1024-dimensional feature map output by the C2PSA module in the backbone network and performs channel and spatial attention weighting on it to focus on key features and suppress background noise; the first efficient multi-scale channel attention module performs multi-scale contextual information capture and fusion on the weighted feature map.
4. The weed detection method according to claim 2, characterized in that, The second high-efficiency multi-scale attention module and the second high-efficiency multi-scale channel attention module are used to refine and enhance the deep high-semantic features in the detection head that will be used for prediction, so as to strengthen the model's ability to represent features of large-scale and dense weed groups.
5. The weed detection method according to claim 1, characterized in that, The enhanced preprocessing operations include at least one of the following: random rotation, brightness and contrast adjustment, Mosaic data enhancement, random affine transformation, and color space enhancement.
6. The weed detection method according to claim 1, characterized in that, The model training employs a cosine annealing learning rate scheduling strategy; the loss function used in the model training is a composite loss function that includes classification loss and confidence loss.
7. The weed detection method according to claim 6, characterized in that, The classification loss is either Focal Loss or Varifocal Loss.
8. The weed detection method according to claim 1, characterized in that, The output of the weed category and location information model is processed by non-maximum suppression to remove redundant detection boxes and obtain the final weed detection results.
9. A weed intelligent identification system based on an improved YOLOv11 model, characterized in that, include: A model building module for building an improved YOLOv11 model in the method as described in any one of claims 1 to 7; The data processing module is used to perform the dataset preparation and enhancement operations as described in claim 1 or 5; A model training module for performing the model training process as described in claim 1, 6 or 7; A weed recognition module is used to load a trained model and perform the weed recognition process as described in claim 1 or 8 on the input image.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1 to 8.