High-resolution ship detection method based on cross-attention and dynamic sampling
By employing cross-attention and dynamic sampling methods, high-resolution feature maps are reconstructed and directional contextual dependencies are modeled, which solves the problems of missed and duplicate detections of ships in high-resolution remote sensing images, thereby improving detection accuracy and the detection rate of small ships.
Patent Information
- Application Number
- CN202511987657.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-26
- Publication Date
- 2026-03-20
- Estimated Expiration
- 2045-12-26
AI Technical Summary
Existing ship detection algorithms struggle to explicitly capture slender geometric priors in high-resolution remote sensing images, leading to missed or duplicate detections. Furthermore, small ships are easily obscured by clutter, making it difficult to distinguish gradient noise from low-quality candidate boxes, which affects detection accuracy.
A high-resolution ship detection method based on cross-attention and dynamic sampling is adopted. The high-resolution feature map is reconstructed by the dynamic sampling operator to enhance the ship feature map. The cross-channel attention module is combined to model the directional context dependency, and the WIoU loss function is designed to suppress noise gradients and improve detection accuracy.
It significantly improves the accuracy of ship detection, especially the detection rate and positioning accuracy of small ships, solves the problems of missed detection and duplicate detection in traditional methods, and enhances the model's ability to detect complex scenes.
Smart Images

