Remote sensing image urban water area segmentation method based on attention regulation and related device
Through the improved Segformer model, combined with the gating and polarization self-attention mechanism, the problems of missing classification, wrong classification and category imbalance in urban water recognition in remote sensing images are solved, the segmentation precision and accuracy are improved, and the segmentation accuracy is improved, and it can adapt to complex backgrounds and Characteristics of variable remote sensing images.
Patent Information
- Application Number
- CN202410656226.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2024-09-24
AI Technical Summary
Existing urban water recognition methods in remote sensing images have problems with missing classifications, wrong classifications, and category imbalances, resulting in low accuracy of segmentation targets, and the Segformer model performs poorly when processing complex backgrounds and changeable remote sensing images.
Using the improved Segformer model, combined with the MiT encoder and decoder, the gated attention mechanism and the polarized self-attention mechanism are introduced, and a hybrid loss function is used to suppress the weight of irrelevant pixels through the gated attention mechanism and fuse deep partial biases. Semantic features and shallow detail features, the polarized self-attention mechanism maintains high resolution at the spatial and channel levels, reduces information loss, and solves the problem of sample category imbalance through a hybrid loss function.
It effectively solves the problems of missed classification, misclassification and category imbalance of urban waters, improves the precision and accuracy of segmentation targets, and enhances the model's ability to identify urban waters.
Smart Images

