A road extraction method based on hybrid attention mechanism and direction prior
By hybridizing the attention mechanism with the directional prior road extraction method, combining sparse and dense attention layers, dynamically extracting local features and performing direction-enhanced fusion, the efficiency and accuracy issues of road extraction in high-resolution remote sensing images are solved, achieving efficient and robust road extraction results.
Patent Information
- Application Number
- CN202411976276.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2044-12-31
AI Technical Summary
Existing road extraction methods find it difficult to achieve high-precision extraction while ensuring computational efficiency in high-resolution remote sensing images. In particular, it is difficult to establish the topological relationship of occluded road sections and capture global and local semantic features in complex scenes.
A road extraction method based on a hybrid attention mechanism and directional prior is adopted. Through the encoder and decoder structure, sparse attention layers and improved dense attention layers are combined to dynamically extract local features. Convolution operations are performed in multiple directions through the direction enhancement fusion module to generate efficient road extraction results.
It significantly improves the accuracy and continuity of road extraction, adapts to the diversity of road shapes in complex scenes, reduces computational complexity, and improves the training efficiency and generalization ability of the model.
Smart Images

Figure CN119810663B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of image processing technology, and in particular relates to a road extraction method based on a hybrid attention mechanism and direction prior. Background Art
[0002] As an important infrastructure, the real-time and accurate updating of road-related information plays a key role in many practical applications, such as urban planning, traffic management, and emergency response. With the rapid development of high-resolution remote sensing technology, the application value of remote sensing images in road extraction has become increasingly prominent. The widespread use of high-resolution remote sensing images, on the one hand, has laid a solid data foundation for the real-time positioning and identification of road targets, but on the other hand, it has also made road extraction face more complex challenges, especially in scenes with diverse morphologies and complex semantics. For example, from rural roads to urban highways, road types show significant differences and are often obscured by vegetation or interference from other targets. What is even more difficult is that existing algorithms find it difficult to achieve high-precision extraction while ensuring computational efficiency.
[0003] Researchers have conducted extensive research to address these issues. Existing road extraction methods can be broadly categorized into three categories: rule-based methods, traditional machine learning methods, and deep learning methods. Rule-based methods primarily rely on image color and texture information, using morphological and texture analysis to detect road edges. These methods are less adaptable to complex scenes, particularly when roads are occluded or blend into the background. Traditional machine learning methods typically employ feature engineering and classifiers for object detection, but these methods rely heavily on handcrafted features and struggle to fully capture both global and local road features. In recent years, deep learning methods have become the mainstream technology for road extraction. Semantic segmentation models based on convolutional neural networks, trained end-to-end, can significantly improve extraction accuracy. However, these methods struggle to establish topological relationships between road segments separated by occlusion when handling complex scenes, facing challenges such as insufficient semantic information. Furthermore, they suffer from high computational costs when processing large amounts of data. Therefore, a road extraction method is needed that effectively captures both global and local semantic features of road objects while improving computational efficiency, ensuring the consistency and accuracy of road extraction results. Summary of the Invention
[0004] The purpose of the present invention is to overcome the defects of the above-mentioned existing technologies and provide a road extraction method based on a hybrid attention mechanism and direction prior, which can effectively capture the global and local semantic features of road targets while improving computational efficiency, and ensure the continuity and accuracy of road extraction results.
[0005] The purpose of the present invention can be achieved by the following technical solutions:
[0006] The present invention provides a road extraction method based on a hybrid attention mechanism and direction prior, comprising the following steps:
[0007] Obtain remote sensing images and input them into a trained road extraction model based on a hybrid attention mechanism and direction prior to obtain road extraction results.
[0008] The road extraction model based on the hybrid attention mechanism and direction prior includes an encoder and a decoder; the encoder includes multiple sequentially connected hybrid attention modules. The remote sensing image is first divided into blocks to generate multiple feature blocks, which are then processed by multiple hybrid attention modules to generate multi-scale feature maps. In each hybrid attention module, the input data first extracts local features through multiple sequentially connected sparse attention layers, and finally captures global semantic associations through an improved dense attention layer. In the improved dense attention layer, the self-attention calculation method is reconstructed into a combination of linear activation function and local convolution.
[0009] The decoder includes a direction-enhanced fusion module and multiple lightweight hybrid attention modules. The direction-enhanced fusion module takes the multi-scale feature map as input, performs convolution operations in multiple directions, obtains corresponding directional information, and fuses all directional information by dynamically adjusting the weights of each directional information to obtain a fused feature map. The fused feature map is further refined by multiple lightweight hybrid attention modules in sequence, and finally generates a pixel-level road extraction result through upsampling. Each lightweight hybrid attention module includes a sparse attention layer and a dense attention layer.
[0010] Furthermore, in the hybrid attention module, the sparse attention layer realizes the dynamic extraction of local features through deformable convolution. The specific expression is as follows:
[0011]
[0012] Among them, y1 is the output of the sparse attention layer, N is the number of sampling points, and w n is the weight of the nth sampling point, x(p0+p n +Δp n ) is the characteristic value of the sampling point position, p0 is the current pixel position, p n represents the nth position in the predefined grid sampling {(-1,-1),(-1,0),...,(0,+1),...,(+1,+1)}, Δp n is the position offset obtained through learning, Δm n It is a dynamically adjusted modulus used to control the addition value at different sampling points.
[0013] Furthermore, in the hybrid attention module, the specific expression of the improved dense attention layer is as follows:
[0014]
[0015] Among them, FLA-Attention is the output of the improved dense attention layer, Q, K, V represent query, key and value respectively, σ is a nonlinear activation function, Conv represents the depth convolution operation of channel grouping, and ⊙ represents the element-level product operation.
[0016] Furthermore, the nonlinear activation function σ adopts ReLU 3 .
[0017] Furthermore, in the directional enhancement fusion module, the specific expressions for performing convolution operations and fusion in multiple directions are as follows:
[0018]
[0019] Among them, y2 is the fusion direction information, N d is the number of directions, N d0 is the number of sampling points in each direction, w i,j represents the convolution weight of the jth sampling point in direction i, p0 is the current pixel position, x(p0+Δp i,j ) is the characteristic value of the offset sampling point predefined based on the direction, Δp i,j Indicates the relative position offset of the j-th sampling point in direction i, b i is the bias in direction i.
[0020] Furthermore, the relative position offset Δp of the j-th sampling point in direction i is ij The specific expression is as follows:
[0021]
[0022] Where r is the distance between the sampling points, δ is the expansion coefficient, and θ i is the angle of direction i, θ i Uniformly distributed in [0,2π).
[0023] Furthermore, in the lightweight hybrid attention module, the channel u of the input feature map c Make the following adjustments:
[0024]
[0025] s c =σ(w2ξ(w1z c ))
[0026] in, is the adjusted channel, σ is the activation function, w1 and w2 are two one-dimensional fully connected layers, used for dimensionality reduction and dimensionality increase respectively, z c is u after global average pooling c , ξ is a nonlinear activation operation.
[0027] Furthermore, u c Perform global average pooling to obtain z c The specific expression is as follows:
[0028]
[0029] Among them, H and W are u c The height and width of the
[0030] Furthermore, the road extraction model based on the hybrid attention mechanism and direction prior adopts a cross entropy loss function and an AdamW optimizer during training.
[0031] Furthermore, the road extraction model based on the hybrid attention mechanism and direction prior introduces a staged learning rate decay strategy and a data enhancement method during the training process.
[0032] Compared with the prior art, the present invention has the following beneficial effects:
[0033] 1. The present invention proposes a road extraction method based on a hybrid attention mechanism and directional prior, designs a road extraction model based on the hybrid attention mechanism and directional prior, and obtains road extraction results based on remote sensing images; the model includes an encoder and a decoder, wherein the encoder includes multiple sequentially connected hybrid attention modules, and the remote sensing image is first divided into blocks to generate multiple feature blocks, and then processed by multiple hybrid attention modules to generate a multi-scale feature map. In each hybrid attention module, the input data first extracts local features through multiple sequentially connected sparse attention layers, and finally captures global semantic associations through an improved dense attention layer. The hybrid attention module can realize full-image scale aggregation of pixel associations, providing more comprehensive support for feature modeling. Specifically, the sparse attention layer can dynamically adjust the sampling position and capture local features with elastic adaptability, thereby adapting to the diversity of road forms in complex scenes. In the improved dense attention layer, the calculation method of self-attention is reconstructed into a combination of linear activation function and local convolution, which can reduce computational complexity and enhance the efficiency of feature expression while maintaining global modeling capabilities;
[0034] The decoder includes a direction-enhanced fusion module and multiple lightweight hybrid attention modules. In high-resolution remote sensing imagery, roads exhibit linear connections and significant directionality. The direction-enhanced fusion module takes a multi-scale feature map as input and performs convolution operations in multiple directions to obtain the corresponding directional information. By dynamically adjusting the weights of each directional information, all directional information is fused to obtain a fused feature map, which can significantly improve the model's ability to model road morphology information. The fused feature map is further refined by multiple lightweight hybrid attention modules in turn, and finally upsampling is used to generate pixel-level road extraction results. The above method significantly improves the efficiency and accuracy of the model while maintaining high-resolution input, providing an efficient and robust solution to the problem of road extraction in complex remote sensing imagery.
[0035] 2. In the present invention, the road extraction model based on the hybrid attention mechanism and direction prior adopts the cross-entropy loss function and AdamW optimizer during the training process, and introduces a staged learning rate decay strategy and data enhancement method, which effectively improves the training efficiency and generalization ability of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 Schematic diagram of the road extraction model based on hybrid attention mechanism and direction prior;
[0037] Figure 2 Comparison diagram of the effective receptive field (ERF) of different backbone networks (untrained state) at each stage,
[0038] Among them, (2a), (2b), and (2c) respectively show the effective receptive fields of the three stages of InternImage using sparse attention, (2d), (2e), and (2f) respectively show the effective receptive fields of the three stages of Swin Transformer using window-based dense attention, and (2g), (2h), and (2i) respectively show the effective receptive fields of the three stages using HDRoad (i.e., the method proposed in this embodiment);
[0039] Figure 3 This is a schematic diagram of the sampling position of the first quadrant of the direction-enhanced convolution.
[0040] Where δ is the expansion coefficient, Δp represents the relative position offset, θ is the angle of the direction, (3a) corresponds to δ = 1, (3b) corresponds to δ = 2;
[0041] Figure 4 Comparison of the results of each model on the DeepGlobe dataset.
[0042] Among them, the rows from top to bottom are: rural areas, densely populated urban areas and urban-rural fringe areas; the columns are: (4a) is the input image (test set), (4b) is the true value label, (4c) is D-LinkNet, (4d) is U-Net, (4e) is DeepLabv3+, (4f) is Swin-T (combined with Upernet), (4g) is InternImage-T (combined with Upernet), (4h) is HDRoad-Mobile (a lightweight version of this method), and (4i) is HDRoad-Standard (a standard version of this method).
[0043] Figure 5 is the structural diagram of the encoder,
[0044] Among them, Image represents image, Patch Partition represents image partitioning, Patch Merging represents image block merging, Hybrid Attention Block represents hybrid attention module, Sparse Attention represents sparse attention, Dense Attention represents dense attention, Patched Map represents block map, Grouping represents grouping, Deformable Convolution represents deformable convolution, Channel Mixing represents channel mixing, LayerNormalization (LN) represents layer normalization, Multi-head represents multi-head mechanism, Focused Linear Attention represents focused linear attention, Q represents query (Query), K represents key (Key), and V represents value (Value). DETAILED DESCRIPTION
[0045] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0046] Example:
[0047] This embodiment provides a road extraction method based on a hybrid attention mechanism and direction prior, combining the encoder-decoder structure and morphological features to design a Figure 1The road extraction model (HDRoad) based on hybrid attention mechanism and direction prior is shown. In the encoder, the input image is segmented into blocks (Patch Partition) and then sent to multiple hybrid attention modules in sequence for multi-scale feature extraction. The hybrid attention module combines sparse and dense attention mechanisms to capture global semantic information while retaining detailed features, and efficiently extract multi-scale semantic information. Subsequently, the decoder restores the multi-scale feature map output by the encoder. During the decoding process, the morphological prior of the road is embedded through the direction-enhanced convolution operation, which can effectively improve the accuracy and continuity of feature restoration; in addition, the multi-scale features are fused layer by layer to ensure semantic expression and spatial consistency, and finally generate pixel-level road prediction results. The specific description of the model is as follows:
[0048] I. Encoder
[0049] In this embodiment, the encoder comprises three sequentially connected hybrid attention modules, forming three feature extraction stages, each responsible for extracting features at different resolutions. The first stage initially extracts local features from the image and generates a low-resolution feature map; the second stage refines features at a medium resolution, taking into account both global and local information; and the third stage captures detailed features of road morphology at a high resolution. The output features of each stage are fused at multiple scales through downsampling.
[0050] The formula of the hybrid attention module is as follows:
[0051] F out =DenseAttention(SparseAttention(F in ))
[0052] Among them, F in and F out Represent the input and output feature maps of the hybrid attention module, respectively.
[0053] like Figure 5 As shown in the figure, the hybrid attention module consists of multiple sequentially connected sparse attention layers and an improved dense attention layer. It is the core module of the encoder. Targeting the characteristics of high-resolution remote sensing imagery, it improves semantic feature extraction while significantly reducing computational complexity. The sparse attention layer dynamically extracts relatively localized features from the feature map, while the improved dense attention layer aggregates these local features, expanding their relevance across the entire image. Ultimately, it generates multi-scale feature maps at high resolution, providing rich feature information for the decoder.
[0054] (1) Sparse Attention Layer
[0055] The sparse attention layer uses deformable convolution (DCNv3) to dynamically extract local features. The expression is as follows:
[0056]
[0057] Among them, y1 is the output of the sparse attention layer, N is the number of sampling points, and w n is the weight of the nth sampling point, x(p0+p n +Δp n ) is the characteristic value of the sampling point position, p0 is the current pixel position, p n represents the nth position in the predefined grid sampling {(-1,-1),(-1,0),...,(0,+1),...,(+1,+1)}, Δm n is the dynamically adjusted modulus used to control the addition value at different sampling points, Δp n is the position offset learned by the existing DCNv3 method, through Δp n The sparse attention layer can dynamically adjust the sampling position, capturing local features with elastic adaptability, thereby adapting to the diversity of road morphology in complex scenes. Specifically, the position offset of DCNv3 is learned by applying an additional convolutional layer to the input feature map. The number of output channels of this convolutional layer is 2N (N is the number of sampling points), representing the offset of each sampling point in the x and y directions.
[0058] (2) Improved Dense Attention Layer
[0059] The dense attention layer models global semantic associations through an efficient linearized self-attention mechanism, avoiding the problem in traditional Transformers where computational complexity grows with the square of the input resolution. The specific formula is as follows:
[0060]
[0061] To improve efficiency, this embodiment uses a combination of linear activation function and local convolution to reconstruct self-attention:
[0062]
[0063] Among them, FLA-Attention is the output of the improved dense attention layer, Q, K, V represent query, key and value respectively, σ is a nonlinear activation function, and ReLU is used in this embodiment. 3 , Conv represents the depth convolution operation of channel grouping. In this embodiment, the convolution kernel size is 5, and ⊙ represents the element-level product operation.
[0064] The above reconstruction significantly reduces the computational cost of dense attention, and the computational complexity is reduced from O(n 2 ) is reduced to O(n), and the efficiency of feature expression is enhanced while maintaining global modeling capabilities. It supports processing high-resolution image input on a single GPU and is suitable for remote sensing road extraction tasks in complex scenarios.
[0065] like Figure 2 As shown in the figure, when the activated pixel is located at the central intersection of the input image, (2a), (2b), and (2c) respectively show the effective receptive fields of the three stages of InternImage using sparse attention, (2d), (2e), and (2f) respectively show the effective receptive fields of the three stages of Swin Transformer using window-based dense attention, and (2g), (2h), and (2i) respectively show the effective receptive fields of the three stages of HDRoad. Compared with methods that only use sparse attention (such as InternImage) or window-based dense attention methods (such as Swin Transformer), the hybrid attention module proposed in this embodiment combines the advantages of sparse attention and dense attention, realizes full-image-scale aggregation of pixel associations in a single stage, and provides more comprehensive support for feature modeling.
[0066] II. Decoder
[0067] The decoder combines the directional prior of road morphology and achieves accurate restoration and refinement of road features through a lightweight structure.
[0068] (1) Directional Augmented Fusion Module (DAFM)
[0069] In high-resolution remote sensing imagery, roads exhibit linear connections and significant directionality. To effectively capture this characteristic, this embodiment designs a directional enhancement fusion module that performs convolution operations in specific directions to extract the corresponding directional information. It then fuses all directional information by dynamically adjusting the weights of each directional information to produce a fused feature map.
[0070] The specific calculation formula for directional information fusion is as follows:
[0071]
[0072] Among them, y2 is the fusion direction information, N d is the number of directions. In this embodiment, it is set to 16 directions. N d0 is the number of sampling points in each direction, w i,j represents the convolution weight of the jth sampling point in direction i, p0 is the current pixel position, x(p0+Δpi,j ) is the characteristic value of the offset sampling point predefined based on the direction, Δp i,j Indicates the relative position offset of the j-th sampling point in direction i, b i is the bias in direction i.
[0073] The relative position offset Δp of the jth sampling point in direction i i,j The specific expression is as follows:
[0074]
[0075] Among them, r is the distance of the sampling point, θ i is the angle of direction i, θ i Uniformly distributed in [0,2π), δ is the expansion coefficient. The sampling position of the first quadrant of the directional enhanced convolution is as follows Figure 3 As shown, (3a) corresponds to the expansion coefficient δ=1, and (3b) corresponds to the expansion coefficient δ=2.
[0076] The obtained fusion feature map is:
[0077]
[0078] Among them, N f Indicates the number of feature maps, F i is the feature map output by the i-th layer, and DA-Conv represents the directional information fusion operation. Through layer-by-layer fusion, the directional enhancement fusion module can ensure the spatial and semantic consistency of the high-resolution feature map.
[0079] (2) Lightweight Hybrid Attention Module
[0080] After completing feature fusion, this embodiment uses multiple lightweight hybrid attention modules to further process the features, and finally generates pixel-level segmentation results through upsampling and 1x1 convolution.
[0081] Each lightweight hybrid attention module consists of a sparse attention layer and an improved dense attention layer. The specific formula is the same as that in the hybrid attention module, but the FNN layer in the sparse attention layer and the improved dense attention layer is transformed into a lighter Squeeze-and-Excitation (SE) module. The FFN layer is placed at the end of each attention layer to perform information fusion operations on the number of channels, that is, the third dimension in addition to x and y. The above replacement operation can reduce the amount of computation. c Represents a channel in the feature map, whose size is H×W, and u c Perform global average pooling (GAP) to obtain z c , the expression is as follows:
[0082]
[0083] According to the above results, the channel u of the input feature map c Make the following adjustments:
[0084]
[0085] s c =σ(w2ξ(w1z c ))
[0086] in, is the adjusted channel, σ is the activation function, w1 and w2 are two one-dimensional fully connected layers, used for dimensionality reduction and dimensionality increase respectively, z c is u after global average pooling c ξ is a nonlinear activation operation. Adjust u by global average pooling c , reducing the full connection in three dimensions of FFN to the full connection in one dimension, further reducing the computational complexity.
[0087] In this embodiment, the road extraction model based on the hybrid attention mechanism and direction prior adopts the cross-entropy loss function and AdamW optimizer during the training process, and introduces a staged learning rate decay strategy and data enhancement method, which can further improve the training efficiency and generalization ability of the model.
[0088] While maintaining high-resolution input, this method significantly improves the model's efficiency and accuracy. Compared with existing methods, it offers significant advantages in extraction accuracy, model efficiency, and adaptability to complex scenarios, providing an efficient and robust solution for road extraction in complex remote sensing imagery. To validate the effectiveness of this method, this example conducted experiments on the publicly available DeepGlobe dataset and compared it with several mainstream algorithms. The DeepGlobe dataset is a commonly used public dataset in the remote sensing field, containing high-resolution remote sensing imagery from a variety of scenarios and widely used for tasks such as road extraction, building detection, and land cover classification. The data subset for the road extraction task includes 6,226 images with a resolution of 1024×1024 and a pixel resolution of 0.5 meters per pixel. These images cover urban-rural fringe areas, rural areas, and densely populated urban areas, with complex and diverse scenes and significant background interference. The dataset includes pixel-level labels for roads, providing the training, validation, and test sets required for standard segmentation tasks.
[0089] The HDRoad model proposed in this embodiment includes two versions: HDRoad-Standard and HDRoad-Mobile. Among them, HDRoad-Standard is the standard version, which adopts a complete hybrid attention module and a direction enhancement fusion module, focusing on optimizing the global modeling and local restoration capabilities of road features, and achieving industry-leading level in segmentation accuracy. HDRoad-Mobile is a lightweight version, which has carried out module optimization and parameter compression for resource-constrained scenarios, while maintaining high segmentation performance while significantly reducing model complexity and computational overhead. The number of parameters of HDRoad-Mobile is only 17.24M, and the number of floating-point operations (FLOPs) is 119G. Compared with the 59.6M parameters and 391G FLOPs of HDRoad-Standard, it is more efficient and suitable for embedded devices or real-time application needs.
[0090] The experiment was conducted on a single NVIDIA RTX 3090 GPU and implemented using the PyTorch framework. During training, the cross entropy loss function was combined with a directional prior regularization term to optimize the model. The AdamW optimizer was used, and the initial learning rate was set to 10. -4 , and a cosine annealing learning rate scheduling strategy was used to improve training stability. To enhance the model's generalization capabilities, data augmentation operations such as random rotation, flipping, and brightness adjustment were performed on the images during training. Furthermore, to comprehensively evaluate the algorithm's performance, the experiment used Intersection over Union (IoU), Precision, Recall, and F1 score as evaluation metrics, and compared this method with mainstream algorithms (including U-Net, DeepLabV3+, Swin transformer, and InternImage).
[0091] (1) Qualitative analysis
[0092] On the DeepGlobe dataset, the segmentation performance of this method in various complex scenarios is significantly better than that of existing mainstream algorithms. Figure 4 The segmentation results of different methods are shown in four typical scenarios, including rural areas, densely populated urban areas, and urban-rural fringe areas. Figure 4In the figure, the rows are: rural areas, densely populated urban areas, and urban-rural fringe areas; the columns are: (4a) input image (test set), (4b) true value label, (4c) D-LinkNet, (4d) U-Net, (4e) DeepLabv3+, (4f) Swin-T (combined with Upernet), (4g) InternImage-T (combined with Upernet), (4h) HDRoad-Mobile (a lightweight version of our method), (4i) HDRoad-Standard (a standard version of our method). From the results, we can see that our method has significant advantages in the following aspects:
[0093] ① Extracting slender roads: In rural areas, roads are often narrow and irregular in shape, with sections obscured by vegetation, shadows, or buildings. Traditional algorithms (such as U-Net and DeepLabV3+) often exhibit road fragmentation or blurred boundaries in these scenarios. This method, using a Directional Enhanced Convolutional Module (DA-Conv), captures the directional characteristics of roads, effectively maintaining the continuity and integrity of slender roads even when their midsections are obscured.
[0094] ② Complex Background Suppression: In densely populated urban areas, false roads are easily detected due to interference from buildings, parking lots, and other linear objects. Mainstream algorithms often introduce significant noise into the segmentation results in these scenarios. This method utilizes a hybrid attention mechanism to effectively focus on road area features while simultaneously suppressing background interference, significantly reducing the generation of false roads.
[0095] Adaptability to Urban-Rural Fringe Areas: Urban-rural fringe areas have complex road morphologies, encompassing both unstructured rural roads and standardized urban roads. Traditional algorithms often struggle to adapt to diverse road morphologies in these scenarios. This method, through a multi-stage feature fusion module, achieves a balance between global and local feature extraction, resulting in greater adaptability to diverse road morphologies.
[0096] (2) Quantitative analysis
[0097] As shown in Table 1, both versions of HDRoad significantly outperform existing mainstream methods on the DeepGlobe dataset. HDRoad-Standard performs particularly well in core evaluation metrics such as Intersection over Union (IoU) and F1 score. Its IoU reaches 75.06%, a 3.58% improvement over the existing best model, InternImage, and 4.23% and 4.32% improvements over DeepLabv3+ and Swin, respectively. It also achieves approximately a 9% improvement over U-Net and D-LinkNet. HDRoad-Standard also achieves an F1 score of 85.67%, demonstrating exceptional performance in both road object recognition accuracy and completeness.
[0098] As a lightweight version, HDRoad-Mobile achieves an IoU of 72.23%, surpassing the more computationally complex InternImage and Swin models, despite significantly reducing the number of model parameters to 17.24M and FLOPs to just 119G. Furthermore, its F1 score reaches 84.01%, only 1.66 percentage points lower than HDRoad-Standard, demonstrating its advantage in maintaining lightweightness without sacrificing segmentation performance.
[0099] Table 1 Quantitative analysis results of each model on the DeepGlobe dataset
[0100]
[0101] In summary, this embodiment proposes a road extraction method based on a hybrid attention mechanism and directional priors. Based on an encoder-decoder architecture, a road extraction model, HDRoad, is constructed. A hybrid attention module and a directional enhancement fusion module are designed to achieve efficient and accurate road segmentation in complex scenes. The hybrid attention module effectively extracts global and local features by combining sparse and dense attention. The directional enhancement fusion module embeds morphological priors for roads, significantly improving the continuity and integrity of segmentation results. Experiments on the DeepGlobe dataset demonstrate that both versions of the HDRoad model outperform existing mainstream methods. HDRoad-Standard achieves leading segmentation accuracy with an Intersection over Union (IoU) of 75.06% and an F1 score of 85.67%. HDRoad-Mobile, a lightweight version, achieves an IoU of 72.23% and an F1 score of 84.01% while maintaining a low parameter count and computational complexity, demonstrating the advantages of a lightweight design.
[0102] If the above method is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program code.
[0103] The above description of the embodiments is intended to facilitate understanding and use of the invention by those skilled in the art. It will be apparent that those skilled in the art can readily make various modifications to these embodiments and apply the general principles described herein to other embodiments without requiring inventive effort. Therefore, the present invention is not limited to the above-described embodiments. Improvements and modifications made by those skilled in the art based on the disclosure of the present invention, without departing from the scope of the present invention, should be within the scope of protection of the present invention.
Claims
1. A road extraction method based on a hybrid attention mechanism and direction prior, characterized in that: The following steps are involved: Obtain remote sensing images and input them into a trained road extraction model based on a hybrid attention mechanism and direction prior to obtain road extraction results. The road extraction model based on the hybrid attention mechanism and direction prior includes an encoder and a decoder; the encoder includes multiple sequentially connected hybrid attention modules. The remote sensing image is first divided into blocks to generate multiple feature blocks, which are then processed by multiple hybrid attention modules to generate multi-scale feature maps. In each hybrid attention module, the input data first extracts local features through multiple sequentially connected sparse attention layers, and finally captures global semantic associations through an improved dense attention layer. In the improved dense attention layer, the self-attention calculation method is reconstructed into a combination of linear activation function and local convolution. The decoder includes a direction enhancement fusion module and multiple lightweight hybrid attention modules. The direction enhancement fusion module takes the multi-scale feature map as input, performs convolution operations in multiple directions to obtain corresponding direction information, and fuses all direction information by dynamically adjusting the weight of each direction information to obtain a fused feature map. The fused feature map is further refined by multiple lightweight hybrid attention modules in sequence, and finally a pixel-level road extraction result is generated by upsampling. Each lightweight hybrid attention module includes a sparse attention layer and a dense attention layer.
2. The road extraction method based on hybrid attention mechanism and direction prior according to claim 1 is characterized in that: In the hybrid attention module, the sparse attention layer realizes dynamic extraction of local features through deformable convolution. The specific expression is as follows: Among them, y1 is the output of the sparse attention layer, N is the number of sampling points, and w n is the weight of the nth sampling point, x(p0+p n +Δp n ) is the characteristic value of the sampling point position, p0 is the current pixel position, p n represents the nth position in the predefined grid sampling {(-1,-1),(-1,0),...,(0,+1),...,(+1,+1)}, Δp n is the position offset obtained through learning, Δm n It is a dynamically adjusted modulus used to control the addition value at different sampling points.
3. The road extraction method based on hybrid attention mechanism and direction prior according to claim 1 is characterized in that: In the hybrid attention module, the specific expression of the improved dense attention layer is as follows: Among them, FLA-Attention is the output of the improved dense attention layer, Q, K, V represent query, key and value respectively, σ is a nonlinear activation function, Conv represents the depth convolution operation of channel grouping, and ⊙ represents the element-level product operation.
4. The road extraction method based on hybrid attention mechanism and direction prior according to claim 3 is characterized in that: The nonlinear activation function σ adopts ReLU 3 .
5. The road extraction method based on hybrid attention mechanism and direction prior according to claim 1 is characterized in that: In the directional enhancement fusion module, the specific expressions for performing convolution operations and fusion in multiple directions are as follows: Among them, y2 is the fusion direction information, N d is the number of directions, N d0 is the number of sampling points in each direction, w i,j represents the convolution weight of the jth sampling point in direction i, p0 is the current pixel position, x(p0+Δp i,j ) is the characteristic value of the offset sampling point predefined based on the direction, Δp i,j Indicates the relative position offset of the j-th sampling point in direction i, b i is the bias in direction i.
6. The road extraction method based on hybrid attention mechanism and direction prior according to claim 5 is characterized in that: The relative position offset Δp of the jth sampling point in direction i i,j The specific expression is as follows: Where r is the distance between the sampling points, δ is the expansion coefficient, and θ i is the angle of direction i, θ i Uniformly distributed in [0,2π).
7. The road extraction method based on hybrid attention mechanism and direction prior according to claim 1 is characterized in that: In the lightweight hybrid attention module, the channel u of the input feature map c Make the following adjustments: s c =σ(w2ξ(w1z c )) in, is the adjusted channel, σ is the activation function, w1 and w2 are two one-dimensional fully connected layers, used for dimensionality reduction and dimensionality increase respectively, z c is u after global average pooling c , ξ is a nonlinear activation operation.
8. The road extraction method based on hybrid attention mechanism and direction prior according to claim 7 is characterized in that: will u c Perform global average pooling to obtain z c The specific expression is as follows: Among them, H and W are u c The height and width of the 9. The road extraction method based on hybrid attention mechanism and direction prior according to claim 1, characterized in that: The road extraction model based on the hybrid attention mechanism and direction prior adopts the cross entropy loss function and AdamW optimizer during training.
10. The road extraction method based on hybrid attention mechanism and direction prior according to claim 1, characterized in that: The road extraction model based on the hybrid attention mechanism and direction prior introduces a staged learning rate decay strategy and a data enhancement method during the training process.