Field weed identification method

By improving the SH-Yolov8 model, introducing attention mechanism and DCNv3 technology, and using MPDIoU loss function, the problem of insufficient field weed recognition performance in the existing technology in small and medium-sized target weed recognition and complex background is solved, and higher recognition accuracy and model stability are achieved.

CN119851253APending Publication Date: 2025-04-18SHANGHAI DIANJI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411926944.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

The prior art lacks performance in field weed recognition in small-target and complex contexts, especially in terms of robustness.

Method used

By improving the SH-Yolov8 model, introducing attention mechanism and DCNv3 technology, the model capture capability and adaptive spatial aggregation capability are improved, and the model structure is optimized by using MPDIoU loss function to reduce redundant calculations and improve convergence speed.

Benefits of technology

It improves the recognition ability of small-target weeds and the recognition accuracy of field weeds in complex backgrounds, enhances the stability and robustness of the model, and speeds up the model training process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119851253A_ABST
    Figure CN119851253A_ABST
Patent Text Reader

Abstract

The invention relates to a field weed identification method, the method uses an improved SH-Yolov8 model to carry out field weed identification based on a collected image, the SH-Yolov8 model comprises a backbone network, a neck network and a head network, and the backbone network introduces an attention mechanism and a deformable convolutional network on the basis of Yolov8; according to the head network, MPDIOU is introduced on the basis of Yov8 to improve a loss function. Compared with the prior art, the field weed identification accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to computer vision technology, and in particular to a method for identifying weeds in a field. Background Art

[0002] In modern agricultural production, weed management is one of the key factors affecting crop yield and quality. Weeds not only compete with crops for water and nutrients in the soil, but may also become hosts for pests and pathogens, directly affecting crop growth and yield. The current weed control scheme that widely relies on chemical herbicides is in urgent need of finding more efficient and environmentally friendly weed control methods due to its environmental pollution and potential risks to human health. In the prior art, target detection technology based on deep learning has been widely used in the field of weed recognition. The YOLO series of algorithms solves object detection as a regression problem. In the prior art, YOLO is often improved to achieve more accurate weed recognition. Common improvement methods include optimization of algorithm model structure, fusion of attention mechanism, improvement of preprocessing technology, and adjustment of activation function and training strategy, so as to better adapt to complex and changeable detection environments and improve its ability to capture key information. However, it still has shortcomings in the recognition of small target weeds, and when it is applied to complex background situations, the robustness of the model needs to be improved.

[0003] Therefore, providing a method that can improve the performance of small target weed recognition and YOLO in complex field weed recognition is a problem that needs to be solved. Summary of the invention

[0004] The purpose of the present invention is to provide a field weed identification method in order to overcome the defects of the above-mentioned prior art, utilize the improved SH-Yolov8 model to achieve high-precision field weed identification, and introduce the attention mechanism and DCNv3 technology to improve the capture ability and adaptive spatial aggregation ability of the model. At the same time, the MPDIoU loss function is used to optimize the model structure to reduce redundant calculations and improve the convergence speed.

[0005] The purpose of the present invention can be achieved by the following technical solutions:

[0006] The invention provides a method for identifying weeds in a field. The method uses an improved SH-Yolov8 model to identify weeds in a field based on collected images. The SH-Yolov8 model comprises a backbone network, a neck network and a head network. The backbone network introduces an attention mechanism and a deformable convolutional network on the basis of Yolov8. The head network introduces MPDIoU on the basis of Yolov8 to improve the loss function.

[0007] As a preferred technical solution, the attention mechanism includes: (2d-1)×(2d-1) depth convolution, (K / d)×(K / d) depth expansion convolution and 1×1 convolution, where d represents the expansion rate and K represents the convolution kernel size of the attention mechanism convolution layer.

[0008] As a preferred technical solution, the method comprises: collecting weed images and performing image preprocessing; based on the preprocessed images, using the SH-Yolov8 model to output field weed recognition results.

[0009] As a preferred technical solution, the method of outputting field weed identification results using the SH-Yolov8 model includes:

[0010] Extracting features based on the preprocessed image, and performing a deformable convolution operation on the features using a deformable convolutional network to obtain a feature map;

