Crop seedling detection method and device

By building a decoupling network and improving the structure of the YOLO target detection model, the residual block and multi-head self-attention mechanism are used to improve the detection accuracy of crop seedlings, and the problem of low detection accuracy in the existing technology is solved, providing support for agricultural production, and improving Crop yields.

CN119478497APending Publication Date: 2025-02-18BEIJING LONGZHI DIGITAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411434054.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-14
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

In the prior art, the detection accuracy of crop seedlings is low, making it difficult to effectively detect small-sized targets.

Method used

Build a decoupled network, combine residual blocks and multi-head self-attention mechanism to build an attention network, and improve the structure of the YOLO object detection model, and use spatial depth conversion convolution layer and decoupled network to improve detection accuracy.

Benefits of technology

The accuracy of crop seedling detection has been improved, the problem of low detection accuracy has been solved, strong support for agricultural production, and crop yield has been improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119478497A_ABST
    Figure CN119478497A_ABST
Patent Text Reader

Abstract

The invention provides a crop seedling detection method and device. The method comprises the following steps: constructing a decoupling network for executing a classification task, a confidence detection task and a positioning task; constructing an attention network by using the residual block and a multi-head self-attention mechanism; the structure of the YOLO target detection model is improved according to the following mode: a space depth conversion convolutional layer is utilized to replace a convolutional layer with a preset step length in a backbone network and a neck network in the YOLO target detection model, an attention network is added at the tail end of the backbone network, and a decoupling network is utilized to replace a head network in the YOLO target detection model; and performing crop seedling detection training on the improved YOLO target detection model, and performing crop seedling detection by using the trained YOLO target detection model. By adopting the technical means, the problem of poor detection precision of the crop seedlings in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of crop yield prediction, and in particular to a method and device for detecting crop seedlings. Background Art

[0002] Drones are widely used in smart agriculture for environmental monitoring and crop growth monitoring. Due to the minimum flight altitude limit, the size of crop seedlings in aerial images is relatively small, which makes the detection task difficult. How to improve the detection accuracy of the detection algorithm for crop seedlings is a major technical problem in the current agricultural production field. Summary of the invention

[0003] In view of this, the embodiments of the present application provide a crop seedling detection method, device, electronic device and computer-readable storage medium to solve the problem of poor detection accuracy of crop seedlings in the prior art.

[0004] According to a first aspect of an embodiment of the present application, a method for detecting crop seedlings is provided, including: constructing a decoupled network for performing classification tasks, confidence detection tasks, and positioning tasks; constructing an attention network using residual blocks and a multi-head self-attention mechanism; improving the structure of a YOLO target detection model in the following manner: replacing the convolutional layers with preset step sizes in a backbone network and a neck network in the YOLO target detection model with a spatial depth conversion convolutional layer, adding an attention network at the end of the backbone network, and replacing the head network in the YOLO target detection model with a decoupled network; training the improved YOLO target detection model for crop seedling detection, and using the trained YOLO target detection model for crop seedling detection.

[0005] According to a second aspect of an embodiment of the present application, a crop seedling detection device is provided, including: a first construction module, configured to construct a decoupled network for performing classification tasks, confidence detection tasks and positioning tasks; a second construction module, configured to construct an attention network using residual blocks and a multi-head self-attention mechanism; an improvement module, configured to improve the structure of a YOLO target detection model in the following manner: replacing the convolutional layers with preset step sizes in the backbone network and the neck network in the YOLO target detection model with spatial depth conversion convolutional layers, adding an attention network at the end of the backbone network, and replacing the head network in the YOLO target detection model with a decoupled network; and a detection module, configured to perform crop seedling detection training on the improved YOLO target detection model, and performing crop seedling detection using the trained YOLO target detection model.

[0006] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.

