Rice field weed recognition method and device, computer equipment and storage medium

By constructing the RMS-DETR model, using multi-scale feature layers and cross-scale feature fusion, combined with CGA's improved Transformer and convolutional neural network, the problem of poor small target detection in rice field weed identification is solved, and the weeds in the rice field environment are improved. Grass recognition accuracy and efficiency.

CN118865124AActive Publication Date: 2024-10-29SHENYANG AGRI UNIV
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410907583.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-08
Publication Date
2024-10-29
Estimated Expiration
2044-07-08

AI Technical Summary

Technical Problem

The existing technology has the problem of extensive spraying in rice field weed identification, which makes it difficult to accurately identify small target weeds, resulting in low agent utilization. Moreover, the DETR model based on Transformer has poor detection effect on small targets and slow convergence speed, making it difficult to meet the needs of rice fields. environmental needs.

Method used

Construct the RMS-DETR model, using multi-scale feature layers and cross-scale feature fusion, combined with CGA's improved Transformer and convolutional neural network, extracting high-level semantic and low-level semantic features through multiple parallel convolution layers and dilated convolutions, and replacing them with Pconv Regular convolution to improve model efficiency.

Benefits of technology

It improves the accuracy and efficiency of small target detection, enhances the model's ability to identify rice field weeds, and improves the weed recognition effect in the rice field environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118865124A_ABST
    Figure CN118865124A_ABST
Patent Text Reader

Abstract

The invention provides a rice field weed recognition method and device, computer equipment and a storage medium, and belongs to the field of crop recognized.The method comprises the steps that a target image is acquired, and an RMS-DETR model is constructed; the model comprises a Backbone module, a hybrid encoder and a decoder, the hybrid encoder comprises a feature extraction module and a feature fusion module, and the feature extraction module is used for extracting multi-scale features; the feature fusion module is used for fusing multi-scale features; the decoder is used for identifying target features; training the model to obtain a weed recognition model; and inputting the target image into a weed recognition model to determine rice field weeds. By constructing the RMS-DETR model and generating the multi-scale features according to the to-be-detected image, the high-level semantic features and detail features of the weeds can be extracted, cross-scale fusion is performed, the features of different levels are organically combined, the comprehensive performance of the model is improved, the performance of the model on small target detection is enhanced, and the accuracy of weed recognition is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of crop identification, and in particular relates to a rice field weed identification method, device, computer equipment and storage medium. Background Art

[0002] During the rice growing period, paddy field weeds compete with rice for soil nutrients and water, which will lead to the loss of water and fertilizer resources. At the same time, the overgrowth of weeds will also promote the emergence and spread of pests and diseases. Paddy field weeds have become a key biological hazard source that restricts rice yield and quality. Therefore, effective weed control is a necessary link to achieve high and stable yields. The characteristics of the paddy field environment, such as soft soil, low-lying terrain, and narrow space, have brought certain limitations to traditional mechanical weeding methods. UAVs, with their flexible and maneuverable characteristics, have demonstrated unique applicability in this context. In recent years, with the improvement of the load capacity and performance of agricultural plant protection drones, aerial spraying is becoming the mainstream method of weeding in rice fields.

[0003] At present, plant protection drones have the problem of extensive spraying in rice field weeding. They cannot spray precisely at the weed location, and the utilization rate of pesticides is low, which may have a negative impact on the environment. Using remote sensing images of rice fields collected by drones to accurately identify weeds, generate variable spraying prescription maps, and enable plant protection drones to perform variable spraying according to the location and number of weeds is an effective way to solve this problem.

[0004] Barnyard grass is one of the most common weeds in rice fields. It belongs to the same family as rice, Poaceae, and the two are highly similar in appearance, structure, and growth habits. In the rice field images obtained by drones, barnyard grass weeds often only occupy a few dozen pixels, which is a typical small target. The recognition process of such small targets is very susceptible to interference from lighting conditions and mutual occlusion, resulting in missed detection or false detection. The high similarity between barnyard grass and rice, coupled with the characteristics of small targets and complex and changeable background environments, poses a huge challenge to the accurate identification of barnyard grass in rice fields based on drone remote sensing images.

[0005] In the prior art, weeds are mainly identified by the Transformer-based DETR model. However, when the Transformer component is initialized, the attention module applies almost the same attention weights to all pixels in the feature map, which requires longer training time to converge, and the final training effect is not good, and the detection effect of small targets is poor. Therefore, the advantages of deformable convolution sparse spatial sampling and the relational modeling ability of the transformer are combined, and a deformable attention module is proposed to avoid the problem of slow convergence of the DETR model. The reason for the slow convergence of the DETR model is that the instability of bipartite graph matching leads to inconsistent optimization targets in the early training stage. In order to solve this problem, the noisy GT bounding box is input into the Transformer decoder, which effectively reduces the difficulty of bipartite graph matching and accelerates the convergence speed. However, although the convergence speed and performance of the model have been improved to a certain extent, its effect on small target detection is poor. Summary of the invention