[0011] Based on the feature map, the attention mechanism is used to process and obtain an output feature map;

[0012] Based on the output feature map, using the neck network to perform feature extraction and feature fusion to obtain a fused feature map;

[0013] The head network receives and processes the fused feature map, and outputs a field weed recognition result.

[0014] As a preferred technical solution, the expression of the deformable convolution operation is:

[0015]

[0016] Among them, p o Represents the current position of the regular convolution predefined grid sampling; y(p o ) represents the feature map; G represents the total number of aggregation groups; g represents the g-th group aggregation; K represents the total number of sampling points; k represents the k-th sampling point; w g represents weight; m gk A scalar representing the kth sampling point in the gth group; x g represents the characteristics of the g-th group aggregation; p k represents the kth position of the regular convolution predefined grid sampling; Δp gk Indicates the offset of the sampling position corresponding to the g-th group of grids.

[0017] As a preferred technical solution, the expression processed using the attention mechanism is:

[0018]

[0019] Among them, H represents the height of the feature map; W represents the width of the feature map; * represents convolution; represents the Hadamard product; d represents the dilation rate; represents the deep convolution output; k represents the maximum receptive field; A C represents the attention map; F C Represents a feature map; Represents the output feature map.

[0020] As a preferred technical solution, the training process of the SH-Yolov8 model includes:

[0021] Construct a model training data set and divide it into training set, validation set and test set according to the preset ratio;

[0022] Multiple image data in the training set are randomly selected and input into the SH-Yolov8 model, the predicted weed recognition results are output, and the loss function based on MPDIoU is used to calculate the loss between the predicted weed recognition results and the actual results. The expression is:

[0023]

[0024] Among them, A and B represent the predicted weed identification result and prediction result, respectively; The coordinates of the upper left corner of the rectangular box representing the predicted weed recognition result; The coordinates of the upper left corner of the rectangular box representing the predicted weed recognition result; The coordinates of the upper left corner of the rectangular box representing the true result; The coordinates of the upper right corner of the rectangular box representing the true result; d represents the distance; w represents the width of the rectangular box; h represents the height of the rectangular box; MPDIoU represents the loss value;

[0025] Optimize the parameters of the SH-Yolov8 model based on the loss values ​​and evaluate the model performance;

[0026] Based on the results of the model performance evaluation, the best performing parameters are selected.

[0027] As a preferred technical solution, the model training data set includes a weed data set and a self-built data set; the method for constructing the model training data set is:

[0028] Collect existing weed images to generate a weed dataset;

[0029] The image acquisition device is fixed vertically at a preset height of the ground to be collected, and the weed images in the ground to be collected are collected to generate a self-built data set;

[0030] Integrate the weed data set to build a self-built data set, and classify the data in the integrated data set according to requirements;

[0031] The classified data set is preprocessed to generate a model training data set.

[0032] As a preferred technical solution, the pretreatment method is:

[0033] Scaling the weed image to a preset size to obtain a first image;

[0034] The first image is enhanced to complete the preprocessing.

[0035] As a preferred technical solution, the enhancement processing includes salt and pepper noise, brightness, grayscale, rotation and random cropping and splicing.

[0036] Compared with the prior art, the present invention introduces an attention mechanism and a deformable convolutional network into the backbone network of YOLOv8 on the basis of YOLOv8, thereby improving the capture ability and adaptive spatial aggregation ability of the improved SH-Yolov8 model, improving its ability to identify small target weeds, enhancing its accuracy in processing field weeds under complex backgrounds and the stability of the SH-Yolov8 model; and adopts the MPDIoU loss function in the head network of YOLOv8 to optimize the model structure, so as to reduce redundant calculations, improve the convergence speed, and accelerate the model training process. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 A data bar chart of a model training data set of the present invention;

[0038] Figure 2 It is a line graph of the multi-model experimental results of the present invention;

[0039] Figure 3 The figure is a flow chart of the method of the present invention. DETAILED DESCRIPTION

[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0041] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantitative limitation, and may represent the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0042] The particularity of the spinach field environment, such as the large change in lighting conditions and the similarity in morphology between weeds and spinach, increases the difficulty of identifying weeds in the spinach field. In order to solve this problem, the present invention provides a method suitable for identifying weeds in spinach fields. The traditional YOLOv8 is improved to an SH-Yolov8 model and the SH-Yolov8 model is trained. The trained SH-Yolov8 model is used to realize weed identification in the spinach field.