Figure CN118691809A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of remote sensing image urban water area segmentation, and in particular relates to a remote sensing image urban water area segmentation method based on attention regulation and a related device. Background Art
[0002] As the main land object in remote sensing images, accurate identification of urban waters can provide data support for urban planning, pollution control, natural disaster assessment and other fields. However, the rapid advancement of urbanization has led to the large-scale outward expansion of urban space, which has put tremendous pressure on the fragile ecological environment. In many places, industrial wastewater and domestic sewage are directly discharged, resulting in water pollution in urban rivers, which has destroyed the orderly planning and sustainable development of cities and caused many hazards to urban planning and management: the governance process is blocked and the economic cost increases, the uneven distribution of resources and the intensification of social contradictions, the chaos of urban planning and the damage of the city image, the decline of water environment quality and the threat to public health. In the face of the challenges of urban water governance, urban planning departments have continuously strengthened supervision and implemented water resources management and protection strategies. Although certain results have been achieved, they have not completely solved the fundamental problem of urban water damage due to the lack of monitoring methods and human resources. Therefore, it is urgent to reform the existing planning concepts and management methods to ensure the timely discovery of urban water problems in order to improve the efficiency of urban planning management and promote sustainable development.
[0003] Traditional methods for urban water area recognition in remote sensing images are mainly based on threshold methods, classifier methods, and object-oriented methods. However, they have the problems of strong subjective judgment of experts, high time cost, low degree of automation, and slow data update speed. Thanks to the advancement of data storage technology and the continuous enhancement of hardware computing power, deep learning methods have made significant breakthroughs in the field of image segmentation, and are expected to overcome the limitations of traditional urban water area recognition methods. Deep learning can automatically and comprehensively mine hidden pattern information in remote sensing images through multi-layer network iterations, avoiding the subjectivity and uncertainty of manual feature selection, and has powerful multi-scale feature representation capabilities. It can be seen that combining remote sensing images with deep learning technology can significantly improve the recognition efficiency and accuracy of urban water areas, thereby promoting the application and development of remote sensing images in the field of intelligent recognition and interpretation of urban water areas.
[0004] As an outstanding basic model for image segmentation, Segformer has attracted much attention for its simple, efficient and powerful semantic segmentation framework. Although the Segformer model performs well in large-scale general datasets, it has inherent difficulties in urban water identification tasks due to the particularity of remote sensing images. For example: in terms of the complexity of the background information of remote sensing images, due to the interweaving influence of many factors such as illumination, geographical location, seasonal changes, sensor characteristics, etc. during the imaging process, the phenomenon of different spectra of the same object and different objects of the same spectrum is common in high-resolution remote sensing images; in terms of the complex morphological structure of urban waters, the waters in urban areas can be divided into artificial lakes, canals, lakes, ponds and wetlands. Affected by human factors and topography, the scale and distribution of urban waters vary greatly. These uncertain factors make the Segformer model unable to be directly applied to urban water identification tasks based on remote sensing images, so the model needs to be specially adjusted and optimized to meet the specific needs of remote sensing images. Summary of the invention
[0005] In view of the problems existing in the prior art, the present invention provides a remote sensing image urban water area segmentation method and related devices based on attention regulation, which can solve the problems of missed classification, wrong classification and category imbalance of urban water areas, thereby improving the segmentation target accuracy.
[0006] In order to solve the above technical problems, the present invention is implemented by the following technical solutions:
[0007] According to a first aspect of the present invention, a method for segmenting urban water areas in remote sensing images based on attention regulation is provided, comprising:
[0008] Acquire a remote sensing image to be segmented;
[0009] The remote sensing image is processed by using a remote sensing image urban water segmentation model to obtain a segmentation result; the remote sensing image urban water segmentation model is obtained by training an improved Segformer model using remote sensing image samples containing urban waters, the improved Segformer model includes a MiT encoder and a decoder, the MiT encoder is used to extract the feature map of the remote sensing image; the decoder is added with a gated attention mechanism module after the upsampling operation, the input of the gated attention mechanism module is the deep feature map of the decoder and the shallow feature map of the encoder, the decoder is added with a polarized self-attention mechanism module after the MLP layer, the input of the polarized self-attention mechanism module is a multi-scale feature map with the same size after being processed by the MLP layer; the improved Segformer model adopts a mixed loss function.
[0010] In a possible implementation manner of the first aspect, the gated attention mechanism module includes the following calculation formula:
[0011]
[0012] α i =σ 2 (q att (F xi ,F gi θ att ))
[0013]
[0014] In the formula, q att Represents additive attention calculation, and the vector is scaled to the interval [0,1] through the Sigmoid layer to obtain α i ; α i represents the learned attention coefficient; F gi represents the deep feature map from the i-th layer of the decoder; F xi represents the shallow feature map from the i-th layer of the encoder; W g , W x and ψ represent convolution operations; b g and b ψ W g and the bias term of ψ; σ 1 represents the ReLU activation function; σ 2 represents the Sigmoid activation function; the attention operation is performed through θ att to characterize; Indicates that the corresponding elements are multiplied in sequence; F' represents the feature map after gated attention enhancement.
[0015] In a possible implementation of the first aspect, the polarized self-attention mechanism module includes channel self-attention and spatial self-attention, the channel self-attention is used to generate a channel attention feature map, and the spatial self-attention is used to generate a spatial attention feature map.
[0016] In a possible implementation manner of the first aspect, the implementation process of the channel self-attention specifically includes:
[0017] First, the original input feature X∈R is transformed into C×H×W Convert to W q ∈R 1×H×W and W v ∈R C / 2×H×W Two branches;
[0018] Second, adjust W through the Reshape operation q and W v The shape of W q ∈R HW×1×1 and Wv ∈R C / 2×HW ;
[0019] Then, the Softmax operation is used to q Perform information enhancement;
[0020] Next, the enhanced W q With W v Perform matrix multiplication to generate a new input feature W q,v ∈R C / 2×1×1 ;
[0021] Then, W is transformed into q,v ∈R C / 2×1×1 The channel dimension is increased to C, and the Sigmoid activation function is applied to ensure that all parameter values are between [0,1];
[0022] Finally, W q,v ∈R C×1×1 With the original input feature X∈R C×H×W Perform point multiplication on the channel dimension to generate the final channel attention feature map W ch ∈R C×H×W ;
[0023] The calculation formula for this process is as follows:
[0024] W cz =σ(E c (E SM (Re shape(E c (X)))×Re shape(E c (X))))
[0025] W ch =W cz ⊙ C X
[0026] Where Ec(·) represents a convolution unit with a convolution kernel size of 1×1; X represents the original input feature; E SM (·) represents the Softmax function; “×” represents matrix multiplication; σ(·) represents the Sigmoid activation function; ⊙ C Represents feature point multiplication on the channel dimension; Reshape() represents dimension transformation.
[0027] In a possible implementation manner of the first aspect, the implementation process of the spatial self-attention is specifically as follows:
[0028] First, the original input feature X∈R is transformed into C×H×W Convert to W q∈R C / 2×H×W and W v ∈R C / 2×H×W Two branches;
[0029] Secondly, a global average pooling operation is used to q Compress the spatial dimension, and the pooled W q Changes to W q ∈R C / 2×1×1 ;
[0030] Then, use Reshape to resize W q and W v The shape of the information is enhanced q With W v Perform matrix multiplication to obtain the new input feature W q,v ∈R 1×HW ;
[0031] Then W q,v Reshape to W q,v ∈R 1×H×W After normalization, it is compared with the original input feature X∈R C×H×W Multiply the points in the spatial dimension, redistribute the weights of the spatial dimension, and generate the final spatial attention feature map W sp ∈R C×H×W ;
[0032] The calculation formula for this process is as follows:
[0033]
[0034] W q =E GP (W q )
[0035]
[0036] W sp =W q,v ⊙ S X
[0037] In the formula, E GP represents global average pooling; H represents the height of the feature map; W represents the width of the feature map; X(:,i,j) represents the pixel value of the input feature map at the position (:,i,j); ⊙ S Represents the feature point multiplication in the spatial dimension.
[0038] In a possible implementation manner of the first aspect, the hybrid loss function is formed by mixing a Focal Loss loss function and a Dice Loss loss function, as follows:
[0039] Loss Total =αLoss Focal +βLoss Dice ,α+β=1
[0040] Loss Focal =-α t (1-p t ) γ log(p t )
[0041]
[0042] In the formula, α and β represent the weights of each part in the mixed loss function; p t Represents the probability that the model predicts that the sample is a positive example; α t represents the weight of the sample; γ is the parameter for adjusting the difficult and easy samples; Loss Focal 、Loss Dice 、Loss Total They represent Focal Loss loss function, Dice Loss loss function and mixed loss function respectively; A represents the pixel label of the real segmentation image, and B represents the pixel category of the segmentation image predicted by the model.
[0043] According to a second aspect of the present invention, a remote sensing image urban water area segmentation device based on attention regulation is provided, comprising:
[0044] An acquisition module, used for acquiring a remote sensing image to be segmented;
[0045] A segmentation processing module is used to use a remote sensing image urban water area segmentation model to perform segmentation processing on the remote sensing image to obtain a segmentation result; the remote sensing image urban water area segmentation model is obtained by training an improved Segformer model using remote sensing image samples containing urban water areas, and the improved Segformer model includes a MiT encoder and a decoder, and the MiT encoder is used to extract the feature map of the remote sensing image; the decoder is added with a gated attention mechanism module after the upsampling operation, and the input of the gated attention mechanism module is the deep feature map of the decoder and the shallow feature map of the encoder. The decoder is added with a polarized self-attention mechanism module after the MLP layer, and the input of the polarized self-attention mechanism module is a multi-scale feature map with the same size after being processed by the MLP layer; the improved Segformer model adopts a mixed loss function.
[0046] According to a third aspect of the present invention, there is provided a device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method for segmenting urban water areas in remote sensing images based on attention regulation are implemented.
[0047] According to a fourth aspect of the present invention, there is provided a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of a method for urban water area segmentation in remote sensing images based on attention regulation.
[0048] Compared with the prior art, the present invention has at least the following beneficial effects:
[0049] The present invention provides a remote sensing image urban water segmentation method based on attention regulation, which improves the Segformer model. The decoder in the improved Segformer model adds a gated attention mechanism module after the upsampling operation, that is, the gated attention mechanism module is introduced when merging detail information, and the gated attention mechanism is used to suppress the weights of irrelevant pixels when merging detail information. This is a method for fusing deeper partial semantic features with shallower partial detail features. When fusing the main semantic features, the weight of the shallow detail information is adjusted according to the spatial context information, which is conducive to the model focusing on segmenting the features related to the target and reducing the interference of background information, thereby achieving more accurate prediction in the urban water segmentation task. At the same time, the decoder adds a polarization self-attention mechanism module after the MLP layer, that is, the polarization self-attention mechanism is integrated into the decoder end to keep the target feature at high resolution in the space and channel layer, and output more delicate features through nonlinear synthesis, and finally adopts a mixed loss function to solve the problem of sample category imbalance. It can be seen that the present invention effectively solves the problems of missed classification, misclassification and category imbalance in urban waters, thereby improving the accuracy of segmentation targets.
[0050] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions in the specific implementation modes of the present invention, the drawings required for use in the description of the specific implementation modes will be briefly introduced below. Obviously, the drawings described below are some implementation modes of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0052] Figure 1 A flowchart of a remote sensing image urban water area segmentation method based on attention regulation of the present invention;
[0053] Figure 2 The overall framework structure diagram of the Segformer model combined with attention regulation provided by the present invention;
[0054] Figure 3 A diagram of the gated attention mechanism module provided by the present invention;
[0055] Figure 4 A module diagram of the polarized self-attention mechanism provided by the present invention;
[0056] Figure 5 This is an example diagram of the Zhongke Star Map Cup urban water data set in an embodiment of the present invention;
[0057] Figure 6 A visual comparison diagram of the method of this embodiment and other models in an embodiment of the present invention;
[0058] Figure 7 A schematic diagram of an urban water area segmentation system implemented in an embodiment of the present invention. DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0060] Combination Figure 1 and Figure 2 As shown, the embodiment of the present invention provides a remote sensing image urban water segmentation method based on attention regulation. Aiming at the problem that the overall segmentation accuracy of urban water identification tasks is low due to misclassification, omission of target features and imbalance of sample categories, the traditional Segformer network structure is optimized (the optimized one is defined as APMFormer model) by combining attention regulation. The segmentation method specifically includes the following steps:
[0061] S100: Acquire a remote sensing image to be segmented.
[0062] S101. Process the remote sensing image using a remote sensing image urban water area segmentation model to obtain a segmentation result.
[0063] Specifically, the remote sensing image urban water segmentation model is obtained by training an improved Segformer model using remote sensing image samples containing urban waters. The improved Segformer model includes a MiT encoder (an encoder inherent to the Segformer model) and a decoder. The MiT encoder is used to extract feature maps of remote sensing images. Among them, the decoder adds a gated attention mechanism module after the upsampling operation, and the input of the gated attention mechanism module is the deep feature map of the decoder and the shallow feature map of the encoder. The decoder adds a polarized self-attention mechanism module after the MLP layer, and the input of the polarized self-attention mechanism module is a multi-scale feature map of the same size after being processed by the MLP layer. The improved Segformer model adopts a mixed loss function.
[0064] Specifically, a detailed explanation is given about adding a gated attention mechanism module after the upsampling operation: the urban water remote sensing data set not only has interference from objects such as buildings, plants, and roads, but also the complex urban structure will cause noise effects such as occlusion and shadows between target objects. These interference factors make it difficult to locate and identify urban water features in image segmentation, which ultimately leads to misclassification and omission of small water areas and target edges in remote sensing images. Unlike the method of splicing after feature upsampling or using 1×1 convolution to integrate information of different scales and channels, the present invention introduces a gated attention mechanism module when merging detail information. This is a method of fusing deeper partial semantic features with shallower partial detail features. When fusing the main semantic features, the weight of the shallow detail information is adjusted according to the spatial context information, which is beneficial for the model to focus on segmenting features related to the target and reduce the interference of background information, thereby achieving more accurate predictions in urban water segmentation tasks, such as Figure 3 shown.
[0065] The gated attention mechanism takes the deep feature map of the decoder and the shallow feature map from the encoder as input, and is composed of upsampling, ReLU activation function and Sigmoid activation function. The deep features from the decoder contain deeper information, which enables the shallow features from the encoder to learn the gap between the deep features and focus on the pixels of urban waters. By reducing the interference of redundant information, the segmentation effect of the model is improved. Specifically, the shallow feature map from the encoder and the deep feature map from the decoder are operated through the gated attention mechanism to keep their sizes consistent. This process can increase the weight of alignment and relatively reduce the weight of misalignment, so that the model can strengthen its attention to urban waters in space. After the added feature map is operated through the ReLU activation function and 1×1×1 convolution, the nonlinear expression ability of the model can be improved, and a new feature map with 1 channel number is generated at the same time. Next, the new feature map is activated by the Sigmoid function and then upsampled to make it the same size as the shallow feature map of the encoder, and then the attention coefficient matrix α is obtained. The final output result can be obtained by multiplying the shallow feature map of the encoder by α. The calculation formula of this process is as follows:
[0066]
[0067] α i =σ 2 (q att (F xi ,F gi θ att ))
[0068]
[0069] In the formula, q att Represents additive attention calculation, and the vector is scaled to the interval [0,1] through the Sigmoid layer to obtain α i ; α i represents the learned attention coefficient; F gi represents the deep feature map from the i-th layer of the decoder; F xi represents the shallow feature map from the i-th layer of the encoder; W g , W x and ψ represent convolution operations; b g and b ψ W g and the bias term of ψ; σ 1 represents the ReLU activation function; σ 2 represents the Sigmoid activation function; the attention operation is performed through θ att to characterize; Indicates that the corresponding elements are multiplied in sequence; F' represents the feature map after gated attention enhancement.
[0070] Specifically, a detailed explanation is given about adding a polarized self-attention mechanism module after the MLP layer: Unlike target detection and image classification, fine-grained pixel-level tasks (such as semantic segmentation) need to effectively model the long-distance dependencies of high-resolution input / output features while maintaining a low computational cost, so as to accurately predict pixel-level semantic information with high complexity. However, although the MiT encoder can generate multi-level feature maps similar to CNN networks, covering image information from coarse-grained to fine-grained, its feature extraction capability is still insufficient when performing more detailed pixel-level segmentation tasks, especially in areas where the edge of urban waters borders the background and in waters with long and narrow shapes, large segmentation errors are prone to occur. In order to solve the above problems, the present invention introduces a polarized self-attention module after the MLP layer, such as Figure 4 shown.
[0071] The polarized self-attention mechanism can realize a very effective long-distance modeling method, which can significantly improve the accuracy of urban water area identification. The polarized self-attention mechanism module (PSA module) contains two branches: channel self-attention and spatial self-attention. By fusing the results of these two branches, the model can maintain a high resolution in both channel and spatial dimensions, which can effectively reduce the information loss caused by reducing the dimension. This means that the model can more effectively capture the dependencies between remote pixels while maintaining a high resolution. In addition, the polarized self-attention mechanism also adds nonlinearity to the attention mechanism, making the fitted output more delicate and closer to the real output.
[0072] In one embodiment, the implementation process of channel self-attention is as follows: First, the original input feature X∈R is transformed into C×H×W Convert to W q ∈R 1×H×W and W v ∈R C / 2×H×W Two branches. Second, adjust W through the Reshape operation q and W v The shape of W q ∈R HW×1×1 and W v ∈R C / 2×HW Then, to reduce W q Since the channel is compressed and the information is lost, the Softmax operation is used to q Then, the enhanced W q With W v Perform matrix multiplication operations to deeply mine the information of the channel self-attention branch and generate a new input feature W q,v ∈R C / 2×1×1Then, W is transformed into q,v ∈R C / 2×1×1 The channel dimension of is increased to C, and the Sigmoid activation function is applied to ensure that all parameter values are between [0,1]. q,v ∈R C×1×1 With the original input feature X∈R C×H×W Perform point multiplication on the channel dimension to generate the final channel attention feature map W ch ∈R C×H×W , the calculation formula of this process is as follows:
[0073] W cz =σ(E c (E SM (Re shape(E c (X)))×Re shape(E c (X))))
[0074] W ch =W cz ⊙ C X
[0075] Where Ec(·) represents a convolution unit with a convolution kernel size of 1×1; X represents the original input feature; E SM (·) represents the Softmax function; “×” represents matrix multiplication; σ(·) represents the Sigmoid activation function; ⊙ C Represents feature point multiplication on the channel dimension; Reshape() represents dimension transformation.
[0076] In one embodiment, the implementation process of spatial self-attention is as follows: First, the original input feature X∈R is transformed into C×H×W Convert to W q ∈R C / 2×H×W and W v ∈R C / 2×H×W Two branches. Second, use the global average pooling operation to q Compress the spatial dimension, and the pooled W q Changes to W q ∈R C / 2×1×1 Then, use Reshape to resize W q and W v The shape of the information is enhanced q With W v Perform matrix multiplication to obtain the new input feature W q,v ∈R 1×HW Next, W q,v Reshape to W q,v ∈R 1×H×WAfter normalization, the feature tensor X∈R C×H×W Multiply the points in the spatial dimension, redistribute the weights of the spatial dimension, and generate the final spatial attention feature map W sp ∈R C×H×W , the calculation formula of this process is as follows:
[0077]
[0078] W q =E GP (W q )
[0079]
[0080] W sp =W q,v ⊙ S X
[0081] In the formula, E GP represents global average pooling; H represents the height of the feature map; W represents the width of the feature map; X(:,i,j) represents the pixel value of the input feature map at the position (:,i,j); ⊙ S Represents the feature point multiplication in the spatial dimension.
[0082] Finally, the feature map W of the channel attention branch ch and the feature map W of the spatial attention branch sp Add them together to get the features after noise removal.
[0083] In one embodiment, the hybrid loss function is explained as follows: The role of the loss function in the semantic segmentation model is crucial, and it directly affects the training process and final performance of the model. In the task of urban waters identification in remote sensing images, the number of pixels in the background category is far greater than the number of pixels in urban waters. A single loss function may cause the model to tend to focus more on the background during training, while the hybrid loss function can reduce the impact of this imbalance by adjusting the weights of the loss function, allowing the model to pay more attention to difficult-to-classify pixels. Based on the above analysis, in order to make the present invention more suitable for urban waters identification tasks, the present invention combines the characteristics of Focal Loss and Dice Loss loss functions, uses the two in combination, improves the prediction accuracy of pixel points, and accelerates the convergence of the model.
[0084] Loss Total =αLoss Focal +βLoss Dice ,α+β=1
[0085] Wherein, α and β represent the weights of each part in the hybrid loss function. In order to ensure that the two functions have equal influence in this embodiment, α and β are both set to 0.5.
[0086] Loss Focal Calculated by the following formula:
[0087] Loss Focal =-α t (1-p t ) γ log(p t )
[0088] Loss Dice Calculated by the following formula:
[0089]
[0090] Loss Focal and Loss Dice In the calculation formula, p t Represents the probability that the model predicts that the sample is a positive example, α t represents the weight of the sample, γ is the parameter for adjusting the difficulty of the sample. When γ = 0, Focal Loss is equivalent to the cross entropy loss function. A represents the pixel label of the real segmented image, and B represents the pixel category of the segmented image predicted by the model.
[0091] According to the present invention, a remote sensing image urban water area segmentation method based on attention regulation is analyzed and explained in combination with experimental results.
[0092] In order to verify the segmentation performance of the scheme of the present invention for urban waters, based on the ZKXT and GF-UWS datasets, the APMFormer model of the present invention is compared with the U-Net, Deeplab-v3+, PSPNet, HRNet, TransFuse, Swin-Unet, TransUnet, and Segformer methods to verify the effectiveness of the method of the present invention.
[0093] 1. ZKXT Urban Water Area Dataset
[0094] The ZKXT dataset is derived from the "2020 Fourth China Science Star Map Cup High-resolution Remote Sensing Image Interpretation Software Competition". Figure 5As shown. The dataset is composed of GF-2 optical data with a resolution of 1 to 4 meters. It contains 1,000 high-quality GF-2 cropped images of different cities in China. The image size is 492×492 pixels. Each image is annotated with pixel-level images of rivers, lakes, seas, etc. In the experiment, the present invention sets the image and label size to 224×224 pixels, and divides the expanded dataset into a training set, a validation set, and a test set in a ratio of 6:2:2, including: 14,400 training sets, 4,800 validation sets, and 4,800 test sets.
[0095] 2. Experimental Configuration and Training
[0096] 2.1 Experimental environment and parameter settings
[0097] The experimental platform of the present invention is Windows 10 operating system, the processor is Intel Core i7-10700K, and the graphics card is NVIDIA GeForce GTX3090Ti. The programming language version is Python 3.7, the development framework version is Pytorch-GPU 1.10.2, and the acceleration platform is CUDA 11.3 and CUDNN 11. The Adam optimizer is used in model training, the initial learning rate is 10-4, the learning descent method is cosine descent, the number of training iterations (epoch) is set to 300, and the batch size (batch size) is set to 4.
[0098] 2.2 Evaluation indicators
[0099] In order to quantitatively evaluate the performance of the model, the experiment sets six evaluation indicators: accuracy (OA), intersection over union (IoU), precision (Precision), recall (Recall), F1 score (F1-score), and average F1 score value (MF1).
[0100] 3. Performance testing and result analysis
[0101] Depend on Figure 6 As can be seen from Table 1, when the training model converges, the APMFormer model achieves excellent performance in the four key comprehensive evaluation indicators of Precision, Recall, F1-score and IoU, and has good segmentation results. Specifically, compared with other mainstream methods, the APMFormer model improves Precision by 1.01% to 7.56%, Recall by 0.57% to 6.24%, F1-score by 0.06% to 6.9%, and IoU by 0.23% to 6.79%.
[0102] Table 1 Data of various indicators on the ZKXT dataset
[0103]
[0104] The present invention selects six complex scenes from the test results of the ZKXT dataset as entry points for rationality analysis, namely: low contrast and inter-class similarity, strip-shaped urban waters, intra-class heterogeneity, small urban waters, narrow and long urban waters, and irregular urban waters.
[0105] Depend on Figure 6 It can be seen that in the first scene, the patchy urban waters have a lower contrast with the surrounding environment, and the pixel colors of some target areas are similar to those of the surrounding land, which may lead to a reduction in the pixel features of urban waters obtained by the model, a decrease in the feature expression ability of urban waters, and thus affect the final recognition results. Other methods have misclassification and misclassification in the urban waters recognition task, while the method of the present invention can effectively maintain the continuity and integrity of the urban waters recognition results, and significantly improve the recognition accuracy. In the second scene, the urban waters are strip-shaped and have a small width change, but some waters are blocked by bridges, resulting in discontinuities in the river. The method of the present invention not only ensures the integrity of the urban waters, but also ensures that the water gaps are accurately extracted. Compared with other methods, the method of the present invention is more accurate and smooth in determining the boundaries of urban waters. In the third scene, there is interference similar to plant communities near and inside the small strip of water on the left, which leads to heterogeneity inside the waters, reduces semantic relevance, and causes the other comparison methods to miss recognition at the junction of waters and land, while the method constructed by the present invention can effectively capture the detailed information of the junction while ensuring semantic integrity. In the fourth scene, since the pond occupies a small number of pixels, its feature expression is not particularly strong compared to large objects such as buildings, land and roads. If there is a lack of sufficient contextual information, the semantic segmentation model will easily ignore them. The method of the present invention can extract more complete small urban waters than other methods. In the fifth scene, the narrow and long water area is located in a dense community of buildings. The characteristics of the urban water area are not particularly obvious, which causes other methods to miss or misclassify, while the method of the present invention extracts the urban water area more completely. In the sixth scene, it can be seen that the irregular shape of the urban water area makes image segmentation more difficult. Other methods cannot accurately identify small objects inside the water area and the gaps between the water areas, while the present invention ensures a high degree of completeness and also shows great advantages at the junction.
[0106] like Figure 7 As shown, for example, a remote sensing image urban water segmentation system based on attention regulation is provided, and its main interface is as follows Figure 7 (a), including:
[0107] User authentication module: The user authentication module includes the registration interface and the login interface, such as Figure 7 (b) Figure 7 (c) As shown in Figure 1. New users can start the account creation process by clicking the Register button. After completing the registration, the user will automatically jump to the login page. On this page, the user needs to enter the reserved email address or mobile phone number and the corresponding password, and then click the Login button to submit the access request. The system backend will execute the login verification logic and query the database to check the matching of the account and password. After the verification is passed, the user will be authorized to enter the system. If the verification fails, the user will not be able to access the system and may receive a corresponding prompt message.
[0108] Dataset management module: The dataset management module includes the dataset upload interface and dataset preview interface, such as Figure 7 (d) Figure 7 (e) The dataset management module mainly includes dataset upload, deletion, download, and preview functions. Users can select the dataset to be uploaded through the terminal interface and transfer the dataset to the system by clicking the upload button. The system will automatically store the image and related information in the database so that users can easily retrieve, view, and manage the uploaded image data.
[0109] Image recognition module: The image recognition module includes an image segmentation interface and a segmentation result viewing interface, such as Figure 7 (f) Figure 7 (g). The segmentation result management module includes the viewing and deletion of historical segmentation records. To meet the diverse semantic segmentation needs, the Web-based urban water area identification system integrates the APMFormer model and the classic semantic segmentation network, allowing users to select the appropriate model according to specific task requirements. After the user selects an image, the system will automatically schedule the selected model to segment the image, and after the processing is completed, the results will be presented to the user through a visual interface.
[0110] Image segmentation model management module: This module is equipped with a remote sensing image urban water segmentation method based on attention regulation. The image segmentation model management module includes a model details interface and a weight file management interface, such as Figure 7 (h) Figure 7(i). Image segmentation model management mainly involves unified management of online weight files and user-uploaded weight files. The system supports users to upload, delete, and download weight files. This function can help users easily retrieve and obtain existing model codes and the latest weight files. The weight file upload function ensures that users can replace model weights in a timely manner, thereby supporting the iterative upgrade of the model and ensuring its continuous optimization over time. The weight file deletion function can help users clean up unnecessary weight files and ensure that users focus on key data and tasks. The weight file download function can help users export data in the system to the local, facilitating data sharing and distribution, especially when collaboration with external users or partners is required.
[0111] Personal Center Module: Users can view and modify their personal information on this interface. The specific interface is shown below: Figure 7 (j) as shown.
[0112] In one embodiment of the present invention, a remote sensing image urban water area segmentation device based on attention regulation is provided, comprising:
[0113] The acquisition module is used to acquire the remote sensing image to be segmented.
[0114] The segmentation processing module is used to use the remote sensing image urban water segmentation model to perform segmentation processing on the remote sensing image to obtain the segmentation result; the remote sensing image urban water segmentation model is obtained by training the improved Segformer model with remote sensing image samples containing urban waters, and the improved Segformer model includes a MiT encoder and a decoder, and the MiT encoder is used to extract the feature map of the remote sensing image; the decoder adds a gated attention mechanism module after the upsampling operation, and the input of the gated attention mechanism module is the deep feature map of the decoder and the shallow feature map of the encoder. The decoder adds a polarization self-attention mechanism module after the MLP layer, and the input of the polarization self-attention mechanism module is a multi-scale feature map with the same size after being processed by the MLP layer; the improved Segformer model adopts a mixed loss function.
[0115] In one embodiment of the present invention, a computer device is provided, which includes a processor and a memory, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is used to execute the program instructions stored in the computer storage medium. The processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. It is the computing core and control core of the terminal, which is suitable for implementing one or more instructions, and is specifically suitable for loading and executing one or more instructions to implement the corresponding method flow or corresponding function; the processor described in the embodiment of the present invention can be used to implement the operation of a remote sensing image urban water segmentation method based on attention regulation.
[0116] In one embodiment of the present invention, a method for urban water segmentation of remote sensing images based on attention regulation can be stored in a computer-readable storage medium if it is implemented in the form of a software functional unit and sold or used as an independent product. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing related hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of each of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. Computer-readable storage media include permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data.
[0117] The computer storage medium can be any available medium or data storage device that can be accessed by a computer, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NANDFLASH), solid-state drive (SSD)), etc.
[0118] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0119] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products of the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0120] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0121] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0122] In the description of the present invention, the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" etc. mean that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0123] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A remote sensing image urban water segmentation method based on attention regulation, characterized in that: include: Acquire a remote sensing image to be segmented; The remote sensing image is processed using a remote sensing image urban water area segmentation model to obtain a segmentation result; The remote sensing image urban water segmentation model is obtained by training an improved Segformer model using remote sensing image samples containing urban waters. The improved Segformer model includes a MiT encoder and a decoder. The MiT encoder is used to extract feature maps of remote sensing images. The decoder is added with a gated attention mechanism module after the upsampling operation. The input of the gated attention mechanism module is the deep feature map of the decoder and the shallow feature map of the encoder. The decoder is added with a polarized self-attention mechanism module after the MLP layer. The input of the polarized self-attention mechanism module is a multi-scale feature map with the same size after being processed by the MLP layer. The improved Segformer model adopts a mixed loss function.
2. The method for urban water area segmentation in remote sensing images based on attention regulation according to claim 1, characterized in that: The gated attention mechanism module includes the following calculation formula: a i =σ2(q att (F xi ,F gi ;θ att )) In the formula, q att Represents additive attention calculation, and the vector is scaled to the interval [0,1] through the Sigmoid layer to obtain α i ; α i represents the learned attention coefficient; F gi represents the deep feature map from the i-th layer of the decoder; F xi represents the shallow feature map from the i-th layer of the encoder; W g , W x and ψ represent convolution operations; b g and b ψ W g and ψ are bias terms; σ1 represents the ReLU activation function; σ2 represents the Sigmoid activation function; the attention operation is performed through θ att to characterize; Indicates that the corresponding elements are multiplied in sequence; F' represents the feature map after gated attention enhancement.
3. The method for urban water area segmentation in remote sensing images based on attention regulation according to claim 1, characterized in that: The polarized self-attention mechanism module includes channel self-attention and spatial self-attention. The channel self-attention is used to generate a channel attention feature map, and the spatial self-attention is used to generate a spatial attention feature map.
4. The method for urban water area segmentation in remote sensing images based on attention regulation according to claim 3, characterized in that: The implementation process of the channel self-attention specifically includes: First, the original input feature X∈R is transformed into C×H×W Convert to W q ∈R 1×H×W and W v ∈R C / 2×H×W Two branches; Second, adjust W through the Reshape operation q and W v The shape of W q ∈R HW×1×1 and W v ∈R C / 2×HW ; Then, the Softmax operation is used to q Perform information enhancement; Next, the enhanced W q With W v Perform matrix multiplication to generate a new input feature W q,v ∈R C / 2×1×1 ; Then, W is transformed into q,v ∈R C / 2×1×1 The channel dimension is increased to C, and the Sigmoid activation function is applied to ensure that all parameter values are between [0,1]; Finally, W q,v ∈R C×1×1 With the original input feature X∈R C×H×W Perform point multiplication on the channel dimension to generate the final channel attention feature map W ch ∈R C×H×W ; The calculation formula for this process is as follows: W cz =σ(E c (THAT SM (Reshape(E c (X)))×Reshape(E c (X)))) W ch =W cz ⊙ C X Where Ec(·) represents a convolution unit with a convolution kernel size of 1×1; X represents the original input feature; E SM (·) represents the Softmax function; "×" represents matrix multiplication; σ(·) represents the Sigmoid activation function; ⊙ C Represents feature point multiplication on the channel dimension; Reshape() represents dimension transformation.
5. The method for urban water area segmentation in remote sensing images based on attention regulation according to claim 4, characterized in that: The implementation process of the spatial self-attention is as follows: First, the original input feature X∈R is transformed into C×H×W Convert to W q ∈R C / 2×H×W and W v ∈R C / 2×H×W Two branches; Secondly, a global average pooling operation is used to q Compress the spatial dimension, and the pooled W q Changes to W q ∈R C / 2×1×1 ; Then, use Reshape to resize W q and W v The shape of the information is enhanced q With W v Perform matrix multiplication to obtain the new input feature W q,v ∈R 1×HW ; Then W q,v Reshape to W q,v ∈R 1×H×W After normalization, it is compared with the original input feature X∈R C×H×W Multiply the points in the spatial dimension, redistribute the weights of the spatial dimension, and generate the final spatial attention feature map W sp ∈R C×H×W ; The calculation formula for this process is as follows: W q =E GP (W q ) W sp =W q,v ⊙ S X In the formula, E GP represents global average pooling; H represents the height of the feature map; W represents the width of the feature map; X(:,i,j) represents the pixel value of the input feature map at the position (:,i,j); ⊙ S Represents the feature point multiplication in the spatial dimension.
6. The method for urban water area segmentation in remote sensing images based on attention regulation according to claim 1, characterized in that: The hybrid loss function is formed by mixing the Focal Loss loss function and the Dice Loss loss function, as follows: Loss Total =αLoss Focal +βLoss Dice ,a+b=1 Loss Focal =-α t (1-p t ) γ log(p t ) In the formula, α and β represent the weights of each part in the mixed loss function; p t Represents the probability that the model predicts that the sample is a positive example; α t represents the weight of the sample; γ is a parameter to adjust the difficulty of samples; Loss Focal 、Loss Dice 、Loss Total They represent FocalLoss loss function, Dice Loss loss function and mixed loss function respectively; A represents the pixel label of the real segmentation image, and B represents the pixel category of the segmentation image predicted by the model.
7. A remote sensing image urban water segmentation device based on attention regulation, characterized in that: include: An acquisition module, used for acquiring a remote sensing image to be segmented; A segmentation processing module is used to use a remote sensing image urban water area segmentation model to perform segmentation processing on the remote sensing image to obtain a segmentation result; the remote sensing image urban water area segmentation model is obtained by training an improved Segformer model using remote sensing image samples containing urban water areas, and the improved Segformer model includes a MiT encoder and a decoder, and the MiT encoder is used to extract the feature map of the remote sensing image; the decoder is added with a gated attention mechanism module after the upsampling operation, and the input of the gated attention mechanism module is the deep feature map of the decoder and the shallow feature map of the encoder. The decoder is added with a polarized self-attention mechanism module after the MLP layer, and the input of the polarized self-attention mechanism module is a multi-scale feature map with the same size after being processed by the MLP layer; the improved Segformer model adopts a mixed loss function.
8. A device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of a remote sensing image urban water area segmentation method based on attention regulation are implemented as described in any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of a remote sensing image urban water area segmentation method based on attention regulation are implemented as described in any one of claims 1 to 6.
Citation Information
Cited By
Tunnel water inrush automatic identification method and system based on water inrush target detection model
CN119649173A
Medical image segmentation method and system based on multi-modal data
CN119919432A
Remote sensing image road semantic segmentation method based on polarization self-attention feature enhancement
CN119992101A
Road semantic segmentation method for remote sensing images based on polarization self-attention feature enhancement
CN119992101B
