Method for detecting and counting corn seedlings and weeds in UAV remote sensing images
Through the improved YOLOv4-Tiny model and corn seedling and weed detection model, the problem of data analysis of the entire farmland is solved, efficient corn seedling and weed identification and counting is achieved, the annotation cost is reduced, and data support for farmland management is provided.
Patent Information
- Application Number
- CN202210535029.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-17
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2042-05-17
AI Technical Summary
Existing weed and crop detection technologies are difficult to efficiently analyze the entire farmland. The number of crops is much larger than the number of weeds, resulting in an imbalance in the data volume. In addition, there are too many crops in a single image and similar characteristics, and the labeling cost is high and the value is not high.
High-resolution farmland images were collected using drone remote sensing images, and crop row detection and mask processing were performed through the improved YOLOv4-Tiny model. The corn seedling and weed detection models were optimized in combination with the Meta-ACON activation function and the CBAM attention module. The soft-NMS non-maximum suppression treatment was used to achieve efficient identification and counting of corn seedlings and weeds.
Efficiently obtaining high-resolution images of the entire farmland solves the problem of data imbalance, reduces labeling costs, and realizes efficient identification and counting of corn seedlings and weeds, providing data support for farmland management.
Smart Images

Figure CN114926752B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of target detection, and in particular to a method for detecting and counting corn seedlings and weeds in drone remote sensing images. Background Art
[0002] Weeds in farmland not only compete with crops for living space but also contribute to the spread of pests and diseases, resulting in crop failures. Weed and crop detection play an important role in farmland management, providing data support and agricultural operation decision-making for the implementation of precise spraying and weeding. Effectively detecting the quantity and distribution of weeds and crops in farmland helps to increase crop yields, reduce pesticide use, and protect the environment.
[0003] The existing weed and crop detection has the following problems: First, most of them process images collected by close-range shooting, making it difficult to analyze the data of the entire farmland; Second, the number of crops in the farmland is much larger than the number of weeds, and the imbalance in the data volume of the two affects the construction of the detection model; Third, the number of crops in a single image is too large and the features are similar, resulting in too high a labeling cost and low value. Summary of the Invention
[0004] The purpose of the present invention is to provide a method for detecting and counting corn seedlings and weeds in drone remote sensing images, which can efficiently obtain high-resolution images of the entire farmland and efficiently analyze the data of the entire farmland.
[0005] To achieve the above object, the present invention adopts the following technical solutions: A method for detecting and counting corn seedlings and weeds in drone remote sensing images, the method comprising the following steps in sequence:
[0006] (1) Collect farmland images and perform preprocessing: Obtain high-resolution farmland remote sensing images by shooting with a drone, and cut the high-resolution farmland remote sensing images to obtain the cut images;
[0007] (2) Construct a crop row detection model and perform masking processing: Make crop row training samples from the cut images to obtain a crop row training sample set, construct a crop row detection model YOLOv4-Tiny, add an ECA channel attention module to improve the crop row detection model YOLOv4-Tiny to obtain an improved crop row detection model; Input the crop row training sample set into the improved crop row detection model for training, input the cut images into the improved crop row detection model, and perform masking processing on the crop row areas in the images output by the improved crop row detection model to obtain the masked images with only inter-row weeds;
[0008] (3) Establish a training sample set for corn seedlings and weeds: Select some images from the cut images and label the corn seedlings and weeds in them; Select some images from the images after masking and label the weeds in them; The quantity ratio of the selected cut images to the images after masking is 3:7, and the labeled cut images and the images after masking are combined to form a training sample set for corn seedlings and weeds;
[0009] (4) Construct a detection model for corn seedlings and weeds: Construct a detection model for corn seedlings and weeds YOLOv4, use the Meta-ACON activation function, add the CBAM attention module, and perform soft-NMS non-maximum suppression processing to improve the detection model YOLOv4 for corn seedlings and weeds, obtain the improved detection model for corn seedlings and weeds, and input the training sample set for corn seedlings and weeds into the improved detection model for corn seedlings and weeds for training to obtain the best detection model for corn seedlings and weeds;
[0010] (5) Detection and data analysis of corn seedlings and weeds: Input the sample to be detected into the best detection model for corn seedlings and weeds, identify the corn seedlings and weeds in the sample to be detected, obtain the distribution positions of the corn seedlings and weeds, and count the corn seedlings and weeds.
[0011] The step (1) includes the following steps:
[0012] (1a) Plan the UAV flight route of the farmland, set the flight altitude to 25 meters, and the shooting period is the corn seedling period. After two-dimensional reconstruction of the captured farmland images, synthesize a complete high-resolution farmland remote sensing image;
[0013] (1b) After removing the non-farmland areas at the edges of the high-resolution farmland remote sensing image, preprocess the high-resolution farmland remote sensing image, that is, cut the high-resolution farmland remote sensing image to obtain the cut image.
[0014] The step (2) includes the following steps:
[0015] (2a) Take the cut image to label the crop row data, label each complete crop row in the image with a label, and after sample enhancement of the produced data, form a crop row training sample set;
[0016] (2b) Build the crop row detection model YOLOv4-Tiny, add the ECA channel attention module to improve the crop row detection model YOLOv4-Tiny, and obtain the improved crop row detection model: The ECA channel attention module first performs global average pooling on the feature map output by the backbone network of the crop row detection model YOLOv4-Tiny; then performs a one-dimensional convolution operation, and obtains the weights of each channel through the sigmoid activation function; finally, multiplies the weights by the corresponding elements of the feature map output by the backbone network of the crop row detection model YOLOv4-Tiny to obtain the final output feature map. The calculation formula of the ECA channel attention module is:
[0017] ω = σ(C1D k (y)) (1)
[0018] where ω represents the weight of the channel, y represents the channel, σ represents the sigmoid activation function, and C1D k represents a one-dimensional convolution operation with a convolution kernel size of k. The calculation formula of the convolution kernel k is:
[0019]
[0020] where γ = 2, b = 1, odd represents rounding up to an odd number, and C represents the number of channels;
[0021] (2c) Input the crop row training sample set into the improved crop row detection model for training. Input the cut image as the sample to be detected into the improved crop row detection model to detect the coordinate information of each crop row in the sample to be detected. Perform mask processing on the crop row area in the image output by the improved crop row detection model to obtain the masked image with only inter-row weeds.
[0022] Step (4) includes the following steps:
[0023] (4a) Build the corn seedling and weed detection model YOLOv4;
[0024] (4b) Introduce the Meta-ACON activation function into the built corn seedling and weed detection model YOLOv4, and replace the Leakey ReLU activation function in the CBL module of the NECK part of the corn seedling and weed detection model YOLOv4 with the Meta-ACON activation function. The formula of the Meta-ACON activation function is:
[0025] f(x) = (p1 - p2)x·σ[β(p1 - p2)x] + p2x (3)
[0026] Among them, p1 and p2 are two learnable parameters for adaptive adjustment, responsible for controlling the upper and lower limits of the first-order derivative of the function; β is responsible for dynamically controlling the linear or non-linear of the activation function; σ represents the sigmoid function;
[0027] (4c) Add the CBAM attention module to the maize seedling and weed detection model YOLOv4, and replace the activation function of the CBAM channel attention module with the Meta-ACON activation function. The CBAM attention module operates on the feature map output by the backbone network of the maize seedling and weed detection model YOLOv4 in turn through two parts: channel and space:
[0028] In the channel attention part of CBAM, perform global average pooling and global max pooling on the feature map output by the backbone network of the maize seedling and weed detection model YOLOv4. After being processed by the shared fully connected layer, add the two processed results, obtain the weight through the sigmoid function, and finally multiply it by the feature map output by the backbone network of the maize seedling and weed detection model YOLOv4 to obtain the inferred feature map. The calculation formula of channel attention is shown in formula (4), and the element-wise multiplication is performed to obtain the feature map F′ output by the channel attention module as shown in formula (5):
[0029]
[0030] Among them, and respectively represent the features of average pooling and max pooling in the channel attention part. MLP represents the shared fully connected layer, F is the input feature map of channel attention, Mc is the channel attention, F′ is the feature map output by the channel attention module, σ represents the sigmoid activation function, represents element-wise multiplication;
[0031] In the spatial attention part of CBAM, perform max pooling and average pooling on the feature map F′ output by the channel attention module in the previous step, then stack the two together, then change the number of channels to 1 through a convolutional operation, and finally obtain the spatial attention weight through the sigmoid function. The calculation formula of spatial attention is shown in formula (6), and the element-wise multiplication is performed to obtain the final output feature map F″ of CBAM as shown in formula (7):
[0032]
[0033] Among them, and are respectively the features of average pooling and max pooling in the spatial attention part, f 7*7 represents a 7*7 convolutional layer, M SLet $F'$ be the spatial attention, and $F''$ be the final output feature map of the CBAM attention module;
[0034] (4d) In the corn seedling and weed detection model YOLOv4, soft-NMS is introduced for non-maximum suppression processing. When dealing with other detection boxes whose overlap with the detection box with the highest detection score exceeds the threshold, the scores of these detection boxes are attenuated by a formula.
[0035] The step (5) includes the following steps:
[0036] (5a) Input the sample to be detected into the corn seedling and weed detection model, and the model outputs images for identifying and locating corn seedlings and weeds.
[0037] (5b) Synthesize all the detected output images into a complete farmland image, count the corn seedlings and weeds in two categories respectively, and obtain the detailed distribution map of corn seedlings and weeds in this farmland, as well as the number of corn seedlings and the number of weeds in this farmland.
[0038] (5c) Divide the whole farmland into multiple small regions, count the corn seedlings and weeds in each small region respectively, calculate the ratio of weeds to corn seedlings, and draw the number of weeds and corn seedlings and their ratio in each small region on the farmland image.
[0039] As can be seen from the above technical solutions, the beneficial effects of the present invention are as follows: First, the present invention fully considers the characteristics of the distribution of corn seedlings and weeds in the field, and obtains two characteristics: the number of corn seedlings is much larger than the number of weeds, and the corn seedlings basically grow in the corn seedling rows; Second, based on these characteristics, a method for corn seedling row masking processing is proposed, which solves the two problems of consuming time cost for a large number of corn seedling annotations on the original image and the imbalance between the total data volume of weeds and corn seedlings; Third, the present invention analyzes the UAV remote sensing image, can efficiently obtain high-resolution images of the whole farmland, and efficiently analyze the data of the whole farmland; Fourth, the optimized weed and corn seedling detection model of the present invention can effectively identify weeds and corn seedlings. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 is the flowchart of the method of the present invention;
[0041] Figure 2 is the network structure diagram of the corn seedling and weed detection model;
[0042] Figure 3 is the output detection result diagram and the distribution map of weeds and corn seedlings in the complete farmland;
[0043] Figure 4 is the distribution map of weed and corn seedling regions in the farmland. DETAILED DESCRIPTION OF THE INVENTION
[0044] As Figure 1 shown, a method for detecting and counting corn seedlings and weeds in UAV remote sensing images, the method includes the following steps in sequence:
[0045] (1) Collect farmland images and perform preprocessing: Obtain high-resolution farmland remote sensing images by shooting with a UAV, cut the high-resolution farmland remote sensing images to obtain the cut images;
[0046] (2) Build a crop row detection model and perform masking processing: Make crop row training samples from the cut images to obtain a crop row training sample set, build the crop row detection model YOLOv4-Tiny, add an ECA channel attention module to improve the crop row detection model YOLOv4-Tiny to obtain an improved crop row detection model; Input the crop row training sample set into the improved crop row detection model for training, input the cut images into the improved crop row detection model, and perform masking processing on the crop row areas in the images output by the improved crop row detection model to obtain the masked image with only inter-row weeds;
[0047] (3) Establish a corn seedling and weed training sample set: Select some images from the cut images and label the corn seedlings and weeds in them; Select some images from the masked images and label the weeds in them; The quantity ratio of the selected cut images to the masked images is 3:7, and the labeled cut images and masked images are combined to form a corn seedling and weed training sample set;
[0048] (4) Build a corn seedling and weed detection model: Build the corn seedling and weed detection model YOLOv4, use the Meta-ACON activation function, add the CBAM attention module, and perform soft-NMS non-maximum suppression processing to improve the corn seedling and weed detection model YOLOv4 to obtain an improved corn seedling and weed detection model, input the corn seedling and weed training sample set into the improved corn seedling and weed detection model for training to obtain the best corn seedling and weed detection model;
[0049] (5) Corn seedling and weed detection and data analysis: Input the sample to be detected into the best corn seedling and weed detection model, identify the corn seedlings and weeds in the sample to be detected to obtain the distribution positions of the corn seedlings and weeds, and count the corn seedlings and weeds.
[0050] The step (1) includes the following steps:
[0051] (1a) Plan the UAV flight route for the farmland, set the flight altitude to 25 meters, and the shooting period to the corn seedling stage. After two-dimensional reconstruction of the captured farmland images, synthesize a complete high-resolution farmland remote sensing image;
[0052] (1b) After removing the non-farmland areas at the edges from the high-resolution farmland remote sensing image, preprocess the high-resolution farmland remote sensing image, that is, cut the high-resolution farmland remote sensing image to obtain the cut image.
[0053] Step (2) includes the following steps:
[0054] (2a) Take the cut image for annotation of crop row data, label each complete crop row in the image with a tag, and after sample augmentation of the produced data, form a crop row training sample set;
[0055] (2b) Build a crop row detection model YOLOv4-Tiny, add an ECA channel attention module to improve the crop row detection model YOLOv4-Tiny, and obtain an improved crop row detection model: The ECA channel attention module first performs global average pooling on the feature map output by the backbone network of the crop row detection model YOLOv4-Tiny; then performs a one-dimensional convolution operation, and obtains the weights of each channel through the sigmoid activation function; finally, multiply the weights by the corresponding elements of the feature map output by the backbone network of the crop row detection model YOLOv4-Tiny to obtain the final output feature map. The calculation formula of the ECA channel attention module is:
[0056] ω=σ(C1D k (y)) (1)
[0057] where ω represents the weight of the channel, y represents the channel, σ represents the sigmoid activation function, C1D k represents a one-dimensional convolution operation with a convolution kernel size of k. The calculation formula of the convolution kernel k is:
[0058]
[0059] where γ = 2, b = 1, odd represents rounding up to an odd number, and C represents the number of channels;
[0060] (2c) Input the crop row training sample set into the improved crop row detection model for training, input the cut image as the sample to be detected into the improved crop row detection model to detect the coordinate information of each crop row in the sample to be detected, and perform masking processing on the crop row area in the image output by the improved crop row detection model to obtain a masked image with only inter-row weeds.
[0061] Step (4) includes the following steps:
[0062] (4a) Build the maize seedling and weed detection model YOLOv4;
[0063] (4b) Introduce the Meta-ACON activation function into the built maize seedling and weed detection model YOLOv4, and replace the Leakey ReLU activation function of the CBL module in the NECK part of the maize seedling and weed detection model YOLOv4 with the Meta-ACON activation function. The formula of the Meta-ACON activation function is:
[0064] f(x)=(p1 - p2)x·σ[β(p1 - p2)x]+p2x (3)
[0065] Among them, p1 and p2 are two learnable parameters for adaptive adjustment, responsible for controlling the upper and lower limits of the first derivative of the function; β is responsible for dynamically controlling the linear or non-linear of the activation function; σ represents the sigmoid function;
[0066] (4c) Add the CBAM attention module to the maize seedling and weed detection model YOLOv4, and replace the activation function of the CBAM channel attention module with the Meta-ACON activation function. The CBAM attention module operates on the feature map output by the backbone network of the maize seedling and weed detection model YOLOv4 in turn through two parts: channel and space:
[0067] In the channel attention part of CBAM, perform global average pooling and global maximum pooling on the feature map output by the backbone network of the maize seedling and weed detection model YOLOv4. After being processed by the shared fully connected layer, add the two processed results, obtain the weight through the sigmoid function, and finally multiply it by the feature map output by the backbone network of the maize seedling and weed detection model YOLOv4 to obtain the inferred feature map. The calculation formula of the channel attention is shown in formula (4), and the feature map F′ output by the channel attention module is obtained by element-wise multiplication as shown in formula (5):
[0068]
[0069] Among them, and respectively represent the features of average pooling and maximum pooling in the channel attention part, MLP represents the shared fully connected layer, F is the input feature map of the channel attention, Mc is the channel attention, F′ is the feature map output by the channel attention module, σ represents the sigmoid activation function, represents element-wise multiplication;
[0070] In the spatial attention part of CBAM, the feature map F′ output by the channel attention module obtained in the previous step of channel attention is subjected to max pooling and average pooling, and then the two are stacked together. Next, the number of channels is changed to 1 through a convolutional operation, and finally, the spatial attention weight is obtained through the sigmoid function. The calculation formula of spatial attention is shown in formula (6), and the element-wise multiplication is performed to obtain the final output feature map F″ of CBAM as shown in formula (7):
[0071]
[0072] Among them, and are the features of average pooling and max pooling in the spatial attention part respectively, f 7*7 represents a 7×7 convolutional layer, M S is the spatial attention, and F″ is the final output feature map of the CBAM attention module;
[0073] (4d) In the corn seedling and weed detection model YOLOv4, soft-NMS is introduced for non-maximum suppression processing. When dealing with other detection boxes whose overlap with the detection box with the highest detection score exceeds the threshold, the scores of these detection boxes are attenuated by a formula.
[0074] The step (5) includes the following steps:
[0075] (5a) Input the sample to be detected into the corn seedling and weed detection model, and the model outputs an image for identifying and locating corn seedlings and weeds;
[0076] (5b) Synthesize all the detected images into a complete farmland image, count the two categories of corn seedlings and weeds respectively, and obtain the detailed distribution map of corn seedlings and weeds in the farmland as well as the number of corn seedlings and the number of weeds in the farmland;
[0077] (5c) Divide the entire farmland into multiple small regions, count the corn seedlings and weeds in each small region respectively, calculate the ratio of weeds to corn seedlings, and draw the number of weeds and corn seedlings and their ratio in each small region on the farmland image.
[0078] Such as Figure 2As shown in the figure, CBM and CBA are the smallest components in the YOLOv4 network structure. CBM consists of conv + bn + mish, and CBL consists of conv + bn + Meta-ACON. Here, conv is the convolutional layer, bn is the batch normalization layer, mish is the activation function, and Meta-ACON is the activation function. CSP_X consists of multiple convolutional layers and Res unit, and Res unit is the residual unit. SPP is the spatial pyramid pooling, Upsample is the upsampling, downsample is the downsampling, concat is the stacking, and YOLO head is the head module.
[0079] As Figure 3 shown in the figure, the distribution map of corn seedlings and weeds: The images output by the corn seedling and weed detection model YOLOv4 are integrated into a complete farmland image to obtain a detailed distribution map of corn seedlings and weeds in the entire farmland. By separately counting the corn seedlings and weeds in all output images, the number of corn seedlings and weeds in the entire farmland can be obtained.
[0080] As Figure 4 shown in the figure, the number and proportion of corn seedlings and weeds in small areas: By dividing the entire farmland into several small areas, calculating the number and proportion of corn seedlings and weeds in each small area provides data support for variable pesticide spraying. Here, m represents the number of corn seedlings, w represents the number of weeds, and r represents the ratio of weeds to corn seedlings.
[0081] By processing the UAV remote sensing images, based on the feature that crops in the farmland grow within crop rows, after extracting the crop rows and performing masking processing on them, images with a large number of green targets where there are only weeds and no crops can be quickly obtained. Only the weed labels need to be marked for these images. Labeling the unprocessed images and the images after masking processing in an appropriate proportion can achieve the purpose of balancing the data volume of crops and weeds and saving the labeling time. Finally, all the images output by the detection are synthesized into a complete farmland image to obtain the distribution map of weeds and crops in the farmland, the number of plants per mu, and the number of weeds, and the number and ratio of weeds and crops in each area are plotted on the farmland map, providing a basis for variable pesticide spraying.
[0082] In summary, the present invention fully considers the characteristics of the distribution of corn seedlings and weeds in the field, obtains two characteristics: the number of corn seedlings is much larger than the number of weeds and the corn seedlings basically grow within the corn seedling rows. Based on these characteristics, a method for masking the corn seedling rows is proposed. This method solves the two problems of consuming time cost for a large number of corn seedling annotations on the original images and the imbalance in the total data volume of weeds and corn seedlings. The present invention analyzes UAV remote sensing images, can efficiently obtain high-resolution images of the entire farmland, efficiently analyze the data of the entire farmland, and can effectively identify weeds and corn seedlings.
Claims
1. A method for detecting and counting corn seedlings and weeds in UAV remote sensing images, characterized in that: The method includes the following steps in sequence: (1) Collect farmland images and perform preprocessing: Obtain high-resolution farmland remote sensing images by using a drone to take pictures, and cut the high-resolution farmland remote sensing images to obtain the cut images; (2) Construct a crop row detection model and perform masking processing: Make crop row training samples from the cut images to obtain a crop row training sample set, construct a crop row detection model YOLOv4-Tiny, add an ECA channel attention module to improve the crop row detection model YOLOv4-Tiny, and obtain an improved crop row detection model; Input the crop row training sample set into the improved crop row detection model for training, input the cut images into the improved crop row detection model, and perform masking processing on the crop row areas in the images output by the improved crop row detection model to obtain the masked images with only inter-row weeds; (3) Establish a corn seedling and weed training sample set: Select some images from the cut images and label the corn seedlings and weeds in them; Select some images from the masked images and label the weeds in them; The quantity ratio of the selected cut images to the masked images is 3:7, and the labeled cut images and masked images are combined to form a corn seedling and weed training sample set; (4) Construct a corn seedling and weed detection model: Construct a corn seedling and weed detection model YOLOv4, adopt a Meta-ACON activation function, add a CBAM attention module, and perform soft-NMS non-maximum suppression processing to improve the corn seedling and weed detection model YOLOv4, and obtain an improved corn seedling and weed detection model; Input the corn seedling and weed training sample set into the improved corn seedling and weed detection model for training to obtain the best corn seedling and weed detection model; (5) Corn seedling and weed detection and data analysis: Input the sample to be detected into the best corn seedling and weed detection model, identify the corn seedlings and weeds in the sample to be detected, obtain the distribution positions of the corn seedlings and weeds, and count the corn seedlings and weeds; Step (4) includes the following steps: (4a) Construct a corn seedling and weed detection model YOLOv4; (4b) Introduce a Meta-ACON activation function into the constructed corn seedling and weed detection model YOLOv4, and replace the Leakey ReLU activation function of the CBL module in the NECK part of the corn seedling and weed detection model YOLOv4 with a Meta-ACON activation function. The formula of the Meta-ACON activation function is: f(x)=(p1 - p2)x·σ[β(p1 - p2)x]+p2x (3) where p1 and p2 are two learnable parameters for adaptive adjustment, responsible for controlling the upper and lower limits of the first-order derivative of the function; β is responsible for dynamically controlling the linear or non-linear of the activation function; σ represents the sigmoid function; (4c) Add the CBAM attention module to the corn seedling and weed detection model YOLOv4, and replace the activation function of the CBAM channel attention module with the Meta-ACON activation function. The CBAM attention module operates on the feature map output by the backbone network of the corn seedling and weed detection model YOLOv4 successively through two parts: the channel and the space: In the channel attention part of CBAM, global average pooling and global max pooling are performed on the feature map output by the backbone network of the maize seedling and weed detection model YOLOv4. After passing through the shared fully connected layer, the two processed results are added together, and weights are obtained through the sigmoid function. Finally, the feature map output by the backbone network of the maize seedling and weed detection model YOLOv4 is multiplied to obtain the inferred feature map. The calculation formula of channel attention is shown in formula (4), and the element-wise multiplication is used to obtain the feature map F output by the channel attention module ′ As shown in formula (5): Among them, and represent the features of average pooling and max pooling of the channel attention part respectively. MLP represents the shared fully connected layer, F is the feature map of the input channel attention, Mc is the channel attention, and F ′ is the feature map output by the channel attention module, σ represents the sigmoid activation function, represents element-wise multiplication; In the spatial attention part of CBAM, the feature map F output by the channel attention module obtained in the previous step of the channel attention part is used. ′ Through max pooling and average pooling, then stack the two together, then change the number of channels to 1 through a convolutional operation, and finally obtain the spatial attention weight through the sigmoid function. The calculation formula of the spatial attention is shown in formula (6). Multiply element by element to get the final output feature map F″ of CBAM as shown in formula (7): Among them, and are the features of average pooling and max pooling in the spatial attention part respectively, and f 7*7 represents a 7×7 convolutional layer, M S is the spatial attention, and F″ is the final output feature map of the CBAM attention module; (4d) Introduce soft-NMS in the corn seedling and weed detection model YOLOv4 for non-maximum suppression processing. When processing other detection boxes that overlap with the detection box with the highest detection score by more than the threshold, the scores of these detection boxes are attenuated by a formula.
2. The method for detecting and counting corn seedlings and weeds in UAV remote sensing images according to claim 1, wherein: (1a) Plan the drone flight route of the farmland, set the flight altitude to 25 meters, and the shooting period to the corn seedling period. After two-dimensional reconstruction of the captured farmland images, synthesize a complete high-resolution farmland remote sensing image; (1b) After removing the non-farmland areas at the edges of the high-resolution farmland remote sensing image, preprocess the high-resolution farmland remote sensing image, that is, cut the high-resolution farmland remote sensing image to obtain the cut image. (2a) Take the cut image for the annotation of crop row data, label each complete crop row in the image with a label, and after sample augmentation of the produced data, form a crop row training sample set; 3. The method for detecting and counting corn seedlings and weeds in drone remote sensing images according to claim 1, characterized in that: (2b) Build the crop row detection model YOLOv4-Tiny, add the ECA channel attention module to improve the crop row detection model YOLOv4-Tiny to obtain an improved crop row detection model: The ECA channel attention module first performs global average pooling on the feature map output by the backbone network of the crop row detection model YOLOv4-Tiny; then performs a one-dimensional convolution operation, and obtains the weights of each channel through the sigmoid activation function; finally, multiply the weights by the corresponding elements of the feature map output by the backbone network of the crop row detection model YOLOv4-Tiny to obtain the final output feature map. The calculation formula of the ECA channel attention module is: (2c) Input the crop row training sample set into the improved crop row detection model for training, input the cut image as the sample to be detected into the improved crop row detection model to detect the coordinate information of each crop row in the sample to be detected, and perform masking processing on the crop row area in the image output by the improved crop row detection model to obtain the masked image with only inter-row weeds. (5a) Input the sample to be detected into the corn seedling and weed detection model, and the corn seedling and weed detection model outputs an image for identifying and locating corn seedlings and weeds; ω=σ(C1D k (y)) (1) where ω represents the weight of the channel, y represents the channel, σ represents the sigmoid activation function, and C1D k represents a one-dimensional convolution operation with a convolution kernel of size k. The calculation formula for the convolution kernel k is: (5b) Synthesize all the detected output images into a complete farmland image, count the two categories of corn seedlings and weeds respectively, and obtain the detailed distribution map of corn seedlings and weeds in this farmland and the number of corn seedlings and weeds in this farmland; 4. The method for detecting and counting corn seedlings and weeds in UAV remote sensing images according to claim 1, characterized in that: (5c) Divide the entire farmland into multiple small areas, count the corn seedlings and weeds in each small area respectively, calculate the ratio of weeds to corn seedlings, and draw the number of weeds and corn seedlings and their ratios in each small area on the farmland image.