[0043] The SH-Yolov8 model has the same structure as the traditional Yolov8 model, including the backbone network, the head network and the neck network. The difference is that the SH-Yolov8 model makes three improvements on the basis of the Yolov8 model, including a) introducing the DCNv3 deformable convolutional network, b) introducing the LSKA attention mechanism and c) introducing MPDIoU to improve the loss function.

[0044] a) Introducing DCNv3 deformable convolutional network:

[0045] In order to cope with the phenomenon of a large number of overlapping samples in the data set, DCNv3 is introduced into the backbone network of YOLOv8 to make up for the shortcomings of traditional convolution in long-distance modeling and adaptive spatial aggregation capabilities and reduce the amount of computation.

[0046] Deformable Convolutional Networks (DCN) are mainly used for target detection in complex environments, especially when the target to be detected is irregular in shape or has occlusion or overlap. It is very suitable for extracting some weeds that are very similar to spinach and overlap and interlace. It introduces long-distance dependency and adaptive spatial aggregation capabilities into conventional convolution, and extends conventional convolution, allowing convolution to adaptively adjust its receptive field to better capture long-distance dependency and complex spatial changes. By giving the input x and the current pixel point, the convolution operation is no longer fixed, and the offset is learned to dynamically adjust the sampling position according to the input features. DCNv3 is the result of the third generation of the deformable convolutional network iteration. To a certain extent, it avoids the efficiency limitations of extracting features and adapting to certain extreme structures, and further improves the performance of identifying occluded targets. Compared with the previous two generations, the new deformable convolutional network has three main characteristics:

[0047] (1) Convolutional neurons share weights. The linear projection weights of convolutional neurons in DCNv2 are independent of each other, similar to general convolution operations. This results in the number of parameters and memory complexity being linearly related to the total number of sampling points, which reduces the efficiency when DCN is applied to large-scale models. To this end, we consider borrowing the concept of separable convolution and decomposing the original convolution weights into depth and points. The depth is controlled by a position-aware modulation scalar, and the points are composed of shared projection weights between sampling points.

[0048] (2) Introducing the multi-head mechanism. The multi-head design was first proposed in group convolution and has been widely used in the Transformer's multi-head self-attention mechanism (MHSA), which extracts rich information from representation subspaces at different positions through adaptive spatial aggregation. Through a similar design, different groups on a single convolutional layer in DCNv3 can achieve different spatial aggregation modes, providing enhanced feature expression for downstream tasks.

[0049] (3) Normalize the sampling points of the modulation scalar. In DCNv2, the modulation scalar is normalized by applying the sigmoid function element by element, so that the value range of each modulation scalar is between 0 and 1. Therefore, the sum of the modulation scalars of all sampling points always fluctuates between 0 and a certain value, which will cause the problem of gradient instability when encountering large-scale parameter and data training. For this reason, softmax normalization is used to replace the original method.

[0050] b) Introducing LSKA attention mechanism:

[0051] In order to improve the ability to extract key features of the target and reduce the interference when the field background color is close to the target, the LSKA attention mechanism is introduced on the SPPF module of the YOLOv8 backbone network.

[0052] In the field of computer vision, especially in target detection tasks, incorporating an attention mechanism is one of the key strategies to improve model performance. An attention mechanism that meets the needs of task design can enable the model to focus more effectively on the key parts of the input data, thereby improving the model's processing efficiency and prediction accuracy. This type of mechanism is mainly used to enhance the model's sensitivity to specific areas or features of the input data, giving the model the ability to automatically identify and prioritize parts with rich information content. The Large Separable Kernel Attention (LSKA) mechanism effectively reduces the impact of background noise on target detection performance by capturing long-distance dependencies and improving adaptive processing capabilities, demonstrating the potential to maintain model performance in complex environments. It optimizes the model's attention allocation and improves responsiveness to key features, providing a new way to achieve efficient and accurate target detection.

