Crop real-time classification method

Through the improved PP-Liteseg semantic segmentation model, combined with the spatial pyramid pooling module and Transformer's lightweight sparse self-attention mechanism, the problem of slow UAV remote sensing data processing speed is solved, and fast and accurate real-time classification of crops is achieved. , suitable for real-time monitoring of agriculture.

CN118799618APending Publication Date: 2024-10-18AGRI INFORMATION INST OF CHINESE ACAD OF AGRI SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410769276.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

Existing technologies cannot achieve both the accuracy and timeliness of crop classification, especially due to the large amount and high resolution of UAV remote sensing data, which results in slow processing speed of deep learning models and difficulty in real-time application.

Method used

Using the improved PP-Liteseg semantic segmentation model, by replacing the simple pyramid pooling module with a spatial pyramid pooling module, and integrating a lightweight sparse self-attention mechanism based on Transformer in the decoder, a real-time crop classification model is constructed, using no Classify real-time images collected by humans and machines.

Benefits of technology

It achieves fast and real-time crop classification while ensuring classification accuracy, improves classification accuracy and processing speed, and is suitable for real-time monitoring and management needs in agricultural production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118799618A_ABST
    Figure CN118799618A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image classification, and particularly provides a crop real-time classification method, which comprises the following steps: constructing a classification model; obtaining a training set of crop images; training the classification model by using a training set of crop images; collecting real-time images of crops; and inputting the crop real-time image into a trained classification model to obtain a classification image. According to the technical scheme, the rapid and real-time crop classification is realized while the classification precision is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of image classification, and specifically provides a real-time classification method for crops. Background Art

[0002] At present, the classification methods for crops are mainly based on satellite remote sensing and UAV remote sensing technology. Among them, satellite remote sensing technology cannot meet the needs of fine classification of crop information due to its limitations such as low resolution, long re-entry period, large interference from meteorological factors, and high data acquisition cost. UAV remote sensing technology has become an important means of obtaining high-resolution remote sensing data due to its advantages such as strong flexibility, short cycle, low cost, and simple operation.

[0003] The implementation of UAV remote sensing technology is generally based on a feature extraction method based on multiple features such as spectral features, texture features and spatial features, and then introduces a neural network and uses deep learning technology to design an end-to-end method. However, due to the large amount of UAV remote sensing data and the high resolution, the deep learning model has a slow processing speed and is difficult to achieve real-time application. Summary of the invention

[0004] In order to overcome the above defects, the present invention is proposed to solve the technical problem that the prior art cannot achieve both accuracy and timeliness in crop classification.

[0005] The present invention provides a method for real-time classification of crops, comprising the following steps:

[0006] S1: Build a classification model;

[0007] S2: obtain the training set of crop images;

[0008] S3: training the classification model using a training set of crop images;

[0009] S4: Collect real-time images of crops;

[0010] S5: Inputting the real-time image of the crop into a trained classification model to obtain a classified image.

[0011] Further, the step S1 comprises the steps of:

[0012] S11: Obtain a PP-Liteseg semantic segmentation model, where the PP-Liteseg semantic segmentation model includes an encoder, a simple pyramid pooling module, and a decoder;

[0013] S12: replacing the simple pyramid pooling module with a spatial pyramid pooling module;

[0014] S13: Integrate a Transformer-based lightweight sparse self-attention mechanism in the decoder.

[0015] Further, the step S2 comprises the steps of:

[0016] Get the original images collected by the drone;

[0017] For each original image of the flight route, one original image is selected every preset number of images;

[0018] Crop the selected original image to get the area containing the relevant category;

[0019] Use LabelMe to semantically annotate the processed original image.

[0020] Further, the step S5 comprises the steps of:

[0021] S51: inputting the real-time image into an encoder, extracting features of different levels of the real-time image, and obtaining an original feature map;

[0022] S52: inputting the original feature map into a spatial pyramid pooling module, extracting key information from the original feature map, and outputting a key feature map;

[0023] S53: Input the key feature map into the decoder, capture the long-distance dependency relationship between the pixels of the key feature map and restore it to obtain a classified image.

[0024] Further, the step S52 includes the steps of:

[0025] S521: Perform convolution operations on the original feature map through self.cv1, self.cv3, and self.cv4 respectively, and output the convolution result;

[0026] S522: performing adaptive average pooling on the convolution result, and outputting a pooling result;

[0027] S523: performing adaptive average pooling on the first pooling result to obtain a second pooling result;

