Transformer dual-branch road extraction method and device based on edge constraints and feature adaptation

By introducing edge constraints and feature adaptation mechanisms into the Transformer dual-branch road extraction method, combined with cross-window self-attention and asymmetric upsampling, the boundary blur problem of the existing network model in road extraction is solved, and the road edge details are significantly improved. and connectivity extraction effects.

CN114926797BActive Publication Date: 2024-10-11CHINA UNIV OF GEOSCIENCES (WUHAN)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210539771.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-18
Publication Date
2024-10-11
Estimated Expiration
2042-05-18

AI Technical Summary

Technical Problem

Existing network models have boundary blur problems when extracting roads. Especially in high-resolution remote sensing images with complex backgrounds, it is difficult to effectively extract the features of roads that are slender, small in proportion, and large in span.

Method used

The Transformer dual-branch road extraction method based on edge constraints and feature adaptation is used to achieve multi-scale representation and refinement of road features through data enhancement, dual-branch model construction, cross-window self-attention mechanism, edge constraint branches and asymmetric upsampling modules. Granularity extraction.

Benefits of technology

It effectively solves the problems of blurred ground object boundaries and missing small-scale targets, improves the extraction effect of road edge details and connectivity, and realizes context relationship modeling from local to global.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114926797B_ABST
    Figure CN114926797B_ABST
Patent Text Reader

Abstract

The present invention provides a Transformer dual-branch road extraction method and device based on edge constraints and feature adaptation, the method comprising: building a dual-branch road extraction model, inputting high-resolution remote sensing images and corresponding sample data sets; using a cross-window self-attention mechanism model to model road features; using an asymmetric upsampling decoder to integrate multi-scale feature maps in the road surface extraction branch; refining constraints on edge extraction branch roads; and classifying road features of images to be classified through a trained road feature extraction model to obtain road feature classification results for each image. The present invention provides a novel dual-branch road extraction model architecture, which has the ability to accumulate local and global contextual information, adapts to long-distance features with large road spans, makes full use of the edge prior information of the image itself, ensures segmentation accuracy, and enhances the integrity of the road extraction results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of deep learning and remote sensing image processing, and in particular to a Transformer double-branch road extraction method and device based on edge constraint and feature adaptation. Background Art

[0002] Road extraction is a type of image segmentation based on the geometric shape and spatial features of roads. It has always been a hot topic in the field of remote sensing and is of great significance in many applications such as urban planning, geographic information system updates, intelligent transportation, and vehicle navigation. The huge growth of satellite observation data has enabled researchers to obtain more information from remote sensing images. In a rapidly developing region, the road network changes rapidly. However, manual road annotation is time-consuming and laborious and cannot be actually applied to real-time road extraction tasks such as disaster relief. Therefore, it is necessary to design good road extraction methods and models to extract the latest road networks in a timely manner to meet the corresponding applications and needs. However, the characteristics of roads, such as large spans, small proportions, complex and diverse road surface materials and spatial structures, as well as the noise, occlusion and complex background of remote sensing images, make road extraction challenging.

[0003] Traditional road extraction methods can be divided into pixel-based and object-oriented methods. Common pixel-based road extraction methods include edge detection, spectral analysis, threshold segmentation, etc. This method is easy to generate "salt and pepper" noise and it is difficult to distinguish the shadows caused by trees and buildings beside the road. Therefore, most pixel-based methods require various post-processing methods to refine the extracted results. In object-oriented extraction methods, roads are regarded as objects. This method is mainly divided into regional methods, knowledge models, texture analysis, etc., usually first segmenting or clustering the image into small areas, and then using them as units for road detection. Compared with pixel-based methods, it has good anti-noise characteristics and wide applicability, but the design is relatively complex, highly dependent on the intermediate segmentation results, and easily confuses adjacent and similarly shaped ground objects.

[0004] In recent years, the development of deep learning has greatly promoted the progress of road extraction. Deep learning methods combine the features of objects and pixels, have the ability to mine higher-level features and have better results. Deep learning methods such as Unet and D-Linknet in the current field have performed well in many road extraction tasks, but they still have major limitations. Roads are characterized by being slender, small in proportion, and large in span in high-resolution remote sensing images with complex backgrounds. Many network models lose high-frequency detail information of the ground objects while gradually convolving to expand the receptive field, which makes the road boundaries blurred and the extraction effect is not ideal. Summary of the invention