[0053] In the present invention, the K×K convolution is first decomposed into (2d-1)×(2d-1) depth convolution, (K / d)×(K / d) depth expansion convolution and 1×1 convolution, and then the 2D depth convolution kernel and the depth expansion convolution kernel are further decomposed into 1D horizontal (transverse) convolution kernel and vertical (longitudinal) convolution kernel. Finally, the decomposed convolution kernels are connected in series, where d is the expansion rate and K is the convolution kernel size of the convolution layer in LSKA.

[0054] c) Introduce MPDIoU to improve the loss function:

[0055] In order to solve the problems of slow convergence and excessive redundant calculation when the aspect ratio of the predicted box and the real box is the same in the loss function, MPDIoU is introduced in the head network of YOLOv8 to improve the loss function.

[0056] In object detection, the bounding box regression loss function based on the intersection over union (IoU) is often used to determine the precise position of the object in the image. Generally, the size and position of a rectangular box are uniquely determined by determining the coordinates of the upper left and lower right points. The traditional IoU measurement method cannot distinguish the situation where two bounding boxes do not overlap. When the two boxes have no intersection, the IoU value is 0, which limits its ability to describe the distance between boxes. In order to overcome this limitation, GIoU (Generalized-IoU) is introduced. On the basis of traditional IoU, the minimum closed area containing two boxes is further considered to penalize the non-overlapping situation. The calculation is based on the difference between the closed area and the union. DIoU (Distance-IoU) introduces the distance between the center points of the box. By subtracting the ratio of the center point distance to the minimum closed box diagonal length from IoU, even when the two boxes do not overlap, the predicted box can be pushed closer to the real box by minimizing the distance between the center points. CIoU (Complete-IoU) further considers the difference in aspect ratio of the bounding box to enhance the accuracy of regression. It not only penalizes the center point distance, but also considers the similarity of shape, so that even if the predicted box has deviations in size and proportion, it can be effectively adjusted. EIoU further adds a direct comparison of the width and height of the predicted box and the true box, taking into account the shape similarity, especially when dealing with scenes with extreme aspect ratios, it can provide a better adjustment strategy. On the basis of the above, in order to solve the problems of poor handling of non-overlapping boxes and over-reliance on threshold selection, the minimum point distance IoU loss function is introduced to simplify the comparison of the similarity between two rectangular boxes. A new loss function is defined, which is applicable to overlapping or non-overlapping situations, encouraging the predicted box to be close to the true box in position, size and shape. For the situation where spinach and weeds overlap more, it speeds up the convergence speed while also improving the detection accuracy.

[0057] In order to enable the SH-Yolov8 model to better identify weeds in the spinach field, it is trained, including the following steps:

[0058] A1. Build a model training dataset and divide it into a training set, a validation set, and a test set. The model training dataset includes a weed dataset and a self-built dataset.

[0059] The method to construct the model training data set is:

[0060] A11. Collect weed images publicly available on the Internet to generate a weed dataset.

[0061] A13. Fix the Intel RealSense D435i depth camera vertically within 30 to 50 cm of the ground to be collected to simulate the actual conditions of weeding equipment. Use an RGB camera with a pixel of 1920×1080 to collect weed images on the ground to be collected and generate a self-built data set.

[0062] A14. Integrate the weed data set to build a self-built data set, and classify the data in the integrated data set as required.

[0063] There are more than 20 common weeds in the model training data set, of which annual weeds account for about 80% of the total and perennial weeds account for 20%. Among them, the dominant species of Poaceae weeds include crabgrass, Setaria viridis, Goosegrass, teff and spontaneous wheat seedlings; the dominant species of broad-leaved weeds include Portulaca oleracea, Rudbeckia retroflexa, Hemp, Ligusticum chuanxiong, Xanthium sibiricum and others; the dominant species of Cyperus family is mainly Cyperus rotundus. In order to meet the development needs of the weed control module as much as possible and improve the robustness of the improved model, the data set images are divided into three types according to the crop growth conditions: sparse spinach or weeds, dense spinach or weeds, and spinach and weeds. Each type of growth condition is taken on sunny, rainy and cloudy days. Classification is based on weather conditions and crop growth conditions, and the results are as follows. Figure 1 shown.

[0064] A15. Preprocess the classified data set to generate a model training data set.