[0028] S524: performing adaptive average pooling on the secondary pooling result to obtain a tertiary pooling result;

[0029] S525: splicing the convolution result, the first pooling result, the second pooling result and the third pooling result along the channel dimension to obtain a spliced ​​feature map;

[0030] S526: performing a convolution operation on the concatenated feature map through self.cv5 and self.cv6, and fusing the feature representations of the two levels after the convolution to obtain a first feature map y1;

[0031] S527: Perform a convolution operation on the first feature map y1 to obtain a second feature map y2;

[0032] S528: Concatenate the first feature map y1 and the second feature map y2 along the channel dimension, and perform a convolution operation through self.cv7 to obtain a key feature map.

[0033] Further, the step S53 includes the steps of:

[0034] S531: Flatten the key feature graph into a one-dimensional sequence to obtain a key feature sequence X = [x 1 ,x 2 ,…,x n ], where n represents the product of the height and width of the key feature map, and each x i is a feature vector;

[0035] S532: Map the key feature map to Query, Key and Value through 1x1 convolution and flatten it into a 2D matrix;

[0036] S533: Perform dot product calculation on the 2D matrix of Query and Key to obtain the attention weight, and apply SoftMax to the attention weight;

[0037] S534: Apply the attention weights to the 2D matrix of Value, perform weighted summation, and obtain the classified image.

[0038] Working principle and beneficial effects of the present invention:

[0039] In the technical solution of the present invention, when it is necessary to classify crops, real-time images of crops are collected by drones or other devices. The real-time images are input into the trained model. The model will first extract features in the image through the encoder, then capture contextual information of different scales through the spatial pyramid pooling module, and use the Transformer-based lightweight sparse self-attention mechanism in the decoder to consider the dependencies between different positions. Finally, the model will output a classification result, indicating the types of crops in the image and surrounding objects. The classification model of the present invention can achieve fast and real-time crop classification while ensuring classification accuracy, which is of great significance for real-time monitoring and management in agricultural production. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The disclosure of the present invention will become more easily understood with reference to the accompanying drawings. It is easy for those skilled in the art to understand that these drawings are only for illustrative purposes and are not intended to limit the scope of protection of the present invention. In addition, similar numbers in the figures are used to represent similar components, among which:

[0041] Figure 1 It is a schematic flow chart of the main steps of a method for real-time classification of crops of the present invention;

[0042] Figure 2 It is a structural schematic diagram of a classification model in a real-time crop classification method of the present invention;

[0043] Figure 3 It is a schematic diagram of the structure of the spatial pyramid pooling module in the classification model of the present invention;

[0044] Figure 4 It is a schematic diagram of the structure of the self-attention mechanism in the classification model of the present invention;

[0045] Figure 5 It is a schematic diagram of outputting the final image of the present invention. DETAILED DESCRIPTION

[0046] Some embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.

[0047] Figure 1 FIG. 1 is a flow chart showing the main steps of a method for real-time classification of crops according to the present invention. Figure 1 As shown, a real-time crop classification method in this embodiment mainly includes the following steps S1 to S5.

[0048] Step S1: Build a classification model.

[0049] Figure 2 Schematic diagram of the structure of the classification model in the real-time classification method of crops of the present invention. Figure 2 As shown in the figure, the improved model is the PP-Liteseg semantic segmentation model, which is a lightweight model that has achieved the best match between speed and accuracy in urban remote sensing images. The model consists of an encoder, a pooling module, and a decoder. The accuracy is improved by improving the pooling module and the decoder, and the processing speed remains basically unchanged.

[0050] Specifically, the pooling module of the PP-Liteseg semantic segmentation model is changed from the simple pyramid pooling module (SPPM) to the SPPFCSPCA spatial pyramid pooling module, and a Transformer-based lightweight sparse self-attention mechanism is integrated in the decoder.

[0051] Step S2: Obtain a training set of crop images.

[0052] Before the experiment begins, the various crop categories in the experimental area are determined, including the crops to be planted, the planting area, and whether there are canals, ridges, trees, roads, etc. around the crops. The number of categories is determined to prepare for subsequent data labeling.

[0053] Step S21: obtaining the original image collected by the drone;

[0054] Data collection covers the growing period of all crops on the farm, from the sowing of the first crop to the harvesting of the last crop, during which data is collected by drone every 14 days.