[0007] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0008] Compared with the prior art, the embodiments of the present application have the following beneficial effects: constructing a decoupled network for performing classification tasks, confidence detection tasks and positioning tasks; constructing an attention network using residual blocks and a multi-head self-attention mechanism; improving the structure of the YOLO target detection model in the following manner: using a spatial depth conversion convolutional layer to replace the convolutional layer with a preset step length in the backbone network and the neck network in the YOLO target detection model, adding an attention network at the end of the backbone network, and using a decoupled network to replace the head network in the YOLO target detection model; training the improved YOLO target detection model for crop seedling detection, and using the trained YOLO target detection model for crop seedling detection. The above-mentioned technical means can solve the problem of poor detection accuracy of crop seedlings in the prior art, thereby improving the detection accuracy of crop seedlings, providing strong support for agricultural production, and increasing crop yields. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0010] Figure 1 It is a schematic diagram of a process of detecting crop seedlings provided in an embodiment of the present application;

[0011] Figure 2 It is a flowchart of a training method for a YOLO target detection model provided in an embodiment of the present application;

[0012] Figure 3 It is a structural schematic diagram of a crop seedling detection device provided in an embodiment of the present application;

[0013] Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0014] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0015] A crop seedling detection method and device according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.

[0016] Figure 1 It is a flow chart of a crop seedling detection method provided in an embodiment of the present application. Figure 1 The crop seedling detection method can be executed by a computer or a server, or software on a computer or a server. Figure 1 As shown, the crop seedling detection method comprises:

[0017] S101, constructing a decoupled network for performing classification tasks, confidence detection tasks, and positioning tasks;

[0018] S102, construct an attention network using residual blocks and multi-head self-attention mechanism;

[0019] S103, improving the structure of the YOLO target detection model in the following manner: using a spatial depth conversion convolutional layer to replace the convolutional layers with preset steps in the backbone network and the neck network in the YOLO target detection model, adding an attention network at the end of the backbone network, and using a decoupled network to replace the head network in the YOLO target detection model;

[0020] S104, performing crop seedling detection training on the improved YOLO target detection model, and performing crop seedling detection using the trained YOLO target detection model.

[0021] YOLO (You Only Look Once) is a popular target detection algorithm known for its high speed and efficiency. YOLO treats target detection as a regression problem and predicts the bounding box and category of the object directly from the image, which enables it to complete the detection task in a single network reasoning process. The YOLO target detection model in the embodiment of the present application can be YOLO v5S. YOLO v5 is the fifth major version of YOLO, and YOLO v5S is a lightweight model in the YOLO v5 series. The spatial depth conversion convolution layer is SPD-Conv (Space-to-Depth Conversion Convolution), which is a convolution operation that aims to improve the performance of convolutional neural networks in processing low-resolution images and small objects by converting spatial information into depth information.

[0022] Crops can be corn, wheat, millet, and rice. Crop seedlings are small-sized targets. Directly using the existing YOLO target detection model for detection is prone to missed detection and has poor results. Using the spatial depth conversion convolution layer to replace the convolution layer with a preset step size in the backbone network and the neck network in the YOLO target detection model, for example, using the spatial depth conversion convolution layer to replace the convolution layer with a step size of 2 can fill the defects of using the convolution step size in the YOLO target detection model, which leads to the loss of fine-grained information and inefficient feature representation learning. Using the residual block and the multi-head self-attention mechanism in the Transformer network to build an attention network, adding an attention network at the end of the backbone network can simultaneously utilize the feature extraction capability of the convolution and the self-attention mechanism of the Transformer, combining the advantages of the two to improve the detection performance. The decoupled network contains three branches, which are used to perform classification tasks, confidence detection tasks, and positioning tasks, respectively. It can solve the problem of conflict between classification and positioning in target detection tasks and improve detection accuracy.