Figure CN121392262B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of ship detection, and particularly relates to a high-resolution ship detection method based on cross-attention and dynamic sampling. BACKGROUND
[0002] With the rapid deployment of remote sensing satellites, sub-meter optical images can be acquired daily, providing a data basis for large-scale and near-real-time ship monitoring. However, manual interpretation is inefficient and costly, and there is an urgent need for high-precision automated interpretation algorithms. In recent years, with the resurgence of deep learning, ship detection has made significant progress. Most of the latest ship detection algorithms adapt general detectors to the characteristics of remote sensing images. For example, some people have proposed MSSD-Net, which embeds FC-FPN based on learnable coefficients to enhance multi-scale fusion, and performs well in detecting ships arranged densely near the port. Some people have proposed CHPDet, which is an anchor-free center head detector that can regress a rotating box with a bow stern distinction, and has set new records on FGSD2021, HRSC2016 and UCAS-AOD. Some people have proposed CTF-Net, which combines convolution and Transformer through parallel fusion to balance global and local features for higher precision and recall. Some people combine dual-channel CNN with controllable false alarm classifier (DCCNN-FACC) to suppress sea clutter and enhance the recognition ability of low-altitude optical ship targets. Some people have proposed a rotating YOLO model (RYM) that combines RD-head, attention mechanism and BiFPN for detecting tilted ships. It achieves 96.7% average accuracy and 45.6 FPS processing speed in marine video, realizing high-precision real-time ship imaging positioning. These efforts continue to push the boundaries of ship detection accuracy in complex marine scenarios. Although the above progress is impressive, existing ship detectors still have three fixed limitations when facing high-resolution remote sensing port scenes. First, since existing backbone networks usually use square convolution kernels, their receptive fields are expanded equally in the horizontal and vertical directions, making it difficult to explicitly capture the elongated geometric prior. Therefore, the bow and stern edges of the ship are fused with the straight-shaped wharf contour in the feature space, leading to missed detection or repeated detection. Second, mainstream single-stage frameworks rely on bilinear / near neighbor upsampling to restore high-resolution feature maps. These fixed interpolation methods smooth edge details, so small ships with a width of only 5-15 pixels are easily submerged in the surrounding clutter. Third, the widely used IoU or GIoU loss function treats each anchor equally. Low-quality candidate boxes thus produce noisy gradients that dominate in training, hindering the model's ability to further distinguish difficult cases, ultimately limiting the improvement of detection accuracy.
[0003] The fidelity of feature extraction is closely related to the final detection accuracy. The mainstream backbone network relies on square convolution kernels, whose isotropic receptive field performs well in capturing local texture statistics, but lacks inductive bias for elongated structures. When facing ships with an aspect ratio usually exceeding 10:1, these convolution kernels cannot obtain the context clues in the front-back direction, so the elongated geometric information is gradually diluted in the encoder, ultimately leading to missed detection. Equally important, the discrimination ability of the decoder depends on the quality of its upsampling. Fixed bilinear or nearest-neighbor interpolation treats every pixel equally when upsampling the feature map, so the already weak edge response is further smoothed, and 5-15-pixel-wide ships gradually "disappear" during the expansion process. Therefore, the existing state-of-the-art detectors can accurately locate large offshore ships, but once the outline of the near-shore ship is diluted, they will continue to miss detection. Compared with traditional methods, the above detection algorithms have made significant progress, but there are still deficiencies in ship target detection under high-resolution satellite perspective. SUMMARY
[0004] Therefore, it is necessary to provide a high-resolution ship detection method based on cross-attention and dynamic sampling, which can improve the detection accuracy of ships.
[0005] A high-resolution ship detection method based on cross-attention and dynamic sampling, the method comprising:
[0006] Obtaining a high-resolution synthetic aperture radar ship image, inputting the high-resolution synthetic aperture radar ship image into a YOLOv11n backbone network, and outputting a multi-scale initial feature map through a hierarchical feature extraction operation of the backbone network;
[0007] Inputting the multi-scale initial feature map into an enhanced neck module, the enhanced neck module comprising a dynamic sampling operator and a cross-channel attention module, first performing adaptive upsampling processing on the multi-scale initial feature map through the dynamic sampling operator to reconstruct a high-resolution feature map, and then inputting the reconstructed high-resolution feature map into the cross-channel attention module integrated at the output end of the corresponding prediction layer;
[0008] Modeling the horizontal and vertical context-dependent relationship of the input high-resolution feature map using the cross-channel attention module to generate spatial perception weights, highlighting the ship structure features aligned with the direction mode in the SAR image through the spatial perception weights, and suppressing the background interference features, and outputting an enhanced ship feature map;
[0009] Inputting the enhanced ship feature map into a detection head, performing end-to-end training on the detection head using a pre-set standard detection loss, performing ship class recognition and bounding box positioning on the enhanced ship feature map through the trained detection head, and outputting a ship detection result.
[0010] The high-resolution ship detection method based on cross attention and dynamic sampling has the cross channel attention module integrated in the prediction layer. By specially modeling the context dependence relationship in the horizontal and vertical directions, spatial perception weights are generated, which can accurately highlight the ship structure features aligned with the direction mode of the SAR image, effectively distinguish the bow and stern edges of the ship from the straight contours of the wharf, and avoid missed detection or repeated detection caused by feature fusion, thereby enhancing the recognition of ship shape features from the source. Secondly, to solve the problem of blurred small target edge details and easy to be submerged by clutter caused by fixed upsampling method, the enhanced neck module uses a dynamic sampling operator to replace the traditional interpolation method. By adaptively upsampling the high-resolution feature map, it can specifically retain the edge details of small ships with a width of only 5-15 pixels, avoid their disappearance in the feature amplification process, and significantly improve the detection rate of small ships near the shore. Finally, the Wiou loss function is designed to punish the quality variance of low-quality samples, adaptively suppress the noise gradient generated by low-quality candidate boxes, solve the problem of insufficient difficult example discrimination ability in training, and make the model focus more on feature learning of high-quality samples in the end-to-end training process, further improve the accuracy of ship class recognition and bounding box positioning, and finally achieve significant improvement in detection accuracy. BRIEF DESCRIPTION OF DRAWINGS
[0011] Figure 1 FIG. 1 is a flowchart of a high-resolution ship detection method based on cross attention and dynamic sampling in one embodiment;
[0012] Figure 2 FIG. 3 is a schematic diagram of the overall detection framework in one embodiment;
[0013] Figure 3 FIG. 5 is a schematic diagram of the dynamic sampling module (DSM) framework in one embodiment;
[0014] Figure 4 FIG. 7 is a schematic diagram of the cross channel attention module (CCAM) framework in another embodiment;
[0015] Figure 5 FIG. 9 is a schematic diagram of the Wiou loss calculation in one embodiment. DETAILED DESCRIPTION
[0016] In order to make the purpose, technical scheme and advantages of the present application clearer, the following will further describe the present application in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0017] In one embodiment, as shown in FIG. 1, the high-resolution ship detection method based on cross attention and dynamic sampling includes the following steps: Figure 1 and Figure 2As shown, a high-resolution ship detection method based on cross-attention and dynamic sampling is provided, comprising the following steps:
[0018] In step 102, a high-resolution synthetic aperture radar ship image is obtained, and the high-resolution synthetic aperture radar ship image is input to a YOLOv11n backbone network. Through hierarchical feature extraction operation of the backbone network, a multi-scale initial feature map is output.
[0019] In view of the significant scale difference of ships in SAR images (from small ships with a width of 5-15 pixels to large offshore ships), the multi-stage down-sampling and feature aggregation of the backbone network output an initial feature map suitable for different scale targets. These multi-scale feature maps can respectively match the identification requirements of small, medium and large ships in subsequent detection, and provide targeted input for adaptive up-sampling of the dynamic sampling module and feature enhancement of the cross-channel attention module, avoiding feature loss or redundancy caused by scale mismatch. The YOLOv11n backbone network has efficient feature extraction capability, which can maximize the preservation of the difference information of ships and background in the original SAR image while realizing hierarchical and multi-scale feature output, and reduce distortion in the feature transmission process. The initial feature map output contains key clues of ship structure and also retains basic features of background clutter, providing reliable raw data support for the subsequent enhanced neck module to highlight ship features and suppress background interference, ensuring that the subsequent optimization module can act on core features accurately and avoid affecting the detection effect due to insufficient basic feature quality.
[0020] In step 104, the multi-scale initial feature map is input to the enhanced neck module, which includes a dynamic sampling operator and a cross-channel attention module. First, the dynamic sampling operator is used to perform adaptive up-sampling processing on the multi-scale initial feature map to reconstruct a high-resolution feature map, and then the reconstructed high-resolution feature map is input to the cross-channel attention module integrated at the output end of the corresponding prediction layer.
[0021] To solve the challenges of scale variation and boundary ambiguity in synthetic aperture radar (SAR) ship detection, especially for small ships or distant ships, a dynamic sampling module (DSM) is introduced, which is a lightweight but effective up-sampling operator to replace the traditional interpolation or transpose convolution layer in the detection head. Unlike fixed grid up-sampling methods, DSM predicts content-aware sampling offsets in a data-driven manner to adaptively refine feature positions during resolution recovery. The overall architecture of DSM is as follows: Figure 3As shown, the input feature map is first projected through two parallel linear layers to generate the original offset field and the dynamic range modulation field. The original offset is then scaled using the activated range map, followed by pixel shuffling to produce a high-resolution spatial offset, resulting in a refined offset. This offset is added to a regular normalized sampling grid, and the resulting sampled coordinates are used for differentiable grid sampling operations to reconstruct the upsampled feature map.
[0022] Specifically, given a low-resolution input feature map, the DSM first generates a learnable offset field through a 1×1 linear projection. These offsets are combined with an initialized regular sampling grid and modulated, upon activation, through a learnable range map to limit the deformation amplitude. The resulting coordinates guide bilinear sampling from the input features, enabling accurate and context-sensitive high-resolution representation reconstruction. By introducing dynamic spatial awareness into the upsampling process, the DSM significantly enhances the model's ability to recover fine-grained structural details of ships while maintaining robustness to speckle noise and diverse scales. Given an input feature map... With an upsampling scaling factor s, the DSM generates a high-resolution output through the following four steps. .
[0023] First, two lightweight linear projections are applied to generate the original offset field and the dynamic range modulation field, as shown in Equations (1) and (2):
[0024] (1)
[0025] (2)
[0026] Where g is the number of channel groups (default g=2).
[0027] Secondly, the original offset is adaptively scaled using the activated range map and modulated by a fixed scaling factor to obtain a refined low-resolution offset field, as shown in Equation (3):
[0028] (3)
[0029] Third, the refined offset field The pixels are shuffled and rearranged into a high-resolution spatial offset map, as shown in formula (4):
[0030] (4)
[0031] Currently, a standard regular sampling grid is being constructed. All coordinates are normalized to the range [ 1,1]. The final sample set is obtained by adding elements one by one, as shown in formula (5):
[0032] (5)
[0033] Fourth, the output feature map is reconstructed by using the sampling set for differentiable bilinear interpolation, as shown in equation (6):
[0034] (6)
[0035] This design ensures that sampling is learned in a compact low-resolution space and efficiently expands to full resolution, achieving accurate alignment of fine-grained ship boundaries. The dynamic range mechanism further stabilizes the training process by limiting the amplitude of spatial adaptation, significantly improving the robustness and accuracy of ship detection in SAR images.
[0036] The dynamic sampling module of this step serves as a parameter-free dynamic upsampling operator, replacing traditional bilinear / nearest neighbor fixed interpolation methods. By learning content-aware sampling offsets, it adaptively reconstructs high-resolution feature maps. Its beneficial effects mainly lie in solving the problem of edge pixel feature confusion in small target upsampling process: by dynamically generating spatially varying interpolation weights, it reshapes the edge gradient, effectively preserving the fine-grained edge details of small ships with a width of only 5-15 pixels, and avoiding the situation where small targets are overwhelmed by surrounding sea clutter during feature map enlargement. At the same time, this module limits the deformation amplitude through dynamic range modulation, enhancing the robustness to speckle noise and scale changes, significantly improving the detection rate and positioning accuracy of small ships near the shore, and making up for the defects of traditional upsampling methods that are not sensitive to small targets.
[0037] Step 106, using the cross-channel attention module to model the horizontal and vertical contextual dependencies of the input high-resolution feature map, generating spatially aware weights, highlighting the ship structure features aligned with the direction patterns in the SAR image, while suppressing background interference features, and outputting enhanced ship feature maps.
[0038] To capture directional context and enhance the representation of ship structures in SAR images, a cross-channel attention module (CCAM) is proposed. As shown in Figure 4 The input features are processed through two parallel branches. The horizontal branch uses 1D convolution to capture row-wise contextual dependencies after width-wise pooling, while the vertical branch models column-wise contextual cues through height-wise pooling and 1D convolution. Their outputs are fused through element-wise multiplication to generate a cross-shaped attention map, which is then applied to enhance features sensitive to ships through residual attention fusion. Conv_1, Conv_2, and Conv_3 modules are 1x1 convolution layers, and it is worth noting that Conv_1 is shared.
[0039] CCAM consists of two consecutive stages: channel dimension reduction and cross-direction attention modeling. For horizontal attention, a channel dimension reduction operation is first applied to compress the feature map into a low-dimensional space, followed by adaptive pooling along the height direction to extract row features. These features are then processed through a series of 1D convolutions to model the global dependency within each row, capturing the horizontal contextual information. Similarly, for vertical attention, adaptive pooling is applied along the width direction to extract column features, which are also processed through 1D convolutions to highlight the vertical patterns. To refine the extracted features and suppress background noise, an outer product operation is applied between the horizontally processed features and the vertically processed features. This operation generates a cross-shaped attention map, emphasizing the intersection of important horizontal and vertical structures, effectively highlighting the potential ship regions while filtering out irrelevant background clutter. Specifically, the cross-shaped attention map is computed through element-wise multiplication of the horizontal and vertical attention maps, followed by a sigmoid activation function to normalize the weights between 0 and 1. By combining the horizontal and vertical attention mechanisms, CCAM is able to effectively capture the directional context around the ship, enhancing the network's ability to focus on relevant features, thereby improving detection accuracy. Given an input feature map extracted from the backbone network
[0040] First, to reduce computational overhead while preserving essential information, the input features are compressed along the channel dimension through point-wise convolution, as defined in equation (7):
[0041] (7)
[0042] where is the compression ratio .
[0043] Second, the contextual dependency in both horizontal and vertical directions is modeled in parallel. For the horizontal branch, adaptive average pooling is applied along the width direction to aggregate column statistics, as shown in equation (8):
[0044] (8)
[0045] The pooled features are then squeezed and processed through two consecutive 1D convolutions to capture the inter-row relationships, resulting in a horizontal attention vector, as shown in equation (9):
[0046] (9)
[0047] This vector is broadcasted along the width axis to form .
[0048] Similarly, for the vertical branch, adaptive pooling is performed along the height direction, as shown in equation (10):
[0049] (10)
[0050] After squeezing, the features are refined by 1D convolution, resulting in a vertical attention vector, as shown in equation (11):
[0051] (11)
[0052] Then, it is expanded along the height axis to obtain .
[0053] Third, the final cross-attention map is generated by element-wise multiplication of and , followed by sigmoid normalization, as shown in equation (12):
[0054] (12)
[0055] where denotes the Hadamard product, is the sigmoid function.
[0056] Finally, the enhanced feature representation is obtained by residual attention fusion, as shown in equation (13):
[0057] (13)
[0058] This design enables CCAM to efficiently capture cross-shaped contextual cues—emphasizing areas where strong horizontal and vertical structures intersect (e.g., ship hulls in SAR images)—while maintaining low computational cost due to decomposition into 1D operations. The resulting attention map enhances the distinguishability of ship features and suppresses sea clutter interference.
[0059] Overall, the cross-channel attention module designed in this step significantly enhances the model's feature expression ability for the slender ship structure by aggregating the feature stripes in the horizontal and vertical directions through two orthogonal 1-D convolutions without increasing excessive computational cost. The core advantage lies in breaking the limitations of the isotropic receptive field of traditional square convolution kernels, enabling explicit modeling of the contextual dependency of the ship's slender geometry, generating spatial perception weights, accurately highlighting the ship structure features aligned with the direction pattern of the SAR image, while effectively suppressing background interference such as the straight contours of the wharf. This design solves the problem of missed detection and repeated detection caused by the fusion of ship bow and stern edges with wharf features in traditional methods, especially for slender ships with an aspect ratio exceeding 10:1, achieving accurate capture and strengthening of shape features, and significantly improving the distinguishability of ship features in complex port scenarios.
[0060] In step 108, the enhanced ship feature map is input into the detection head, and the detection head is trained end-to-end using a pre-set standard detection loss. The ship class recognition and bounding box positioning are performed on the enhanced ship feature map through the trained detection head, and the ship detection result is output.
[0061] In the ship SAR data set, small size and blurred appearance often lead to inaccurate bounding box annotation, and traditional regression loss is not sensitive to these poorly positioned small targets. This may hinder the convergence of the model and lead to suboptimal feature learning. Based on its dynamic non-monotonic edge regression focusing mechanism, as shown in FIG. 1, a WIoU loss is designed. Figure 5
[0062] The calculation formula of WIoU is as follows (formula (14)):
[0063] (14)
[0064] By reasonably designing the gradient gain distribution, WIoU ensures that the gradient gain r presents a non-monotonic change. Wherein, α and δ are hyperparameters, specifically, the gradient gain is dynamically allocated according to the anomaly factor of the anchor box, and the calculation formula is as follows (formula (15)):
[0065] (15)
[0066] Wherein, β represents the anomaly factor, is the sliding average value of the momentum-based IoU loss in the last training iteration, and is the current predicted IoU loss.
[0067] The penalty term is defined as follows (formula (16)):
[0068] (16)
[0069] in, As a penalty, it is used to increase the loss of normal quality anchor frames, while As a base IoU loss, it reduces the penalty for high-quality anchor boxes and enhances sensitivity to center distance when the predicted and ground truth boxes highly overlap. Additionally, the asterisk... This means that the denominator does not participate in backpropagation, effectively preventing the network from generating large and unstable gradients that are difficult to converge during training. and Let represent the width and height of the smallest bounding rectangle formed by the ground truth bounding box and the predicted bounding box, respectively. and These are the width and height of the actual bounding box, respectively. and These are the width and height of the predicted bounding box, respectively. Among the evaluated regression losses, WIoU achieved the highest detection accuracy, despite a slight increase in the number of parameters and computational cost (GFLOPs).
[0070] This loss calculation method focuses more on samples of average quality and solves the bounding box regression (BBR) balance problem between high-quality and low-quality anchor boxes, significantly improving the model's ability to accurately locate challenging ship targets in SAR images. Secondly, the WIoU loss function, based on a three-dimensional weighting of IoU, centrality, and area ratio, achieves adaptive suppression of gradients for low-quality anchor boxes. Unlike traditional IoU / GIoU losses that treat all anchor points equally, its dynamic non-monotonic edge regression focusing mechanism allows gradient gain to be dynamically distributed according to anchor box quality, penalizing the quality variance of low-quality samples while preventing high-quality anchor boxes from being over-constrained. This feature solves the problem of noisy gradients generated by low-quality candidate boxes dominating training, improving the model's ability to distinguish difficult examples, especially suitable for scenarios where some ship bounding box annotations are inaccurate and small target localization is ambiguous in high-resolution SAR images. Simultaneously, its sensitivity to center distance enhances the accuracy of bounding box regression, further improving the accuracy of ship localization and breaking the detection accuracy ceiling imposed by traditional loss functions.
[0071] The high-resolution ship detection method based on cross attention and dynamic sampling has the following advantages. Firstly, the cross-attention channel module is integrated in the prediction layer. By modeling the context dependence relationship in the horizontal and vertical directions, spatial perception weights are generated, which can accurately highlight the ship structure features aligned with the direction mode of the SAR image, effectively distinguish the bow and stern edges of the ship from the straight contours of the wharf, and avoid missed detection or repeated detection caused by feature fusion, thereby enhancing the recognition of ship shape features from the source. Secondly, to address the pain point of blurred edge details of small targets caused by fixed upsampling methods and easy to be submerged by clutter, the enhanced neck module uses a dynamic sampling operator instead of the traditional interpolation method. By adaptively upsampling the high-resolution feature map, it can specifically retain the edge details of small ships with a width of only 5-15 pixels, avoid their disappearance during feature enlargement, and significantly improve the detection rate of small ships near the shore. Finally, the Wiou loss function is designed to punish the quality variance of low-quality samples, adaptively suppress the noise gradient generated by low-quality candidate boxes, solve the problem of insufficient difficult example discrimination during training, and make the model focus more on feature learning of high-quality samples during end-to-end training, further improve the accuracy of ship class recognition and bounding box positioning, and finally achieve significant improvement in detection accuracy.
[0072] In one embodiment, the multi-scale initial feature map is adaptively upsampled by a dynamic sampling operator, including:
[0073] The input feature map is subjected to a linear projection operation to generate an original offset field and a dynamic range modulation field. The generation process of the original offset field is
[0074] ;
[0075] Wherein, represents the original offset field, represents the first linear projection operation, represents the feature map input into the dynamic sampling operator, represents the number of channel groups, represents the upsampling ratio, represents the height of the input feature map, represents the width of the input feature map.
[0076] The generation process of the dynamic range modulation field is:
[0077] ;
[0078] Wherein, represents the dynamic range modulation field, represents the second linear projection operation.
[0079] In one of the embodiments, after the original offset field and the dynamic range modulation field are generated by linear projection, the original offset field is adaptively scaled to obtain a refined low-resolution offset field as follows:
[0080] ;
[0081] wherein, denotes the refined low-resolution offset field, denotes a sigmoid activation function, denotes a Hadamard product, and 0.5 denotes a fixed scaling factor, denotes the original offset field.
[0082] In one of the embodiments, a pixel shuffling operation is performed on the refined low-resolution offset field to obtain a high-resolution spatial offset map, and the pixel shuffling operation satisfies the following formula:
[0083] ;
[0084] wherein, denotes the refined low-resolution offset field, denotes the pixel shuffling operation, denotes the height of the up-sampled feature map, denotes the width of the up-sampled feature map.
[0085] In one of the embodiments, a standard regular sampling grid is constructed, and the high-resolution spatial offset map is added to the regular sampling grid element by element to obtain a final sampling set;
[0086] Based on the final sampling set, a differentiable bilinear interpolation operation is performed on the feature map of the input dynamic sampling operator to reconstruct a high-resolution feature map as follows:
[0087] ;
[0088] wherein, denotes the reconstructed high-resolution feature map, denotes the differentiable bilinear interpolation operation, denotes the feature map of the input dynamic sampling operator, denotes the dynamic range modulation field.
[0089] In one of the embodiments, a pre-set standard detection loss is
[0090] ;
[0091] ;
[0092] ;
[0093] where, denotes the gradient gain, a and d are hyperparameters, and b denotes the anomaly factor, is the sliding average of the momentum-based IoU loss in the last training iteration, is a penalty term, is the base IoU loss.
[0094] In one of the embodiments, when the cross-channel attention module processes the high-resolution feature map, the cross-channel attention module first performs a channel dimension reduction operation on the input high-resolution feature map, and the channel dimension reduction operation is:
[0095] ;
[0096] where, denotes the feature map after channel dimension reduction, denotes a 1x1 convolution operation, denotes the high-resolution feature map input to the cross-channel attention module, denotes the number of channels after dimension reduction, denotes the height of the input feature map, denotes the width of the input feature map.
[0097] In one of the embodiments, after the channel dimension reduction, the context-dependent relationship in the horizontal direction and the vertical direction is modeled respectively. When modeling the context-dependent relationship in the horizontal direction, an adaptive average pooling operation is first performed along the width direction, and the adaptive average pooling operation is:
[0098] ;
[0099] where, denotes the feature map after horizontal direction pooling, denotes the adaptive average pooling operation in the horizontal direction;
[0100] The horizontally pooled feature map is then squeezed and 1D convolution processed to obtain a horizontal attention vector, and the horizontal attention vector is:
[0101] ;
[0102] where, denotes the horizontal attention vector, denotes the 1D convolution operation in the horizontal direction, denotes the 1D convolution operation of the output layer, denotes the squeezing operation;
[0103] The horizontal attention vector is broadcasted along the width axis to obtain a horizontal attention feature map, and the horizontal attention feature map satisfies .
[0104] In one of the embodiments, the process of context-dependent relationship modeling in the vertical direction includes:
[0105] First, the adaptive average pooling operation is performed along the height direction, and the adaptive average pooling operation is:
[0106] ;
[0107] wherein, represents the feature map after vertical direction pooling, represents the vertical direction adaptive average pooling operation;
[0108] Then, the squeezed and 1D convolution processing is performed on the feature map after vertical direction pooling, to obtain the vertical attention vector, and the vertical attention vector is:
[0109] ;
[0110] wherein, represents the vertical attention vector, represents the 1D convolution operation in the vertical direction, represents the 1D convolution operation of the output layer;
[0111] The vertical attention vector is broadcasted along the height axis to obtain the vertical attention feature map, and the vertical attention feature map satisfies .
[0112] In one of the embodiments, the horizontal attention feature map and the vertical attention feature map are subjected to element-wise multiplication operation, and are normalized by the sigmoid activation function to generate the cross-attention map, and the cross-attention map is:
[0113] ;
[0114] wherein, represents the cross-attention map; then, the cross-attention map is subjected to residual attention fusion with the high-resolution feature map input into the cross-channel attention module, to obtain the enhanced ship feature map, and the residual attention fusion process is:
[0115] ;
[0116] wherein, represents the enhanced ship feature map.
[0117] It should be understood that, although Figure 1The steps in the flowcharts of the above embodiments are displayed in sequence according to the arrows, but the steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, the execution of the steps is not strictly limited in sequence, and the steps can be executed in other sequences. Moreover, Figure 1 At least a part of the steps in the flowcharts of the above embodiments can include a plurality of sub-steps or a plurality of stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of the sub-steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least a part of other steps or sub-steps or stages of other steps.
[0118] The technical features of the above embodiments can be combined in any manner. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described, but it should be understood that any combination of the technical features is within the scope of the present disclosure as long as there is no contradiction.
[0119] The above embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it should not be understood as a limitation on the scope of the present application. It should be noted that, for those skilled in the art, several modifications and improvements can be made without departing from the concept of the present application, and these are within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A high-resolution ship detection method based on cross-attention and dynamic sampling, characterized in that, The method includes: A high-resolution synthetic aperture radar (SAR) image of a ship is acquired, and the image is input into the YOLOv11n backbone network. Through the hierarchical feature extraction operation of the backbone network, a multi-scale initial feature map is output. The multi-scale initial feature map is input to the enhanced neck module, which includes a dynamic sampling operator and a cross-channel attention module. First, the multi-scale initial feature map is adaptively upsampled by the dynamic sampling operator to reconstruct a high-resolution feature map. Then, the reconstructed high-resolution feature map is input to the cross-channel attention module integrated at the output end of the corresponding prediction layer. The cross-channel attention module is used to model the horizontal and vertical context dependencies of the input high-resolution feature map, generate spatially aware weights, highlight ship structure features that are aligned with the orientation patterns in the SAR image, and suppress background interference features to output an enhanced ship feature map. The enhanced ship feature map is input into the detection head, and the detection head is trained end-to-end using a pre-set standard detection loss. The trained detection head is then used to identify the ship category and locate the bounding box of the enhanced ship feature map, and the ship detection result is output. Adaptive upsampling of multi-scale initial feature maps is performed using dynamic sampling operators, including: A linear projection operation is performed on the input feature map to generate an original offset field and a dynamic range modulation field. The generation process of the original offset field is as follows: in, Represents the original offset field. This indicates the first linear projection operation. The feature map represents the input dynamic sampling operator. Indicates the number of channel groups. Indicates the upsampling ratio. Indicates the height of the input feature map. Indicates the width of the input feature map; The generation process of the dynamic range modulation field is as follows: in, Indicates the dynamic range modulation field. This indicates the second linear projection operation.
2. The method according to claim 1, characterized in that, After generating the original offset field and dynamic range modulation field through linear projection, the original offset field is adaptively scaled to obtain a refined low-resolution offset field: in, This represents a refined low-resolution offset field. This represents the sigmoid activation function. This represents the Hadamard product, and 0.5 represents a fixed scaling factor. This represents the original offset field.
3. The method according to claim 1, characterized in that, A pixel shuffling operation is performed on the refined low-resolution offset field to obtain a high-resolution spatial offset map. The pixel shuffling operation satisfies the following formula: in, This represents a refined low-resolution offset field. This indicates a pixel shuffle operation. This indicates the height of the feature map after upsampling. This indicates the width of the feature map after upsampling.
4. The method according to claim 3, characterized in that, The method further includes: A standard regular sampling grid is constructed, and the high-resolution spatial offset map is added element-wise to the regular sampling grid to obtain the final sampling set; Based on the final sample set, a differentiable bilinear interpolation operation is performed on the feature map of the input dynamic sampling operator to reconstruct a high-resolution feature map: in, This represents the reconstructed high-resolution feature map. This represents a differentiable bilinear interpolation operation. The feature map represents the input dynamic sampling operator. This indicates a dynamic range modulation field.
5. The method according to claim 1, characterized in that, The pre-set standard detection loss is: in, This represents the gradient gain, where α and δ are hyperparameters, and β represents the anomaly factor. It is the moving average of the momentum-based IoU loss over the most recent training iterations. As a penalty item, Based on IoU loss.
6. The method according to claim 1, characterized in that, When processing high-resolution feature maps, the cross-channel attention module first performs channel dimensionality reduction on the input high-resolution feature maps. The channel dimensionality reduction operation is as follows: in, This represents the feature map after dimensionality reduction of the channel. This represents a 1×1 convolution operation. This represents a high-resolution feature map of the input cross-channel attention module. This represents the number of channels after dimensionality reduction. Indicates the height of the input feature map. This indicates the width of the input feature map.
7. The method according to claim 6, characterized in that, The method further includes: After channel dimensionality reduction, context dependencies in the horizontal and vertical directions are modeled for the reduced feature maps. For horizontal context dependency modeling, an adaptive average pooling operation is first performed along the width direction. The adaptive average pooling operation is as follows: in, This represents the feature map after horizontal pooling. This indicates an adaptive average pooling operation in the horizontal direction; The feature map after horizontal pooling is then compressed and subjected to 1D convolution to obtain the horizontal attention vector, which is: in, Represents the horizontal attention vector. This represents a 1D convolution operation in the horizontal direction. This represents a 1D convolution operation in the output layer. Indicates a squeezing operation; The horizontal attention vector is broadcast along the width axis to obtain a horizontal attention feature map, which satisfies... .
8. The method according to claim 7, characterized in that, The process of modeling context dependencies in the vertical direction includes: First, perform an adaptive average pooling operation along the height direction. The adaptive average pooling operation is as follows: in, This represents the feature map after vertical pooling. This indicates an adaptive average pooling operation in the vertical direction; The feature map after vertical pooling is then compressed and subjected to 1D convolution to obtain the vertical attention vector, which is: in, Represents the vertical attention vector. This represents a 1D convolution operation in the vertical direction. This represents a 1D convolution operation in the output layer; The vertical attention vector is broadcast along the height axis to obtain a vertical attention feature map, which satisfies... .
9. The method according to claim 8, characterized in that, The method further includes: The horizontal and vertical attention feature maps are multiplied element-wise and then normalized using the sigmoid activation function to generate a cross-shaped attention map. The cross-shaped attention map is as follows: in, The cross-shaped attention map is represented; then, the cross-shaped attention map is fused with the high-resolution feature map of the input cross-shaped channel attention module using residual attention to obtain the enhanced ship feature map. The residual attention fusion process is as follows: in, This represents the enhanced ship feature map.
Citation Information
Patent Citations
Infrared target detection method based on dynamic upsampling and multi-dimensional attention mechanism
CN118447233A
Night plant image processing method, device and equipment
CN118918478A