A crop remote sensing image segmentation method based on patch-level classification labels
Through a method based on patch-level classification labels, knowledge distillation and multi-layer pseudo-supervision technology are used to solve the problems of insufficient model generalization ability and high computing resources in crop remote sensing image segmentation, achieving more efficient and accurate segmentation results, and Reduces labeling requirements and computational costs.
Patent Information
- Application Number
- CN202410736895.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2044-06-07
AI Technical Summary
In current crop remote sensing image segmentation, models based on weakly supervised or unsupervised learning methods have insufficient generalization capabilities, knowledge transfer methods have high computational resource and time costs when adapting to crop characteristics, and traditional methods fail to make full use of unreliable Forecast information.
Using a method based on patch-level classification labels, the robustness is enhanced by pre-training the image model for patch-level annotation, and low-quality pseudo-label data is used in knowledge distillation to reduce the need for image annotation, and the patch-level is reduced through multi-layer pseudo supervision. and the information gap between pixel-level labels, using SwinTransformer and Unet network for knowledge distillation and segmentation model training.
It significantly reduces the need for finely labeled data, improves the accuracy and robustness of the segmentation network, provides more precise spatial information, reduces computational costs, and improves model generalization capabilities.
Smart Images

Figure CN118314352B
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of remote sensing image processing, and in particular relates to a crop remote sensing image segmentation method based on patch-level classification labels. Background Art
[0002] Image classification is the process of distinguishing different categories of images based on their semantic information. It uses computers to quantitatively analyze images and classify images or each pixel or region in them into one of several categories. Image segmentation is the technology and process of dividing an image into several specific regions with unique properties and proposing objects of interest.
[0003] Specifically, image semantic segmentation is the pixel-level classification of images.
[0004] Crop remote sensing image segmentation is one of the key technologies for realizing intelligent land management and decision support. Traditional deep learning-based methods require accurate labeling of each pixel to distinguish different crops, soils, etc. This process requires professional knowledge and experience, and the labeling workload is large and time-consuming. Therefore, data labeling has become an important factor restricting the size of the data set. In addition, traditional pixel-level classification methods only retain prediction results with high confidence, and fail to make full use of unreliable prediction information during the training process; while image patch-level labels label or classify specific areas or blocks (patches) in the image, greatly saving labeling costs.
[0005] Existing frameworks for improving the utilization of crop remote sensing image segmentation data can be divided into two categories:
[0006] Based on weakly supervised or unsupervised learning methods and knowledge transfer methods. The former aims to use incomplete labeled data for training and reduce the threshold for data annotation details, while the latter uses other related fields as pre-trained models and parameters as starting points, and then fine-tunes them on agricultural remote sensing image datasets to reduce the requirements for the amount of labeled data.
[0007] For example, Chinese patent CN116434075A, published on July 14, 2023, discloses a method for classifying objects in optical remote sensing images based on multi-level pseudo-relationship learning. It uses a multi-level pseudo-relationship network model, combines the pixel and local patch-level pseudo-relationship losses of the source and target domains, optimizes the model and transfers knowledge to achieve object classification in optical remote sensing images. The paper "Semi-Supervised Semantic Segmentation Using Unreliable Pseudo-Labels" proposes to make full use of unlabeled data including unreliable samples, and achieved the best accuracy on both PASCAL VOC datasets.
[0008] At present, the shortcomings of the prior art are as follows:
[0009] First, when weakly supervised or unsupervised learning methods are used to train by using incompletely labeled data or data that does not require labeling, since weakly supervised or unsupervised learning methods usually do not rely on accurate pixel-level labels, the generalization ability of the model may be limited due to insufficient labeling information, and the segmentation accuracy on new data sets is not high.
[0010] Second, the knowledge transfer-based method uses a pre-trained model in other related fields as a starting point and then fine-tunes it on the agricultural remote sensing image dataset. Although the pre-trained model may perform well in other related fields, crop remote sensing images have their own unique characteristics and challenges, such as lighting conditions, crop growth stage, terrain, etc.; therefore, the pre-trained model may not be fully adapted to the crop remote sensing image segmentation task, resulting in poor transfer effect; in addition, although the knowledge transfer method can reduce the requirement for the amount of labeled data, it still requires a lot of computing resources and time costs during the fine-tuning process. Summary of the invention
[0011] In view of the shortcomings of the prior art, the present invention provides a crop remote sensing image segmentation method based on patch-level classification labels. The method firstly enhances the robustness to noise and local changes by pre-training the model of patch-level annotated images; at the same time, makes full use of low-quality pseudo-label data in knowledge distillation to improve the generalization ability of the model; secondly, uses the pixel-level classification results to obtain the pseudo-mask in the segmentation process, effectively reducing the requirements on the quality and quantity of image annotation; and narrows the information gap between patch-level labels and pixel-level labels through multi-layer pseudo-supervision.
[0012] Specifically, the embodiment of the present invention is implemented as follows: a crop remote sensing image segmentation method based on patch-level classification labels, the method comprising the following steps:
[0013] Step S1: Use the image encoding matrix with patch-level labels and tags Train the teacher network and student network in knowledge distillation separately, use the reliable prediction results of the teacher network as pseudo labels of the student network, include the unreliable prediction results into the negative sample queue, and calculate the total loss function ;
[0014] Step S2: Generate pixel-level pseudo mask of segmentation model based on category activation map ;
[0015] Step S3: Pixel-level pseudo mask generated by the classification stage Train the segmentation model, generate multiple layers of pseudo labels from three different layers of the student network in the classification stage, and calculate the cross entropy loss between the semantic segmentation results and the pseudo labels at different layers;
[0016] Step S4: Initialize the parameters of the classification network, then use the training data for forward propagation and back propagation, calculate the gradient of the loss function, and use optimization algorithms such as gradient descent to update the network parameters until the total loss function reaches the preset convergence condition;
[0017] Step S5: For a given test set of crop remote sensing images, the student network is used as the backbone network model to extract features, the probability of the category to which each pixel of the segmented output target image belongs is obtained, and a threshold is set to mark the pixel as a segmentation target or background.
[0018] As a further solution of the present invention, in step S1, an image preprocessing step is also included. In the image preprocessing step, for a given Input images with patch-level labels, unify the image size, and normalize the input images to obtain the encoding matrix , label Convert to one-hot encoding format and then use the patch-level labeled image encoding matrix and tags Train the teacher network and student network in knowledge distillation separately.
[0019] As a further solution of the present invention, in step S2, the teacher network and the student network respectively include an encoder based on SwinTransformer and Unet , a decoder with a segmentation header and a representation head .
[0020] As a further solution of the present invention, unreliable pixel-level pseudo labels are filtered based on pixel-level entropy during teacher network training, and pixel-level pseudo masks of images are generated by the student network.
[0021] As a further solution of the present invention, during the training process of the teacher network, all images The encoding is input into the teacher network for unsupervised prediction, and the confidence of the pseudo label is evaluated by calculating the entropy value of each pixel in its classification prediction. The specific calculation formula is as follows:
[0022] (1)
[0023] in, represents the probability of the teacher model generating the i-th image segmentation head at pixel j, Indicates the number of categories;
[0024] The smaller the entropy, the higher the prediction confidence. Set the threshold to filter out unreliable prediction results:
[0025] (2)
[0026] in, Indicates The entropy threshold for training steps, Represents the predicted probability value The label corresponding to the maximum value;
[0027] Sample each class anchor pixel in the current batch during the training phase to obtain the feature set :
[0028] (3);
[0029] in, Representative image No. Pixels represent; is the positive threshold, set to 0.3;
[0030] The positive samples of the same type of anchor points are all anchor point centers, and the extraction formula is:
[0031] (4);
[0032] No. Negative samples of semantic segmentation images meet the following three basic conditions: first, they are unreliable prediction results; second, the image does not belong to the Class; secondly, it does not belong to the most likely class predicted by the teacher model;
[0033] Introducing pixel-level category indexing , specifically:
[0034] (5);
[0035] in, Express The index of the sorted elements;
[0036] No. The negative sample judgment formula for semantic segmentation images is as follows:
[0037] (6);
[0038] Among them, for When pixel entropy Higher than hour Set to 1, pixel-level category index Greater than the lower threshold and is less than the high-order threshold hour Set to 1;
[0039] Finally, The class negative sample set is:
[0040] (7).
[0041] As a further solution of the present invention, in the training process of the student network, the image And the corresponding patch-level label Fully supervised training of the student model, and pseudo-supervised training using reliable labels generated by the teacher model, respectively calculating the full supervision loss function and pseudo-supervisory loss function , the calculation method is as follows:
[0042] (8);
[0043] in, represents the ReLU activation function, represents the cross entropy loss function, Represents the predicted probability corresponding to each patch of the student network, are reliable labels from the teacher model;
[0044] In order to reduce the information loss caused by the underutilization of pseudo labels, the student network introduces unreliable pseudo label comparison loss , as shown in formula (9):
[0045] (9);
[0046] in, represents the total number of anchor pixels, represent Class Anchor feature representation, Indicates each The corresponding positive sample is Indicates each Corresponding negative samples, Used to calculate the cosine similarity between two different pixel features. is a hyperparameter.
[0047] As a further solution of the present invention, in the process of generating pixel-level pseudo masks, based on the trained multi-label classification student model, a gradient weighted class activation mapping Grad-CAM method is used to generate pixel-level pseudo masks; specifically:
[0048] (10);
[0049] in, is the encoder, It represents the head. represents the classification parameters, and Grad-CAM is the class activation mapping calculation method.
[0050] As a further solution of the present invention, in the segmentation stage of step S3, new training data is formed by using the pixel-level pseudo mask obtained in step S2; at the same time, in order to reduce the information gap between the patch-level label and the pixel-level label, multi-layer pseudo supervision is performed on the final segmentation result; specifically, it can be divided into two steps:
[0051] Step S31: Image After all the inputs are put into the encoder-decoder of the segmentation model, the output result feature maps of different categories are obtained. Then, each feature map is processed by global average pooling in turn. The obtained results are used together with the pseudo mask generated in the classification stage to calculate the loss function for full supervision. ;
[0052] Specific:
[0053] (11);
[0054] (12);
[0055] in, represents global average pooling, Represents a decoder, represents the encoder, represents the segmentation parameters;
[0056] Step S32: In order to integrate the semantic information of different levels in different coding stages, the final segmentation result obtained in step S31 is Perform full supervision with the three-stage feature maps generated by the encoder in the classification network to calculate the loss function of the segmentation stage :
[0057] (13);
[0058] in, , and is the weight factor, and its corresponding values are 0.2, 0.3, and 0.5 respectively. The loss function between the semantic segmentation result and each semantic feature map uses the cross entropy loss.
[0059] As a further solution of the present invention, in step S4, the first part of the loss is a linear combination of the student network full supervision loss, knowledge distillation pseudo supervision loss and positive and negative sample comparison loss in the segmentation stage in step S2; the second part of the loss is the classification-segmentation fusion loss in step S3 and the multi-layer pseudo supervision loss in step S3;
[0060] The parameters of the above classification network are updated iteratively until the total loss function reaches the preset convergence condition. Specifically:
[0061] The first part of the loss calculation is shown in formula (14):
[0062] (14);
[0063] in , and It is a weight factor, the purpose of which is the proportion of the full supervision loss contrast loss, knowledge distillation pseudo-supervision loss and positive and negative sample contrast loss of the student network model in the loss function of the classification stage.
[0064] As a further solution of the present invention, in step S5, for the target image data prediction, a prediction probability greater than a threshold of 0.5 is foreground, and a prediction probability less than 0.5 is for background, so as to obtain a final segmentation mask.
[0065] Compared with the prior art, the crop remote sensing image segmentation method based on patch-level classification labels of the present invention has the following beneficial effects:
[0066] First, the present invention introduces the classification model prediction results as pixel-level pseudo labels in the segmentation network, making full use of the fine-grained information in the classification model prediction results, significantly reducing the need for a large amount of finely labeled data;
[0067] Second, compared with traditional weakly supervised or unsupervised methods, pixel-level pseudo-labels provide more precise and detailed spatial information, which helps the segmentation network to more accurately locate the boundaries of different objects;
[0068] Third, most traditional methods ignore the value of unreliable prediction results, resulting in a large amount of information loss. The present invention incorporates unreliable pseudo labels into the negative sample queue to calculate the contrast loss through knowledge distillation, thereby improving the accuracy and robustness of segmentation;
[0069] Fourth, in the knowledge distillation stage, the present invention adopts Swin Transformer as the teacher network and Unet student network as the backbone network, which ensures the segmentation performance while achieving model lightweight and reducing computational costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1This is an overall framework diagram of a crop remote sensing image segmentation method based on patch-level classification labels of the present invention;
[0071] Figure 2 A flowchart for implementing the crop remote sensing image segmentation method based on patch-level classification labels provided by the present invention;
[0072] Figure 3 This is a flow chart of student network training in the crop remote sensing image segmentation method based on patch-level classification labels of the present invention. DETAILED DESCRIPTION
[0073] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0074] In view of the shortcomings of the existing technology, the present invention designs a crop remote sensing image segmentation method based on patch-level classification labels. First, by pre-training the model of patch-level labeled images, the robustness to noise and local changes is enhanced; at the same time, low-quality pseudo-label data is fully utilized in knowledge distillation to improve the generalization ability of the model; secondly, the pixel-level classification results are used to obtain the pseudo-mask in the segmentation process, effectively reducing the requirements on the quality and quantity of image annotation; and the information gap between patch-level labels and pixel-level labels is narrowed through multi-layer pseudo-supervision.
[0075] The crop remote sensing image segmentation method based on patch-level classification labels of the present invention comprises the following steps: using patch-level annotated image data to respectively train a teacher network (Swin Transformer) and a student network (Unet); in the output of the teacher network, reliable prediction results are screened out as pseudo labels of the student network, and unreliable results are used as negative samples of the student network; secondly, the classification results of the student network are used to generate pixel-level pseudo masks of the image segmentation model, and feature maps of different encoding stages of the student network are used as pseudo labels of the segmentation model; finally, the fully trained student model is used as the backbone network to segment the test set images, and the accuracy of the results is evaluated.
[0076] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments.
[0077] like Figure 1 and Figure 2 As shown, in one embodiment of the present invention, a crop remote sensing image segmentation method based on patch-level classification labels comprises the following steps:
[0078] Step S1: Use the image encoding matrix with patch-level labels and tags Train the teacher network and student network in knowledge distillation separately, use the reliable prediction results of the teacher network as pseudo labels of the student network, put the unreliable prediction results into the negative sample queue, and calculate the total loss function ;
[0079] Before step S1, the present invention further comprises a step of preprocessing the image. In the step of preprocessing the image, for a given Input images with patch-level labels, unify the image size, and normalize the input images to obtain the encoding matrix , label Convert to one-hot encoding format and then use the patch-level labeled image encoding matrix and tags Train the teacher network and student network in knowledge distillation separately.
[0080] Among them, the steps for image preprocessing can be divided into three steps:
[0081] Image cropping: First, the nearest neighbor interpolation algorithm is applied to scale the image to the same size so that the input image meets the input specifications of the Swin Transformer and Unet networks;
[0082] Normalization: For images of the same size Normalize the pixel values to the range [0,1] to improve the convergence speed and performance of the algorithm; the specific calculation formula is as follows:
[0083] ;
[0084] in, Represents the pixel values of the three channels of the image RGB, represents the minimum pixel value, Represents the maximum pixel value;
[0085] Image and label encoding: The normalized image pixel values are used as the input of the network model. Tags are divided into different categories, create a The two-dimensional matrix stores the one-hot encoding; for each label , find the index in the category set, set the element at the index position to 1 in the corresponding row of the one-hot encoding matrix, and set the remaining positions to 0.
[0086] For further information, please refer to Figure 1 and Figure 2 The crop remote sensing image segmentation method based on patch-level classification labels of the present invention also includes:
[0087] Step S2: Generate pixel-level pseudo mask of segmentation model based on category activation map ;
[0088] Step S3: Pixel-level pseudo mask generated by the classification stage Train the segmentation model, generate multiple layers of pseudo labels from three different layers of the student network in the classification stage, and calculate the cross entropy loss between the semantic segmentation results and the pseudo labels at different layers;
[0089] Step S4: Initialize the parameters of the classification network, then use the training data for forward propagation and back propagation, calculate the gradient of the loss function, and use optimization algorithms such as gradient descent to update the network parameters until the total loss function reaches the preset convergence condition;
[0090] Step S5: For a given test set of crop remote sensing images, the student network is used as the backbone network model to extract features, the probability of the category to which each pixel of the segmented output target image belongs is obtained, and a threshold is set to mark the pixel as a segmentation target or background; preferably, for target image data prediction, a predicted probability greater than a threshold of 0.5 is foreground, and a probability less than 0.5 is background, so as to obtain the final segmentation mask.
[0091] Among them, the teacher network and the student network in step S2 include an encoder based on Swin Transformer and Unet respectively. , a decoder with a segmentation header and a representation head .
[0092] Furthermore, in an embodiment of the present invention, unreliable pixel-level pseudo labels are filtered based on pixel-level entropy during teacher network training, and a pixel-level pseudo mask of an image is generated by a student network.
[0093] Furthermore, during the training of the teacher network, all images The encoding is input into the teacher network for unsupervised prediction, and the confidence of the pseudo label is evaluated by calculating the entropy value of each pixel in its classification prediction. The specific calculation formula is as follows:
[0094] (1)
[0095] in, represents the probability of the teacher model generating the i-th image segmentation head at pixel j, Indicates the number of categories;
[0096] The smaller the entropy, the higher the prediction confidence. Set the threshold to filter out unreliable prediction results:
[0097] (2)
[0098] in, Indicates The entropy threshold for training steps, Represents the predicted probability value The label corresponding to the maximum value;
[0099] Sample each class anchor pixel in the current batch during the training phase to obtain the feature set :
[0100] (3);
[0101] in, Representative image No. Pixels represent; is the positive threshold, set to 0.3;
[0102] The positive samples of the same type of anchor points are all anchor point centers, and the extraction formula is:
[0103] (4);
[0104] No. Negative samples of semantic segmentation images meet the following three basic conditions: first, they are unreliable prediction results; second, the image does not belong to the Class; secondly, it does not belong to the most likely class predicted by the teacher model;
[0105] Introducing pixel-level category indexing , specifically:
[0106] (5);
[0107] in, Express The index of the sorted elements;
[0108] No. The negative sample judgment formula for semantic segmentation images is as follows:
[0109] (6);
[0110] Among them, for When pixel entropy Higher than hour Set to 1, pixel-level category index Greater than the lower threshold and is less than the high-order threshold hour Set to 1;
[0111] Finally, The class negative sample set is:
[0112] (7).
[0113] like Figure 3 As shown, during the training of the student network, the image And the corresponding patch-level label Fully supervised training of the student model, and pseudo-supervised training using reliable labels generated by the teacher model, respectively calculating the full supervision loss function and pseudo-supervisory loss function , the calculation method is as follows:
[0114] (8);
[0115] in, represents the ReLU activation function, represents the cross entropy loss function, Represents the predicted probability corresponding to each patch of the student network, are reliable labels from the teacher model;
[0116] In order to reduce the information loss caused by the underutilization of pseudo labels, the student network introduces unreliable pseudo label comparison loss , as shown in formula (9):
[0117] (9);
[0118] in, represents the total number of anchor pixels, represent Class Anchor feature representation, Indicates each The corresponding positive sample is Indicates each Corresponding negative samples, Used to calculate the cosine similarity between two different pixel features. is a hyperparameter.
[0119] Furthermore, in the process of generating pixel-level pseudo masks, based on the trained multi-label classification student model, the gradient-weighted class activation mapping Grad-CAM method is used to generate pixel-level pseudo masks; specifically:
[0120] (10);
[0121] in, is the encoder, It represents the head. Represents classification parameters; represents the combination function of h and g; Grad-CAM is the class activation mapping calculation method (Selvaraju RR, Cogswell M, Das A, et al. Grad-cam: Visual explanations from deep networks via gradient-based localization[C] / / Proceedings of the IEEE internationalconference on computer vision. 2017:618-626.).
[0122] Furthermore, in the segmentation stage of step S3, new training data is formed by the pixel-level pseudo mask obtained in step S2; at the same time, in order to reduce the information gap between patch-level labels and pixel-level labels, multi-layer pseudo supervision is performed on the final segmentation result; specifically, it can be divided into two steps:
[0123] Step S31: Image After all the inputs are put into the encoder-decoder of the segmentation model, the output result feature maps of different categories are obtained. Then, each feature map is processed by global average pooling in turn. The obtained results are used together with the pseudo mask generated in the classification stage to calculate the loss function for full supervision. ;
[0124] Specific:
[0125] (11);
[0126] (12);
[0127] in, represents global average pooling, Represents a decoder, represents the encoder, represents the segmentation parameters;
[0128] Step S32: In order to integrate the semantic information of different levels in different coding stages, the final segmentation result obtained in step S31 is Perform full supervision with the three-stage feature maps generated by the encoder in the classification network to calculate the loss function of the segmentation stage :
[0129] (13);
[0130] in, , and is the weight factor, and its corresponding values are 0.2, 0.3, and 0.5 respectively. The loss function between the semantic segmentation result and each semantic feature map uses the cross entropy loss.
[0131] Furthermore, in step S4, the first part of the loss is a linear combination of the student network full supervision loss, knowledge distillation pseudo supervision loss, and positive and negative sample comparison loss in the segmentation stage in step S2; the second part of the loss is the classification-segmentation fusion loss in step S3 and the multi-layer pseudo supervision loss in step S3;
[0132] The parameters of the above classification network are updated iteratively until the total loss function reaches the preset convergence condition. Specifically:
[0133] The first part of the loss calculation is shown in formula (14):
[0134] (14);
[0135] in , and It is a weight factor, the purpose of which is the proportion of the full supervision loss contrast loss, knowledge distillation pseudo-supervision loss and positive and negative sample contrast loss of the student network model in the loss function of the classification stage.
[0136] The present invention aims to improve the classification performance of crop remote sensing images under unreliable pseudo-labels by introducing knowledge distillation technology. The unreliable prediction results predicted by the teacher model are used to calculate the positive and negative sample comparison loss, which effectively prevents information loss during the image data training process, realizes efficient semantic classification under limited labeled data, and greatly enhances the robustness of the model to wrong labels.
[0137] The present invention uses the pixel-level encoding generated by the segmentation model as the pseudo-label in the segmentation stage, which effectively solves the workload problem of the segmentation model for annotating crop remote sensing images. At the same time, multi-layer pseudo-supervision enables the network to learn richer contextual information and multi-scale features, narrows the information gap between patch-level labels and pixel-level labels, and improves the accuracy and generalization ability of segmentation.
[0138] In summary, the present invention introduces the prediction results of the classification model as pixel-level pseudo-labels in the segmentation network, fully utilizes the fine-grained information in the prediction results of the classification model, and significantly reduces the demand for a large amount of finely labeled data; compared with traditional weakly supervised or unsupervised methods, pixel-level pseudo-labels provide more precise and detailed spatial information, which helps the segmentation network to more accurately locate the boundaries of different objects; most traditional methods ignore the value of unreliable prediction results, resulting in a large amount of information loss. The present invention incorporates unreliable pseudo-labels into the negative sample queue through knowledge distillation to calculate the contrast loss, thereby improving the accuracy and robustness of segmentation.
[0139] Although the embodiments of the present invention have been disclosed above, they are not limited to the applications listed in the specification and the embodiments. It can be fully applied to various fields suitable for the present invention. For those familiar with the art, additional modifications can be easily realized. Therefore, without departing from the general concept defined by the claims and equivalent scope, the present invention is not limited to the specific details and the illustrations shown and described here.
Claims
1. A crop remote sensing image segmentation method based on patch-level classification labels, characterized in that: The method comprises the following steps: Step S1: Use the image encoding matrix with patch-level labels and tags Train the teacher network and student network in knowledge distillation separately, use the reliable prediction results of the teacher network as pseudo labels of the student network, include the unreliable prediction results into the negative sample queue, and calculate the total loss function ; Step S2: Generate a segmentation model pixel-level pseudo mask p based on the category activation map; Step S3: train the segmentation model through the pixel-level pseudo mask p generated in the classification stage, generate multiple layers of pseudo labels from three different levels of the student network in the classification stage, and calculate the cross entropy loss between the semantic segmentation results and the pseudo labels in different layers; Step S4: Initialize the parameters of the classification network, then use the training data for forward propagation and back propagation, calculate the gradient of the loss function, and use the gradient descent optimization algorithm to update the network parameters until the total loss function reaches the preset convergence condition; Step S5: for a given test set of crop remote sensing images, the student network is used as the backbone network model to extract features, the probability of the category to which each pixel of the segmented output target image belongs is obtained, and a threshold is set to mark the pixel as a segmentation target or background; In the teacher network training, unreliable pixel-level pseudo labels are filtered based on pixel-level entropy, and the student network generates pixel-level pseudo masks for the images. During the training of the teacher network, all images The encoding is input into the teacher network for unsupervised prediction, and the confidence of the pseudo label is evaluated by calculating the entropy value of each pixel in its classification prediction. The specific calculation formula is as follows: (1); in, represents the probability of the teacher model generating the i-th image segmentation head at pixel j, Indicates the number of categories; The smaller the entropy, the higher the prediction confidence. Set the threshold to filter out unreliable prediction results: (2); in, Indicates The entropy threshold for training steps, Represents the predicted probability value The label corresponding to the maximum value; Sample each class anchor pixel in the current batch during the training phase to obtain the feature set : (3); in, Representative image No. Pixels represent; is the positive threshold, set to 0.3; The positive samples of the same type of anchor points are all anchor point centers, and the extraction formula is: (4); No. Negative samples of semantic segmentation images meet the following three basic conditions: first, they are unreliable prediction results; second, the image does not belong to the Class; secondly, it does not belong to the most likely class predicted by the teacher model; Introducing pixel-level category indexing , specifically: (5); in, Express The index of the sorted elements; No. The negative sample judgment formula for semantic segmentation images is as follows: (6); Among them, for When pixel entropy Higher than hour Set to 1, pixel-level category index Greater than the lower threshold and is less than the high-order threshold hour Set to 1; Finally, The negative sample set is: (7); In the process of pixel-level pseudo mask generation, based on the trained multi-label classification student model, the gradient weighted class activation mapping Grad-CAM method is used to generate pixel-level pseudo masks; specifically: (10); in, is the encoder, It represents the head. represents the classification parameters, Grad-CAM is the class activation mapping calculation method; represents the combination function of h and g.
2. The crop remote sensing image segmentation method based on patch-level classification labels according to claim 1 is characterized in that: In step S1, an image preprocessing step is also included. In the image preprocessing step, for a given m input images with patch-level labels, the image size is unified and the input images are normalized to obtain a coding matrix. , label Convert to one-hot encoding format and then use the patch-level labeled image encoding matrix and tags Train the teacher network and student network in knowledge distillation separately.
3. The crop remote sensing image segmentation method based on patch-level classification labels according to claim 2 is characterized in that: In step S2, the teacher network and the student network include an encoder based on Swin Transformer and Unet respectively. , a decoder with a segmentation header and a representation head .
4. The crop remote sensing image segmentation method based on patch-level classification labels according to claim 3 is characterized in that: In the training process of the student network, images are used And the corresponding patch-level labels Fully supervised training of the student model, and pseudo-supervised training using reliable labels generated by the teacher model, respectively calculating the full supervision loss function and pseudo-supervisory loss function , the calculation method is as follows: (8); in, represents the ReLU activation function, represents the cross entropy loss function, Represents the predicted probability corresponding to each patch of the student network, are reliable labels from the teacher model; In order to reduce the information loss caused by the underutilization of pseudo labels, the student network introduces the unreliable pseudo label comparison loss , as shown in formula (9): (9); in, represents the total number of anchor pixels, represent Class Anchor feature representation, Indicates each The corresponding positive sample is Indicates each Corresponding negative samples, Used to calculate the cosine similarity between two different pixel features. is a hyperparameter.
5. The crop remote sensing image segmentation method based on patch-level classification labels according to claim 4 is characterized in that: In the segmentation stage of step S3, new training data is formed by using the pixel-level pseudo mask obtained in step S2; multi-layer pseudo supervision is performed on the final segmentation result; specifically, it can be divided into two steps: Step S31: Image After all the inputs are put into the encoder-decoder of the segmentation model, the output result feature maps of different categories are obtained. Then, each feature map is processed by global average pooling in turn. The obtained results are used together with the pseudo mask generated in the classification stage to calculate the loss function for full supervision. ; Specific: (11); (12); in, represents global average pooling, Represents a decoder, represents the encoder, represents the segmentation parameters; Step S32: In order to integrate the semantic information of different levels in different coding stages, the final segmentation result obtained in step S31 is Perform full supervision with the three-stage feature maps generated by the encoder in the classification network to calculate the loss function of the segmentation stage : (13); in, , and is the weight factor, and its corresponding values are 0.2, 0.3, and 0.5 respectively. The loss function between the semantic segmentation result and each semantic feature map uses the cross entropy loss.
6. The crop remote sensing image segmentation method based on patch-level classification labels according to claim 5 is characterized in that: In step S4, the first part of the loss is a linear combination of the student network full supervision loss, knowledge distillation pseudo supervision loss, and positive and negative sample comparison loss in the segmentation stage in step S2; the second part of the loss is the classification-segmentation fusion loss in step S3 and the multi-layer pseudo supervision loss in step S3; The parameters of the above classification network are updated iteratively until the total loss function reaches the preset convergence condition. Specifically: The first part of the loss calculation is shown in formula (14): (14); in , and is a weight factor, the purpose of which is the proportion of the full supervision loss contrast loss, knowledge distillation pseudo-supervision loss and positive and negative sample contrast loss of the student network model in the loss function of the classification stage.
7. The crop remote sensing image segmentation method based on patch-level classification labels according to claim 6 is characterized in that: In step S5, for the target image data prediction, the predicted probability is greater than the threshold 0.5 for the foreground, and less than 0.5 for the background, so as to obtain the final segmentation mask.
Citation Information
Patent Citations
Optical remote sensing image ground object classification method based on multistage pseudo relation learning
CN116434075A
Semi-supervised hyperspectral image classification method based on unreliable pseudo-label learning
CN115953621A
Semi-supervised semantic segmentation method and device based on MIM and comparative learning
CN116363357A
Semi-supervised remote sensing image semantic segmentation method based on double consistency
CN116416618A
Self-supervised pre-training method based on diffusion model
CN116524307A