[0006] In order to solve the above problems, the present invention provides a method, device, computer equipment and storage medium for identifying weeds in rice fields.

[0007] In order to achieve the above object, the present invention provides the following technical solutions:

[0008] In a first aspect, the present invention provides a method for identifying weeds in a paddy field, the method comprising:

[0009] The original rice field image is obtained, and the original rice field image is preprocessed by bilinear interpolation to obtain a target image of a preset size; an RMS-DETR model is constructed; the RMS-DETR model includes a Backbone module, a hybrid encoder and a decoder; a plurality of parallel convolutional layers are added to the Backbone module; the image is recognized by the Backbone module to obtain a feature map, and a multi-scale convolution operation is performed on the feature map through a plurality of parallel convolutional layers to generate a multi-scale feature of a fixed dimension; the hybrid encoder includes a feature extraction module and a cross-scale feature fusion module; the feature extraction module includes a transformer and a convolutional neural network improved based on CGA The invention relates to a method for realizing a weed recognition model of paddy field weeds, wherein the first feature is encoded by the transformer structure on the high-level semantics in the multi-scale feature, and the second feature is extracted by the convolutional neural network structure on the low-level semantics in the multi-scale feature; the first feature, the second feature and other scale features except the high-level semantics and the low-level semantics in the multi-scale feature are fused by the cross-scale feature fusion module to obtain a target feature; the target feature is identified by the decoder; the RMS-DETR model is trained by the training sample of the paddy field image containing weeds to obtain a weed recognition model capable of identifying paddy field weeds; the target image is input into the weed recognition model to identify paddy field weeds.

[0010] Optionally, the improved attention mechanism structure transformer based on the cascade group attention module CGA includes: providing features of different channel subsets as input to each head of the transformer structure through CGA, calculating the attention map of each head in a cascade manner, and adding the output of each head to the subsequent head.

[0011] Optionally, the convolutional neural network structure includes multiple branches, each branch includes a hole convolution with a different expansion coefficient, a batch normalization layer and a ReLU activation function, and then a residual structure is introduced in parallel, and the residual structure includes a 1×1 convolution layer; the convolutional neural network structure is used to extract features of low-level semantics in multi-scale features to obtain a second feature, including: fusing the output of each branch with the output of the residual structure to obtain a branch feature, and splicing multiple branch features to obtain the second feature.

[0012] Optionally, the method further includes: replacing conventional convolution in the RMS-DETR model with Pconv; the conventional convolution includes multiple parallel convolution layers in the Backbone module and a 1×1 convolution layer in the residual structure.

[0013] Optionally, the training of the RMS-DETR model using training samples of rice field images containing weeds to obtain a weed recognition model capable of identifying rice field weeds includes: obtaining training samples of rice field images containing weeds, wherein the training samples of rice field images containing weeds include image samples to be identified and weed images corresponding to the image samples to be identified; inputting the image samples to be identified into the RMS-DETR model, and obtaining recognition results of the image samples to be identified through the RMS-DETR model; and training the RMS-DETR model with the optimization goal of minimizing the deviation between the recognition results and the weed images to obtain the weed recognition model.

[0014] Optionally, inputting the image sample to be identified into the RMS-DETR model, and obtaining the first result of the image sample to be identified through the RMS-DETR model includes: inputting multiple batches into the RMS-DETR model, setting the number of image samples to be identified in each batch and the maximum number of iterations; optimizing the RMS-DETR model parameters according to the iteration results using the SGD optimizer, and controlling the update amplitude of the RMS-DETR model parameters during the training process through the learning rate of the SGD optimizer, wherein the learning rate lr is determined by the following formula:

[0015]

[0016] Among them, base_lr is the basic learning rate, max_iterations is the maximum number of iterations, iter_num is the iteration index, and p is the polynomial decay exponent.

[0017] Optionally, the step of training the RMS-DETR model with minimizing the deviation between the recognition result and the first result as the optimization goal to obtain the weed recognition model includes: measuring the distance between the recognition result and the true result of the RMS-DETR model during the training process by a cross entropy loss function; taking the predicted probability distribution of the RMS-DETR model as the recognition result, and determining the error distance between the predicted probability distribution and the true probability distribution, wherein the specific determination method is as follows:

[0018]