[0065] In order to enhance the diversity of the synthetic data set, simulate the actual working scenario of the weeding equipment in the field as much as possible, and avoid the improved model from being too dependent on specific image attributes and reducing the risk of overfitting, the present invention preprocesses the classified data set and uses roboflow for data enhancement. The process is as follows:

[0066] A151, scaling the weed image to 640×640 to obtain a first image;

[0067] A152. Perform Salt and pepper noise, Brightness, Grayscale, Rotate and Mosaic enhancement processing on the first image.

[0068] A153. Use the image visualization annotation tool LabelImg to manually annotate the first image after enhancement processing, save the annotation information in the XML standard format, and the annotation format follows the PASCAL VOC (Visual Object Classes) standard to complete the preprocessing.

[0069] Through steps A11 to A15, the present invention constructs a high-quality image dataset specifically for identifying weeds in spinach fields, which not only takes into account the similarity challenges between crops and weeds, but also makes full use of the complementarity of field photography and network collection data, providing a basis for subsequent model training and verification.

[0070] A16. Divide the model training data set into training set, validation set and test set in a ratio of 70:15:15.

[0071] A2. Randomly select multiple image data from the training set and input them into the SH-Yolov8 model, output the predicted weed recognition results, and use the MPDIoU-based loss function to calculate the loss between the predicted weed recognition results and the true results. The expression is:

[0072]

[0073] Among them, A and B represent the predicted weed identification result and prediction result, respectively; The coordinates of the upper left corner of the rectangular box representing the predicted weed recognition result; The coordinates of the upper left corner of the rectangular box representing the predicted weed recognition result; The coordinates of the upper left corner of the rectangular box representing the true result; The coordinates of the upper right corner of the rectangular box representing the true result; d represents the distance; w represents the width of the rectangular box; h represents the height of the rectangular box; MPDIoU represents the loss value;

[0074] A3. Optimize the parameters of the SH-Yolov8 model based on the loss value and evaluate the model performance. The specific indicators of the model performance evaluation include:

[0075] Precision, which indicates the proportion of weeds in the target at the detection location, is expressed as:

[0076]

[0077] Among them, TP represents the number of weeds; FP represents the number of targets detected incorrectly.

[0078] Recall rate refers to the proportion of detected weeds to all weeds, and its expression is:

[0079]

[0080] Among them, TP represents the number of weeds; FN represents the number of missed detections.

[0081] The F1 score indicates the balance between recall and precision, and is particularly useful when the two may be unbalanced. Its expression is:

[0082]

[0083] Among them, R represents the recall rate and P represents the precision rate.

[0084] Average precision represents the area around the recall curve and the precision curve and the coordinates, and its expression is:

[0085]

[0086] The mean average precision represents the mean of the average precision corresponding to all detection categories. Its calculation method is to first sort the prediction boxes by confidence, then calculate their P and R under each confidence threshold, and then calculate their mean. The expression is:

[0087]

[0088] Where N represents the number of detection categories; AP i Represents the average precision of the i-th detection category.

[0089] Floating point calculation amount, which indicates the total number of floating point calculations per second of the SH-Yolov8 model.

[0090] The number of model parameters indicates the total number of learnable parameters in the SH-Yolov8 model. The larger the value, the more complex the model.

[0091] A4. Based on the results of model performance evaluation, select the best performing parameters.

[0092] In order to verify the feasibility and superiority of the improved SH-Yolov8 model of the present invention, ablation experiments and comparative experiments were performed in this embodiment, wherein:

[0093] i. Ablation experiment:

[0094] To verify the effectiveness of SH-Yolov8, ablation experiments were carried out on each improved module using the constructed model training dataset. The experimental groups were set as follows: in Experiment 1 (baseline experiment), no improved technology (LSKA, DCNv3, MPDIoU) was used; in Experiment 2, LSKA was introduced; in Experiment 3, DCNv3 was further added on the basis of LSKA; in Experiment 4, MPDIoU was added on the basis of Experiment 3, and the data shown in Table 1 were obtained. In the table, “×” indicates that the part is not introduced, and “√” indicates that the part is introduced.