[0005] The main technical problem solved by the present invention is to solve the boundary fuzzy problem existing in the existing network model when extracting roads. The technical solution adopted by the present invention is to provide a Transformer dual-branch road extraction method and device based on edge constraints and feature adaptation.

[0006] According to one aspect of the present invention, a Transformer dual-branch road extraction method based on edge constraints and feature adaptation comprises the following steps:

[0007] S1. Perform data enhancement processing on the input training data set to obtain an enhanced training data set;

[0008] S2. Build a two-branch road extraction model and perform initialization and hyperparameter setting to obtain an initialized two-branch road extraction model;

[0009] S3, inputting the enhanced training data set into the initialized dual-division road extraction model, downsampling the image of the enhanced training data set four times through the Transformer encoder, and using the cross-window self-attention mechanism to model and obtain a feature map containing local information and global information;

[0010] S4, inputting the enhanced image of the training data set into the hierarchical feature convolution model to obtain the road edge label, restoring the size of the feature map containing local information and global information output by the Transformer encoder through the edge constraint branch, and obtaining the road edge mask for constraining the road surface extraction;

[0011] S5, through the decoder with asymmetric upsampling module of the road surface extraction branch, the high-level semantic features output by each layer of the Transformer encoder are integrated with multi-scale features in a skip connection manner, the feature map is restored, and the road surface prediction result is output in combination with the edge branch feature constraints;

[0012] S6. Calculate the road surface loss function through the road surface prediction results and the road surface labels in the enhanced training data set, calculate the road edge loss function through the road edge mask and the road edge label, and then calculate the joint loss function to supervise the extraction of the two branch features of the dual-branch road extraction model, train the model feature map through the joint loss function and the back propagation algorithm, and update the parameters in the encoder and decoder;

[0013] S7. Repeat steps S3-S6 until a trained road feature extraction model is obtained, and use the trained road feature extraction model to perform road feature extraction and classification on the image to be classified to obtain a road surface classification result of the image to be classified.

[0014] Preferably, step S3 includes

[0015] S31, the enhanced training set images are divided into non-overlapping blocks of 4×4 size, and the feature map dimensions are flattened using the feature map linear normalization layer to obtain The feature map of size, where H, W and C represent the length, width and number of channels of the feature map respectively;

[0016] S32, downsample the feature map four times, each downsampling is composed of 2, 2, 6, and 2 identical Transformer modules connected in series. Between each downsampling, the length and width of the feature map are halved through the block reorganization layer, and the number of channels is doubled to realize the multi-scale hierarchical representation of the Transformer encoder features. The sizes of the feature maps obtained by the four downsamplings are as well as That is, a feature map containing local information and global information is obtained.

[0017] Preferably, in step S32, each Transformer module includes: a feature map linear normalization layer, a multi-head self-attention module, a residual connection, and a nonlinear 2-layer multilayer perceptron with a GELU function;

[0018] Two Transformer modules form a group. The multi-head self-attention module of the first Transformer module calculates the relationship between each image block and other image blocks based on the normal window. The calculation formula is:

[0019]

[0020]

[0021] Among them, z l-1 and are the input and output of the multi-head self-attention module based on normal window in the l-1th and lth Transformer modules respectively. W-MSA is the multi-head self-attention module based on normal window. LN is the feature map linear normalization layer. MLP is the multi-layer perceptron. l is the output of the MLP layer of the lth Transformer module;

[0022] After the normal window self-attention calculation, the multi-head self-attention module in the second Transformer module captures wider spatial details of objects at different scales of the image based on sliding dislocated windows. The calculation formula is:

[0023]

[0024]

[0025] Among them, z l and are the input and output of the multi-head self-attention module based on sliding offset window in the lth and l+1th Transformer modules, respectively. SW-MSA is the multi-head self-attention module based on sliding offset window. LN is the feature map linear normalization layer. MLP is the multi-layer perceptron. l+1 is the output of the MLP layer of the l+1th Transformer module.

[0026] Preferably, step S4 comprises:

[0027] S41, mining edge information of the enhanced training data set image using a pre-trained hierarchical feature convolution model to obtain a road edge label;

[0028] S42, the feature map output by the last layer of the Transformer encoder is subjected to a four-fold bilinear upsampling and a 3×3 convolutional layer, and is channel-superimposed with the feature map output by the second layer of the Transformer encoder;

[0029] S43, the superimposed feature map is subjected to a four-fold bilinear upsampling and a 3×3 convolutional layer, and is connected to the output of the last decoder layer of the road surface extraction branch; after two bilinear upsamplings, the edge branch feature map is restored to the original resolution, thereby obtaining a road edge mask for constraining road surface extraction.