[0019] Among them, Loss is the loss value, which represents the error distance, M is the number of pixels; N is the number of categories; i is the current pixel; C is the current category; b i is the true label category of pixel i; h is a 0-1 probability distribution function. If b i =C then h is 1, if b i ≠C then h is 0; p icis the predicted probability that pixel i belongs to category C, which is determined by the Sigmoid function through the score of the predicted category; the cross entropy loss function measures the training performance of the model through an iterative process, and adjusts the weights through back propagation so that the error distance represented by the loss value gradually decreases, and the weed recognition model is obtained when the training goal is achieved.

[0020] In a second aspect, the present invention provides a rice field weed identification device, the device comprising:

[0021] An acquisition module is used to acquire an original paddy field image and perform bilinear interpolation preprocessing on the original paddy field image to obtain a target image of a preset size;

[0022] A construction module is used to construct an RMS-DETR model; the RMS-DETR model includes a Backbone module, a hybrid encoder and a decoder; a plurality of parallel convolutional layers are added to the Backbone module; an image is recognized through the Backbone module to obtain a feature map, and a multi-scale convolution operation is performed on the feature map through a plurality of parallel convolutional layers to generate a multi-scale feature of a fixed dimension; the hybrid encoder includes a feature extraction module and a cross-scale feature fusion module; the feature extraction module includes a transformer and a convolutional neural network structure improved based on CGA; a first feature is obtained by encoding high-level semantics in the multi-scale feature through the transformer structure, and a second feature is obtained by extracting low-level semantics in the multi-scale feature through the convolutional neural network structure; the first feature, the second feature and other scale features in the multi-scale feature except high-level semantics and low-level semantics are fused through the cross-scale feature fusion module to obtain a target feature; the target feature is recognized through the decoder; the RMS-DETR model is trained through image training samples to obtain a weed recognition model capable of recognizing weeds in paddy fields;

[0023] The recognition module is used to input the target image into a weed recognition model to recognize paddy field weeds.

[0024] In a third aspect, the present invention provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned rice field weed identification method is implemented.

[0025] In a fourth aspect, the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned rice field weed identification method when executing the program.

[0026] The paddy field weed identification method provided by the present invention has the following beneficial effects:

[0027] By constructing the RMS-DETR model, the image to be detected is subjected to multi-scale convolution operations to generate multi-scale features, which is conducive to extracting the high-level semantic features and detail features of weeds, and cross-scale fusion of multi-scale features, organically combining features at different levels, improving the overall performance of the model, enhancing the performance of the model in small target detection, and improving the accuracy of weed recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the embodiment of the present invention and its design scheme, the following briefly introduces the drawings required for this embodiment. The drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0029] Figure 1 The present invention is a flow chart of a method for identifying weeds in a paddy field according to an exemplary embodiment of the present invention.

[0030] Figure 2 The present invention is a block diagram of a rice field weed identification device according to an exemplary embodiment of the present invention.

[0031] Figure 3 A schematic diagram of a computer device for implementing a rice field weed identification method provided by the present invention. DETAILED DESCRIPTION

[0032] In order to enable those skilled in the art to better understand the technical solution of the present invention and implement it, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the scope of protection of the present invention.

[0033] In order to address the limitations of the DETR model in small target detection, the present invention introduces a multi-scale feature layer into the DETR model and constructs the RMS-DETR model (Rmote Multi-Scale Detection Transform, remote sensing multi-scale feature detection model), which aims to better adapt to small targets, especially the detection of single barnyard grass in rice fields.

[0034] Low-level semantic information usually contains more fine-grained and local features. For small targets, these local features may be more discriminative and sensitive. Therefore, in order to improve the recognition rate of weeds, the present invention differentiates the design of different feature layers of multi-scale features, applies the Transformer structure to extract features for high-level semantic information, so as to fully integrate the contextual information under different perceptual domains, and uses the more computationally efficient CNN structure for extraction and encoding of low-level semantic information. Then, the two types of features are effectively fused through cross-scale feature fusion, which not only brings out the advantages of each, but also forms an information-rich feature space through cross-scale feature fusion.

[0035] In addition, in the traditional Transformer structure, since all heads share the same input features and rely on isolated learning without sharing parameters, it often leads to highly homogenized redundancy expressed by different heads. In order to reduce computational redundancy, the present invention adopts a new structure of a CGA (Cascaded Group Attention) module to optimize the traditional attention mechanism structure Transformer. This module provides each head with features of different channel subsets as input, so that each head can learn more unique features to improve the model learning ability and reduce computational redundancy. The introduction of multi-scale feature layers is bound to increase the amount of calculation of the model and slow down the reasoning speed of the model. Therefore, the present invention also uses an efficient and parallelizable Pconv (Partial convolution) in RMS-DETR to replace conventional convolution to maximize the model reasoning speed.

