A two-stream Swin Transformer remote sensing scene classification method
Through the combination of the dual-stream Swin Transformer and the derivable Sobel operator module, the problem of extracting local structural information and edge features in remote sensing images is solved, the classification accuracy of remote sensing images is improved, and better scene object recognition and interference factor suppression are achieved.
Patent Information
- Application Number
- CN202210372827.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-11
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2042-04-11
Smart Images

Figure CN114937202B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a remote sensing image scene classification method, in particular to a dual-stream Swin Transformer remote sensing scene classification method, and belongs to the technical field of remote sensing information processing. Background Art
[0002] Remote sensing images are valuable resources that help us observe the earth. With the advancement of earth observation technology, the number of high-resolution remote sensing images has increased dramatically. Therefore, understanding complex and massive remote sensing images has become an important task for remote sensing scene classification. Remote sensing scene classification technology has been widely used in many fields such as urban planning, geographic image retrieval, environmental detection, vegetation mapping, and geospatial object detection.
[0003] In recent decades, many scene classification methods based on traditional manual features or deep learning features have been proposed. Deep learning methods are still the mainstream scene classification methods. Deep learning methods include deep belief neural networks (DBNN), convolutional neural networks (CNN) and visual transformers. Cheng et al. first used CNN for feature extraction in remote sensing scene classification tasks. Zhou et al. completed end-to-end remote sensing classification tasks using pre-trained CNN.
[0004] Recently, Transformer has made remarkable achievements in the field of natural language processing (NLP) and has also been introduced to the field of image classification. The Vision Transformer (ViT) proposed by Dosoviskiy et al. has achieved excellent results in the field of image classification. Transformer has also been recently introduced to remote sensing scene classification, and most of the work is based on the classic ViT model. For example, Bazi et al. combined the preprocessed ViT model with data enhancement and network pruning to improve the performance of ViT in remote sensing scene classification. Deng et al. proposed a joint model CTNet for scene classification, in which ViT is used to extract image semantic features and CNN is used to extract local structural features. TRSNet proposed by Zhang et al. optimizes the residual network, adds the Transformer structure, achieves better interactivity between Transformer and CNN, and improves classification performance.
[0005] Although ViT is the dominant Transformer solution, it still has many shortcomings. For example, its feature map has a single constant resolution and the computational complexity of self-attention reaches quadratic. In addition, ViT over-focuses on long-distance semantic information and ignores local structural information. The Shift windows (Swin) Transformer proposed by Liu et al. solves the above problems by introducing some features of CNN and constructing hierarchical feature maps by merging image blocks. And Swin Transformer has linear self-attention computational complexity. Therefore, in this paper, we chose Swin Transformer as the backbone network of the framework.
[0006] In addition, the above methods are all networks designed for natural images, and do not fully consider the characteristics of remote sensing images. Remote sensing images are usually large in size, high in resolution, and cover a large number of ground objects. More importantly, since remote sensing scene images are composed of randomly distributed ground objects, they are more difficult to identify effectively. Features such as edge curves are of great help in remote sensing scene classification. Therefore, in order to effectively extract edge information, we propose a differentiable edge Sobel operator module. Unlike other methods that directly use the Sobel operator for edge extraction, we use a differentiable Sobel operator to extract edges.
[0007] In this context, we propose a two-stream Swin Transformer remote sensing scene classification method with a differentiable Sobel operator, which improves the accuracy of remote sensing scene classification by fusing original features and edge features. We innovatively construct a differentiable edge Sobel operator module that can generate images with rich edge information. Summary of the invention
[0008] The purpose of the present invention is to improve the scene classification accuracy of remote sensing images, and a two-stream Swin Transformer scene classification method with Sobel operator (expressed as TSTNet) is proposed.
[0009] The first purpose of the present invention is to propose a two-stream Swin Transformer scene classification method with a Sobel operator, which includes four modules: a differentiable Sobel operator, an original feature extraction flow, an edge feature extraction flow, and a feature fusion flow. The technical details of the four modules are as follows:
[0010] Derivable Sobel operator module: First, this module is based on the traditional edge detection algorithm. First, the original remote sensing image T Convert to grayscale A, and then put the Sobel operator into the 3×3 convolution kernel, and extract the edge image of the image on the horizontal and vertical axes through two convolution kernels G x and G y In addition, the convolution kernel has a gradient and can be used to update parameters. This operation realizes the adaptive learning of the Sobel operator. At the same time, in order to supplement the content information, the edge image G x , G y and grayscale A Concatenate in the channel dimension to form a three-channel image T(i) . T(i) There is both edge emphasis information and content information, which is subsequently input into the edge stream for feature extraction.
[0011] Edge feature extraction flow: The edge feature flow uses Swin Transformer as the backbone network to extract features of the image generated by the Sobel operator module. These features mainly contain edge emphasis information of the synthesized image. Feature extraction first divides the synthesized edge image into multiple image blocks through linear mapping and inputs them into Swin Transformer. Swin Transformer divides the image blocks into windows through the window division mechanism, performs self-attention mechanism calculations within the window, and increases global communication between image blocks through the cross-window mechanism. Therefore, each image block integrates the associated information of other image blocks. Through the multi-layer resolution mechanism, features are filtered layer by layer. Finally, high-quality edge features are generated for subsequent feature fusion.
[0012] Original feature extraction flow: The original feature extraction flow also uses Swin Transformer as the backbone network to extract the features of the original remote sensing image. The extraction process is the same as the edge feature flow. The extracted original features are finally merged with the edge features to facilitate classification and prediction.
[0013] Feature fusion module: This module consists of two parts: feature fusion and loss function. F 1 and F 2 are the extracted original features and edge features. They are vectors of dimension d. By connecting the two vectors in series, we can form a vector F , and then through the full connection F Map to F’ ,final F'ϵR n(where n is the number of task classifications). The features of the two streams are fused in this way. At the same time, in order to emphasize the importance of the original feature extraction stream, an auxiliary loss function is designed to expand the back propagation of the original stream. A weight coefficient λ is used to balance the two cross entropy loss functions. Finally, the fused features are sent to the softmax function for the final classification prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 .Overall structure diagram of a two-stream SwinTransformer remote sensing classification method (front part).
[0015] Figure 2 .Overall structure diagram of a two-stream SwinTransformer remote sensing classification method (latter part).
[0016] Figure 3 .Differentiable Sobel operator module.
[0017] Figure 4 .Fusion module and loss function.
[0018] Figure 5 Internal structure of the .Swin Transformer block.
[0019] Figure 6 .The present invention was subjected to ablation experiments under different training ratios of different data sets, using the AID data set.
[0020] Figure 7 .Visualize the network attention map of the present invention and compare the attention maps of TSTNet and Swin Transformer. DETAILED DESCRIPTION
[0021] The present invention is described in more detail below with reference to the accompanying drawings and examples.
[0022] The method proposed in the present invention includes three steps: adaptive edge image generation, original feature and edge feature extraction, and feature fusion. The specific analysis steps are as follows:
[0023] Step S1: Adaptive edge image generation
[0024] Step S1.1: Original remote sensing image T Input to the differentiable Sobel operator module, such as Figure 2 shown.
[0025] Step S1.2: First convert the image into a grayscale image A .
[0026] Step S1.3: The edge detection images of two conventional Sobel operators in the horizontal and vertical directions are:
[0027]
[0028] in, A Represents the grayscale image converted from the original remote sensing image. The two matrices are the operators in the horizontal and vertical directions respectively. G x Represents the horizontal edge detection image. G y Represents the edge detection image on the vertical axis.
[0029] Step S1.4: The specific implementation of the algorithm in our method is completed through convolution operation. Figure 2 In the figure, the two 3×3 convolution kernel filters use the Sobel horizontal operator and the vertical operator respectively. The convolution kernel has a gradient and can update the parameters.
[0030] Step S1.5: Finally, G x and G y and grayscale A By connecting together in the channel dimension, a three-channel edge composite remote sensing image is formed. T(i) .
[0031] Step S2: extracting original features and edge features;
[0032] Step S2.1: Transform the original image features T and edge composite image T(i) Divide into many image blocks and input into Swin Transformer. Figure 1 As shown, the upper part shows the original remote sensing image input into Swin Transformer for original feature extraction, and the lower part shows the edge synthesis image input into Swin Transformer for edge feature extraction.
[0033] Step S2.2: Feature extraction process of Swin Transformer;
[0034] The specific structure of Swin Transformer is as follows Figure 7 As shown, the remote sensing image size is H×W×C ,in H Represents the height of the image, W Represents the width of the image, C Represents the number of channels of the image. After being converted into image blocks through linear mapping, the image is converted into N ×CThe size characteristics, where N represents the number of image blocks, C Represents the dimension of each image block. Swin Transformer uses a self-attention mechanism with a window mechanism to calculate the association between features. The structure of two consecutive Transformer blocks is as follows: Figure 4 The specific operation process is as follows:
[0035]
[0036] Among them, W-MSA is the conventional window multi-head self-attention calculation, MLP is a multi-layer perceptron, and SW-MSA is a sliding window multi-head self-attention mechanism. and z l They are (S)W-MAS and MLP in the l The output of each block. Each input needs to be layer normalized (LN) in advance.
[0037] Step S3: feature fusion;
[0038] Figure 3 The details of the feature fusion module and loss function are shown. F 1 and F 2 They are the extracted original features and edge features, both of which are vectors of dimension d. They are fused in the following way:
[0039]
[0040] Among them, Concat stands for serial connection and FC stands for full connection. Through full connection, the edge features and original features are effectively fused. The generated features F’ The original features and edge features are combined. F'ϵR n (where n is the number of task categories).
[0041] In order to emphasize the importance of the original flow, an auxiliary loss function is added to the final loss function. The loss function form is as follows:
[0042]
[0043] in, L F It is a fusion feature F’ The cross entropy loss function. L F1 is the output feature F 1The original flow plays an important role in the final classification task, so we introduce the weight coefficient λ (λϵ[0,1]) to balance the two loss functions. Experiments have shown that λ=0.8 can bring better performance.
[0044] In order to illustrate the effectiveness of the present invention, the following experimental demonstration is conducted. The experimental data comes from remote sensing images of the Aerial Image Dataset (AID), which has a large image size and rich scene coverage. These images are from different countries and regions, collected at different times and seasons, and cover 30 scenes. The size of each image is 600600 pixels.
[0045] Experimental environment of the present invention:
[0046] All experiments used the Pytorch1.8 deep learning framework, and the model was trained on an NVIDIA RTX 3090 (24GB) GPU. The basic type (Swin-B) was used for Swin Transformer.
[0047] The first set of experiments focuses on studying the impact of each component of the present invention on the overall classification accuracy to prove the effectiveness of the present invention. Figure 5 shown.
[0048] Swin-B vs. ViT-B: It can be observed that the overall classification accuracy (OA) of Swin-B is higher than that of ViT-B. Specifically, on the AID dataset with different training rates, the Swin-B-based branch is 3.2% and 1.6% higher than the ViT-B-based branch. This observation shows that Swin-B is always better than ViT-B, so we use Swin-B as the backbone network.
[0049] Comparison between differentiable and non-differentiable Sobel operators: The edge flow with differentiable Sobel operator has a higher accuracy than the edge flow with non-differentiable Sobel operator. Specifically, on the AID dataset, the edge flow with differentiable Sobel operator is 0.6% and 0.4% higher than the edge flow with non-differentiable Sobel operator. This shows that the differentiable Sobel operator module of the present invention is effective and can extract better edge features.
[0050] Comparison of weighted loss function and original loss function: On the AID dataset, the performance of the proposed TSTNet is further improved compared with TSTNet-add. Specifically, TSTNet improves by 0.3% and 0.1% respectively at different training rates compared with TSTNet-add.
[0051] Comparison between edge flow and no edge flow: On the AID dataset with two training ratios, the overall classification accuracy of the proposed TSTNet is improved by 1.8% and 1.3% compared with the original flow and edge flow. This shows that the auxiliary edge flow with a differentiable Sobel operator can help the network achieve better performance.
[0052] The second set of experiments focuses on the image of network attention. Figure 6 As shown, for the airport scene, the TSTNet of the present invention can better focus on the aircraft and ignore some interference factors of the airport. In short, the present invention can pay more attention to the scene objects and ignore interference factors.
[0053] The third group of experiments focuses on the overall classification accuracy (OA) comparison between the present invention and some advanced methods. In the experiment, the AID dataset was used for comparison. 20% training samples and 50% training samples were used to compare with the most advanced methods. In order to reduce the error caused by random factors, all experiments were repeated 10 times, and the average and standard deviation were taken. The overall classification accuracy OA was used as the metric. The results are shown in Table I. It can be observed that the accuracy of the TSTNet of the present invention exceeds the most advanced methods, whether it is a CNN-based method or a ViT-based method. Specifically, compared with Inception-v3-CapsNet based on Inception-v3, TSTNet has improved by 3.41% and 2.47%. TSTNet has improved the accuracy of KFBNet (DenseNet-121) based on CNN by 1.7% and 1.05%. Compared with TRS based on ViT, TSTNet has improved the accuracy by 1.66% and 0.22%, respectively. In summary, our invention is still better than other baseline models with only a small amount of training data. This shows that our invention is robust and effective.
Claims
1. A remote sensing scene classification method based on a two-stream Swin Transformer, characterized in that: The following steps are involved: S1: Processing raw remote sensing images X∈R H×W×C , where H, W, and C are the height, width, and number of channels of the image respectively. The image is grayscale processed to generate a single-channel grayscale image G ; S2: The edge images of the horizontal and vertical axes are generated through the differentiable Sobel operator. G x and G y , and grayscale image G Connect in the channel dimension to form a three-channel edge image T(i)= Concat (G, G x , G y ) , where Concat represents serial connection; S3: The original remote sensing image T and edge images T(i) Divide into image blocks, where n Refers to the number of image blocks in an image. T={x 1 , x 2 … x n } , T(i)={x 1 , x 2 … x n } ; S4: The original image block and the edge image block are sent to the two-stream Swin Transformer to extract features respectively. The two-stream Transformers have the same structure, and their parameters are learned separately. The features extracted by Swin Transformer for edge images are more special, containing both the original image information and the edge emphasis information; S5: The original features and edge features extracted by Swin Transformer are F 1 and F 2 , and are fused in the following form: F'=FC( Concat (F 1 ,F 2 )) Concat stands for serial connection. FC Represents full connection, F’ represents fusion features; S6: Fusion features F’ Send it to the softmax classifier for final prediction.
2. The method according to claim 1, characterized in that The step S2 adopts a differentiable Sobel operator, places the operator in a convolution kernel, and completes edge extraction through a convolution operation. The convolution kernel can update parameters during the back propagation process of the network to achieve adaptive learning of the Sobel operator value.
3. The method according to claim 1, characterized in that While integrating the features in step S5, the loss function is also redesigned, and an auxiliary loss function is introduced. λ Control the balance of the two loss functions, the formula is: L = λL F +(1-λ)L F1 in L F and L F1 Characteristics F’ and F 1 The cross entropy loss function is: L is the final loss function.
Citation Information
Patent Citations
A remote sensing image scene classification method based on the fusion of depth features and saliency features
CN109165682A
Satellite image small target detection method based on improved YOLOv5
CN114220015A
Cited By
Multi-layer fusion picture classification method and system based on long-distance dependency mechanism
CN117197663A
Multi-layer fusion picture classification method and system based on long-range dependence mechanism
CN117197663B