[0030] Preferably, step S5 comprises:

[0031] S51, the feature map is upsampled four times by the decoder to gradually restore the size of the feature map; each time it first passes through a layer of 1×1 convolution and Relu function and a layer of asymmetric upsampling layer, the asymmetric upsampling layer contains a one-dimensional convolution kernel connected in series in four directions: vertical, horizontal, positive diagonal, and negative diagonal. The number of parameters of each direction filter is the same as that of the 3×3 transposed filter, which is one-fourth of the 3×3 transposed filter, so that the calculation amount and parameter amount of the decoder are not changed;

[0032] S52, channel superposition of the feature map output by the fourth layer of the decoder and the edge feature map output by the edge constraint branch;

[0033] S53, the superimposed feature map passes through 4×4 convolution and 3×3 convolution with a span of 2, and is activated by the Relu function to restore the feature map to the original image resolution, and finally passes through the Sigmoid function to output the road surface prediction result map.

[0034] Preferably, in step S6, the joint loss function calculation formula is as follows:

[0035] L=L surface +αL edge

[0036] Among them, the road surface loss function L surface is the binary cross entropy, Dice coefficient loss function, road edge loss function L edge is the root mean square loss function, and the hyperparameter α controls the balance between the two branches.

[0037] According to a second aspect of the present invention, a Transformer dual-branch road extraction device based on edge constraints and feature adaptation includes the following modules:

[0038] A data enhancement module is used to perform data enhancement processing on the input training data set to obtain an enhanced training data set;

[0039] The network building and initialization module is used to build a two-branch road extraction model and perform initialization and hyperparameter setting to obtain an initialized two-branch road extraction model;

[0040] A downsampling module, used to input the enhanced training data set into the initialized dual-division road extraction model, downsample the image of the enhanced training data set four times through a Transformer encoder, and use a cross-window self-attention mechanism to model and obtain a feature map containing local information and global information;

[0041] The edge constraint module is used to input the enhanced training dataset image into the hierarchical feature convolution model to obtain the road edge label, and restore the size of the feature map containing local and global information output by the Transformer encoder through the edge constraint branch to obtain the road edge mask used to constrain the road surface extraction;

[0042] The upsampling module is used to integrate the high-level semantic features output by each layer of the Transformer encoder through a decoder with an asymmetric upsampling module in the road surface extraction branch, restore the feature map, and output the road surface prediction result in combination with the edge branch feature constraints;

[0043] A network training module is used to calculate a road surface loss function through road surface prediction results and road surface labels in an enhanced training data set, calculate a road edge loss function through road edge masks and road edge labels, and then calculate a joint loss function to supervise the extraction of two branch features of a dual-branch road extraction model, train the model feature map through the joint loss function and a back propagation algorithm, update parameters in the encoder and decoder, repeat the training until the training is completed, and obtain a trained road feature extraction model;

[0044] The road extraction and classification module is used to extract and classify road features of the image to be classified through the trained road feature extraction model to obtain the road surface classification result of the image to be classified.

[0045] The technical solution provided by the present invention has the following beneficial effects:

[0046] (1) Through the cross-window self-attention mechanism of Transformer, the problems of blurred boundary of objects and missed classification of small-scale targets caused by the loss of high-frequency details of objects in the process of gradually expanding the receptive field and accumulating contextual information in traditional convolutional neural networks are solved, and the hierarchical representation of road features and the modeling of contextual relationships from local to global are realized.

[0047] (2) The asymmetric upsampling layer reduces the influence of complex background in the convolution area without changing the number of parameters. The one-dimensional convolution in the horizontal, vertical, positive diagonal, and negative diagonal directions adapts to the characteristics of slender roads, small proportions, and large spans.

[0048] (3) By adding edge constraint branches, the edge features contained in the image itself are fully exploited. The dual-branch road extraction framework is used with a joint loss function to achieve dual supervision of semantics and edges and extraction of fine-grained road features, thereby improving road edge details and connectivity. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] The specific effects of the present invention will be further described below in conjunction with the accompanying drawings and embodiments, in which:

[0050] Figure 1 It is a flowchart of the Transformer double-branch road extraction method based on edge constraints and feature adaptation in a specific implementation manner of the present invention;

[0051] Figure 2 A model diagram of a Transformer dual-branch road extraction framework based on edge constraints and feature adaptation in a specific embodiment of the present invention;