[0095] From the analysis, we can see that for precision and recall, from the baseline experiment to Experiment 4, we can observe that the recall rate increased from 63.9% to 70.2%. Although the precision rate fluctuated slightly, it eventually increased to about 83%, indicating that the overall detection accuracy and coverage have improved. For mAP and F1 scores, mAP increased from 70.3% to 73.4%, and F1 score increased from 0.72 to 0.76, which significantly proved that the model's ability to balance precision and recall has been improved overall. For computational complexity, although it increased from 28.7GFLOPs to 33.1GFLOPs, this increase is reasonable and acceptable considering the significant improvement in performance.

[0096] Table 1 Ablation experiment results

[0097] LSKA DCNv3 MPD P(%) R(%) mAP50(%) F1 GFLOPs × × × 82.3 63.9 70.3 0.72 28.7 √ × × 83 67.1 70.9 0.74 35.9 √ √ × 83.6 64 72.3 0.73 33.1 √ √ √ 83.4 70.2 73.6 0.76 33.1

[0098] ii. Comparative experiment:

[0099] In order to comprehensively evaluate the performance of the proposed model, it is compared with several popular target detection models, including Yolov4-tiny, Yolov5s, Yolov7-tiny and Yolov8s. The results are shown in the figure. Figure 2 As shown in the figure, the analysis shows that for precision and recall, the improved model has achieved 83.4% in precision and 70.2% in recall, both higher than other models. In particular, compared with Yolov8s, the new model has a slight advantage in precision, and the improvement in recall is more significant, which shows that the model can identify more targets more accurately. For the recognition ability of mAP occluded targets, a new lightweight convolution module DCNv3 is introduced to make up for the shortcomings of traditional convolution in long-distance modeling and adaptive spatial aggregation capabilities, and then MPDIoU is introduced to replace the original loss function to solve the problems of slow convergence and excessive redundant calculation when the aspect ratio of the loss function prediction box and the real box is the same. Finally, the improved model is compared with the mainstream target detection algorithm. The experiment shows that the improved model has a synthetic data value of 73.6%, which is ahead of other models. This result further verifies the advantage of the SH-Yolov8 model in detection accuracy. In addition, although the improved model is relatively large in terms of computation and parameter size, 33.1G FLOPs and 15.0Million respectively, which means higher computing resource requirements, this increase is reasonable considering the significant performance improvement.

[0100] In summary, SH-Yolov8 performs well in multiple key performance indicators, especially in recall and mAP50, which fully demonstrates the effectiveness and superiority of the improved model in the task of weed identification in spinach fields. Although the computational complexity and parameter count of the model have increased, this can be considered an acceptable trade-off given the performance improvement it brings. Future work will further optimize the model structure to reduce the demand for computing resources while maintaining or even improving detection performance.

[0101] The process of using the trained SH-Yolov8 model to output the spinach field weed recognition results is as follows: Figure 3 As shown, including:

[0102] S1, collecting weed images and performing image preprocessing;

[0103] S2. Extract features based on the preprocessed image, and use the deformable convolution network to perform a deformable convolution operation on the features to obtain a feature map, where the expression of the deformable convolution operation is:

[0104]

[0105] Where p0 represents the current position of the regular convolution predefined grid sampling; y(p0) represents the feature map; G represents the total number of aggregation groups; g represents the g-th group aggregation; K represents the total number of sampling points; k represents the k-th sampling point; % weight; m gk A scalar representing the kth sampling point in the gth group; x g represents the characteristics of the g-th group aggregation; p k represents the kth position of the regular convolution predefined grid sampling; Δp gk Indicates the offset of the sampling position corresponding to the g-th group of grids.

[0106] S3. Process the feature map using the attention mechanism to obtain an output feature map, where the expression processed using the attention mechanism is:

[0107]

[0108] Among them, H represents the height of the feature map; W represents the width of the feature map; * represents convolution; represents the Hadamard product; d represents the dilation rate; represents the deep convolution output; k represents the maximum receptive field; A C represents the attention map; F C Represents a feature map; Represents the output feature map.

[0109] S4. Based on the output feature map, the neck network is used to perform feature extraction and feature fusion to obtain a fused feature map.

[0110] S5. The head network receives and processes the fused feature map and outputs the field weed recognition result.