[0023] According to the technical solution provided in the embodiment of the present application, a decoupled network for performing classification tasks, confidence detection tasks and positioning tasks is constructed; an attention network is constructed using residual blocks and a multi-head self-attention mechanism; the structure of the YOLO target detection model is improved in the following manner: a spatial depth conversion convolution layer is used to replace the convolution layer with a preset step length in the backbone network and the neck network in the YOLO target detection model, an attention network is added at the end of the backbone network, and a decoupled network is used to replace the head network in the YOLO target detection model; the improved YOLO target detection model is trained for crop seedling detection, and the trained YOLO target detection model is used for crop seedling detection. The above-mentioned technical means can solve the problem of poor detection accuracy of crop seedlings in the prior art, thereby improving the detection accuracy of crop seedlings, providing strong support for agricultural production, and increasing crop yields.

[0024] Furthermore, a decoupled network for performing classification tasks, confidence detection tasks and positioning tasks is constructed, including: constructing a classification network for performing classification tasks, constructing a confidence detection network for performing confidence detection tasks, and constructing a positioning network for performing positioning tasks; and constructing a decoupled network using the classification network, the confidence detection network and the positioning network.

[0025] Based on the classification task, confidence detection task and positioning task, a classification network, a confidence detection network and a positioning network are constructed respectively. Then, a decoupled network is constructed using the classification network, the confidence detection network and the positioning network. Through the above technical means, the classification network, the confidence detection network and the positioning network in the decoupled network are used to determine the classification results, classification confidence and detection box of the crop seedlings in the image respectively, which can avoid the problem of classification and positioning conflicts in the target detection task.

[0026] Furthermore, a classification network for performing a classification task is constructed, a confidence detection network for performing a confidence detection task is constructed, and a positioning network for performing a positioning task is constructed, including: constructing a common network using a convolutional layer of a first convolutional kernel and a plurality of convolutional layers of a second convolutional kernel; using a convolutional layer of the common network followed by a first convolutional kernel as a classification network; using a convolutional layer of the common network followed by a plurality of first convolutional kernels as a confidence detection network; using a convolutional layer of the common network followed by a plurality of first convolutional kernels as a positioning network.

[0027] For example, the first convolution kernel is 1*1, and the second convolution kernel is 2*2. Connect a 1*1 convolution layer and two 2*2 convolution layers in sequence to get a public network. Use the public network followed by a 1*1 convolution layer as a classification network. Use the public network followed by two 1*1 convolution layers as a confidence detection network; use the public network followed by two 1*1 convolution layers as a positioning network. The public network is the common part of the classification network, confidence detection network, and positioning network. The classification network, confidence detection network, and positioning network each have their own unique convolution layers to determine the classification results, classification confidence, and detection box of the crop seedlings in the image.

[0028] Furthermore, an attention network is constructed using a residual block and a multi-head self-attention mechanism, including: the residual block includes a convolution layer of a first convolution kernel, a convolution layer of a second convolution kernel, a convolution layer of the first convolution kernel, and an addition layer, wherein the addition layer is used to add the input of the residual block and the input of the addition layer; the multi-head self-attention mechanism is used to replace the convolution layer of the second convolution kernel in the residual block to obtain an attention network.

[0029] For example, if the first convolution kernel is 1*1 and the second convolution kernel is 2*2, then the internal structure of the attention network is a 1*1 convolution layer, a multi-head self-attention mechanism, a 1*1 convolution layer, and an addition layer. The input of the attention network is recorded as the fifth image feature map, and the fifth image feature map is processed by a 1*1 convolution layer, a multi-head self-attention mechanism, and a 1*1 convolution layer in turn to obtain the sixth image feature map. The addition layer adds the fifth image feature map and the sixth image feature map to obtain the first image feature map. The first image feature map is the output of the attention network, that is, the output of the improved backbone network.

[0030] Figure 2 is a flow chart of a training method for a YOLO target detection model provided in an embodiment of the present application. Figure 2 As shown, the method includes:

[0031] S201, obtaining training images of crop seedlings, and inputting the training images into the improved YOLO target detection model:

[0032] S202, processing the training image through the improved backbone network to obtain a first image feature map;

[0033] S203, processing the first image feature map through the improved neck network to obtain a second image feature map;

[0034] S204, processing the second image feature map through a decoupling network to obtain a classification result, a classification confidence, and a detection box;