[0036] The technical solutions provided by various embodiments of the present invention are described in detail below in conjunction with the accompanying drawings.

[0037] The present invention provides a method for identifying weeds in rice fields. Figure 1 As shown, the following steps are included:

[0038] S101, acquiring a target image.

[0039] Specifically, the original rice field image may be first obtained, and then bilinear interpolation preprocessing may be performed on the original rice field image to obtain a target image of a preset size.

[0040] For example, a 600x600 rice field weed image can be selected, preprocessed, and resized to 640×640×3 by bilinear interpolation.

[0041] S102: construct a weed recognition model.

[0042] The present invention obtains a weed recognition model by training an RMS-DETR model, and the RMS-DETR model includes a backbone network Backbone module, a hybrid encoder and a decoder.

[0043] In one embodiment, multiple parallel convolutional layers are added to the Backbone module; the image is recognized through the Backbone module to obtain a feature map, and multi-scale convolution operations are performed on the feature map through multiple parallel convolutional layers to generate multi-scale features of fixed dimensions.

[0044] For example, three multi-scale feature layers can be generated through the multi-layer convolution operation of the Backbone module, which are marked as s1, s2 and s3, and their sizes are 80×80×128, 40×40×256, and 20×20×512 respectively.

[0045] In another embodiment, the hybrid encoder includes a feature extraction module and a cross-scale feature fusion module, and the feature extraction module includes a transformer structure and a convolutional neural network structure improved based on CGA.

[0046] For example, the transformer structure is used to encode high-level semantics in the multi-scale features to obtain the first feature.

[0047] For example, the high-level semantic s3 feature layer is input into the transformer structure for feature encoding, and the output encoding feature layer y1 is still of size 20×20×512.

[0048] In addition, in the traditional transformer structure, due to the shared input features, there is a certain redundancy in the information learned by different heads. At the same time, since the parameters are not shared, each head learns weights and feature representations independently, which may cause the features learned by different heads to be too similar and lack diversity. In order to overcome this problem, the present invention introduces the CGA module. Through CGA, the features of different channel subsets are provided as input to each head of the transformer structure, so that each head can learn more unique features. At the same time, the output features are cascaded between the heads, thereby improving the learning ability of the model and reducing computational redundancy. The structure of CGA can be expressed as:

[0049]

[0050] in, Representing the jth head X ij Self-attention, X ij Characterize the input feature X i The jth shard of

[0051] Xi =[X i1 ,X i2 ,…,X ih ], and 1≤j≤h

[0052] h is the total number of heads, and Represents the projection layer that maps the input feature slices into different subspaces, Represents a linear layer that projects the concatenated output features back to the same dimension as the input.

[0053] CGA determines the attention map of each head in a cascade manner and adds the output of each head to the subsequent head. This design encourages the Q, K, and V layers to learn feature projections with richer information and gradually improve the capacity of feature representation. This process enables the model to continuously accumulate and pass richer information in each attention head through the cascade structure, which helps to improve the model's learning ability and further optimize the feature representation:

[0054]

[0055] Among them, X' ij To replace X ij As the new input features of the j-th head.

[0056] CGA can save h× floating-point operations FLOPS and feature map parameters because the input and output channels of the QKV layer are reduced by h×. Secondly, cascading attention heads can increase the network depth, thereby further improving the model capacity without introducing any additional parameters.

[0057] For example, the convolutional neural network structure is used to extract low-level semantic features from multi-scale features to obtain the second feature.

[0058] For example, the low-level semantic s1 feature layer is input into the CNN network for feature extraction, and the output feature y2 has a size of 80×80×256.

[0059] Since the low-level semantic feature layer contains more fine-grained local information, it is more critical and sensitive for the detection of small targets, and the convolution operation and pooling operation of CNN help to extract local information such as texture and shape in the image, and it is easy to capture local features and details in the image, which is more suitable for extracting and encoding detail features in the low-level semantic feature layer. Therefore, when designing the hybrid encoder of the RMS-DETR model, the present invention uses the CNN structure in the feature extraction module to extract the weed detail information in the low-level semantic feature layer. When using the CNN network to extract the underlying detail features, appropriately expanding the receptive range of the CNN network can enable it to capture richer features of the target and the surrounding background area, thereby improving the detection quality of small targets. Compared with ordinary convolution, the hole convolution can expand the receptive field and obtain wider and richer features, which is very important for detecting small targets of different scales. Therefore, the present invention uses hole convolution to extract features from the underlying semantic feature layer.