[0052] Figure 3 It is a structural diagram of the Transformer module in a specific implementation manner of the present invention;

[0053] Figure 4 It is a structural diagram of an asymmetric up-sampling module in a specific implementation manner of the present invention;

[0054] Figure 5 This is a comparison result diagram of road extraction on the Deepglobe road dataset in a specific implementation manner of the present invention;

[0055] Figure 6It is a structural diagram of a Transformer dual-branch road extraction device based on edge constraints and feature adaptation in a specific implementation manner of the present invention. DETAILED DESCRIPTION

[0056] In order to have a clearer understanding of the technical features, purposes and effects of the present invention, specific embodiments of the present invention are now described in detail with reference to the accompanying drawings.

[0057] refer to Figure 1 , this embodiment discloses a Transformer double-branch road extraction method based on edge constraint and feature adaptation, and the specific operation steps are as follows:

[0058] S1, perform data enhancement processing on the input training data set to obtain an enhanced training data set;

[0059] Step S1 is specifically as follows:

[0060] Input high-resolution remote sensing image dataset, this paper uses the Deepglobe road dataset for analysis and discussion. The Deepglobe road dataset is pixel-level annotated data from three countries: Thailand, India, and Indonesia. The ground resolution of each image is 50cm / pixel, and the pixel resolution is 1024×1024. The original 6226 training images are divided into: 4976 for training and 1250 for testing. In order to expand the training set, each picture is cropped to 512×512 size. Finally, the new DeepGlobe road dataset has 18784 training images and 6210 test images;

[0061] The data enhancement operations specifically include: cropping, horizontal flipping, vertical flipping, diagonal flipping, horizontal or vertical movement, scaling, and color jittering.

[0062] S2. Build a two-branch road extraction model and perform initialization and hyperparameter setting to obtain an initialized two-branch road extraction model;

[0063] In step S2, the initialization and hyperparameter settings are as follows:

[0064] The parameters of the tiny version of Swin Transformer (SwinT) pre-trained on the ImageNet dataset are used to initialize the road feature extraction model, aiming to accelerate the convergence speed of gradient descent and effectively improve the performance of the road feature extraction model;

[0065] Adam is used as the optimizer, the batch size is 8, the road surface branch uses the binary cross entropy (BCE) and Dice coefficient loss function, and the road edge branch uses the binary cross entropy (BCE) loss; the initial learning rate is set to 2e-3, and it is reduced 4 times by 5 times each time. The pre-set epoch size is 300, and the training is stopped early when the model loss no longer decreases continuously and the accuracy does not improve within 6 rounds.

[0066] refer to Figure 2 , Figure 2 A model diagram of a Transformer dual-branch road extraction framework based on edge constraints and feature adaptation in a specific embodiment of the present invention;

[0067] S3, taking the enhanced training data set as an input image, inputting it into the initialized dual-division road extraction model, downsampling the image of the enhanced training data set four times through the Transformer encoder, and using the cross-window self-attention mechanism to model and obtain a feature map containing local information and global information;

[0068] Step S3 specifically includes:

[0069] S31, the enhanced training set images are divided into non-overlapping blocks of 4×4 size, and the feature map dimensions are flattened using the feature map linear normalization layer to obtain The feature map of size, where H, W and C represent the length, width and number of channels of the feature map respectively;

[0070] S32, downsample the feature map four times, each downsampling is composed of 2, 2, 6, and 2 identical Transformer modules connected in series. Between each downsampling, the length and width of the feature map are halved through the block reorganization layer, and the number of channels is doubled to realize the multi-scale hierarchical representation of the Transformer encoder features. The sizes of the feature maps obtained by the four downsamplings are as well as That is, a feature map containing local information and global information is obtained.

[0071] refer to Figure 3 In the above step S32, each Transformer module includes: a feature map linear normalization layer, a multi-head self-attention module, a residual connection, and a nonlinear 2-layer multilayer perceptron with a GELU function;

[0072] Two Transformer modules are grouped together. The multi-head self-attention module of the first Transformer module calculates the relationship between each image block and other image blocks based on a normal window (i.e., a non-overlapping window). The calculation formula is:

[0073]

[0074]

[0075] Among them, z l-1 and are the input and output of the multi-head self-attention module based on normal window in the l-1th and lth Transformer modules, respectively. W-MSA is the multi-head self-attention module based on normal window. LN is the feature map linear normalization layer (LayerNorm). MLP is the multi-layer perceptron. l is the output of the MLP layer of the lth Transformer module;

