Water-Res-Swin remote sensing image water body segmentation method based on improved attention
By improving the attentional Water-Res-Swin model, combined with Swin Transformer and ResNet50 network, the problem of poor performance and high computational complexity of traditional remote sensing image water segmentation methods in complex backgrounds is solved, achieving high precision and efficiency. For water body segmentation, the average intersection ratio reaches 71.58%.
Patent Information
- Application Number
- CN202410776988.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-09-06
AI Technical Summary
Traditional water body segmentation methods in remote sensing images are not effective when the background is complex and the illumination changes, and the calculation complexity is high, resulting in inaccurate or discontinuous segmentation results.
The Water-Res-Swin model based on improved attention is adopted, by combining the Swin Transformer network and the ResNet50 network, and introducing optimized agent attention and feature fusion modules to reduce computational complexity and improve segmentation accuracy.
It effectively solves the problem of water body segmentation in complex backgrounds, improves segmentation accuracy and model training speed, with an average intersection ratio of 71.58%, and improves the continuity of segmentation results through morphological operations and edge smoothing technology.
Smart Images

Figure CN118608786A
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of neural networks, and in particular to a Water-Res-Swin remote sensing image water body segmentation method based on improved attention. Background Art
[0002] Water segmentation in remote sensing images is one of the important tasks in remote sensing image processing and is widely used in environmental monitoring, water resources management, disaster warning and other fields. It analyzes remote sensing images and distinguishes land and water accurately at the pixel level to ensure the accuracy and continuity of the segmentation results. However, traditional water segmentation methods often have difficulty in dealing with complex background environments and are easily affected by the environment, resulting in unsatisfactory segmentation results. Traditional water segmentation methods mainly rely on algorithms based on thresholds, spectral features and texture features. These methods work well when dealing with simple scenes, but they show obvious limitations when faced with complex backgrounds, lighting changes and water body morphology diversity, and cannot effectively obtain global and local features.
[0003] Deep learning models such as convolutional neural networks and Transformer can automatically extract multi-level features of images, thus achieving remarkable results in remote sensing image segmentation tasks. However, traditional convolutional neural network models have certain deficiencies in capturing global information and long-distance dependencies, and although the Transformer model performs well in capturing global information, it has high computational complexity and is difficult to directly apply to the processing of high-resolution remote sensing images. Summary of the invention
[0004] In order to solve the technical problems of poor application effect in the above-mentioned fields, high computational complexity, inaccurate or discontinuous segmentation results, the present technical solution provides a Water-Res-Swin remote sensing image water body segmentation method based on improved attention, which greatly reduces the computational complexity of Swin Transformer, increases the model training speed, and improves the model segmentation accuracy; it can effectively solve the problems in the background technology.
[0005] The present invention is achieved through the following technical solutions:
[0006] A water body segmentation method for remote sensing images based on Water-Res-Swin with improved attention, comprising the following steps:
[0007] Step 1: Data preparation: intercept the original high-resolution remote sensing image, annotate it and obtain the water body segmentation dataset. The dataset consists of three parts: training set, test set and validation set.
[0008] Step 2: Build the model: For the original Swin Transformer model, replace the multi-head self-attention with the optimized proxy attention OAG, add the ResNet50 module, and process the features extracted by the two models in the same dimension through the feature fusion module to obtain the Water-Res-Swin model; the specific implementation process of the Water-Res-Swin model is as follows:
[0009] Step 2.1: The Water-Res-Swin model consists of three parts, namely the Swin Transformer network, the ResNet50 network and the feature fusion module; the H×W×C image is input into the Swin Transformer network and the ResNet50 network respectively, where H represents the image height, W represents the image width, and C represents the number of image channels; the outputs of the Swin Transformer network and the ResNet50 network are input into the feature fusion module to obtain the segmentation result output;
[0010] The SwinTransformer network consists of four stages, each of which contains a downsampling module and a Swin module. The four stages will output feature maps X s1 , X s2 , X s3 , X s4 And passed into the feature fusion module, where
[0011] Step 2.2: The Resnet50 network consists of an initial convolutional layer, a pooling layer, stage 1, stage 2, and stage 3; stage 1 consists of three convolutional layers, a normalization layer, and a ReLU layer, outputting Stage 2 contains three convolutional layers, a normalization layer, and a ReLU layer, outputting Stage 3 contains three convolutional layers, a normalization layer, and a ReLU layer, outputting
[0012] Step 2.3: The feature fusion module uses the X s1 , X s2 , X s3 , X s4 and X as described in step 2.2 r2 , X r3 , X r4 Perform feature fusion for input;
[0013] Step 3: Train the model. Pre-train and fine-tune the Water-Res-Swin model using the public dataset and the training and test sets of the water body segmentation dataset in step 1 to obtain the segmentation model Y.
[0014] Step 4: Post-segmentation processing: Use the test set of the water body segmentation dataset in step 1 to test the model, obtain the initial segmentation result, and then perform post-processing to obtain the final segmentation result.
[0015] Furthermore, the implementation process of the Swin module described in step 2.1 is as follows:
[0016] Step 2.1.1: Downsample the output result X p-1 As input to the Swin module;
[0017] Step 2.1.2: Perform layer normalization on the input feature map;
[0018] Step 2.1.3: Input the normalized output result into the optimized proxy attention module; the specific implementation process of the optimized proxy attention module is:
[0019] Step 2.1.3.1: Generate query feature map Q, key feature map K, and value feature map V based on the normalized result of the input;
[0020] Step 2.1.3.2: Perform a pooling operation on the query feature map Q to generate a more compact representation A;
[0021] Step 2.1.3.3: Replace Q with A and input the focused linear attention together with K and V described in step 2.1.3.1, aggregate global information from K and V, and get the result V A ;
[0022] Step 2.1.3.4: Replace Q in step 2.1.3.1, A in step 2.1.3.2 with K, and V in step 2.1.3.3 with A Instead of V, input the focused linear attention module and broadcast the aggregated information back to Q to get the output result R1;
[0023] Step 2.1.3.5: Input V described in step 2.1.3.1 into the separable convolution SepConv to obtain the output result R2;
[0024] Step 2.1.3.6: Perform a residual connection between R1 described in step 2.1.3.4 and R2 described in step S2.1.3.5 to obtain the output of the optimized proxy attention module. The optimized proxy attention module can be expressed as:
[0025] O A =Atten(Q,A,Atten(A,K,V))+SepConv;
[0026] In the formula, O A represents the output feature representation after calculation by the optimized proxy attention module;
[0027] Step 2.1.4: Convert the output of step 2.1.3.6 to A With the input X from step 2.1.1 p-1 Perform residual connection;
[0028] Step 2.1.5: Normalize the residual connection result described in step 2.1.4;
[0029] Step 2.1.6: Input the normalized result described in step 2.1.5 into the multi-layer perceptron MLP;
[0030] Step 2.1.7: Perform a residual connection on the result of the MLP processing described in step 2.1.6 and the residual connection result described in step 2.1.4 to obtain the output X of the Swin module p .
[0031] Furthermore, the implementation process of focusing linear attention described in step 2.1.3.3 is as follows:
[0032] The focused linear attention formula is defined as follows:
[0033] O=Atten(Q,K,V)=Sim(Q,K)V;
[0034] Where O represents the output feature representation after focused linear attention calculation, Atten(Q,K,V) represents the focused linear attention calculation for Q, K, V, Sim(Q,K) represents the similarity calculation function, and the similarity calculation function is defined as follows:
[0035] Sim(Q,K)=φ p (Q)φ p (K) T ;
[0036] In the formula, Sim(Q,K) represents the similarity calculation function, φ p (Q) represents the feature vector of query Q after mapping, φ p (K) T represents the transposed eigenvector of key K after mapping, and the mapping function φ p (x) is defined as follows:
[0037] φ p (x) = f p (ReLU(x));
[0038] In the formula, φ p (x) means the input parameter is x and the output is φ p (x), φ p (Q) is the input mapping function φ with Q as the parameter p (x), we get φ p(Q); ReLU(x) means that the input feature x is applied with the ReLU activation function, which changes the negative values in the input to zero and keeps the positive values unchanged; f p The function (x) is defined as follows:
[0039]
[0040] In the formula, f p (x) means the input parameter is x and the output is f p (x); f p (ReLU(x)) takes ReLU(x) as a parameter and inputs the function f p (x), we get f p The output of (ReLU(x)); x **p represents the p-th power of each element of x, and ||x|| represents the L2 norm of the eigenvector x.
[0041] Furthermore, the implementation process of the feature fusion module described in step 2.3 is as follows:
[0042] Step 2.3.1: Enter the and Perform feature map concatenation, interpolation calculation, convolution and ReLU function activation to obtain Will and Perform convolution, normalization, ReLU function activation, adaptive pooling, convolution, optimization proxy attention and feature map recovery as described in step 2.1.3 to obtain
[0043] Step 2.3.2: Replace the and Perform feature map concatenation, interpolation calculation, convolution and ReLU function activation to obtain Will and Perform convolution, normalization, ReLU function activation, adaptive pooling, convolution, optimization proxy attention and feature map recovery as described in step 2.1.3 to obtain
[0044] Step 2.3.3: Replace the and Perform feature map concatenation, interpolation calculation, convolution and ReLU function activation to obtain Will and Perform convolution, normalization, ReLU function activation, adaptive pooling, convolution, optimization proxy attention and feature map recovery as described in step 2.1.3 to obtain
[0045] Step 2.3.4: Repeat the steps in step 2.3.3. After two upsampling operations, the feature map size becomes H×W×2C; finally, a convolution operation is performed and the feature map output size becomes H×W×C.
[0046] Furthermore, the annotation processing described in step 1 is to use a tool to annotate the data set into two categories, including background and water body; then use random rotation, horizontal flipping and adding Gaussian noise to enhance the data; and perform standardization and normalization during data preprocessing.
[0047] Furthermore, the specific implementation process of pre-training and fine-tuning the segmentation model Y using the public dataset and the training set and test set of the water body segmentation dataset in step 1 described in step 3 is as follows:
[0048] S3.1: Data preprocessing: First, check the public dataset and clean the data to ensure there are no missing values and outliers; second, perform data augmentation on the training data to increase the robustness of the model;
[0049] S3.2: Training settings: set model learning rate, batch size and other hyperparameters;
[0050] S3.3: Define loss function: The mixed loss function is used during model training. The specific calculation formula is as follows:
[0051]
[0052] Where L Celoss represents the value of the cross entropy loss function; N represents the number of samples; C represents the total number of categories; y i An indicator variable indicating whether pixel i belongs to a certain category. If pixel i belongs to this category, then y i =1, otherwise y i =0; p i Indicates the probability that the model predicts that pixel i belongs to a certain category;
[0053]
[0054] Where L Diceloss represents the value of the Dice loss function; |X| represents the total number of pixels of the segmented image predicted by the model; |Y| represents the total number of pixels of the real segmented image; |X∩Y| represents the number of intersection pixels between the segmented image predicted by the model and the real segmented image;
[0055]
[0056] Where L Total Represents the value of the total loss function;
[0057] S3.4: Input a batch of training data in each training round, calculate the loss, and update the model parameters according to the loss gradient; use the validation set to evaluate the model performance and adjust the hyperparameters to optimize the model;
[0058] S3.5: Use the training set of the self-made water body segmentation dataset to further fine-tune the basic model; in each training round, input a batch of self-made training data, calculate the loss, and update the model parameters according to the loss gradient; use the validation set of the self-made dataset for verification and evaluate the performance of the model in water body segmentation.
[0059] Furthermore, the specific implementation process of post-processing the initial segmentation model in step 4 is as follows:
[0060] S4.1: Load the parameters of the Water-Res-Swin model trained on a large-scale dataset and input the test set of the self-made dataset into the model;
[0061] S4.2: Use morphological operations to process the initial segmentation results to remove noise and small areas;
[0062] S4.3: Use edge smoothing technology to process the segmentation results to make the boundaries smoother and more continuous.
[0063] Beneficial Effects
[0064] The Water-Res-Swin remote sensing image water body segmentation method based on improved attention proposed in the present invention has the following beneficial effects compared with the prior art:
[0065] (1) The main features of Water-Res-Swin in the present invention are that it consists of a Swin Transformer network, a Resnet50 network and a feature fusion module. The Swin Transformer network can pay more attention to global characteristics; while the Renet50 network can pay more attention to local features. The features of the two networks are fused through the feature fusion module, so that the Water-Res-Swin network can pay attention to local features and global features at the same time. The optimized proxy attention is introduced, the feature map Q is queried for pooling operations, a more compact representation A is generated, and A is used instead of Q for calculation, which greatly reduces the computational complexity. At the same time, the focused linear attention calculation is used in the optimized proxy attention, and linear calculation is used instead of nonlinear calculation, so that similar Q and K are closer, and dissimilar Q and K are farther away, so that the optimized proxy attention can focus on richer features, and the nonlinear function is realized with linear calculation.
[0066] (2) The present invention uses morphological operations and edge smoothing technology in the post-processing process to remove noise and small areas while making the boundaries smoother and more continuous.
[0067] (3) The present invention adopts the Water-Res-Swin remote sensing image water segmentation method based on improved attention, which reduces the calculation complexity of the model while improving the accuracy of water segmentation, with a mean Intersection over Union (mIoU) of 71.58%. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] Figure 1 This is a flowchart of the Water-Res-Swin remote sensing image water segmentation method based on improved attention.
[0069] Figure 2 This is the network structure diagram of Water-Res-Swin based on improved attention proposed in the present invention.
[0070] Figure 3 It is the network structure diagram of the Swin module proposed in the present invention.
[0071] Figure 4 This is the network structure diagram of the feature fusion module proposed in the present invention.
[0072] Figure 5 This is the structural diagram of the optimized agent attention network proposed in the present invention. DETAILED DESCRIPTION
[0073] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. The described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Under the premise of not departing from the design concept of the present invention, various modifications and improvements made by ordinary persons in the art to the technical solutions of the present invention should all fall within the protection scope of the present invention.
[0074] Embodiment 1:
[0075] like Figure 1 As shown, a water body segmentation method for remote sensing images based on Water-Res-Swin with improved attention includes the following steps:
[0076] Step 1: Data preparation: capture the original high-resolution remote sensing images and annotate them. The annotation process is to use tools to annotate the data set into two categories, including background and water body; then use random rotation, horizontal flipping and adding Gaussian noise to enhance the data; standardize and normalize the data during data preprocessing; obtain the water body segmentation data set, which consists of three parts: training set, test set and validation set.
[0077] Step 2: Build the model: For the original SwinTransformer model, replace the multi-head self-attention with the optimized proxy attention OAG, add the ResNet50 module, and process the features extracted by the two models in the same dimension through the feature fusion module to obtain the Water-Res-Swin model; the specific implementation process of the Water-Res-Swin model is as follows:
[0078] Step 2.1: The Water-Res-Swin model consists of three parts, namely the Swin Transformer network, the ResNet50 network and the feature fusion module; the H×W×C image is input into the Swin Transformer network and the ResNet50 network respectively, where H represents the image height, W represents the image width, and C represents the number of image channels; the outputs of the Swin Transformer network and the ResNet50 network are passed into the feature fusion module to obtain the segmentation result output.
[0079] The SwinTransformer network consists of four stages, each of which contains a downsampling module and a Swin module. The four stages will output feature maps X s1 , X s2 , X s3 , X s4 And passed into the feature fusion module, where The implementation process of the Swin module is as follows:
[0080] Step 2.1.1: Downsample the output result X p-1 As input to the Swin module.
[0081] Step 2.1.2: Perform layer normalization on the input feature map.
[0082] Step 2.1.3: Input the normalized output result into the optimized proxy attention module; the specific implementation process of the optimized proxy attention module is:
[0083] Step 2.1.3.1: Generate query feature map Q, key feature map K, and value feature map V based on the normalized result of the input.
[0084] Step 2.1.3.2: Perform a pooling operation on the query feature map Q to generate a more compact representation A.
[0085] Step 2.1.3.3: Replace Q with A and input the focused linear attention together with K and V described in step 2.1.3.1, aggregate global information from K and V, and get the result V A The implementation process of focused linear attention is:
[0086] The focused linear attention formula is defined as follows:
[0087] O=Atten(Q,K,V)=Sim(Q,K)V;
[0088] Where O represents the output feature representation after focused linear attention calculation, Atten(Q,K,V) represents the focused linear attention calculation for Q, K, V, Sim(Q,K) represents the similarity calculation function, and the similarity calculation function is defined as follows:
[0089] Sim(Q,K)=φ p (Q)φ p (K) T ;
[0090] In the formula, Sim(Q,K) represents the similarity calculation function, φ p (Q) represents the feature vector of query Q after mapping, φ p (K) T represents the transposed eigenvector of key K after mapping, and the mapping function φ p (x) is defined as follows:
[0091] φ p (x) = f p (ReLU(x));
[0092] In the formula, φ p (x) means the input parameter is x and the output is φ p (x), φ p (Q) is the input mapping function φ with Q as the parameter p (x), we get φ p (Q); ReLU(x) means that the input feature x is applied with the ReLU activation function, which changes the negative values in the input to zero and keeps the positive values unchanged; f p The function (x) is defined as follows:
[0093]
[0094] In the formula, f p (x) means the input parameter is x and the output is f p (x); f p (ReLU(x)) takes ReLU(x) as a parameter and inputs the function f p (x), we get f p The output of (ReLU(x)); x **p represents the p-th power of each element of x, and ‖x‖ represents the L2 norm of the eigenvector x.
[0095] Step 2.1.3.4: Replace Q in step 2.1.3.1, A in step 2.1.3.2 with K, and V in step 2.1.3.3 with A Instead of V inputting the focused linear attention module, the aggregated information is broadcasted back to Q to obtain the output result R1.
[0096] Step 2.1.3.5: Input V described in step 2.1.3.1 into the separable convolution SepConv to obtain the output result R2.
[0097] Step 2.1.3.6: Perform a residual connection between R1 described in step 2.1.3.4 and R2 described in step S2.1.3.5 to obtain the output of the optimized proxy attention module. The optimized proxy attention module can be expressed as:
[0098] O A =Atten(Q,A,Atten(A,K,V))+SepConv;
[0099] In the formula, O A Represents the output feature representation after calculation by the optimized proxy attention module.
[0100] Step 2.1.4: Convert the output of step 2.1.3.6 to A With the input X from step 2.1.1 p-1 Perform residual connection.
[0101] Step 2.1.5: Normalize the residual connection result described in step 2.1.4.
[0102] Step 2.1.6: Input the normalized result described in step 2.1.5 into the multi-layer perceptron MLP.
[0103] Step 2.1.7: Perform a residual connection on the result of the MLP processing described in step 2.1.6 and the residual connection result described in step 2.1.4 to obtain the output X of the Swin module p .
[0104] Step 2.2: The Resnet50 network consists of an initial convolutional layer, a pooling layer, stage 1, stage 2, and stage 3; stage 1 consists of three convolutional layers, a normalization layer, and a ReLU layer, outputting Stage 2 contains three convolutional layers, a normalization layer, and a ReLU layer, outputting Stage 3 contains three convolutional layers, a normalization layer, and a ReLU layer, outputting
[0105] Step 2.3: The feature fusion module uses the X s1 , X s2 , X s3, X s4 and X as described in step 2.2 r2 , X r3 , X r4 Perform feature fusion for input; the implementation process of the feature fusion module is as follows:
[0106] Step 2.3.1: Enter the and Perform feature map concatenation, interpolation calculation, convolution and ReLU function activation to obtain Will and Perform convolution, normalization, ReLU function activation, adaptive pooling, convolution, optimization proxy attention and feature map recovery as described in step 2.1.3 to obtain
[0107] Step 2.3.2: Replace the and Perform feature map concatenation, interpolation calculation, convolution and ReLU function activation to obtain Will and Perform convolution, normalization, ReLU function activation, adaptive pooling, convolution, optimization proxy attention and feature map recovery as described in step 2.1.3 to obtain
[0108] Step 2.3.3: Replace the and Perform feature map concatenation, interpolation calculation, convolution and ReLU function activation to obtain Will and Perform convolution, normalization, ReLU function activation, adaptive pooling, convolution, optimization proxy attention and feature map recovery as described in step 2.1.3 to obtain
[0109] Step 2.3.4: Repeat the steps in step 2.3.3. After two upsampling operations, the feature map size becomes H×W×2C; finally, a convolution operation is performed and the feature map output size becomes H×W×C.
[0110] Step 3: Train the model. Pre-train and fine-tune the Water-Res-Swin model using the public dataset and the training and test sets of the water body segmentation dataset in step 1 to obtain the segmentation model Y. The specific implementation process is as follows:
[0111] S3.1: Data preprocessing: First, check the public dataset and clean the data to ensure that there are no missing values and outliers; secondly, perform data augmentation on the training data to increase the robustness of the model.
[0112] S3.2: Training settings: Set model hyperparameters such as learning rate and batch size.
[0113] S3.3: Define loss function: The mixed loss function is used during model training. The specific calculation formula is as follows:
[0114]
[0115] Where L Celoss represents the value of the cross entropy loss function; N represents the number of samples; C represents the total number of categories; y i An indicator variable indicating whether pixel i belongs to a certain category. If pixel i belongs to this category, then y i =1, otherwise y i =0; p i It represents the probability that the model predicts that pixel i belongs to a certain category.
[0116]
[0117] Where L Diceloss represents the value of the Dice loss function; X| represents the total number of pixels of the segmented image predicted by the model; |Y| represents the total number of pixels of the true segmented image; |X∩Y| represents the number of intersection pixels between the segmented image predicted by the model and the true segmented image.
[0118]
[0119] Where L Total Represents the value of the total loss function.
[0120] S3.4: Input a batch of training data in each training round, calculate the loss, and update the model parameters according to the loss gradient; use the validation set to evaluate the model performance and adjust the hyperparameters to optimize the model.
[0121] S3.5: Use the training set of the self-made water body segmentation dataset to further fine-tune the basic model; in each training round, input a batch of self-made training data, calculate the loss, and update the model parameters according to the loss gradient; use the validation set of the self-made dataset for verification and evaluate the performance of the model in water body segmentation.
[0122] Step 4: Segmentation post-processing, use the test set of the water body segmentation dataset in step 1 to test the model, get the initial segmentation result, and then perform post-processing to get the final segmentation result; the specific implementation process of post-processing the initial segmentation model is:
[0123] S4.1: Load the parameters of the Water-Res-Swin model trained on a large-scale dataset and input the test set of the self-made dataset into the model;
[0124] S4.2: Use morphological operations to process the initial segmentation results to remove noise and small areas;
[0125] S4.3: Use edge smoothing technology to process the segmentation results to make the boundaries smoother and more continuous.
[0126] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable people familiar with the technology to understand the content of the present invention and implement it accordingly, and they cannot be used to limit the protection scope of the present invention. Any equivalent transformation or modification made according to the spirit of the present invention should be included in the present invention.
Claims
1. A water segmentation method for remote sensing images based on Water-Res-Swin with improved attention, Features: The following steps are involved: Step 1: Data preparation: intercept the original high-resolution remote sensing image, annotate it and obtain the water body segmentation dataset. The dataset consists of three parts: training set, test set and validation set. Step 2: Build the model: For the original SwinTransformer model, replace the multi-head self-attention with the optimized proxy attention OAG, add the ResNet50 module, and process the features extracted by the two models in the same dimension through the feature fusion module to obtain the Water-Res-Swin model; the specific implementation process of the Water-Res-Swin model is as follows: Step 2.1: The Water-Res-Swin model consists of three parts, namely the Swin Transformer network, the ResNet50 network and the feature fusion module; the H×W×C image is input into the Swin Transformer network and the ResNet50 network respectively, where H represents the image height, W represents the image width, and C represents the number of image channels; the outputs of the Swin Transformer network and the ResNet50 network are input into the feature fusion module to obtain the segmentation result output; The SwinTransformer network consists of four stages, each of which contains a downsampling module and a Swin module. The four stages will output feature maps X s1 , X s2 , X s3 , X s4 And passed into the feature fusion module, where Step 2.2: The Resnet50 network consists of an initial convolutional layer, a pooling layer, stage 1, stage 2, and stage 3; stage 1 consists of three convolutional layers, a normalization layer, and a ReLU layer, outputting Stage 2 contains three convolutional layers, a normalization layer, and a ReLU layer, outputting Stage 3 contains three convolutional layers, a normalization layer, and a ReLU layer, outputting Step 2.3: The feature fusion module uses the X s1 , X s2 , X s3 , X s4 and X as described in step 2.2 r2 , X r3 , X r4 Perform feature fusion for input; Step 3: Train the model. Pre-train and fine-tune the Water-Res-Swin model using the public dataset and the training and test sets of the water body segmentation dataset in step 1 to obtain the segmentation model Y. Step 4: Post-segmentation processing: Use the test set of the water body segmentation dataset in step 1 to test the model, obtain the initial segmentation result, and then perform post-processing to obtain the final segmentation result.
2. According to claim 1, an intelligent traffic recommendation method based on driver style diagnosis, Features: The implementation process of the Swin module described in step 2.1 is as follows: Step 2.1.1: Downsample the output result X p-1 As input to the Swin module; Step 2.1.2: Perform layer normalization on the input feature map; Step 2.1.3: Input the normalized output result into the optimized proxy attention module; the specific implementation process of the optimized proxy attention module is: Step 2.1.3.1: Generate query feature map Q, key feature map K, and value feature map V based on the normalized result of the input; Step 2.1.3.2: Perform a pooling operation on the query feature map Q to generate a more compact representation A; Step 2.1.3.3: Replace Q with A and input the focused linear attention together with K and V described in step 2.1.3.1, aggregate global information from K and V, and get the result V A ; Step 2.1.3.4: Replace Q in step 2.1.3.1, A in step 2.1.3.2 with K, and V in step 2.1.3.3 with A Instead of V, input the focused linear attention module and broadcast the aggregated information back to Q to get the output result R 1 ; Step 2.1.3.5: Input V described in step 2.1.3.1 into the separable convolution SepConv to obtain the output result R 2 ; Step 2.1.3.6: Replace the R 1 and R as described in S2.1.3.5 2 Perform residual connection to obtain the output of the optimized proxy attention module, which can be expressed as: O A =Atten(Q,A,Atten(A,K,V))+SepConv; In the formula, O A represents the output feature representation after calculation by the optimized proxy attention module; Step 2.1.4: Convert the output of step 2.1.3.6 to A With the input X from step 2.1.1 p-1 Perform residual connection; Step 2.1.5: Normalize the residual connection result described in step 2.1.4; Step 2.1.6: Input the normalized result described in step 2.1.5 into the multi-layer perceptron MLP; Step 2.1.7: Perform a residual connection on the result of the MLP processing described in step 2.1.6 and the residual connection result described in step 2.1.4 to obtain the output X of the Swin module p .
3. The intelligent traffic recommendation method based on driver style diagnosis according to claim 2, Features: The implementation process of focusing linear attention described in step 2.1.3.3 is as follows: The focused linear attention formula is defined as follows: O=Atten(Q,K,V)=Sim(Q,K)V; Where O represents the output feature representation after focused linear attention calculation, Atten(Q,K,V) represents the focused linear attention calculation for Q, K, V, Sim(Q,K) represents the similarity calculation function, and the similarity calculation function is defined as follows: Sim(Q,K)=φ p (Q)φ p (K) T ; In the formula, Sim(Q,K) represents the similarity calculation function, φ p (Q) represents the feature vector of query Q after mapping, φ p (K) T represents the transposed eigenvector of key K after mapping, and the mapping function φ p (x) is defined as follows: ϕ p (x)=f p (ReLU(x))? In the formula, φ p (x) means the input parameter is x and the output is φ p (x), φ p (Q) is to use Q as a parameter and input the mapping function φ p (x), we get φ p (Q); ReLU(x) means that the input feature x is applied with the ReLU activation function, which changes the negative values in the input to zero and keeps the positive values unchanged; f p The function (x) is defined as follows: In the formula, f p (x) means the input parameter is x and the output is f p (x); f p (ReLU(x)) takes ReLU(x) as a parameter and inputs the function f p (x), we get f p The output of (ReLU(x)); x **p represents the p-th power of each element of x, and ||x|| represents the L2 norm of the eigenvector x.
4. The intelligent traffic recommendation method based on driver style diagnosis according to claim 1 or 3, Features: The implementation process of the feature fusion module described in step 2.3 is as follows: Step 2.3.1: Enter the and Perform feature map concatenation, interpolation calculation, convolution and ReLU function activation to obtain Will and Perform convolution, normalization, ReLU function activation, adaptive pooling, convolution, optimization proxy attention and feature map recovery as described in step 2.1.3 to obtain Step 2.3.2: Replace the and Perform feature map concatenation, interpolation calculation, convolution and ReLU function activation to obtain Will and Perform convolution, normalization, ReLU function activation, adaptive pooling, convolution, optimization proxy attention and feature map recovery as described in step 2.1.3 to obtain Step 2.3.3: Replace the and Perform feature map concatenation, interpolation calculation, convolution and ReLU function activation to obtain Will and Perform convolution, normalization, ReLU function activation, adaptive pooling, convolution, optimization proxy attention and feature map recovery as described in step 2.1.3 to obtain Step 2.3.4: Repeat the steps in step 2.3.
3. After two upsampling operations, the feature map size becomes H×W×2C; finally, a convolution operation is performed and the feature map output size becomes H×W×C.
5. The intelligent traffic recommendation method based on driver style diagnosis according to claim 1, Features: The annotation process described in step 1 is to use a tool to annotate the dataset into two categories, including background and water; then perform data augmentation using random rotation, horizontal flipping, and adding Gaussian noise; Standardization and normalization are performed during data preprocessing.
6. The intelligent traffic recommendation method based on driver style diagnosis according to claim 1, Features: The specific implementation process of pre-training and fine-tuning the segmentation model Y using the public dataset and the training set and test set of the water body segmentation dataset in step 1 described in step 3 is as follows: S3.1: Data preprocessing: First, check the public dataset and clean the data to ensure there are no missing values and outliers; second, perform data augmentation on the training data to increase the robustness of the model; S3.2: Training settings: set model learning rate, batch size and other hyperparameters; S3.3: Define loss function: The mixed loss function is used during model training. The specific calculation formula is as follows: Where L Celoss represents the value of the cross entropy loss function; N represents the number of samples; C represents the total number of categories; y i An indicator variable indicating whether pixel i belongs to a certain category. If pixel i belongs to this category, then y i =1, otherwise y i =0; p i Indicates the probability that the model predicts that pixel i belongs to a certain category; Where L Diceloss represents the value of the Dice loss function; |X| represents the total number of pixels of the segmented image predicted by the model; |Y| represents the total number of pixels of the real segmented image; |X∩Y| represents the number of intersection pixels between the segmented image predicted by the model and the real segmented image; Where L Total Represents the value of the total loss function; S3.4: Input a batch of training data in each training round, calculate the loss, and update the model parameters according to the loss gradient; use the validation set to evaluate the model performance and adjust the hyperparameters to optimize the model; S3.5: Use the training set of the self-made water body segmentation dataset to further fine-tune the basic model; in each training round, input a batch of self-made training data, calculate the loss, and update the model parameters according to the loss gradient; use the validation set of the self-made dataset for verification and evaluate the performance of the model in water body segmentation.
7. The intelligent traffic recommendation method based on driver style diagnosis according to claim 1, Features: The specific implementation process of post-processing the initial segmentation model described in step 4 is: S4.1: Load the parameters of the Water-Res-Swin model trained on a large-scale dataset and input the test set of the self-made dataset into the model; S4.2: Use morphological operations to process the initial segmentation results to remove noise and small areas; S4.3: Use edge smoothing technology to process the segmentation results to make the boundaries smoother and more continuous.
Citation Information
Cited By
Remote sensing image water body recognition method based on deep learning
CN121438133A
A deep learning-based remote sensing image water body recognition method
CN121438133B