[0060] Specifically, the convolutional neural network structure includes multiple branches, each branch includes a hole convolution with a different expansion coefficient, a batch normalization layer and a ReLU activation function, and then a residual structure is introduced in parallel, and the residual structure includes a 1×1 convolution layer; the output of each branch is fused with the output of the residual structure to obtain a branch feature, and multiple branch features are concatenated to obtain the second feature.

[0061] For example, in order to capture multi-scale features in different receptive fields, the present invention uses dilated convolutions with expansion coefficients of 6, 12, and 18 to extract low-level semantic information of the multi-scale feature layer. Here, the convolution kernel size of the dilated convolution is 3×3, and the dilated convolutions with different expansion coefficients constitute a branch with the batch normalization layer and the ReLU activation function. In order to alleviate the problem of gradient disappearance or explosion that may occur in the network during training, the present invention introduces a residual structure in each branch, which contains a 1×1 convolution layer. The output of each branch is added to obtain features, and then the features are spliced ​​together. By applying a 1x1 convolution operation, the number of channels is reduced from 240 to 80, thereby obtaining a global feature representation that integrates multi-scale contextual information, which helps to capture the subtle features of barnyard grass in rice field scenes.

[0062] In yet another embodiment, the first feature, the second feature, and other scale features in the multi-scale feature except high-level semantics and low-level semantics are fused by the cross-scale feature fusion module to obtain a target feature; and the target feature is identified by the decoder.

[0063] For example, y1, y2 and s2 are input into the feature fusion module to perform cross-scale feature fusion. The output is the fused feature y3, whose size is 80×80×512. y3 is the final target feature representation of the present invention, and is input into the subsequent decoding layer to complete the recognition prediction of the target feature.

[0064] In addition, the introduction of the multi-scale feature layer increases the computational complexity of the model and slows down the reasoning speed of the model. Current research points out that frequent memory access of operators is the main reason for low FLOPS. In order to maximize the reasoning speed of the model, the present invention uses a PConv (PartialConvolution) that can simultaneously reduce memory access time and computational redundancy, and replaces the conventional convolution in the RMS-DETR model with Pconv; the conventional convolution includes multiple parallel convolution layers in the Backbone module and a 1×1 convolution layer in the residual structure. The working principle of PConv is that for continuous or regular memory access, the first or last continuous channel is used as the representative of the entire feature map for conventional Conv to extract spatial features, and the remaining channels remain unchanged. Therefore, the FLOPs of PConv are:

[0065]

[0066] Among them, h represents the height of the input feature map, w represents the width of the input feature map, k represents the size of the convolution kernel, and c p Characterizes the number of channels of the PConv input feature map.

[0067] In typical part ratios It is easy to see that the number of floating point operations of PConv is only 1 / 16 of that of conventional convolution, where c represents the number of channels of the input feature map of the conventional convolution. In addition, PConv also has less memory access, namely:

[0068]

[0069] For r=1 / 4, the memory access of PConv is only 1 / 4 of that of regular convolution.

[0070] In yet another embodiment, the RMS-DETR model may be trained using rice field image training samples containing weeds to obtain a weed recognition model capable of recognizing weeds in rice fields.

[0071] Specifically, a training sample of a rice field image containing weeds can be first obtained, wherein the training sample of a rice field image containing weeds includes an image sample to be identified and a weed image corresponding to the image sample to be identified; the image sample to be identified is input into the RMS-DETR model, and a recognition result of the image sample to be identified is obtained through the RMS-DETR model; and the RMS-DETR model is trained with the optimization goal of minimizing the deviation between the recognition result and the weed image to obtain a weed recognition model.

[0072] In addition, considering the physical memory and learning efficiency, the RMS-DETR model is input in multiple batches, and the number of image samples to be identified and the maximum number of iterations in each batch are set; the SGD optimizer is used to optimize the RMS-DETR model parameters according to the iteration results, and the update amplitude of the RMS-DETR model parameters during the training process is controlled by the learning rate. The learning rate lr is determined by the following formula:

[0073] For example, the number of training images per batch is set to 4, and the maximum number of iterations is set to 500. During training, the model uses the SGD optimizer, and the decay strategy of the learning rate lr can be described as follows:

[0074]

[0075] Wherein, base_lr is the basic learning rate, max_iterations is the maximum number of iterations, iter_num is the iteration index, p is the polynomial decay exponent, the basic learning rate of the present invention can be set to 0.001, the momentum is 0.9, the weight decay is 1e-4, and the learning rate update lower limit is 0.