[0076] After the normal window self-attention calculation, the multi-head self-attention module in the second Transformer module captures wider spatial details of objects at different scales of the image based on sliding dislocated windows. The calculation formula is:

[0077]

[0078]

[0079] Among them, z l and are the input and output of the multi-head self-attention module based on sliding offset window in the lth and l+1th Transformer modules, respectively. SW-MSA is the multi-head self-attention module based on sliding offset window. LN is the feature map linear normalization layer. MLP is the multi-layer perceptron. l+1 is the output of the MLP layer of the l+1th Transformer module.

[0080] S4. Input the enhanced images of the training dataset into the hierarchical feature convolution model to obtain road edge labels. The feature map containing local and global information output by the Transformer encoder is restored to its original size through the edge constraint branch to obtain a road edge mask for constraining road surface extraction.

[0081] Step S4 specifically includes:

[0082] S41. The pre-trained hierarchical feature convolution model is used to mine edge information for the enhanced image in S1. The hierarchical feature convolution model is improved on the basis of VGG16. All the fully connected layers of the VGG16 model are removed and a loss function is set at the end of each layer to supervise the acquisition of hierarchical edge features at multiple scales. For the edge judgment probability of a series of pixel points output by the model, a specific loss function loss is assigned to the pixel point pixel (xi ,ω) is defined as:

[0083]

[0084] where x i and i is the value and prediction probability of the i-th pixel, ω is the learning parameter threshold, δ takes values ​​between 0 and 1, and the edge prediction probability of the pixel is divided into three cases for discussion. The calculation formulas for parameters α and β are as follows:

[0085]

[0086]

[0087] N + With N - are the number of edge and non-edge pixels in the image, respectively, and λ is a hyperparameter, so the loss function Loss(ω) of the entire image is recorded as:

[0088]

[0089] Where N is the number of pixels, is the k-th layer feature vector, is the mixed layer feature vector, K is the number of layers, and thus the image edge label is obtained.

[0090] S42, the feature map output by the last layer of the Transformer encoder is subjected to a four-fold bilinear upsampling and a 3×3 convolutional layer, and is channel-superimposed with the feature map output by the second layer of the Transformer encoder;

[0091] S43, the superimposed feature map is subjected to a four-fold bilinear upsampling and a 3×3 convolutional layer, and connected to the output of the last decoder layer of the road surface extraction branch; after two bilinear upsamplings, the edge branch feature map is restored to the original resolution to obtain a road edge mask for constraining road surface extraction.

[0092] S5. Through the decoder with an asymmetric upsampling module in the road surface extraction branch, the high-level semantic features output by each layer of the Transformer encoder are integrated into multi-scale features in a skip-level connection manner, the feature map is restored, and the road surface prediction result is output in combination with the edge branch feature constraints.

[0093] Step S5 specifically includes:

[0094] S51, the feature map is upsampled four times by the decoder to gradually restore the size of the feature map; each time it first passes through a layer of 1×1 convolution and ReLU function and a layer of asymmetric upsampling layer, refer to Figure 4The asymmetric upsampling layer contains one-dimensional convolution kernels in series in four directions: vertical, horizontal, positive diagonal, and negative diagonal. The number of parameters of each direction filter is the same as that of the 3×3 transposed filter, which is one-fourth of the 3×3 transposed filter, so that the computational amount and parameter amount of the decoder are not changed;

[0095] S52, channel superposition of the feature map output by the fourth layer of the decoder and the edge feature map output by the edge constraint branch;

[0096] S53, the superimposed feature map passes through 4×4 convolution and 3×3 convolution with a span of 2, and is activated by the Relu function to restore the feature map to the original image resolution, and finally passes through the Sigmoid function to output the road surface prediction result map.

[0097] S6. Calculate the road surface loss function through the road surface prediction results and the road surface labels in the enhanced training data set, calculate the road edge loss function through the road edge mask and the road edge label, and then calculate the joint loss function to supervise the extraction of the two branch features of the dual-branch road extraction model, train the model feature map through the joint loss function and the back propagation algorithm, and update the parameters in the encoder and decoder;

[0098] The calculation formula of the joint loss function in step S6 is as follows:

[0099] L=L surface +αL edge

[0100] Among them, the road surface loss function L surface is the binary cross entropy, Dice coefficient loss function, road edge loss function L edge is the root mean square loss function, and the hyperparameter α controls the balance between the two branches.

