A comparative pre-training cloud detection method combined with CNN Mamba
By combining CNN Mamba's comparison pre-training method, the problem of difficulty in distinguishing cloud and snow in cloud detection and irregular cloud boundaries is solved, achieving more accurate cloud detection results.
Patent Information
- Application Number
- CN202510014546.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-06
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2045-01-06
AI Technical Summary
In cloud detection, cloud and snow are difficult to distinguish, and cloud boundaries are irregular and scattered, resulting in increased detection difficulty.
Using a comparison pre-training cloud detection method combined with CNN Mamba, the comparison pre-training and fine-tuning of cloud and snow pixels is carried out to improve the accuracy of cloud detection by building a Mamba encoder, CNN decoder and auxiliary boundary module.
Effectively distinguish between cloud and snow, improve the accuracy and consistency of cloud boundary detection, and achieve more accurate cloud detection.
Smart Images

Figure CN119418176B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of optical remote sensing image processing, and in particular to a comparative pre-training cloud detection method combined with CNN Mamba. Background Art
[0002] Cloud detection is one of the important research directions in the field of remote sensing image processing. In remote sensing images, cloud information has research value for meteorological and environmental monitoring. Cloud detection aims to identify cloud areas by analyzing images. It can not only provide cloud information, but also prepare for cloud removal tasks and restore surface information covered by clouds.
[0003] Most of the current cloud detection methods are based on deep learning, using convolutional neural networks (CNNs) and attention mechanisms (Transformers). The convolution kernels of CNNs are limited to local receptive fields, and although Transformers have a global view, their computational complexity is quadratic, which consumes more computing resources. With the introduction of the time series model Mamba, it solves the computational consumption of Transformers, has linear complexity, and can maintain long-distance dependencies.
[0004] The background of remote sensing images includes various types of landforms such as forests, seawater, and mountains. Clouds in remote sensing images are either clustered or scattered, and the boundaries of clouds are fine and transparent, so they need to be detected from a global perspective. Snow is a common natural phenomenon, and its color is white like clouds. Affected by snowy days, the difficulty of cloud detection is not only the irregular shape of the clouds themselves, but also the easy misclassification of clouds and snow. Summary of the invention
[0005] The purpose of the present invention is to solve the problems that clouds and snow are difficult to distinguish and cloud boundaries are irregular and scattered in cloud detection, and to provide a comparative pre-training cloud detection method combined with CNN Mamba to solve the above problems.
[0006] In order to achieve the above object, the technical solution of the present invention is as follows:
[0007] A comparative pre-trained cloud detection method combined with CNN Mamba, comprising the following steps:
[0008] 11) Construct and process remote sensing image cloud detection dataset:
[0009] 111) Filter out the images with coexistence of cloud and snow from Sentinel-2, crop them without overlapping, and save them as tif images after cropping to 384×384 as the pre-training dataset SnowData;
[0010] 112) Manually label the cloud and snow pixel values in the corresponding labels of SnowData, with cloud as 1, snow as 2, and other background as 0. The labels are also saved as tif as pre-trained labels;
[0011] 113) Select the scenes with clouds in the satellite remote sensing image, crop them without overlapping, and make the image size 384×384 after cropping. Perform gamma correction on the image and save it as a tif image as the fine-tuning dataset CloudData, which is divided into a training set TrainData and a test set TestData according to the ratio of 8:2;
[0012] 114) Get the corresponding label of CloudData, whose cloud pixel value is 1 and others are 0, and save it as a tif file as the label of the fine-tuning dataset;
[0013] 12) Construct a CNN Mamba cloud detection network, which includes three modules: a Mamba encoder to extract image features, a CNN decoder to restore image resolution, and an auxiliary boundary module to extract cloud boundary information;
[0014] 13) Pre-training of cloud-snow pixel comparison of CNN Mamba cloud detection network: In a batch of SnowData, all cloud pixels are positive samples, and all snow pixels are negative samples; input SnowData and corresponding labels into CNN Mamba cloud detection network, calculate the similarity matrix of network prediction mask, if two samples belong to the same class, the mask is 1, if they are different classes, the mask is 0; calculate the dot product similarity between positive and negative samples and normalize them, and maximize the logarithmic probability of the same class and minimize the negative logarithmic probability by comparing InfoNCE loss; save the weights of CNN Mamba cloud detection network after pre-training;
[0015] 14) Fine-tune the CNN Mamba cloud detection network: First, use the pre-trained weights to initialize the CNN Mamba cloud detection network, then input TrainData and the corresponding labels into the CNN Mamba cloud detection network for training. TrainData passes through the Mamba encoder, auxiliary boundary module, and CNN decoder to obtain the cloud mask map, and then back-propagate the network parameters based on the BCE loss and IoU loss, and save the fine-tuned parameters;
[0016] 15) Test the CNN Mamba cloud detection network: Input TestData into the fine-tuned CNN Mamba cloud detection network to obtain the cloud detection results of the test set.
[0017] The construction of the CNN Mamba cloud detection network includes the following steps:
[0018] 21) Construct a Mamba encoder to extract image features. The Mamba encoder includes three encoding blocks.
[0019] 211) The encoding block contains a convolution layer with a kernel size of 3×3, a stride of 1, and a padding of 1, a group normalization, a SiLU activation unit, a Mamba module, and a maximum pooling layer;
[0020] 22) Construct a CNN decoder to restore the image resolution. The CNN decoder includes three decoding blocks, a 1×1 convolution layer and a Sigmoid normalization layer.
[0021] 221) The decoding block contains a deconvolution upsampling layer, a 3×3 convolution layer, a batch normalization layer and a ReLU activation layer;
[0022] 23) Construct an auxiliary boundary module to extract the boundary information of the cloud, including two convolution blocks, a hole convolution block and a 1×1 convolution layer;
[0023] 231) The convolution block contains a 3×3 convolution layer, a batch normalization layer and a ReLU activation layer;
[0024] 232) The dilated convolution block contains a 1×1 convolution, a 3×3 convolution, a 3×3 convolution with a dilation rate of 2, a 3×3 convolution with a dilation rate of 3, and a 3×3 convolution with a dilation rate of 4.
[0025] The cloud and snow pixel comparison pre-training of the CNN Mamba cloud detection network includes the following steps:
[0026] 31) Input SnowData and corresponding labels into the CNN Mamba cloud detection network;
[0027] 32) Run the Mamba encoder on SnowData once to get three downsampled outputs;
[0028] 321) Perform a 3×3 convolution layer, a group normalization, a SiLU activation unit, and a Mamba module on SnowData to obtain a coarsely extracted feature map feature1 with unchanged resolution, and then perform a maximum pooling on feature1 to obtain the first down-sampling output;
[0029] 322) Perform a 3×3 convolution layer, a group normalization, a SiLU activation unit, a Mamba module and a maximum pooling layer on the first downsampled output to obtain the second downsampled output;
[0030] 323) Perform a 3×3 convolution layer, a group normalization, a SiLU activation unit, a Mamba module and a maximum pooling layer on the second downsampled output to obtain the third downsampled output;
[0031] 33) Execute an auxiliary boundary module on the feature map feature1 coarsely extracted by the Mamba encoder;
[0032] 331) Perform a 3×3 convolution layer, a batch normalization and a ReLU activation layer on feature1 to obtain feature2;
[0033] 332) Perform a 1×1 convolution, a 3×3 convolution, a 3×3 convolution with a dilation rate of 2, a 3×3 convolution with a dilation rate of 3, and a 3×3 convolution with a dilation rate of 4 on feature2, and concatenate the feature maps after the convolution;
[0034] 333) Perform a 3×3 convolution layer, a batch normalization, a ReLU activation layer and a 1×1 convolution layer on the concatenated feature map to obtain a boundary feature map;
[0035] 34) Perform a CNN decoder on the third downsampled output of the Mamba encoder;
[0036] 341) Perform a deconvolution upsampling, a 3×3 convolution layer, a batch normalization and a ReLU activation layer on the third down-sampled output to obtain the first up-sampled output;
[0037] 342) Perform a deconvolution upsampling, a 3×3 convolution layer, a batch normalization and a ReLU activation layer on the first upsampled output to obtain the second upsampled output;
[0038] 343) Perform a deconvolution upsampling on the second upsampling output to obtain a third upsampling output;
[0039] 344) The third upsampling output is concatenated with the boundary feature map, and then a 3×3 convolution layer, a batch normalization layer, and a ReLU activation layer are performed to obtain the feature map feature3 with restored resolution;
[0040] 345) Perform a 1×1 convolution and Sigmoid normalization layer on feature3, and forward propagate to obtain the predicted mask map;
[0041] 35) Calculate the contrast loss Loss1 of cloud and snow pixels;
[0042] 351) Calculate the matrix M, if two samples belong to the same class, the mask is 1, otherwise it is 0;
[0043] ,
[0044] in , N is the number of samples, and Respectively represent and The labels of the samples;
[0045] 352) Concatenate a batch of feature3 into a long vector , D is the feature dimension, and then calculate the dot product similarity matrix S of the sample;
[0046] ,
[0047] in is the temperature coefficient, with a value of 0.1, Represents vector transpose;
[0048] 353) Normalize the similarity of each sample;
[0049] ,
[0050] in It is The maximum value of row similarity is used to stabilize the calculation and avoid overflow. Indicates and The similarity between samples, is the normalized and The similarity between samples;
[0051] 354) Calculate cloud-snow contrast loss using the InfoNCE function;
[0052] ,
[0053] in is the basic temperature coefficient, the value is 0.07, Indicates and The similarity of samples, It is a logical NOT operation, which swaps the values 0 and 1;
[0054] 36) Use Loss1 to perform back propagation to update the network parameters, and determine whether the set number of rounds has been reached, or if Loss1 no longer decreases, stop training and save the pre-trained weights. Otherwise, return to step 32) to continue loading data for training.
[0055] The fine-tuning of the CNN Mamba cloud detection network includes the following steps:
[0056] 41) Input TrainData and corresponding labels into the CNN Mamba Cloud Detection Network, and load the pre-trained weights to initialize the network parameters;
[0057] 42) The fine-tuning process is the same as the pre-training process. TrainData passes through the Mamba encoder to obtain a downsampled feature map. The feature map is restored to the resolution of the initial input size through the CNN decoder. The output of the Mamba module in the first encoding block passes through the auxiliary boundary module. The output is spliced with the output of the upsampling layer in the last decoding block. The spliced feature map continues to pass through the 3×3 convolution layer, batch normalization, ReLU activation layer and 1×1 convolution layer, and finally the predicted probability of the cloud is obtained through the forward propagation of the Sigmoid function;
[0058] 43) Use BCE loss and IoU loss for gradient backpropagation;
[0059] 431) Binary cross entropy BCE loss is usually used for binary classification problems. BCELoss is used to classify cloud pixels and background. For the predicted value and label of a sample, the BCE loss formula is as follows:
[0060] ,
[0061] Where N is the number of samples, It is The true label of the sample is 1 for the cloud and 0 for the background. It is The predicted probability of a sample ranges from [0,1]. The smaller the loss, the smaller the gap between the prediction and the label.
[0062] 432) IoU loss is used to optimize the overlap between the predicted cloud area and the label cloud area. It is hoped that the larger the overlap area, the better. In order to minimize the IoU loss, the IoU Loss is defined as:
[0063] ,
[0064] in represents the cloud area predicted by the model, represents the actual cloud area in the label, is the intersection area of the predicted area and the true area, It is the union area of the predicted area and the true area, and the ratio of the intersection area to the union area is IoU;
[0065] 433) The final loss Loss2 is the sum of the two losses ;
[0066] 44) Use Loss2 to perform back propagation to fine-tune the network parameters, and determine whether the set number of rounds has been reached, or if Loss2 no longer decreases, stop training and save the fine-tuned weights. Otherwise, return to step 42) to continue loading data for training.
[0067] The specific steps of testing the CNN Mamba cloud detection network are as follows:
[0068] 51) Input TestData into the fine-tuned CNN Mamba cloud detection network;
[0069] 511) TestData is passed through the Mamba encoder to obtain a downsampled feature map. The feature map is restored to the resolution of the initial input size through three upsampling layers of the CNN decoder. The output of the upsampling layer of the third decoding block is feature4;
[0070] 512) The output of the Mamba module in the first encoding block passes through the auxiliary boundary module to obtain feature 5, feature 5 is concatenated with feature 4, and the concatenated feature map passes through a 3×3 convolution layer, batch normalization and ReLU activation layer, and then passes through a 1×1 convolution layer and Sigmoid normalization layer;
[0071] 52) Forward propagation obtains the predicted probability, and pixels with probability values greater than 0.5 are regarded as cloud pixels, thereby obtaining the final cloud mask map, visualizing the input TestData, the corresponding label and the predicted cloud mask map. Beneficial Effects
[0072] The present invention relates to a cloud detection method combined with CNN Mamba contrast pre-training, which aims to solve the problems of cloud-snow misclassification and irregular cloud boundaries compared with the prior art. By introducing cloud-snow pixel contrast pre-training, the network can recognize the difference between cloud and snow; by introducing an auxiliary boundary module, the network can add cloud boundary prior information; by introducing a Mamba module in the encoder to capture global information, and by also using a convolutional layer to capture local details, more accurate cloud detection can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] Figure 1 It is a flow chart of a comparative pre-trained cloud detection method combined with CNN Mamba;
[0074] Figure 2 This is a schematic diagram of the process of training the CNN Mamba cloud detection network;
[0075] Figure 3 This is a model structure diagram for building a CNN Mamba cloud detection network;
[0076] Figure 4 This is a comparison chart of the results of the comparative pre-trained cloud detection method combined with CNN Mamba; DETAILED DESCRIPTION
[0077] In order to have a further understanding and recognition of the structural features and the effects achieved by the present invention, a preferred embodiment and accompanying drawings are used to provide a detailed description as follows:
[0078] like Figure 1 As shown, the comparative pre-trained cloud detection method combined with CNN Mamba described in the present invention comprises the following steps:
[0079] The first step is to build and process the remote sensing image cloud detection dataset. The specific steps are as follows:
[0080] (1) Filter out the images with coexistence of clouds and snow in the Sentinel-2 dataset, crop the images without overlapping, and save them as tif images after cropping to 384×384 as the pre-training dataset SnowData;
[0081] (2) Manually label the cloud and snow pixel values corresponding to the labels of SnowData, with cloud as 1, snow as 2, and other background as 0. The labels are also saved as tif as pre-trained labels;
[0082] (3) Select the scenes with clouds in the satellite remote sensing images, crop them without overlapping, and resize the images to 384×384. Perform gamma correction on the images and save them as tif images as the fine-tuning dataset CloudData. Divide them into the training set TrainData and the test set TestData according to the ratio of 8:2.
[0083] (4) Set the cloud pixel value of the corresponding label of CloudData to 1 and the others to 0. The label is also saved as tif as the label of the fine-tuning dataset.
[0084] The second step is to build a CNN Mamba cloud detection network. The specific steps are as follows:
[0085] (1) Construct a Mamba encoder to extract image features. The Mamba encoder includes three encoding blocks.
[0086] (1-1) The encoding block contains a convolution layer with a kernel size of 3×3, a stride of 1, and a padding of 1, a group normalization, a SiLU activation unit, a Mamba module, and a maximum pooling layer;
[0087] (2) Construct a CNN decoder to restore the image resolution. The CNN decoder includes three decoding blocks, a 1×1 convolutional layer, and a Sigmoid normalization layer.
[0088] (2-1) The decoding block contains a deconvolution upsampling layer, a 3×3 convolution layer, a batch normalization layer, and a ReLU activation layer;
[0089] (3) Construct an auxiliary boundary module to extract cloud boundary information, including two convolution blocks, a hole convolution block and a 1×1 convolution layer;
[0090] (3-1) The convolution block contains a 3×3 convolution layer, a batch normalization layer, and a ReLU activation layer;
[0091] (3-2) The dilated convolution block contains a 1×1 convolution, a 3×3 convolution, a 3×3 convolution with a dilation rate of 2, a 3×3 convolution with a dilation rate of 3, and a 3×3 convolution with a dilation rate of 4;
[0092] First, the preprocessed remote sensing image is passed through the Mamba encoder to obtain a downsampled feature map. The feature map is restored to its resolution to the initial input size through the CNN decoder. The input of the auxiliary boundary module is the output of the Mamba module in the first encoding block. The output of the auxiliary boundary module is spliced to the upsampling layer output in the last decoding block to complete the construction of the entire model.
[0093] The third step is to pre-train the cloud and snow pixel comparison of the CNN Mamba cloud detection network. The specific steps are as follows:
[0094] (1) Input SnowData and corresponding labels into the CNN Mamba cloud detection network;
[0095] (2) Run the Mamba encoder on SnowData once to obtain three downsampled outputs;
[0096] (2-1) Perform a 3×3 convolution layer, a group normalization, a SiLU activation unit, and a Mamba module on SnowData to obtain a coarsely extracted feature map feature1 with unchanged resolution. Then perform a maximum pooling on feature1 to obtain the first down-sampled output;
[0097] (2-2) Perform a 3×3 convolution layer, a group normalization, a SiLU activation unit, a Mamba module and a maximum pooling layer on the first downsampled output to obtain the second downsampled output;
[0098] (2-3) Perform a 3×3 convolution layer, a group normalization, a SiLU activation unit, a Mamba module and a maximum pooling layer on the second downsampled output to obtain the third downsampled output;
[0099] (3) Execute an auxiliary boundary module on the feature map feature1 coarsely extracted by the Mamba encoder;
[0100] (3-1) Perform a 3×3 convolution layer, a batch normalization and a ReLU activation layer on feature1 to obtain feature2;
[0101] (3-2) Perform a 1×1 convolution, a 3×3 convolution, a 3×3 convolution with a dilation rate of 2, a 3×3 convolution with a dilation rate of 3, and a 3×3 convolution with a dilation rate of 4 on feature2, and concatenate the feature maps after convolution;
[0102] (3-3) Perform a 3×3 convolution layer, a batch normalization, a ReLU activation layer and a 1×1 convolution layer on the concatenated feature map to obtain a boundary feature map;
[0103] (4) Execute a CNN decoder on the third downsampled output of the Mamba encoder;
[0104] (4-1) Perform a deconvolution upsampling, a 3×3 convolution layer, a batch normalization and a ReLU activation layer on the third down-sampled output to obtain the first up-sampled output;
[0105] (4-2) Perform a deconvolution upsampling, a 3×3 convolution layer, a batch normalization and a ReLU activation layer on the first upsampling output to obtain the second upsampling output;
[0106] (4-3) Perform a deconvolution upsampling on the second upsampling output to obtain the third upsampling output;
[0107] (4-4) The third upsampling output is concatenated with the boundary feature map, and then a 3×3 convolution layer, a batch normalization layer, and a ReLU activation layer are performed to obtain the feature map feature3 with restored resolution;
[0108] (4-5) Perform a 1×1 convolution and Sigmoid normalization layer on feature3, and forward propagate to obtain the predicted mask map;
[0109] (5) Calculate the contrast loss Loss1 of cloud and snow pixels;
[0110] (5-1) Calculate the matrix M. If two samples belong to the same class, the mask is 1, otherwise it is 0;
[0111] ,
[0112] in , N is the number of samples, and Respectively represent and The labels of the samples;
[0113] (5-2) Concatenate a batch of feature3 into a long vector , D is the feature dimension, and then calculate the dot product similarity matrix S of the sample;
[0114] ,
[0115] in is the temperature coefficient, with a value of 0.1, Represents vector transpose;
[0116] (5-3) Normalize the similarity of each sample;
[0117] ,
[0118] in It is The maximum value of row similarity is used to stabilize the calculation and avoid overflow. Indicates and The similarity between samples, is the normalized and The similarity between samples;
[0119] (5-4) Calculate the cloud-snow contrast loss using the InfoNCE function;
[0120] ,
[0121] in is the basic temperature coefficient, the value is 0.07, Indicates and The similarity of samples, It is a logical NOT operation, which swaps the values 0 and 1;
[0122] (6) Use Loss1 to perform back propagation to update the network parameters, and determine whether the set number of rounds has been reached, or if Loss1 no longer decreases, stop training and save the pre-trained weights. Otherwise, return to step (1) to continue loading data for training.
[0123] The fourth step is to fine-tune the CNN Mamba cloud detection network. The specific steps are as follows:
[0124] (1) Input TrainData and corresponding labels into the CNN Mamba cloud detection network, and load the pre-trained weights to initialize the network parameters;
[0125] (2) The fine-tuning process is the same as the pre-training process. TrainData passes through the Mamba encoder to obtain a downsampled feature map. The feature map is restored to the resolution of the initial input size through the CNN decoder. The output of the Mamba module in the first encoding block passes through the auxiliary boundary module. The output is concatenated with the output of the upsampling layer in the last decoding block. The concatenated feature map continues to pass through a 3×3 convolution layer, batch normalization, ReLU activation layer, and 1×1 convolution layer. Finally, the predicted probability of the cloud is obtained through forward propagation of the Sigmoid function.
[0126] (3) Use BCE loss and IoU loss for gradient backpropagation;
[0127] (3-1) Binary cross entropy BCE loss is usually used for binary classification problems. BCELoss is used to classify cloud pixels and background. For the predicted value and label of a sample, the BCE loss formula is as follows:
[0128] ,
[0129] Where N is the number of samples, It is The true label of the sample is 1 for the cloud and 0 for the background. It is The predicted probability of a sample ranges from [0,1]. The smaller the loss, the smaller the gap between the prediction and the label.
[0130] (3-2) IoU loss is used to optimize the overlap between the predicted cloud area and the label cloud area. It is hoped that the overlap area is as large as possible. In order to minimize the IoU loss, the IoU Loss is defined as:
[0131] ,
[0132] in represents the cloud area predicted by the model, represents the actual cloud area in the label, is the intersection area of the predicted area and the true area, It is the union area of the predicted area and the true area, and the ratio of the intersection area to the union area is IoU;
[0133] (3-3) The final loss Loss2 is the sum of the two losses ;
[0134] (4) Use Loss2 to perform back propagation to fine-tune the network parameters, and determine whether the set number of rounds has been reached, or if Loss2 no longer decreases, stop training and save the fine-tuned weights. Otherwise, return to step (1) to continue loading data for training.
[0135] The fifth step is to test the CNN Mamba cloud detection network. The specific steps are as follows:
[0136] (1) Input TestData into the fine-tuned CNN Mamba cloud detection network;
[0137] (1-1) TestData is downsampled through the Mamba encoder to obtain a feature map. The feature map is restored to the original input size through three upsampling layers of the CNN decoder. The output of the upsampling layer of the third decoding block is feature4.
[0138] (1-2) The output of the Mamba module in the first encoding block passes through the auxiliary boundary module to obtain feature 5, which is then concatenated with feature 4. The concatenated feature map passes through a 3×3 convolution layer, batch normalization, and ReLU activation layer, and then a 1×1 convolution layer and a Sigmoid normalization layer.
[0139] (2) Forward propagation obtains the predicted probability, and pixels with probability values greater than 0.5 are regarded as cloud pixels, thereby obtaining the final cloud mask map, visualizing the input TestData, the corresponding label, and the predicted cloud mask map.
[0140] The method proposed in the present invention is described below using Sentinel-2 satellite images as an example:
[0141] 76 Sentinel-2 satellite images and labels containing different types of objects were selected, and 8635 image datasets of 384×384 size and corresponding labels were obtained after the preprocessing operation described in the present invention. Using the method described in the present invention, the predicted cloud area is as follows Figure 4 As shown, the first column is the input image, the second column is the corresponding label, and the third column is the prediction result.
[0142] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions only describe the principles of the present invention. The present invention may be subject to various changes and improvements without departing from the spirit and scope of the present invention. These changes and improvements fall within the scope of the present invention. The scope of protection claimed by the present invention is defined by the attached claims and their equivalents.
Claims
1. A comparative pre-trained cloud detection method combined with CNN Mamba, characterized in that: The following steps are involved: 11) Construct and process remote sensing image cloud detection dataset, including the following steps: 111) Filter out the images with coexistence of cloud and snow from Sentinel-2, crop them without overlapping, and save them as tif images after cropping to 384×384 as the pre-training dataset SnowData; 112) Manually label the cloud and snow pixel values corresponding to the labels of SnowData, with cloud as 1, snow as 2, and other background as 0. The labels are also saved as tif as pre-trained labels; 113) Select the scenes with clouds in the satellite remote sensing image, crop them without overlapping, and make the image size 384×384 after cropping. Perform gamma correction on the image and save it as a tif image as the fine-tuning dataset CloudData, which is divided into a training set TrainData and a test set TestData according to the ratio of 8:2; 114) Get the corresponding label of CloudData, whose cloud pixel value is 1 and others are 0. The label is also saved as tif as the label of the fine-tuning dataset; 12) Construct a CNN Mamba cloud detection network, which includes three modules: a Mamba encoder to extract image features, a CNN decoder to restore image resolution, and an auxiliary boundary module to extract cloud boundary information; 13) Pre-training of cloud-snow pixel comparison of CNN Mamba cloud detection network: In a batch of SnowData, all cloud pixels are positive samples, and all snow pixels are negative samples; input SnowData and corresponding labels into CNN Mamba cloud detection network, calculate the similarity matrix of network prediction mask, if two samples belong to the same class, the mask is 1, if they are different classes, the mask is 0; calculate the dot product similarity between positive and negative samples and normalize them, and maximize the logarithmic probability of the same class and minimize the negative logarithmic probability by comparing InfoNCE loss; save the weights of CNN Mamba cloud detection network after pre-training; 14) Fine-tune the CNN Mamba cloud detection network: First, use the pre-trained weights to initialize the CNN Mamba cloud detection network, then input TrainData and the corresponding labels into the CNN Mamba cloud detection network for training. TrainData passes through the Mamba encoder, auxiliary boundary module, and CNN decoder to obtain the cloud mask map, and then back-propagate the network parameters based on the BCE loss and IoU loss, and save the fine-tuned parameters; 15) Test the CNN Mamba cloud detection network: Input TestData into the fine-tuned CNN Mamba cloud detection network to obtain the cloud detection results of the test set.
2. A comparative pre-trained cloud detection method combined with CNN Mamba according to claim 1, characterized in that: The construction of the CNN Mamba cloud detection network includes the following steps: 21) Construct a Mamba encoder to extract image features. The Mamba encoder includes three encoding blocks. 211) The encoding block contains a convolution layer with a kernel size of 3×3, a stride of 1, and a padding of 1, a group normalization, a SiLU activation unit, a Mamba module, and a maximum pooling layer; 22) Construct a CNN decoder to restore the image resolution. The CNN decoder includes three decoding blocks, a 1×1 convolution layer and a Sigmoid normalization layer. 221) The decoding block contains a deconvolution upsampling layer, a 3×3 convolution layer, a batch normalization layer and a ReLU activation layer; 23) Construct an auxiliary boundary module to extract the boundary information of the cloud, including two convolution blocks, a hole convolution block and a 1×1 convolution layer; 231) The convolution block contains a 3×3 convolution layer, a batch normalization layer and a ReLU activation layer; 232) The dilated convolution block contains a 1×1 convolution, a 3×3 convolution, a 3×3 convolution with a dilation rate of 2, a 3×3 convolution with a dilation rate of 3, and a 3×3 convolution with a dilation rate of 4.
3. The method for detecting a cloud using a comparative pre-training method combined with CNN Mamba according to claim 1, characterized in that: The cloud and snow pixel comparison pre-training of the CNN Mamba cloud detection network includes the following steps: 31) Input SnowData and corresponding labels into the CNN Mamba cloud detection network; 32) Run the Mamba encoder on SnowData once to get three downsampled outputs; 321) Perform a 3×3 convolution layer, a group normalization, a SiLU activation unit, and a Mamba module on SnowData to obtain a coarsely extracted feature map feature1 with unchanged resolution, and then perform a maximum pooling on feature1 to obtain the first down-sampling output; 322) Perform a 3×3 convolution layer, a group normalization, a SiLU activation unit, a Mamba module and a maximum pooling layer on the first downsampled output to obtain the second downsampled output; 323) Perform a 3×3 convolution layer, a group normalization, a SiLU activation unit, a Mamba module and a maximum pooling layer on the second downsampled output to obtain the third downsampled output; 33) Execute an auxiliary boundary module on the feature map feature1 coarsely extracted by the Mamba encoder; 331) Perform a 3×3 convolution layer, a batch normalization and a ReLU activation layer on feature1 to obtain feature2; 332) Perform a 1×1 convolution, a 3×3 convolution, a 3×3 convolution with a dilation rate of 2, a 3×3 convolution with a dilation rate of 3, and a 3×3 convolution with a dilation rate of 4 on feature2, and concatenate the feature maps after the convolution; 333) Perform a 3×3 convolution layer, a batch normalization, a ReLU activation layer and a 1×1 convolution layer on the concatenated feature map to obtain a boundary feature map; 34) Perform a CNN decoder on the third downsampled output of the Mamba encoder; 341) Perform a deconvolution upsampling, a 3×3 convolution layer, a batch normalization and a ReLU activation layer on the third down-sampled output to obtain the first up-sampled output; 342) Perform a deconvolution upsampling, a 3×3 convolution layer, a batch normalization and a ReLU activation layer on the first upsampled output to obtain the second upsampled output; 343) Perform a deconvolution upsampling on the second upsampling output to obtain a third upsampling output; 344) The third upsampling output is concatenated with the boundary feature map, and then a 3×3 convolution layer, a batch normalization layer, and a ReLU activation layer are performed to obtain the feature map feature3 with restored resolution; 345) Perform a 1×1 convolution and Sigmoid normalization layer on feature3, and forward propagate to obtain the predicted mask map; 35) Calculate the contrast loss Loss1 of cloud and snow pixels; 351) Calculate the similarity matrix M. If two samples belong to the same class, the mask is 1, otherwise it is 0; , in , N is the number of samples, and Respectively represent and The labels of the samples; 352) Concatenate a batch of feature3 into a long vector , D is the feature dimension, and then calculate the dot product similarity matrix S of the sample; , in is the temperature coefficient, with a value of 0.1, Represents vector transpose; 353) Normalize the similarity of each sample; , in It is The maximum value of row similarity is used to stabilize the calculation and avoid overflow. Indicates and The similarity between samples, is the normalized and The similarity between samples; 354) Calculate cloud-snow contrast loss using the InfoNCE function; , in is the basic temperature coefficient, the value is 0.07, Indicates and The similarity of samples, It is a logical NOT operation, which swaps the values 0 and 1; 36) Use Loss1 to perform back propagation to update the network parameters, and determine whether the set number of rounds has been reached, or if Loss1 no longer decreases, stop training and save the pre-trained weights. Otherwise, return to step 32) to continue loading data for training.
4. The method for detecting a cloud using a comparative pre-training method combined with CNN Mamba according to claim 1, characterized in that: The fine-tuning of the CNN Mamba cloud detection network includes the following steps: 41) Input TrainData and corresponding labels into the CNN Mamba Cloud Detection Network, and load the pre-trained weights to initialize the network parameters; 42) The fine-tuning process is the same as the pre-training process. TrainData passes through the Mamba encoder to obtain a downsampled feature map. The feature map is restored to the resolution of the initial input size through the CNN decoder. The output of the Mamba module in the first encoding block passes through the auxiliary boundary module. The output is spliced with the output of the upsampling layer in the last decoding block. The spliced feature map continues to pass through the 3×3 convolution layer, batch normalization, ReLU activation layer and 1×1 convolution layer, and finally the predicted probability of the cloud is obtained through the forward propagation of the Sigmoid function; 43) Use BCE loss and IoU loss for gradient backpropagation; 431) Binary cross entropy BCE loss is usually used for binary classification problems. BCELoss is used to classify cloud pixels and background. For the predicted value and label of a sample, the BCE loss formula is as follows: , Where N is the number of samples, It is The true label of the sample is 1 for the cloud and 0 for the background. It is The predicted probability of a sample ranges from [0,1]. The smaller the loss, the smaller the gap between the prediction and the label. 432) IoU loss is used to optimize the overlap between the predicted cloud area and the label cloud area. It is hoped that the larger the overlap area, the better. In order to minimize the IoU loss, the IoU Loss is defined as: , in represents the cloud area predicted by the model, represents the actual cloud area in the label, is the intersection area of the predicted area and the true area, It is the union area of the predicted area and the true area, and the ratio of the intersection area to the union area is IoU; 433) The final loss Loss2 is the sum of the two losses; ; 44) Use Loss2 to perform back propagation to fine-tune the network parameters, and determine whether the set number of rounds has been reached, or if Loss2 no longer decreases, stop training and save the fine-tuned weights. Otherwise, return to step 42) to continue loading data for training.
5. The method for detecting a cloud using a comparative pre-training method combined with CNN Mamba according to claim 1, characterized in that: The specific steps of testing the CNN Mamba cloud detection network are as follows: 51) Input TestData into the fine-tuned CNN Mamba cloud detection network; 511) TestData is passed through the Mamba encoder to obtain a downsampled feature map. The feature map is restored to the resolution of the initial input size through three upsampling layers of the CNN decoder. The output of the upsampling layer of the third decoding block is feature4; 512) The output of the Mamba module in the first encoding block passes through the auxiliary boundary module to obtain feature 5, feature 5 is concatenated with feature 4, and the concatenated feature map passes through a 3×3 convolution layer, batch normalization and ReLU activation layer, and then passes through a 1×1 convolution layer and Sigmoid normalization layer; 52) Forward propagation obtains the predicted probability, and pixels with probability values greater than 0.5 are regarded as cloud pixels, thereby obtaining the final cloud mask map.
Citation Information
Patent Citations
Multi-scale feature fusion and alignment domain adaptive cloud detection method
CN115830471A
Systems and Methods for Trainable Deep Active Contours for Image Segmentation
US20210217178A1