[0076] In addition, the present invention also adopts a cross entropy loss function to improve training efficiency. The cross entropy loss function is used to measure the distance between the recognition result of the RMS-DETR model and the true result during the training process; the predicted probability distribution of the RMS-DETR model is used as the recognition result, and the error distance between the predicted probability distribution and the true probability distribution is determined. The specific determination method is as follows:

[0077]

[0078] Where M is the number of pixels; N is the number of categories; i is the current pixel; C is the current category; b i is the true label category of pixel i; h is a 0-1 probability distribution function. If b i =C then h is 1, if b i ≠C then h is 0; p icis the predicted probability that pixel i belongs to category C, which is determined by the Sigmoid function through the score of the predicted category. The cross entropy loss function measures the training performance of the model through an iterative process, and adjusts the weights through back propagation so that the error distance represented by the loss value gradually decreases to achieve the training goal.

[0079] Evaluation indicators: To quantitatively analyze the performance of the model, this paper uses precision and recall to evaluate the effectiveness of the proposed RMS-DETR model. For precision and recall, there are four states after the test sample is predicted: true positive TP, false positive FP, true negative TN, and false negative FN. They are defined as follows:

[0080]

[0081]

[0082] S103: input the target image into a weed recognition model to identify paddy field weeds.

[0083] Specifically, the target image is input into the weed recognition model, the preliminary feature map of the target image is obtained through the Backbone module, and multi-scale features are extracted according to the preliminary feature map. The multi-scale features are fused through the hybrid encoder to obtain the target features, and the target features are identified through the decoder to determine the weeds in the rice field.

[0084] By adopting the above method, the RMS-DETR model is constructed, and the image to be detected is subjected to multi-scale convolution operation to generate multi-scale features, which is conducive to extracting high-level semantic features and detail features of weeds, and cross-scale fusion of multi-scale features, organically combining features at different levels, improving the overall performance of the model, enhancing the performance of the model in small target detection, and improving the accuracy of weed recognition.

[0085] The present invention also provides a rice field weed identification device, such as Figure 2 As shown, including:

[0086] The acquisition module 201 is used to acquire the original rice field image and perform bilinear interpolation preprocessing on the original rice field image to obtain a target image of a preset size.

[0087] The construction module 202 is used to construct an RMS-DETR model; the RMS-DETR model includes a Backbone module, a hybrid encoder and a decoder; a plurality of parallel convolutional layers are added to the Backbone module; the image is recognized through the Backbone module to obtain a feature map, and a multi-scale convolution operation is performed on the feature map through a plurality of parallel convolutional layers to generate a multi-scale feature of a fixed dimension; the hybrid encoder includes a feature extraction module and a cross-scale feature fusion module, and the feature extraction module includes a transformer structure and a convolutional neural network structure improved based on CGA; the high-level semantics in the multi-scale feature are feature encoded through the transformer structure to obtain a first feature, and the low-level semantics in the multi-scale feature are feature extracted through the convolutional neural network structure to obtain a second feature; the first feature, the second feature and other scale features in the multi-scale feature except the high-level semantics and the low-level semantics are fused through the cross-scale feature fusion module to obtain a target feature; the target feature is recognized through the decoder; the RMS-DETR model is trained through a rice field image training sample containing weeds to obtain a weed recognition model capable of recognizing rice field weeds.

[0088] The recognition module 203 is used to input the target image into a weed recognition model to recognize paddy field weeds.

[0089] Specifically, the building module 202 is also used to provide features of different channel subsets as input to each head of the transformer structure through CGA, calculate the attention map of each head in a cascade manner, and add the output of each head to the subsequent head.

[0090] Furthermore, the convolutional neural network structure includes multiple branches, each branch includes a hole convolution with a different expansion coefficient, a batch normalization layer and a ReLU activation function, and then a residual structure is introduced in parallel, and the residual structure includes a 1×1 convolution layer; the construction module 202 is also used to fuse the output of each branch with the output of the residual structure to obtain a branch feature, and splice multiple branch features to obtain the second feature.

[0091] Optionally, the method also includes: replacing the conventional convolution in the RMS-DETR model with Pconv; the conventional convolution includes multiple parallel convolution layers in the Backbone module and a 1×1 convolution layer in the residual structure.

[0092] In addition, the construction module 202 is also used to obtain training samples of rice field images containing weeds, wherein the training samples of rice field images containing weeds include image samples to be identified and weed images corresponding to the image samples to be identified; the image samples to be identified are input into the RMS-DETR model, and the recognition results of the image samples to be identified are obtained through the RMS-DETR model; and the RMS-DETR model is trained with the minimization of the deviation between the recognition result and the weed image as the optimization goal to obtain a weed recognition model.