[0035] S205, calculating the losses between the classification result, the classification confidence and the detection box and the annotation result, the annotation confidence and the annotation box respectively, and optimizing the model parameters of the improved YOLO target detection model according to the losses to complete the training of the improved YOLO target detection model.

[0036] In the improved YOLO target detection model, the improved backbone network processes the training image to obtain the first image feature map, the improved neck network processes the first image feature map to obtain the second image feature map, and the classification network, confidence detection network and positioning network in the decoupled network process the second image feature map in turn to obtain the classification result, classification confidence and detection box. The cross entropy loss function is used to calculate the loss between the classification result, classification confidence and detection box and the annotation result, annotation confidence and annotation box, and the model parameters of the improved YOLO target detection model are optimized based on the loss.

[0037] The classification result is the result of whether the object in the detected image is a crop seedling, the detection box is the position of the object in the detected image that is a crop seedling, and the classification confidence is the probability that each object in the detected image is a crop seedling. The labeling result, labeling confidence, and labeling box correspond to the classification result, classification confidence, and detection box, respectively. The labeling result is the result of whether the object in the labeled image is a crop seedling, the detection box is the position of the object in the labeled image that is a crop seedling, and the classification confidence is the probability that each object in the labeled image is a crop seedling.

[0038] Crop seedling detection is performed using a trained YOLO target detection model, including: obtaining a target image of a crop seedling in a target area, inputting the target image into the trained YOLO target detection model: processing the target image through a trained backbone network to obtain a third image feature map; processing the third image feature map through a trained neck network to obtain a fourth image feature map; processing the fourth image feature map through a trained decoupling network to obtain a classification result, a classification confidence and a detection frame.

[0039] The embodiment of the present application is the reasoning side of the model, and the previous embodiment is the training side of the model. The reasoning side of the model corresponds to the training side of the model, so the reasoning side of the model will not be described in detail here.

[0040] In one embodiment, the structure of the YOLO target detection model can also be improved in the following manner: the convolutional layer in the YOLO target detection model is replaced by a combination of a convolutional layer, a batch normalization layer, and an activation function.

[0041] The batch normalization layer is Batch Normalization, and the activation function can use SiLU. The combination of convolutional layer, batch normalization layer and activation function can effectively extract features.

[0042] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.

[0043] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0044] Figure 3 Schematic diagram of a crop seedling detection device provided in an embodiment of the present application. Figure 3 As shown, the crop seedling detection device comprises:

[0045] A first construction module 301 is configured to construct a decoupled network for performing a classification task, a confidence detection task, and a positioning task;

[0046] A second construction module 302 is configured to construct an attention network using a residual block and a multi-head self-attention mechanism;

[0047] The improvement module 303 is configured to improve the structure of the YOLO target detection model in the following manner: using a spatial depth conversion convolution layer to replace the convolution layer with a preset step size in the backbone network and the neck network in the YOLO target detection model, adding an attention network at the end of the backbone network, and using a decoupled network to replace the head network in the YOLO target detection model;

[0048] The detection module 304 is configured to perform crop seedling detection training on the improved YOLO target detection model, and perform crop seedling detection using the trained YOLO target detection model.

[0049] YOLO (You Only Look Once) is a popular target detection algorithm known for its high speed and efficiency. YOLO treats target detection as a regression problem and predicts the bounding box and category of the object directly from the image, which enables it to complete the detection task in a single network reasoning process. The YOLO target detection model in the embodiment of the present application can be YOLO v5S. YOLO v5 is the fifth major version of YOLO, and YOLO v5S is a lightweight model in the YOLO v5 series. The spatial depth conversion convolution layer is SPD-Conv (Space-to-Depth Conversion Convolution), which is a convolution operation that aims to improve the performance of convolutional neural networks in processing low-resolution images and small objects by converting spatial information into depth information.