[0101] S7. Repeat steps S3-S6 until a trained road feature extraction model is obtained, and use the trained road feature extraction model to perform road feature extraction and classification on the image to be classified to obtain a road surface classification result of the image to be classified.

[0102] After step S7, the method further includes: analyzing and evaluating the road extraction result. Figure 5 , Figure 5 The classification diagram of different methods on the DeepGlobe dataset is shown, among which, Figure 5 (a) Figure 5 (b) Figure 5 (c) Figure 5 (d) Figure 5(e) Classification diagram of input image, road truth label, U-Net model, D-LinkNet model, and SII-Net model [C.Tao, J.Qi, Y.Li, H.Wang, and H.Li, 'Spatial information inference net:Road extraction usingroad-specific contextual information', ISPRS Journal of Photogrammetry and Remote Sensing, vol.158, pp.155–166, Dec.2019.] on the DeepGlobe dataset, Figure 5 (f) is a classification diagram of a Transformer dual-branch road extraction method based on edge constraints and feature adaptation of the present invention. From the perspective of visualization, the road extraction method proposed by the present invention has fewer misclassifications and omissions, and the connectivity of the roads and the edges are refined and improved. For wide roads in urban areas and winding roads in rural areas, the classification results of this method are more in line with the actual road distribution and have better extraction effects. Table 1 shows the accuracy evaluation results of various classification methods on the DeepGlobe road dataset. Table 2 generally shows that a Transformer dual-branch road extraction method based on edge constraints and feature adaptation of the present invention has the best classification accuracy and effectiveness. Table 2 shows the accuracy evaluation results of different module combinations on the DeepGlobe road dataset. The model skeleton network is divided into SwinT (tiny version of SwinTranformer) and ResNet50. By calculating the accuracy scoring indicators of different module combinations, it can be seen that the Transformer cross-window self-attention mechanism, asymmetric upsampling module and edge constraint branch combination significantly improve the road classification accuracy.

[0103] Table 1 Results of various classification methods on the DeepGlobe road dataset

[0104] Invention Model Settings Road intersection ratio (%) Average intersection ratio (%) F1 score (%) U-Net 55.90 76.81 71.71 D-LinkNet 60.39 79.19 75.31 SII-Net 61.53 80.36 76.28 Method of the present invention 72.63 85.62 84.15

[0105] Table 2 Results of different module combinations on DeepGlobe road dataset

[0106]

[0107] In some embodiments, a Transformer dual-branch road extraction device based on edge constraint and feature adaptation is also provided, referring to Figure 6 , the device includes the following modules:

[0108] Data enhancement module 1, used to perform data enhancement processing on the input training data set to obtain an enhanced training data set;

[0109] The network building and initialization module 2 is used to build a two-branch road extraction model and perform initialization and hyperparameter setting to obtain an initialized two-branch road extraction model;

[0110] Downsampling module 3, used for inputting the enhanced training data set into the initialized dual-division road extraction model, downsampling the image of the enhanced training data set four times through the Transformer encoder, and using the cross-window self-attention mechanism to model and obtain a feature map containing local information and global information;

[0111] The edge constraint module 4 is used to input the image of the enhanced training data set into the hierarchical feature convolution model to obtain the road edge label, restore the size of the feature map containing local information and global information output by the Transformer encoder through the edge constraint branch, and obtain the road edge mask used to constrain the road surface extraction;

[0112] Upsampling module 5 is used to integrate the high-level semantic features output by each layer of the Transformer encoder through a decoder with an asymmetric upsampling module in the road surface extraction branch, restore the feature map, and output the road surface prediction result in combination with the edge branch feature constraints;

[0113] The network training module 6 is used to calculate the road surface loss function through the road surface prediction result and the road surface label in the enhanced training data set, calculate the road edge loss function through the road edge mask and the road edge label, and then calculate the joint loss function, supervise the extraction of the two branch features of the dual-branch road extraction model, train the model feature mapping through the joint loss function and the back propagation algorithm, update the parameters in the encoder and the decoder, repeat the training until the training is completed, and obtain the trained road feature extraction model;

[0114] The road extraction and classification module 7 is used to perform road feature extraction and classification on the image to be classified by using the trained road feature extraction model to obtain the road surface classification result of the image to be classified.

[0115] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0116] The serial numbers of the embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments. In a unit claim that lists several means, several of these means may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order and these words may be interpreted as identifiers.