[0093] In order to improve the training speed, the recognition module 203 is also used to input multiple batches of RMS-DETR models, set the number of image samples to be recognized in each batch and the maximum number of iterations; use the SGD optimizer to optimize the RMS-DETR model parameters according to the iteration results, and control the update amplitude of the RMS-DETR model parameters during the training process through the learning rate of the SGD optimizer. The learning rate lr is determined by the following formula:

[0094]

[0095] Among them, base_lr is the basic learning rate, max_iterations is the maximum number of iterations, iter_num is the iteration index, and p is the polynomial decay exponent.

[0096] In order to improve the training accuracy, the recognition module 203 is also used to measure the distance between the recognition result of the RMS-DETR model and the true result during the training process through the cross entropy loss function; the predicted probability distribution of the RMS-DETR model is used as the recognition result to determine the distance between the predicted probability distribution and the true probability distribution. The specific calculation method is as follows:

[0097]

[0098] Among them, Loss is the loss value, which represents the error distance, M is the number of pixels; N is the number of categories; i is the current pixel; C is the current category; b i is the true label category of pixel i; h is a 0-1 probability distribution function. If b i =C then h is 1, if b i ≠C then h is 0; p ic is the predicted probability that pixel i belongs to category C, which is determined by the Sigmoid function through the score of the predicted category; the cross entropy loss function measures the training performance of the model through an iterative process, and adjusts the weights through back propagation so that the error distance represented by the loss value gradually decreases, and the weed recognition model is obtained when the training goal is achieved.

[0099] By using the above device and constructing the RMS-DETR model, the image to be detected is subjected to multi-scale convolution operation to generate multi-scale features, which is conducive to extracting high-level semantic features and detail features of weeds, and cross-scale fusion of multi-scale features, organically combining features at different levels, improving the overall performance of the model, enhancing the performance of the model in small target detection, and improving the accuracy of weed recognition.

[0100] The present invention also provides a computer-readable storage medium, which stores a computer program, which can be used to execute the above Figure 1 Provided is a method for identifying weeds in rice fields.

[0101] The present invention also provides Figure 3 Computer equipment such as Figure 3 As shown in the figure, at the hardware level, the computer device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 Provided is a method for identifying weeds in rice fields.

[0102] It should be noted that the above specific implementation method can enable those skilled in the art to more fully understand the invention, but does not limit the invention in any way. Therefore, although the present specification and embodiments have described the invention in detail, those skilled in the art should understand that the invention can still be modified or replaced by equivalents; and all technical solutions and improvements that do not deviate from the spirit and scope of the invention are included in the protection scope of the patent for the invention. Any figure mark in the claims should not be regarded as limiting the claims involved.

Claims

1. A method for identifying weeds in rice fields, characterized in that: The method comprises: Acquire an original rice field image, and perform bilinear interpolation preprocessing on the original rice field image to obtain a target image of a preset size; Construct a remote sensing multi-scale feature detection model RMS-DETR; the RMS-DETR model includes a backbone network Backbone module, a hybrid encoder and a decoder; a plurality of parallel convolutional layers are added to the Backbone module; the image is recognized through the Backbone module to obtain a feature map, and a multi-scale convolution operation is performed on the feature map through a plurality of parallel convolutional layers to generate a multi-scale feature of a fixed dimension; the hybrid encoder includes a feature extraction module and a cross-scale feature fusion module; the feature extraction module includes an attention mechanism structure transformer and a convolutional neural network structure improved based on a cascade group attention module CGA; the high-level semantics in the multi-scale feature are feature encoded through the transformer structure to obtain a first feature, and the low-level semantics in the multi-scale feature are feature extracted through the convolutional neural network structure to obtain a second feature; the first feature, the second feature and other scale features in the multi-scale feature except the high-level semantics and the low-level semantics are fused through the cross-scale feature fusion module to obtain a target feature; the target feature is recognized through the decoder; The RMS-DETR model is trained using rice field image training samples containing weeds to obtain a weed recognition model that can identify rice field weeds. The target image is input into a weed recognition model to identify paddy field weeds.

2. The method for identifying weeds in rice fields according to claim 1, characterized in that: The improved attention mechanism structure transformer based on the cascade group attention module CGA includes: Through CGA, each head of the transformer structure is provided with features of different channel subsets as input, the attention map of each head is determined in a cascade manner, and the output of each head is added to the subsequent head.

3. The rice field weed identification method according to claim 1, characterized in that: The convolutional neural network structure includes multiple branches, each branch includes a hole convolution with a different expansion coefficient, a batch normalization layer and a ReLU activation function, and then a residual structure is introduced in parallel, and the residual structure includes a 1×1 convolution layer; The convolutional neural network structure is used to extract the low-level semantics in the multi-scale features to obtain the second feature, including: The output of each branch is fused with the output of the residual structure to obtain a branch feature, and multiple branch features are concatenated to obtain the second feature.