[0050] Crops can be corn, wheat, millet, and rice. Crop seedlings are small-sized targets. Directly using the existing YOLO target detection model for detection is prone to missed detection and has poor results. Using the spatial depth conversion convolution layer to replace the convolution layer with a preset step size in the backbone network and the neck network in the YOLO target detection model, for example, using the spatial depth conversion convolution layer to replace the convolution layer with a step size of 2 can fill the defects of using the convolution step size in the YOLO target detection model, which leads to the loss of fine-grained information and inefficient feature representation learning. Using the residual block and the multi-head self-attention mechanism in the Transformer network to build an attention network, adding an attention network at the end of the backbone network can simultaneously utilize the feature extraction capability of the convolution and the self-attention mechanism of the Transformer, combining the advantages of the two to improve the detection performance. The decoupled network contains three branches, which are used to perform classification tasks, confidence detection tasks, and positioning tasks, respectively. It can solve the problem of conflict between classification and positioning in target detection tasks and improve detection accuracy.

[0051] According to the technical solution provided in the embodiment of the present application, a decoupled network for performing classification tasks, confidence detection tasks and positioning tasks is constructed; an attention network is constructed using residual blocks and a multi-head self-attention mechanism; the structure of the YOLO target detection model is improved in the following manner: a spatial depth conversion convolution layer is used to replace the convolution layer with a preset step length in the backbone network and the neck network in the YOLO target detection model, an attention network is added at the end of the backbone network, and a decoupled network is used to replace the head network in the YOLO target detection model; the improved YOLO target detection model is trained for crop seedling detection, and the trained YOLO target detection model is used for crop seedling detection. The above-mentioned technical means can solve the problem of poor detection accuracy of crop seedlings in the prior art, thereby improving the detection accuracy of crop seedlings, providing strong support for agricultural production, and increasing crop yields.

[0052] In some embodiments, the first construction module 301 is further configured to construct a classification network for performing classification tasks, construct a confidence detection network for performing confidence detection tasks, and construct a positioning network for performing positioning tasks; and construct a decoupled network using the classification network, the confidence detection network, and the positioning network.

[0053] Based on the classification task, confidence detection task and positioning task, a classification network, a confidence detection network and a positioning network are constructed respectively. Then, a decoupled network is constructed using the classification network, the confidence detection network and the positioning network. Through the above technical means, the classification network, the confidence detection network and the positioning network in the decoupled network are used to determine the classification results, classification confidence and detection box of the crop seedlings in the image respectively, which can avoid the problem of classification and positioning conflicts in the target detection task.

[0054] In some embodiments, the first construction module 301 is further configured to construct a common network using a convolution layer of a first convolution kernel and a convolution layer of multiple second convolution kernels; use a convolution layer of the common network followed by a first convolution kernel as a classification network; use a convolution layer of the common network followed by multiple first convolution kernels as a confidence detection network; use a convolution layer of the common network followed by multiple first convolution kernels as a positioning network.

[0055] For example, the first convolution kernel is 1*1, and the second convolution kernel is 2*2. Connect a 1*1 convolution layer and two 2*2 convolution layers in sequence to get a public network. Use the public network followed by a 1*1 convolution layer as a classification network. Use the public network followed by two 1*1 convolution layers as a confidence detection network; use the public network followed by two 1*1 convolution layers as a positioning network. The public network is the common part of the classification network, confidence detection network, and positioning network. The classification network, confidence detection network, and positioning network each have their own unique convolution layers to determine the classification results, classification confidence, and detection box of the crop seedlings in the image.

[0056] In some embodiments, the second construction module 302 is further configured such that the residual block includes a convolution layer of a first convolution kernel, a convolution layer of a second convolution kernel, a convolution layer of a first convolution kernel, and an addition layer, wherein the addition layer is used to add the input of the residual block and the input of the addition layer; and a multi-head self-attention mechanism is used to replace the convolution layer of the second convolution kernel in the residual block to obtain an attention network.