[0117] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A Transformer dual-branch road extraction method based on edge constraints and feature adaptation, characterized in that: The following steps are involved: S1. Perform data enhancement processing on the input training data set to obtain an enhanced training data set; S2. Build a two-branch road extraction model and perform initialization and hyperparameter setting to obtain an initialized two-branch road extraction model; S3, inputting the enhanced training data set into the initialized dual-division road extraction model, downsampling the image of the enhanced training data set four times through the Transformer encoder, and using the cross-window self-attention mechanism to model and obtain a feature map containing local information and global information; specifically: S31, the enhanced training set images are divided into non-overlapping blocks of 4×4 size, and the feature map dimensions are flattened using the feature map linear normalization layer to obtain The feature map of size, where H, W and C represent the length, width and number of channels of the feature map respectively; S32, downsample the feature map four times, each downsampling is composed of 2, 2, 6, and 2 identical Transformer modules connected in series. Between each downsampling, the length and width of the feature map are halved through the block reorganization layer, and the number of channels is doubled to realize the multi-scale hierarchical representation of the Transformer encoder features. The sizes of the feature maps obtained by the four downsamplings are as well as That is, a feature map containing local information and global information is obtained; In step S32, each Transformer module includes: a feature map linear normalization layer, a multi-head self-attention module, a residual connection, and a nonlinear 2-layer multilayer perceptron with a GELU function; Two Transformer modules form a group. The multi-head self-attention module of the first Transformer module calculates the relationship between each image block and other image blocks based on the normal window. The calculation formula is: Among them, z l-1 and are the input and output of the multi-head self-attention module based on normal window in the l-1th and lth Transformer modules respectively. W-MSA is the multi-head self-attention module based on normal window. LN is the feature map linear normalization layer. MLP is the multi-layer perceptron. l is the output of the MLP layer of the lth Transformer module; After the normal window self-attention calculation, the multi-head self-attention module in the second Transformer module captures wider spatial details of objects at different scales of the image based on sliding dislocated windows. The calculation formula is: Among them, z l and are the input and output of the multi-head self-attention module based on sliding offset window in the lth and l+1th Transformer modules, respectively. SW-MSA is the multi-head self-attention module based on sliding offset window. LN is the feature map linear normalization layer. MLP is the multi-layer perceptron. l+1 is the output of the MLP layer of the l+1th Transformer module; S4, inputting the enhanced image of the training data set into the hierarchical feature convolution model to obtain the road edge label, restoring the size of the feature map containing local information and global information output by the Transformer encoder through the edge constraint branch, and obtaining the road edge mask for constraining the road surface extraction; S5, through the decoder with asymmetric upsampling module of the road surface extraction branch, the high-level semantic features output by each layer of the Transformer encoder are integrated with multi-scale features in a skip connection manner, the feature map is restored, and the road surface prediction result is output in combination with the edge branch feature constraints; S6. Calculate the road surface loss function through the road surface prediction results and the road surface labels in the enhanced training data set, calculate the road edge loss function through the road edge mask and the road edge label, and then calculate the joint loss function to supervise the extraction of the two branch features of the dual-branch road extraction model, train the model feature map through the joint loss function and the back propagation algorithm, and update the parameters in the encoder and decoder; S7. Repeat steps S3-S6 until a trained road feature extraction model is obtained, and use the trained road feature extraction model to perform road feature extraction and classification on the image to be classified to obtain a road surface classification result of the image to be classified.

2. The Transformer dual-branch road extraction method based on edge constraint and feature adaptation according to claim 1 is characterized in that: Step S4 includes: S41, mining edge information of the enhanced training data set image using a pre-trained hierarchical feature convolution model to obtain a road edge label; S42, the feature map output by the last layer of the Transformer encoder is subjected to a four-fold bilinear upsampling and a 3×3 convolutional layer, and is channel-superimposed with the feature map output by the second layer of the Transformer encoder; S43, the superimposed feature map is subjected to a four-fold bilinear upsampling and a 3×3 convolutional layer, and is connected to the output of the last decoder layer of the road surface extraction branch; after two bilinear upsamplings, the edge branch feature map is restored to the original resolution, thereby obtaining a road edge mask for constraining road surface extraction.