4. The method for identifying weeds in rice fields according to claim 3, characterized in that: The method further comprises: The conventional convolution in the RMS-DETR model is replaced by partial convolution Pconv; the conventional convolution includes multiple parallel convolution layers in the Backbone module and a 1×1 convolution layer in the residual structure.

5. The rice field weed identification method according to claim 1, characterized in that: The RMS-DETR model is trained by using paddy field image training samples containing weeds to obtain a weed recognition model capable of identifying paddy field weeds, including: Acquire a training sample of a rice field image containing weeds, wherein the training sample of the rice field image containing weeds includes an image sample to be identified and a weed image corresponding to the image sample to be identified; Inputting the image sample to be identified into the RMS-DETR model, and obtaining the identification result of the image sample to be identified through the RMS-DETR model; Taking minimizing the deviation between the recognition result and the weed image as the optimization goal, the RMS-DETR model is trained to obtain a weed recognition model.

6. The rice field weed identification method according to claim 5, characterized in that: The image sample to be identified is input into the RMS-DETR model, and the identification result of the image sample to be identified obtained by the RMS-DETR model includes: Multiple batches of inputs are made to the RMS-DETR model, and the number of image samples to be identified in each batch and the maximum number of iterations are set; the SGD optimizer is used to optimize the RMS-DETR model parameters according to the iteration results, and the update amplitude of the RMS-DETR model parameters during the training process is controlled by the learning rate, and the learning rate lr is determined by the following formula: Among them, base_lr is the basic learning rate, max_iterations is the maximum number of iterations, iter_num is the iteration index, and p is the polynomial decay exponent.

7. The rice field weed identification method according to claim 5, characterized in that: The RMS-DETR model is trained with minimizing the deviation between the recognition result and the weed image as the optimization goal to obtain the weed recognition model including: The distance between the recognition result of the RMS-DETR model and the weed image during the training process is measured by the cross entropy loss function; the predicted probability distribution of the RMS-DETR model is used as the recognition result, and the error distance between the predicted probability distribution and the true probability distribution is determined. The specific determination method is as follows: Among them, Loss is the loss value, which represents the error distance, M is the number of pixels; N is the number of categories; i is the current pixel; C is the current category; b i is the true label category of pixel i; h is a 0-1 probability distribution function. If b i =C then h is 1, if b i ≠C then h is 0; p ic is the predicted probability that pixel i belongs to category C, which is determined by the Sigmoid function through the score of the predicted category; the cross entropy loss function measures the training performance of the model through an iterative process, and adjusts the weights through back propagation so that the error distance represented by the loss value gradually decreases, and the weed recognition model is obtained when the training goal is achieved.

8. A rice field weed identification device, characterized in that: The device comprises: An acquisition module is used to acquire an original paddy field image and perform bilinear interpolation preprocessing on the original paddy field image to obtain a target image of a preset size; A construction module is used to construct an RMS-DETR model; the RMS-DETR model includes a Backbone module, a hybrid encoder and a decoder; a plurality of parallel convolutional layers are added to the Backbone module; an image is recognized through the Backbone module to obtain a feature map, and a multi-scale convolution operation is performed on the feature map through a plurality of parallel convolutional layers to generate a multi-scale feature of a fixed dimension; the hybrid encoder includes a feature extraction module and a cross-scale feature fusion module; the feature extraction module includes a transformer and a convolutional neural network structure improved based on CGA; a first feature is obtained by encoding high-level semantics in the multi-scale feature through the transformer structure, and a second feature is obtained by extracting low-level semantics in the multi-scale feature through the convolutional neural network structure; the first feature, the second feature and other scale features in the multi-scale feature except high-level semantics and low-level semantics are fused through the cross-scale feature fusion module to obtain a target feature; the target feature is recognized through the decoder; the RMS-DETR model is trained through image training samples to obtain a weed recognition model capable of recognizing weeds in paddy fields; The recognition module is used to input the target image into a weed recognition model to recognize paddy field weeds.

9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

10. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Target detection model training method and related device

    CN114332479A

  • Security check contraband detection method based on multi-scale attention and data enhancement

    CN116883933A

  • Small target detection method based on full-link multi-scale fusion network

    CN117197441A

  • Infrared target detection method and device, computer equipment and storage medium

    CN118229961A

  • RGB-D saliency target detection method based on layered cross-modal attention and cascade aggregation decoding

    CN118262093A