[0111] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A method for identifying weeds in a field, characterized in that: The method uses an improved SH-Yolov8 model to identify field weeds based on collected images. The SH-Yolov8 model includes a backbone network, a neck network and a head network. The backbone network introduces an attention mechanism and a deformable convolutional network based on Yolov8; the head network introduces MPDIoU based on Yolov8 to improve the loss function.

2. A method for identifying weeds in a field according to claim 1, characterized in that: The attention mechanism includes: (2d-1)×(2d-1) depth convolution, (K / d)×(K / d) depth expansion convolution and 1×1 convolution, where d represents the expansion rate and K represents the convolution kernel size of the attention mechanism convolution layer.

3. A method for identifying weeds in a field according to claim 1, characterized in that: The method includes: Collect weed images and perform image preprocessing; Based on the preprocessed images, the SH-Yolov8 model is used to output the field weed recognition results.

4. A method for identifying weeds in a field according to claim 3, characterized in that: The method of outputting field weed identification results using the SH-Yolov8 model includes: Extracting features based on the preprocessed image, and performing a deformable convolution operation on the features using a deformable convolutional network to obtain a feature map; Based on the feature map, the attention mechanism is used to process and obtain an output feature map; Based on the output feature map, using the neck network to perform feature extraction and feature fusion to obtain a fused feature map; The head network receives and processes the fused feature map, and outputs a field weed recognition result.

5. A method for identifying weeds in a field according to claim 4, characterized in that: The expression of the deformable convolution operation is: Where p0 represents the current position of the regular convolution predefined grid sampling; y(p0) represents the feature map; G represents the total number of aggregation groups; g represents the g-th group aggregation; K represents the total number of sampling points; k represents the k-th sampling point; w g represents weight; m gk A scalar representing the kth sampling point in the gth group; x g represents the characteristics of the g-th group aggregation; p k represents the kth position of the regular convolution predefined grid sampling; Δp gk Indicates the offset of the sampling position corresponding to the g-th group of grids.

6. A method for identifying weeds in a field according to claim 4, characterized in that: The expression processed using the attention mechanism is: Among them, H represents the height of the feature map; W represents the width of the feature map; * represents convolution; represents the Hadamard product; d represents the dilation rate; represents the deep convolution output; k represents the maximum receptive field; A C represents the attention map; F C Represents a feature map; Represents the output feature map.

7. A method for identifying weeds in a field according to claim 3, characterized in that: The training process of the SH-Yolov8 model includes: Construct a model training data set and divide it into training set, validation set and test set according to the preset ratio; Multiple image data in the training set are randomly selected and input into the SH-Yolov8 model, the predicted weed recognition results are output, and the loss function based on MPDIoU is used to calculate the loss between the predicted weed recognition results and the actual results. The expression is: Among them, A and B represent the predicted weed identification result and prediction result, respectively; The coordinates of the upper left corner of the rectangular box representing the predicted weed recognition result; The coordinates of the upper left corner of the rectangular box representing the predicted weed recognition result; The coordinates of the upper left corner of the rectangular box representing the true result; The coordinates of the upper right corner of the rectangular box representing the true result; d represents the distance; w represents the width of the rectangular box; h represents the height of the rectangular box; MPDIoU represents the loss value; Optimize the parameters of the SH-Yolov8 model based on the loss values ​​and evaluate the model performance; Based on the results of the model performance evaluation, the best performing parameters are selected.

8. A method for identifying weeds in a field according to claim 7, characterized in that: The model training data set includes a weed data set and a self-built data set; the method for constructing the model training data set is: Collect existing weed images to generate a weed dataset; The image acquisition device is fixed vertically at a preset height of the ground to be collected, and the weed images in the ground to be collected are collected to generate a self-built data set; Integrate the weed data set to build a self-built data set, and classify the data in the integrated data set according to requirements; The classified data set is preprocessed to generate a model training data set.

9. A method for identifying weeds in a field according to claim 3, characterized in that: The pretreatment method is: Scaling the weed image to a preset size to obtain a first image; The first image is enhanced to complete the preprocessing.

10. A method for identifying weeds in a field according to claim 9, characterized in that: The enhancement processing includes salt and pepper noise, brightness, grayscale, rotation and random cropping and splicing.