[0057] For example, if the first convolution kernel is 1*1 and the second convolution kernel is 2*2, then the internal structure of the attention network is a 1*1 convolution layer, a multi-head self-attention mechanism, a 1*1 convolution layer, and an addition layer. The input of the attention network is recorded as the fifth image feature map, and the fifth image feature map is processed by a 1*1 convolution layer, a multi-head self-attention mechanism, and a 1*1 convolution layer in turn to obtain the sixth image feature map. The addition layer adds the fifth image feature map and the sixth image feature map to obtain the first image feature map. The first image feature map is the output of the attention network, that is, the output of the improved backbone network.

[0058] In some embodiments, the detection module 304 is further configured to obtain training images about crop seedlings, and input the training images into an improved YOLO target detection model: process the training images through the improved backbone network to obtain a first image feature map; process the first image feature map through the improved neck network to obtain a second image feature map; process the second image feature map through the decoupling network to obtain a classification result, a classification confidence and a detection box; calculate the loss between the classification result, the classification confidence and the detection box and the annotation result, the annotation confidence and the annotation box respectively, and optimize the model parameters of the improved YOLO target detection model based on the loss to complete the training of the improved YOLO target detection model.

[0059] In the improved YOLO target detection model, the improved backbone network processes the training image to obtain the first image feature map, the improved neck network processes the first image feature map to obtain the second image feature map, and the classification network, confidence detection network and positioning network in the decoupled network process the second image feature map in turn to obtain the classification result, classification confidence and detection box. The cross entropy loss function is used to calculate the loss between the classification result, classification confidence and detection box and the annotation result, annotation confidence and annotation box, and the model parameters of the improved YOLO target detection model are optimized based on the loss.

[0060] The classification result is the result of whether the object in the detected image is a crop seedling, the detection box is the position of the object in the detected image that is a crop seedling, and the classification confidence is the probability that each object in the detected image is a crop seedling. The labeling result, labeling confidence, and labeling box correspond to the classification result, classification confidence, and detection box, respectively. The labeling result is the result of whether the object in the labeled image is a crop seedling, the detection box is the position of the object in the labeled image that is a crop seedling, and the classification confidence is the probability that each object in the labeled image is a crop seedling.

[0061] In some embodiments, the detection module 304 is also configured to obtain a target image of crop seedlings in the target area, and input the target image into a trained YOLO target detection model: process the target image through the trained backbone network to obtain a third image feature map; process the third image feature map through the trained neck network to obtain a fourth image feature map; process the fourth image feature map through the trained decoupling network to obtain a classification result, classification confidence and detection box.

[0062] The embodiment of the present application is the reasoning side of the model, and the previous embodiment is the training side of the model. The reasoning side of the model corresponds to the training side of the model, so the reasoning side of the model will not be described in detail here.

[0063] In some embodiments, the improvement module 303 is further configured to replace the convolutional layer in the YOLO target detection model with a combination of a convolutional layer, a batch normalization layer, and an activation function.

[0064] The batch normalization layer is Batch Normalization, and the activation function can use SiLU. The combination of convolutional layer, batch normalization layer and activation function can effectively extract features.

[0065] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0066] Figure 4 Schematic diagram of an electronic device 4 provided in an embodiment of the present application. Figure 4 As shown, the electronic device 4 of this embodiment includes: a processor 401, a memory 402, and a computer program 403 stored in the memory 402 and executable on the processor 401. When the processor 401 executes the computer program 403, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 401 executes the computer program 403, the functions of the modules / units in the above-mentioned device embodiments are implemented.

[0067] The electronic device 4 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 4 may include, but is not limited to, a processor 401 and a memory 402. Those skilled in the art will appreciate that Figure 4 The electronic device 4 is merely an example and does not limit the electronic device 4 , and may include more or less components than those shown in the figure, or different components.

[0068] The processor 401 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0069] The memory 402 may be an internal storage unit of the electronic device 4, for example, a hard disk or memory of the electronic device 4. The memory 402 may also be an external storage device of the electronic device 4, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 4. The memory 402 may also include both an internal storage unit and an external storage device of the electronic device 4. The memory 402 is used to store computer programs and other programs and data required by the electronic device.

[0070] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.