3. The Transformer dual-branch road extraction method based on edge constraint and feature adaptation according to claim 1 is characterized in that: Step S5 includes: S51, the feature map is upsampled four times by the decoder to gradually restore the size of the feature map; each time it first passes through a layer of 1×1 convolution and Relu function and a layer of asymmetric upsampling layer, the asymmetric upsampling layer contains a one-dimensional convolution kernel connected in series in four directions: vertical, horizontal, positive diagonal, and negative diagonal. The number of parameters of each direction filter is the same as that of the 3×3 transposed filter, which is one-fourth of the 3×3 transposed filter, so that the calculation amount and parameter amount of the decoder are not changed; S52, channel superposition of the feature map output by the fourth layer of the decoder and the edge feature map output by the edge constraint branch; S53, the superimposed feature map passes through 4×4 convolution and 3×3 convolution with a span of 2, and is activated by the Relu function to restore the feature map to the original image resolution, and finally passes through the Sigmoid function to output the road surface prediction result map.

4. The Transformer dual-branch road extraction method based on edge constraints and feature adaptation according to claim 1 is characterized in that: In step S6, the calculation formula of the joint loss function L is as follows: L=L surface +αL edge Among them, the road surface loss function L surface is the binary cross entropy, Dice coefficient loss function, road edge loss function L edge is the root mean square loss function, and the hyperparameter α controls the balance between the two branches.

5. A Transformer dual-branch road extraction device based on edge constraints and feature adaptation, characterized in that: Includes the following modules: A data enhancement module is used to perform data enhancement processing on the input training data set to obtain an enhanced training data set; The network building and initialization module is used to build a two-branch road extraction model and perform initialization and hyperparameter setting to obtain an initialized two-branch road extraction model; A downsampling module is used to input the enhanced training data set into the initialized dual-division road extraction model, downsample the image of the enhanced training data set four times through the Transformer encoder, and use the cross-window self-attention mechanism to model and obtain a feature map containing local information and global information; specifically, it includes the following steps: The enhanced training set images are divided into non-overlapping blocks of 4×4 size, and the feature map dimensions are flattened using the feature map linear normalization layer to obtain The feature map of size, where H, W and C represent the length, width and number of channels of the feature map respectively; The feature map is downsampled four times. Each downsampling is composed of 2, 2, 6, and 2 identical Transformer modules connected in series. The length and width of the feature map are halved through the block reorganization layer between each downsampling, and the number of channels is doubled to achieve multi-scale hierarchical representation of Transformer encoder features. The sizes of the feature maps obtained by the four downsamplings are as well as That is, a feature map containing local information and global information is obtained; Each Transformer module includes: a feature map linear normalization layer, a multi-head self-attention module, a residual connection, and a 2-layer multilayer perceptron with a nonlinear GELU function; Two Transformer modules form a group. The multi-head self-attention module of the first Transformer module calculates the relationship between each image block and other image blocks based on the normal window. The calculation formula is: Among them, z l-1 and are the input and output of the multi-head self-attention module based on normal window in the l-1th and lth Transformer modules respectively. W-MSA is the multi-head self-attention module based on normal window. LN is the feature map linear normalization layer. MLP is the multi-layer perceptron. l is the output of the MLP layer of the lth Transformer module; After the normal window self-attention calculation, the multi-head self-attention module in the second Transformer module captures wider spatial details of objects at different scales of the image based on sliding dislocated windows. The calculation formula is: Among them, z l and are the input and output of the multi-head self-attention module based on sliding offset window in the lth and l+1th Transformer modules, respectively. SW-MSA is the multi-head self-attention module based on sliding offset window. LN is the feature map linear normalization layer. MLP is the multi-layer perceptron. l+1 is the output of the MLP layer of the l+1th Transformer module; The edge constraint module is used to input the enhanced training dataset image into the hierarchical feature convolution model to obtain the road edge label, and restore the size of the feature map containing local and global information output by the Transformer encoder through the edge constraint branch to obtain the road edge mask used to constrain the road surface extraction; The upsampling module is used to integrate the high-level semantic features output by each layer of the Transformer encoder through a decoder with an asymmetric upsampling module in the road surface extraction branch, restore the feature map, and output the road surface prediction result in combination with the edge branch feature constraints; A network training module is used to calculate a road surface loss function through road surface prediction results and road surface labels in an enhanced training data set, calculate a road edge loss function through road edge masks and road edge labels, and then calculate a joint loss function to supervise the extraction of two branch features of a dual-branch road extraction model, train the model feature map through the joint loss function and a back propagation algorithm, update parameters in the encoder and decoder, repeat the training until the training is completed, and obtain a trained road feature extraction model; The road extraction and classification module is used to extract and classify road features of the image to be classified through the trained road feature extraction model to obtain the road surface classification result of the image to be classified.