Rice ear feature extraction method and computer storage medium
By introducing the attention module and semantic segmentation module into the rice ear detection model, the rice ear features are extracted, solving problems such as complex background and target occlusion, and improving the accuracy of rice detection.
Patent Information
- Application Number
- CN202411346236.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2044-09-26
AI Technical Summary
The prior art is difficult to accurately distinguish rice ears and backgrounds under complex backgrounds, and interference from field planting environment and target overlap affect detection accuracy.
A rice ear feature extraction method is adopted. By obtaining the rice ear sampling image and inputting it into the pre-trained rice ear detection model, the attention module and the semantic segmentation module are used to perform convolution calculation on the image to extract the rice ear features.
On the basis of UAV image acquisition, the complex background in the field, rice ear target occlusion and multi-scale target problems are optimized to improve the detection accuracy of rice and other crops.
Smart Images

Figure CN118864874B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of target detection, and in particular to a rice ear feature extraction method and a computer storage medium. Background Art
[0002] In the prior art, in order to obtain crop information such as rice ears in the field, rice ear information is often obtained through drones, and then the corresponding crop information is identified and / or detected using deep learning. However, due to the complex background of field rice planting, for example, the presence of weeds similar to rice in the field makes it difficult for the detection model based on deep learning to accurately distinguish between rice ears and background. And due to the interference of the field planting environment, for example, changes in natural lighting conditions (cloudy, sunny, morning or evening) affect the brightness or contrast of the target image, thereby increasing the recognition effect of the above detection model. At the same time, if densely planted in the field, the rice ears may block each other and cause target overlap, affecting the counting and recognition accuracy of the above detection model.
[0003] Based on this, there is an urgent need for a target detection solution that can improve the detection accuracy of crops such as rice under complex backgrounds. Summary of the invention
[0004] In view of the above-mentioned deficiencies in the prior art, the present invention provides a rice ear feature extraction method and a computer storage medium, which can optimize the problems of complex field background, rice ear target occlusion and multi-scale targets based on the image acquisition of drone images, and improve the detection accuracy of crops such as rice.
[0005] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is:
[0006] In a first aspect, the present invention provides a method for extracting rice ear features, comprising:
[0007] Acquire rice ear sampling images;
[0008] The rice ear sampling image is input into the pre-trained rice ear detection model to obtain the rice ear feature extraction result; wherein the pre-trained rice ear detection model includes at least an attention module and a semantic segmentation module; the attention module and the semantic segmentation module are used to perform convolution calculations on the rice ear sampling image in turn to obtain the rice ear feature extraction result.
[0009] Preferably, when the pre-trained rice ear detection model further includes a convolution module, the step of inputting the rice ear sampling image into the pre-trained rice ear detection model to obtain the rice ear feature extraction result includes:
[0010] The convolution module is used to perform convolution calculation on the rice ear sampling image to obtain the initial feature image;
[0011] Using the attention module to perform convolution calculation on the initial feature image to obtain the first feature image;
[0012] The semantic segmentation module is used to perform convolution calculation on the initial feature image and the first feature image to obtain the rice ear feature extraction result.
[0013] Preferably, the step of inputting the rice ear sampling image into the pre-trained rice ear detection model to obtain the rice ear feature extraction result includes the following steps:
[0014] Construct an initial rice ear detection model;
[0015] Obtain a sample image of a rice ear; input the sample image of the rice ear into the rice ear detection model, train the initial rice ear detection model using the loss function, and obtain a pre-trained rice ear detection model; wherein the loss function is expressed as:
[0016] ;
[0017] in, is the total loss value, is the intersection-union ratio, is the distance loss value, is the shape loss value.
[0018] Preferably, when the initial feature image includes a first convolution result, a second convolution result and a third convolution result, the convolution module includes a first convolution layer, a second convolution layer and a third convolution layer connected in sequence; the step of performing convolution calculation on the rice ear sampling image using the convolution module to obtain the initial feature image includes:
[0019] Using the first convolution layer to perform convolution calculation on the rice ear sampling image, obtaining the first convolution result;
[0020] Using the second convolution layer to perform convolution calculation on the first image feature to obtain a second convolution result;
[0021] Using the third convolution layer to perform convolution calculation on the second image feature to obtain a third convolution result;
[0022] Among them, the convolution kernel sizes corresponding to the first convolution layer, the second convolution layer, and the third convolution layer are all different.
[0023] Preferably, when the first feature image includes the first feature parameter and the second feature parameter, the attention module includes a first attention feature layer, a second attention feature layer and a third attention feature layer connected in sequence; and the step of performing convolution calculation on the initial feature image using the attention module to obtain the first feature image includes:
[0024] Using the first attention feature layer to perform convolution calculation on the first convolution result to obtain a first feature parameter;
[0025] Using the second attention feature layer to perform convolution calculation on the second convolution result to obtain a second feature parameter;
[0026] Among them, the convolution kernel sizes corresponding to the first attention feature layer and the second attention feature layer are different.
[0027] Preferably, the convolution calculation formula of the first attention feature layer satisfies:
[0028] ;
[0029] in, is the channel statistical feature vector; For the first Input feature map Down( ) branches in the spatial dimension, ∈ , ; The input feature map The height of the space, The input feature map Width; is the average pooling function.
[0030] Preferably, when the convolution kernel of the first attention feature layer satisfies: 40*40*512, the convolution kernel of the second attention feature layer satisfies: 40*40*1024.
[0031] Preferably, when the semantic segmentation module includes: a semantic segmentation layer, a feature fusion layer, and a third attention feature layer connected in sequence; the step of performing convolution calculation on the initial feature image and the first feature image using the semantic segmentation module to obtain the rice ear feature extraction result includes:
[0032] Using the semantic segmentation layer to perform convolution calculation on the third convolution result to obtain a third feature parameter;
[0033] The feature fusion layer is used to sequentially fuse the third feature parameter, the second feature parameter and the first feature parameter to obtain an initial rice ear feature extraction result;
[0034] The third attention feature layer is used to perform convolution calculation on the initial rice ear feature extraction result to obtain the final rice ear feature extraction result;
[0035] Among them, the semantic segmentation layer includes multiple sequentially connected convolutional layers with different deconvolution sampling rates.
[0036] Preferably, when the semantic segmentation layer further includes a pooling layer, the step of performing convolution calculation on the third convolution result using the semantic segmentation layer to obtain the third feature parameter includes:
[0037] Using multiple convolution layers to perform convolution calculations on the third convolution results in sequence to obtain an initial third feature parameter;
[0038] The initial third feature parameter is convolved using the pooling layer to obtain the final third feature parameter.
[0039] In a second aspect, the present invention further provides a computer storage medium, the computer storage medium comprising a stored program, wherein when the program is run, the rice ear feature extraction method of any one of the above-mentioned first aspects is executed.
[0040] Based on this, the beneficial effects of a rice ear feature extraction method and a computer storage medium provided by the present invention are as follows:
[0041] A rice ear feature extraction method is provided, which obtains a rice ear sampling image; then inputs the rice ear sampling image into a pre-trained rice ear detection model to obtain a rice ear feature extraction result; wherein an attention module and a semantic segmentation module are used to perform convolution calculations on the rice ear sampling image in sequence to obtain a rice ear feature extraction result. Based on this, the present invention can optimize the problems of complex field background, rice ear target occlusion and multi-scale targets on the basis of obtaining images with drone images, and improve the detection accuracy of crops such as rice. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 One of the schematic diagrams of the steps of a rice ear feature extraction method provided by the present invention;
[0043] Figure 2 This is one of the structural schematic diagrams of the rice ear detection model in the present invention;
[0044] Figure 3 A second schematic diagram of the steps of a rice ear feature extraction method provided by the present invention;
[0045] Figure 4 This is the second structural schematic diagram of the rice ear detection model in the present invention;
[0046] Figure 5 The third step schematic diagram of a rice ear feature extraction method provided by the present invention;
[0047] Figure 6 The third structural diagram of the rice ear detection model in the present invention;
[0048] Figure 7 A fourth schematic diagram of the steps of a rice ear feature extraction method provided by the present invention;
[0049] Figure 8 A schematic diagram of the fifth step of a rice ear feature extraction method provided by the present invention;
[0050] Fig. 9 This is the fourth structural schematic diagram of the rice ear detection model in the present invention;
[0051] Fig.10 This is a sixth schematic diagram of the steps of a rice ear feature extraction method provided by the present invention.
[0052] Icon: 100-rice ear detection model; 101-attention module; 102-semantic segmentation module; 103-convolution module. DETAILED DESCRIPTION
[0053] The specific implementation modes of the present invention are described below so that those skilled in the art can understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.
[0054] As described in the background technology, most existing studies have combined drones to complete crop ear recognition research, but most of the research objects are wheat ears. This is because the morphological characteristics (including shape, size, density, etc.) of the ears of upright ear crops such as wheat are relatively obvious. However, rice plants are taller and have dense leaves, which leads to serious confusion between the target and the background in the rice image, making image analysis difficult. In addition, mature rice ears will droop due to their own weight, resulting in more multi-scale changes in the rice ears when photographed by drones, which increases the difficulty of detection.
[0055] In view of the above-mentioned deficiencies in the prior art, the present invention provides a target detection solution that can improve the detection accuracy of crops such as rice under complex backgrounds. That is, a rice ear feature extraction method and a computer storage medium are provided, which can optimize the problems of complex field background, rice ear target occlusion and multi-scale targets based on the image acquisition by drone images, and improve the detection accuracy of crops such as rice.
[0056] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is:
[0057] First, please refer to Figure 1 The present invention provides a method for extracting rice ear features, including steps 110 to 140.
[0058] Step 110: Acquire a rice ear sampling image.
[0059] Step 140: input the rice ear sampling image into the pre-trained rice ear detection model to obtain the rice ear feature extraction result.
[0060] Please refer to Figure 2, wherein the rice ear detection model 100 at least includes an attention module 101 and a semantic segmentation module 102 connected in sequence. The attention module and the semantic segmentation module are used to perform convolution calculations on the rice ear sampling image in sequence to obtain the rice ear feature extraction result. In a possible implementation method, in this embodiment, the attention module is used to perform convolution calculations on the rice ear sampling image to obtain an initial feature image. The semantic segmentation module is used to perform convolution calculations on the initial feature image to obtain the rice ear feature extraction result.
[0061] In this embodiment, an initial rice ear detection model can be constructed first, and then rice ear sample images, for example, rice ear images with known correct rice ear detection results, are used as samples, and the initial rice ear detection model is trained using a loss function to obtain a final rice ear detection model.
[0062] Please refer to Figure 3 , before step 140, steps 120 to 130 are also included.
[0063] Step 120, constructing an initial rice ear detection model;
[0064] Step 130, obtaining a sample image of a rice ear; and inputting the sample image of the rice ear into a rice ear detection model, using a loss function to train an initial rice ear detection model, to obtain a pre-trained rice ear detection model.
[0065] In order to improve the generalization ability of the rice ear detection model and accelerate convergence, this embodiment replaces the border loss function of the rice ear detection model with the SIoU loss function. In a possible implementation method, the loss function is expressed as: ;
[0066] in, is the loss value, is the intersection-union ratio, is the distance loss value, is the shape loss value.
[0067] In this embodiment, the specific calculation process is expressed as:
[0068] When the intersection of the predicted bounding box and the true bounding box is represented as A, and the union of the predicted bounding box and the true bounding box is represented as B, where:
[0069] (1) Angle cost is expressed as:
[0070] ;
[0071] in, is the angle loss value, is the height difference between the center point of the real border and the predicted border, is the distance between the center point of the real box and the predicted box.
[0072] In one possible implementation, = Based on this, we can get:
[0073] ;
[0074] ;
[0075] ;
[0076] in, is the center coordinate of the real frame, is the center coordinate of the predicted bounding box.
[0077] (2) Based on the center coordinates of the real frame and the center coordinates of the predicted bounding box Determine the distance cost, which satisfies:
[0078] ;
[0079] in, is the distance loss value, is a constant, is the distance between the center coordinate x of the predicted bounding box and the center coordinate x of the real bounding box, and satisfies: ; represents the square of the distance between the y coordinate of the center of the predicted border and the y coordinate of the center of the real border, normalized to the square of the height of the real border, and satisfies: ; is a parameter used to calculate the distance cost and satisfies: .
[0080] (3) Shape cost, defined as follows:
[0081] ;
[0082] Among them, θ is a hyperparameter used to control the weight of shape loss. The width and height corresponding to the predicted border; is the width and height of the real border; The absolute value of the difference between the predicted border width and the true border width can be normalized to obtain the maximum value of the true border width. This width loss term will adjust the weight according to the size of the shape loss Ω, so that the model can better converge to the correct prediction box size and satisfy: ; The absolute value of the difference between the predicted border height and the true border height can be normalized to obtain the maximum value of the true border height, and it satisfies: ; is the maximum value function; is the absolute value function.
[0083] In this embodiment, the degree of attention paid to shape loss can be controlled. In order to avoid paying too much attention to shape loss and reducing the movement of the predicted border, the parameter range of θ is [2, 6].
[0084] (4) IoU cost, which satisfies:
[0085] ;
[0086] in, is the intersection-union ratio, is the predicted border, and B is the real border. In one possible implementation, when the intersection-and-union ratio When it is greater than or equal to 0.5, the model can achieve a better result.
[0087] Based on this, the overlapping area between the rice field detection border and the ground truth border can be taken into consideration, and the size difference between them can also be considered, so that it has better stability under target features of different scales and is less affected by the size of the target feature. In addition, the SIoU loss function in this embodiment also considers the vector angle between the actual image frame and the predicted image frame, and accelerates the convergence process by reducing the horizontal or vertical angle between the anchor frame and the GT frame. Since SIoULoss is relatively simple and has a small amount of calculation, it can reduce the time cost of training and reasoning, which helps to improve the efficiency of the model.
[0088] In one possible implementation, in order to improve the current detection of rice ears using drone-photographed field rice images, which have problems such as complex background, dense occlusion of rice ears, and missed detection of small-scale rice ears, the YOLOv7 detection model is used as the basis for improvement. First, through the attention module, such as the SA attention module, the rice ear detection model pays more attention to the important features related to rice ear detection in the rice ear image, thereby enhancing the feature representation capability and realizing fast and accurate detection of rice ears in complex field environments. Then, based on the atrous convolution structure, a semantic segmentation module is proposed, which can be expressed as an S-ASPP structure, to improve the multi-scale detection capability of the rice ear detection model, greatly reduce the false alarm rate, and effectively locate small rice ears in the field, so as to more accurately detect rice ears of various sizes.
[0089] In this embodiment, based on the YOLOv7 detection model, the convolution module is used to extract the features of the rice ear image first, and the attention module can be set at the end of the YOLOv7 detection model backbone extraction network. Then, the attention module is combined with the hole convolution neural network to obtain a semantic segmentation module, and the initial features extracted by the convolution module are optimized using the attention module and the semantic segmentation module. Please refer to Figure 4 The rice ear detection model of this embodiment further includes: a convolution module 103. The convolution module 103 is used to perform convolution calculation on the rice ear sample image or the rice ear sampling image to obtain an initial feature image. The attention module 101 is used to perform convolution calculation on the initial feature image to obtain a first feature image. The semantic segmentation module 102 is used to perform convolution calculation on the initial feature image and the first feature image to obtain a rice ear feature extraction result.
[0090] Please refer to Figure 5 When the initial feature image includes the first convolution result, the second convolution result and the third convolution result, the convolution module includes a first convolution layer, a second convolution layer and a third convolution layer connected in sequence. At this time, the convolution module is used to perform convolution calculation on the rice ear sampling image, and the steps of obtaining the initial feature image include steps 210 to 230.
[0091] Step 210: Use the first convolution layer to perform convolution calculation on the rice ear sampling image to obtain a first convolution result.
[0092] Step 220: Use the second convolutional layer to perform convolution calculation on the first image feature to obtain a second convolution result.
[0093] Step 230: Use the third convolutional layer to perform convolution calculation on the second image feature to obtain a third convolution result.
[0094] In this embodiment, please refer to Figure 6 , Figure 6 The convolution structure diagram of the rice ear detection model is shown. In the figure, stage1 is the first convolution layer, stage2 is the second convolution layer, and stage3 is the third convolution layer. The first convolution layer stage1, the second convolution layer stage2, and the third convolution layer stage3 are connected in sequence. In a possible implementation, the first convolution layer stage1, the second convolution layer stage2, and the third convolution layer stage3 can all be composed of multiple convolution layers connected in sequence. Among them, the convolution kernel sizes corresponding to the first convolution layer, the second convolution layer, and the third convolution layer are all different.
[0095] Please continue to refer to Figure 6When the input rice ear image meets the requirements of 640*640*3, the first convolutional layer stage1 is composed of a convolutional layer with a convolution kernel of 640*640*32, a convolutional layer with a convolution kernel of 320*320*32, a convolutional layer with a convolution kernel of 320*320*64, a convolutional layer with a convolution kernel of 320*320*64, a convolutional layer with a convolution kernel of 160*160*256, an MP (downsampling module), and an E-ELAN (extended efficient layer aggregation network) module with a convolution kernel of 80*80*512. The second convolutional layer stage2 is composed of an MP (downsampling module) and an E-ELAN module with a convolution kernel of 40*40*1024. The third convolutional layer stage3 is composed of an MP (downsampling module) and an E-ELAN (extended efficient layer aggregation network) module with a convolution kernel of 20*20*1024. Among them, the 40*40*1024 E-ELAN module is connected to the MP module in the third convolutional layer stage3.
[0096] In this embodiment, please refer to Figure 7 When the first feature image includes the first feature parameter and the second feature parameter, the attention module includes a first attention feature layer and a second attention feature layer connected in sequence; at this time, the step of performing convolution calculation on the initial feature image using the attention module to obtain the first feature image includes steps 310 to 320.
[0097] Step 310: Use the first attention feature layer to perform convolution calculation on the first convolution result to obtain a first feature parameter.
[0098] Step 320: Use the second attention feature layer to perform convolution calculation on the second convolution result to obtain a second feature parameter.
[0099] Among them, the convolution kernel sizes corresponding to the first attention feature layer and the second attention feature layer are different.
[0100] In one possible implementation, the attention module may be an SA module, which combines spatial attention and channel attention, that is, applying spatial attention to the input feature map (the convolution results of the convolution module in the present invention), and then applying channel attention to the generated spatial attended feature map, and then using ShuffleUnits to combine the two types of spatial attention and channel attention. The convolution calculation formula of the first attention feature layer and / or the second attention feature layer satisfies:
[0101] ;
[0102] in, is the channel statistical feature vector; For the first Input feature map Down Branches in the spatial dimension, ∈ , ; The input feature map The height of the space, The input feature map Width; is the average pooling function.
[0103] Specifically, It is through the input feature map Channel statistical features obtained by global average pooling; is the input feature map A branch of is used to generate channel attention map. Represents the size of the spatial dimension, H represents the input feature map The height of the space, Represents the input feature map The width of The input feature map Along the spatial dimension ( ) to perform average pooling and obtain a channel statistics vector This vector s contains the relationship information between channels and can be used to generate channel attention maps.
[0104] This embodiment also creates a compact feature with a sigmoid activation function for accurate and adaptive selection. Based on this, the final output of the channel attention is for:
[0105] ;
[0106] in, and is the parameter used to scale and move s. It is expressed as an enhancement function, is a sigmoid activation function used to generate channel attention maps. is the input feature Figure X A branch of k is used to generate channel attention maps.
[0107] Similarly, the final output of spatial attention is It is expressed as:
[0108] ;
[0109] in, are the first parameter and the second parameter for generating the spatial attention map respectively; For input features Figure X A sub-feature of , which can be obtained by channel segmentation; is a spatial statistics function used to generate Spatial statistics information.
[0110] Based on this, this embodiment enables the interaction between each group of sub-features, so that the cross-group information flow can flow along the channel dimension, wherein the first attention feature layer and the second attention feature layer output feature parameters of the same size (specifically feature images), thereby reducing the above-mentioned calculation process and avoiding increasing the computational cost.
[0111] In one possible implementation, when the convolution kernel of the first attention feature layer meets the requirements of 40*40*512, the convolution kernel of the second attention feature layer meets the requirements of 40*40*1024. Based on this, the feature transmission channel can be increased while ensuring the original feature transmission, so that more feature information can be transmitted to the deep layer of the network. More shallow features can be transmitted to the deep layer, thereby preventing the risk of missing small rice ears due to low contrast and few pixels in the image.
[0112] In this embodiment, please refer to Figure 8 When the semantic segmentation module includes a semantic segmentation layer, a feature fusion layer and a third attention feature layer, the semantic segmentation module is used to perform convolution calculation on the initial feature image and the first feature image, and the step of obtaining the first feature image includes steps 410 to 430.
[0113] Step 410: Use the semantic segmentation layer to perform convolution calculation on the third convolution result to obtain a third feature parameter.
[0114] Step 420: Use the feature fusion layer to sequentially fuse the third feature parameter, the second feature parameter, and the first feature parameter to obtain an initial rice ear feature extraction result.
[0115] Step 430: Use the third attention feature layer to perform convolution calculation on the initial rice ear feature extraction result to obtain the final rice ear feature extraction result.
[0116] Among them, the semantic segmentation layer includes multiple convolutional layers with different deconvolution sampling rates.
[0117] In this embodiment, in order to enhance the focus on the dense small target sample area and further improve the positioning accuracy of dense small targets under mutual occlusion, this paper will use the hole convolution to implement the ASPP (Atrous SpatialPyramid Pooling) structure of the multi-scale receptive field technology to replace the SPP SPC structure. ASPP is a module commonly used in semantic segmentation tasks, mainly used to capture contextual information at different scales. ASPP captures contextual information at different scales through hole convolutions with different sampling rates. Compared with using only one large expansion rate, the use of various expansion rates will more significantly reduce the impact of environmental factors and enhance background data at multiple scales to help detect small objects. Therefore, multi-scale contextual information can be extracted to avoid small target loss. At the same time, the hole convolution in ASPP can share parameters, reduce the number of parameters of the model, and reduce the risk of overfitting.
[0118] Please refer to Fig. 9 The ASPP structure includes 4 convolutional layers connected in sequence: among them, the 1×1 convolution reduces the dimension of the input; the convolution layer with padding of 6, dilation of 6, and kernel size of 3×3 performs convolution; the convolution layer with padding of 12, dilation of 12, and kernel size of 3×3 performs convolution; the convolution layer with padding of 18, dilation of 18, and kernel size of 3×3 performs convolution; and the third characteristic parameter is obtained.
[0119] For further information, please refer to Fig.10 , using the semantic segmentation layer to perform convolution calculation on the third convolution result, and the step of obtaining the third feature parameter includes steps 510 to 520.
[0120] Step 510: Use multiple convolution layers to perform convolution calculations on the third convolution result in sequence to obtain an initial third feature parameter.
[0121] Step 520: Use a pooling layer to convolve the initial third feature parameter to obtain a final third feature parameter.
[0122] After obtaining the third feature parameter, a pooling layer with the size of the input is used to pool the input into 1×1, and then a 1×1 convolution is used for dimensionality reduction, and finally upsampled back to the original input size to obtain the final third feature parameter.
[0123] Subsequently, based on the third feature parameter, an SA module is added, that is, the attention mechanism Shuffle Attention is embedded after the 1×1 Conv to divide the target pixels and other pixels, thereby enhancing the attention to dense small target areas, reducing the effective feature loss, and suppressing the confusing feature expression.
[0124] This embodiment also provides an ablation experiment, using YOLOv7 as the baseline of the ablation experiment and using a preset data set as the experimental data set to evaluate the impact of various improved components in RP-YOLO. A total of four groups of ablation experiments, NO.1 to NO.4, are performed. Through comparative experiments, the advantages, disadvantages and effects of various improvement strategies are compared. Please refer to Table 1 for its data parameters.
[0125] Table 1
[0126]
[0127] As can be seen from the table, after adding the attention module to the YOLOv7 algorithm, the model detection mAP0.5 increased to 96.47%, which indicates that the insertion of the SA module reduces the missed detection caused by the YOLOv7 algorithm's failure to extract the features of small rice ears. Switching the SPPCSPC module to the S-ASPP module, it can be seen from the table that S-ASPP has a more significant impact on rice ear target detection, mainly because traditional downsampling can increase the perception field but reduce the spatial resolution, while the use of cavity convolution can expand the perception field while ensuring resolution. Different expansion rate settings will bring different perception fields to the network, allowing the model to capture multi-scale context information. From the data, the application of the SIoU loss function also significantly improves the value of mAP 0.5:0.95, because when predicting boundary regression, SIoU takes into account the overlapping area, centroid distance and aspect ratio of the two frames, so the final detection accuracy is better. Therefore, this method is more comprehensive and integrated, and more suitable for the training process.
[0128] In a second aspect, the present invention further provides a computer storage medium, the computer storage medium comprising a stored program, wherein when the program is run, the rice ear feature extraction method of any one of the above-mentioned first aspects is executed.
[0129] In summary, the present invention provides a method for extracting features of rice ears, obtaining a sampling image of rice ears; then inputting the sampling image of rice ears into a pre-trained rice ear detection model to obtain a feature extraction result of rice ears; wherein the rice ear detection model at least includes an attention module and a semantic segmentation module. The attention module is used to perform convolution calculation on the sampling image of rice ears to obtain an initial feature image. The semantic segmentation module is used to perform convolution calculation on the initial feature image to obtain a feature extraction result of rice ears. Based on this, the present invention can optimize the problems of complex background in the field, occlusion of rice ears and multi-scale targets on the basis of acquiring images using drone images, thereby improving the detection accuracy of crops such as rice.
[0130] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
[0131] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and should be understood that the protection scope of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific variations and combinations that do not deviate from the essence of the present invention based on the technical revelations disclosed by the present invention, and these variations and combinations are still within the protection scope of the present invention.
Claims
1. A method for extracting rice ear features, characterized in that: include: Acquire rice ear sampling images; Inputting the rice ear sampling image into a pre-trained rice ear detection model to obtain a rice ear feature extraction result; wherein the pre-trained rice ear detection model at least includes an attention module and a semantic segmentation module connected in sequence; The attention module and the semantic segmentation module are used to perform convolution calculations on the rice ear sampling images in sequence to obtain rice ear feature extraction results; When the pre-trained rice ear detection model further includes: a convolution module, the step of inputting the rice ear sampling image into the pre-trained rice ear detection model to obtain the rice ear feature extraction result includes: Using the convolution module to perform convolution calculation on the rice ear sampling image to obtain an initial feature image; Using the attention module to perform convolution calculation on the initial feature image to obtain a first feature image; Using the semantic segmentation module to perform convolution calculation on the initial feature image and the first feature image to obtain a rice ear feature extraction result; The step of inputting the rice ear sampling image into the pre-trained rice ear detection model to obtain the rice ear feature extraction result includes the following steps: Construct an initial rice ear detection model; Obtain a rice ear sample image; input the rice ear sample image into a rice ear detection model, train the initial rice ear detection model using a loss function, and obtain a pre-trained rice ear detection model; wherein the loss function is expressed as: ; in, is the total loss value, is the intersection-union ratio, is the distance loss value, is the shape loss value.
2. The rice ear feature extraction method according to claim 1, characterized in that: When the initial feature image includes a first convolution result, a second convolution result and a third convolution result, the convolution module includes a first convolution layer, a second convolution layer and a third convolution layer connected in sequence; the step of performing convolution calculation on the rice ear sampling image using the convolution module to obtain the initial feature image includes: Using the first convolution layer to perform convolution calculation on the rice ear sampling image to obtain a first convolution result; Using the second convolutional layer to perform convolution calculation on the first image feature to obtain a second convolution result; Using the third convolution layer to perform convolution calculation on the second image feature to obtain a third convolution result; Among them, the convolution kernel sizes corresponding to the first convolution layer, the second convolution layer and the third convolution layer are all different.
3. The rice ear feature extraction method according to claim 2, characterized in that: When the first feature image includes a first feature parameter and a second feature parameter, the attention module includes a first attention feature layer, a second attention feature layer and a third attention feature layer connected in sequence; The step of performing convolution calculation on the initial feature image using the attention module to obtain a first feature image includes: Using the first attention feature layer to perform convolution calculation on the first convolution result to obtain the first feature parameter; Using the second attention feature layer to perform convolution calculation on the second convolution result to obtain the second feature parameter; Among them, the convolution kernel sizes corresponding to the first attention feature layer and the second attention feature layer are different.
4. The rice ear feature extraction method according to claim 3, characterized in that: The convolution calculation formula of the first attention feature layer satisfies: ; in, is the channel statistical feature vector; For the first Input feature map Down( ) branches in the spatial dimension, ∈ , ; The input feature map The height of the space, The input feature map Width; is the average pooling function.
5. The rice ear feature extraction method according to claim 3, characterized in that: When the convolution kernel of the first attention feature layer satisfies: 40*40*512, the convolution kernel of the second attention feature layer satisfies: 40*40*1024.
6. The rice ear feature extraction method according to claim 3, characterized in that: When the semantic segmentation module includes: a semantic segmentation layer, a feature fusion layer, and a third attention feature layer connected in sequence; the step of using the semantic segmentation module to perform convolution calculation on the initial feature image and the first feature image to obtain the rice ear feature extraction result includes: Using the semantic segmentation layer to perform convolution calculation on the third convolution result to obtain a third feature parameter; Using the feature fusion layer to sequentially fuse the third feature parameter, the second feature parameter, and the first feature parameter to obtain an initial rice ear feature extraction result; Using the third attention feature layer to perform convolution calculation on the initial rice ear feature extraction result to obtain a final rice ear feature extraction result; The semantic segmentation layer includes a plurality of sequentially connected convolutional layers with different deconvolution sampling rates.
7. The method for extracting rice ear features according to claim 6, characterized in that: When the semantic segmentation layer further includes a pooling layer, the step of performing convolution calculation on the third convolution result using the semantic segmentation layer to obtain the third feature parameter includes: Using multiple convolution layers to sequentially perform convolution calculations on the third convolution result to obtain an initial third feature parameter; The initial third feature parameter is convolved using the pooling layer to obtain the final third feature parameter.
8. A computer storage medium, characterized in that: The computer storage medium includes a stored program, wherein the rice ear feature extraction method according to any one of claims 1 to 7 is executed when the program is run.
Citation Information
Patent Citations
Image semantic segmentation method and system and computer storage medium
CN111523546A
Rice panicle maturity estimation method based on deep learning
CN117409403A