[0071] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, and the computer program code may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.

[0072] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A method for detecting crop seedlings, characterized in that: include: Construct a decoupled network for performing classification tasks, confidence detection tasks, and localization tasks; Construct an attention network using residual blocks and multi-head self-attention mechanism; The structure of the YOLO target detection model is improved as follows: the convolutional layers with preset step lengths in the backbone network and the neck network in the YOLO target detection model are replaced with spatial depth conversion convolutional layers, the attention network is added to the end of the backbone network, and the head network in the YOLO target detection model is replaced with the decoupled network; The improved YOLO target detection model is trained for crop seedling detection, and the trained YOLO target detection model is used for crop seedling detection.

2. The method according to claim 1, characterized in that Construct a decoupled network for performing classification tasks, confidence detection tasks, and localization tasks, including: Constructing a classification network for performing the classification task, constructing a confidence detection network for performing the confidence detection task, and constructing a positioning network for performing the positioning task; The decoupling network is constructed using the classification network, the confidence detection network and the positioning network.

3. The method according to claim 2, characterized in that Constructing a classification network for performing the classification task, constructing a confidence detection network for performing the confidence detection task, and constructing a positioning network for performing the positioning task, including: A public network is constructed using a convolution layer of a first convolution kernel and a plurality of convolution layers of a second convolution kernel; Using the convolution layer of the public network followed by a first convolution kernel as the classification network; Using the convolution layer of the public network followed by a plurality of first convolution kernels as the confidence detection network; A convolution layer including a plurality of first convolution kernels following the public network is used as the positioning network.

4. The method according to claim 1, characterized in that The attention network is constructed using residual blocks and multi-head self-attention mechanisms, including: The residual block includes a convolution layer of a first convolution kernel, a convolution layer of a second convolution kernel, a convolution layer of a first convolution kernel, and an addition layer, wherein the addition layer is used to add an input of the residual block and an input of the addition layer; The multi-head self-attention mechanism is used to replace the convolution layer of the second convolution kernel in the residual block to obtain the attention network.

5. The method according to claim 1, characterized in that The improved YOLO target detection model is trained for crop seedling detection, including: Obtain training images of crop seedlings and input the training images into the improved YOLO target detection model: Processing the training image through the improved backbone network to obtain a first image feature map; Processing the first image feature map through the improved neck network to obtain a second image feature map; Processing the second image feature map through the decoupling network to obtain a classification result, a classification confidence and a detection box; The losses between the classification result, the classification confidence and the detection box and the annotation result, the annotation confidence and the annotation box are calculated respectively, and the model parameters of the improved YOLO target detection model are optimized according to the losses to complete the training of the improved YOLO target detection model.

6. The method according to claim 1, characterized in that Use the trained YOLO target detection model to detect crop seedlings, including: Obtain a target image of crop seedlings in the target area, and input the target image into the trained YOLO target detection model: Processing the target image through the trained backbone network to obtain a third image feature map; Processing the third image feature map through the trained neck network to obtain a fourth image feature map; The fourth image feature map is processed by the trained decoupling network to obtain a classification result, a classification confidence and a detection frame.

7. The method according to claim 1, characterized in that Improve the structure of the YOLO target detection model as follows: The convolutional layer in the YOLO target detection model is replaced by a combination of a convolutional layer, a batch normalization layer, and an activation function.

8. A crop seedling detection device, characterized in that: include: A first building module is configured to build a decoupled network for performing a classification task, a confidence detection task, and a positioning task; The second building module is configured to build an attention network using residual blocks and multi-head self-attention mechanism; An improvement module is configured to improve the structure of the YOLO target detection model in the following manner: using a spatial depth conversion convolution layer to replace the convolution layer with a preset step size in the backbone network and the neck network in the YOLO target detection model, adding the attention network at the end of the backbone network, and using the decoupled network to replace the head network in the YOLO target detection model; The detection module is configured to perform crop seedling detection training on the improved YOLO target detection model, and perform crop seedling detection using the trained YOLO target detection model.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.