[0055] The DJI M300RTK drone was selected, with a flight altitude of 160 meters, a lateral overlap rate of 70%, a heading overlap rate of 80%, a ground sampling distance (GSD) of 2 cm, and an image resolution of 8192*5460. The total area of ​​the experimental area is 3200 mu, and a set of drone batteries can fly 1000 mu, and 2110 pictures can be obtained each time.

[0056] Step S22: For each original image of the flight route, one original image is selected every preset number of original images.

[0057] Since the heading overlap rate is high enough, data selection is performed for each collected data. Data selection method: First, every other flight route of the drone is selected, and for the images of the same route, every fourth image is selected for model training.

[0058] Step S23: cropping the selected original image to obtain the area containing the relevant category.

[0059] Step S24: Use LabelMe to semantically annotate the processed original image.

[0060] Furthermore, in actual training, the processed data is divided into a training set and a validation set with a ratio of 8:2, which is used for validation after training the expected model.

[0061] Step S3: Train the classification model using the training set of crop images.

[0062] Step S4: Collect real-time images of crops.

[0063] In this embodiment, the trained classification model is deployed on the existing management platform or drone remote control equipment of the farm, and the real-time images of crops collected by the drone are transmitted to the platform using the transmission protocol.

[0064] Step S5: input the real-time image of crops into the trained classification model to obtain a classified image.

[0065] Specifically, step S5 includes steps S51-S53.

[0066] Step S51: input the real-time image into the encoder, extract different levels of features of the real-time image, and obtain the original feature map.

[0067] Step S52: Input the original feature map into the spatial pyramid pooling module, extract the key information in the original feature map, and output the key feature map.

[0068] Figure 3 Schematic diagram of the structure of the spatial pyramid pooling module in the classification model of the present invention. Figure 3 As shown, specifically, step S52 includes steps S521-S527.

[0069] Step S521: Perform convolution operations on the original feature map through self.cv1, self.cv3, and self.cv4 respectively, and output the convolution result as a multi-scale feature x1. The convolution result is a feature representation of three levels;

[0070] Step S522: performing adaptive average pooling on the convolution result, and extracting the pooling result as a multi-scale feature x2;

[0071] Step S523: performing adaptive average pooling on the first pooling result to obtain a multi-scale feature x3 of the second pooling result;

[0072] Step S524: performing adaptive average pooling on the secondary pooling result to obtain a tertiary pooling result;

[0073] Step S525: concatenate the multi-scale features x1, x2, x3 and the features after adaptive average pooling again along the channel dimension;

[0074] Adaptive average pooling is a pooling operation that resizes the input feature map to a specified size. The specific formula is as follows:

[0075]

[0076] Among them, H and W are the height and width of the output feature map, X ij Represents the value of the i-th row and j-th column of the feature map X, y k is the pooled output of the kth channel.

[0077] Step S526: self.cv5 and self.cv6 perform convolution processing on the concatenated features, and fuse the feature representations of the two levels after the convolution to generate the first feature map as the fused feature y1;

[0078] Step S527: self.cv2 performs convolution processing on the fused feature y1 to generate y2;

[0079] Step S526: Concatenate y1 and y2 along the channel dimension, perform convolution operation through self.cv7, and generate a key feature map.

[0080] This module combines the spatial pyramid pooling technology with adaptive average pooling and the cross-stage partial connection technology (CSPC), which enhances the model's ability to perceive the global and local information of the input image and improves the model's receptive field. The application of CSPC technology effectively promotes the propagation of features and the flow of information, accelerating the convergence speed and performance of the network.

[0081] Step S53: Input the original feature map and the key feature map into the decoder to capture and restore the long-distance dependencies between pixels to obtain the final image after classification.

[0082] Figure 4 Schematic diagram of the self-attention mechanism in the classification model of the present invention. Figure 4 As shown, specifically, step S53 includes steps S531-S534.

[0083] Step S531: Flatten the key feature graph into a one-dimensional sequence to obtain a key feature sequence X = [x 1 ,x 2 ,…,x n ], where n represents the product of the height and width of the key feature map, and each x i is a eigenvector;

[0084] Step S532: For the original feature map, map it to Query, Key and Value through 1x1 convolution and flatten it into a 2D matrix;

[0085] Specifically, the key feature sequence is linearly transformed to obtain the Query sequence Query(X)=X*W Q 、Key sequence Key(X)=X*W K And Value sequence Key(X)=X*W K , where W Q , W K , W V is the learnable weight matrix.

[0086] Step S533: Calculate the similarity between the Query sequence and the Key sequence to represent the correlation between positions, where is the dimension of Key; the calculated attention matrix represents the importance distribution of each position to other positions, and SoftMax is a normalization operation on the similarity.

[0087] Specifically, calculate the similarity between the Query sequence and the Key sequence Among them, d k It is the dimension of Key.

[0088] Step S534: Apply the attention weight to the Value to generate an output feature map, perform weighted addition on the output feature map and the key feature map to generate the final output classification image. Figure 5 It is a schematic diagram of outputting the final image of the present invention.

[0089] Specifically, the attention score is used to perform weighted summation on the Value sequence Output(X)=Attention(Q,K)*T to obtain a classified image.

[0090] The self-attention mechanism can capture long-distance dependencies between pixels and enable the model to better understand contextual information, which helps improve the model's semantic understanding of each pixel, especially when there are distant associations between pixels.

[0091] Based on the above classification model PP-Liteseg-ASA, the performance is improved compared with the existing classification methods. The overall classification accuracy is 94.79%, the average interaction ratio MIoU is increased by 2.79%, Kappa is increased by 1%, and the FPS is about 270, which is more suitable for the identification and classification of crops.

[0092] It should be pointed out that although the various steps in the above embodiments are described in a specific order, those skilled in the art can understand that in order to achieve the effects of the present invention, different steps do not have to be performed in such an order. They can be performed simultaneously (in parallel) or in other orders. These changes are within the scope of protection of the present invention.

[0093] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.

Claims

1. A real-time crop classification method, characterized in that: The following steps are involved: S1: Build a classification model; S2: obtain the training set of crop images; S3: training the classification model using a training set of crop images; S4: Collect real-time images of crops; S5: Inputting the real-time image of the crop into a trained classification model to obtain a classified image.

2. A method for real-time classification of crops according to claim 1, characterized in that: The step S1 comprises the steps of: S11: Obtain a PP-Liteseg semantic segmentation model, where the PP-Liteseg semantic segmentation model includes an encoder, a simple pyramid pooling module, and a decoder; S12: replacing the simple pyramid pooling module with a spatial pyramid pooling module; S13: Integrate a Transformer-based lightweight sparse self-attention mechanism in the decoder.

3. A method for real-time classification of crops according to claim 1, characterized in that: The step S2 comprises the steps of: Get the original images collected by the drone; For each original image of the flight route, one original image is selected every preset number of images; Crop the selected original image to get the area containing the relevant category; Use LabelMe to semantically annotate the processed original image.

4. A method for real-time classification of crops according to claim 2, characterized in that: The step S5 comprises the steps of: S51: inputting the real-time image into an encoder, extracting features of different levels of the real-time image, and obtaining an original feature map; S52: inputting the original feature map into a spatial pyramid pooling module, extracting key information from the original feature map, and outputting a key feature map; S53: Input the key feature map into the decoder, capture the long-distance dependency relationship between the pixels of the key feature map and restore it to obtain a classified image.

5. A method for real-time classification of crops according to claim 4, characterized in that: The step S52 comprises the steps of: S521: Perform convolution operations on the original feature map through self.cv1, self.cv3, and self.cv4 respectively, and output the convolution result; S522: performing adaptive average pooling on the convolution result, and outputting a pooling result; S523: performing adaptive average pooling on the first pooling result to obtain a second pooling result; S524: performing adaptive average pooling on the secondary pooling result to obtain a tertiary pooling result; S525: splicing the convolution result, the first pooling result, the second pooling result and the third pooling result along the channel dimension to obtain a spliced ​​feature map; S526: performing a convolution operation on the concatenated feature map through self.cv5 and self.cv6, and fusing the feature representations of the two levels after the convolution to obtain a first feature map y1; S527: Perform a convolution operation on the first feature map y1 to obtain a second feature map y2; S528: Concatenate the first feature map y1 and the second feature map y2 along the channel dimension, and perform a convolution operation through self.cv7 to obtain a key feature map.

6. A method for real-time classification of crops according to claim 4, characterized in that: The step S53 comprises the steps of: S531: Flatten the key feature graph into a one-dimensional sequence to obtain the key feature sequence X = [x1, x2, ..., x n ], where n represents the product of the height and width of the key feature map, and each x i is a feature vector; S532: Map the key feature map to Query, Key and Value through 1x1 convolution and flatten it into a 2D matrix; S533: Perform dot product calculation on the 2D matrix of Query and Key to obtain the attention weight, and apply SoftMax to the attention weight; S534: Apply the attention weights to the 2D matrix of Value, perform weighted summation, and obtain the classified image.