A SAR image ship target detection method based on a Transformer

By employing a local sparse information aggregation Transformer and an edge guidance module in SAR image detection, the problem of blurred ship target outlines was solved, and high-precision detection of small-scale ship targets was achieved.

CN115565066BActive Publication Date: 2026-01-02BEIJING INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211173313.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-26
Publication Date
2026-01-02
Estimated Expiration
2042-09-26

AI Technical Summary

Technical Problem

Existing SAR image ship detection methods suffer from blurred ship target outlines and reduced detection accuracy in the context of coastlines, islands, and ocean waves, especially for small-scale ship targets.

Method used

We employ a local sparse information aggregation Transformer based on the Swin Transformer architecture as the backbone network, combined with a deformable attention mechanism and an edge guidance module. We fuse information about small ships through a sparse attention mechanism and use a feature pyramid network for feature fusion and edge enhancement to improve detection accuracy.

Benefits of technology

It effectively improves the detection accuracy of small-scale SAR ship targets, can better distinguish ship targets from the background, and improves detection efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115565066B_ABST
    Figure CN115565066B_ABST
Patent Text Reader

Abstract

The application discloses a SAR image ship target detection method based on a Transformer, aiming at small-scale SAR ship targets, taking the Transformer as a backbone network, fusing effective ship information through a deformable attention mechanism, and improving detection precision. Firstly, patch division is performed on the input original image. The image after patch division is input into a four-stage feature extraction backbone network composed of the Transformer to obtain four features of different scales from shallow to deep. The four features of different scales are input into a feature pyramid network for feature fusion to obtain five fusion features of different scales from shallow to deep. According to the ship position label of the original image, a coarse extraction edge image of the target is extracted. The shallowest layer fusion feature and the coarse extraction edge image are input into an edge-guided shape enhancement module to obtain an enhanced shallowest layer fusion feature. The enhanced shallowest layer fusion feature and the other four scale fusion features are input into an anchor-free target detection head to obtain a target detection result.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of target detection, and particularly relates to a SAR image ship target detection method based on a Transformer. BACKGROUND

[0002] Synthetic Aperture Radar (SAR) is an active remote sensing system operating at microwave frequencies. SAR sensors operating on aircraft or satellites can image and monitor the ground or sea surface. Compared with optical sensors, the main advantage of SAR sensors is that they can work all day and all weather, and the transmitted signals have strong penetration ability, which can penetrate clouds and fog.

[0003] With the wide application of SAR sensors, the automatic detection technology for targets in SAR images has become an important research. The existing SAR image target detection methods can be divided into traditional methods and deep learning methods. The traditional SAR target detection methods mainly include methods based on contrast information, geometric and texture features, and statistical analysis. Benefiting from the development of deep learning and GPU computing power, deep convolutional neural networks (CNN) have made great breakthroughs in target detection. At present, the target detection technology based on convolutional neural networks has become the mainstream direction in the field of target detection. The algorithm mainly includes two categories. The first category is the two-stage target detection algorithm represented by Faster R-CNN, which generates candidate regions on the bounding box containing the target and then detects the target. The detection accuracy is high but the efficiency is low. The second category is the single-stage target detection algorithm, mainly represented by SSD (Single Shot MultiBox Detector, SSD) and YOLO (You Only Look Once, YOLO) series. This kind of algorithm does not generate candidate regions, but directly detects the target through regression, which has high detection efficiency but lower accuracy than the first category method. As a new neural network structure, Transformer provides a new way of thinking for visual tasks. Initially, Transformer was used in the field of natural language processing (NLP). It uses an encoder-decoder and self-attention mechanism non-recurrent network structure to achieve the best performance in machine translation. The successful application of Transformer in the field of NLP has led scholars to discuss and try its application in the field of computer vision. Some backbone networks using Transformer instead of convolution, such as ViT and Swin Transformer, have been proven to have better performance than CNN, because the global interaction mechanism of Transformer can quickly expand the effective receptive field of features.

[0004] However, there are two problems in using the Transformer as the backbone network in SAR ship detection. One is that the background of the SAR ship image at sea is very simple, so the global relationship modeling mechanism in the Transformer will associate some redundant background information. The other is that the outline between the near-shore SAR ship target and the coast is blurred, and it is difficult to distinguish the near-shore ship target from the background. Therefore, the features extracted by the Transformer need to be reconstructed through more object details to focus on the SAR ship target in a similar background.

[0005] Currently, there is no related technical solution to solve the problem of blurred ship target outline caused by the background of the coast, islands and waves in the SAR image, thereby reducing the detection accuracy, SUMMARY

[0006] Therefore, the present application provides a SAR image ship target detection method based on the Transformer, which can be used for small-scale SAR ship targets, uses a local sparse information aggregation Transformer based on the Swin Transformer architecture as the backbone network, effectively fuses the effective information of small ships through the sparse attention mechanism of deformable attention, and improves the detection accuracy.

[0007] To achieve the above purpose, the technical scheme of the present application includes the following steps:

[0008] Step 1: performing patch division on the input original image to obtain a patch-divided image.

[0009] Step 2: inputting the patch-divided image into a four-stage feature extraction backbone network composed of a local sparse information aggregation Transformer to obtain four different scale features from shallow to deep.

[0010] Step 3: inputting the four different scale features into a feature pyramid network to fuse the features between different scales, and obtaining five fused features of different scales from shallow to deep.

[0011] Step 4: extracting the target edge according to the ship position label of the original image to obtain a rough extracted edge image of the target.

[0012] Step 5: inputting the shallowest fused feature of the five different scale fused features and the rough extracted edge image into an edge-guided shape enhancement module to obtain an enhanced shallowest fused feature.

[0013] Step 6: inputting the enhanced shallowest fused feature and the other four scale fused features into an anchor-free target detection head to obtain a target detection result.

[0014] Further, the patch division on the input original image comprises the following steps: dividing the input image with the size of HxWx3 into 4x4 non-overlapping patches, and the feature dimension of each patch is 4x4x3=48, and the number of patches is H / 4xW / 4.

[0015] Further, the four-stage feature extraction backbone network composed of the local sparse information aggregation Transformer comprises: a basic component structure of a Swin Transformer backbone network structure, which is divided into four stages and is sequentially recorded as stage one, stage two, stage three and stage four, and sequentially outputs four different scale features from shallow to deep.

[0016] The stage one comprises sequentially connected linear embedding modules and double Transformer modules; the linear embedding module is used for dimension transformation on the patch-divided image.

[0017] The stage two comprises sequentially connected patch fusion modules and double Transformer modules.

[0018] The stage three comprises sequentially connected patch fusion modules and three sequentially connected double Transformer modules.

[0019] The stage four comprises sequentially connected patch fusion modules and double Transformer modules.

[0020] The double Transformer module comprises two front and rear Transformer modules, wherein the front Transformer module performs the following steps: calculating the local sparse information aggregation attention map for the input feature of the front Transformer module, performing residual connection on the local sparse information aggregation attention map and the input feature of the front Transformer module, and then performing residual connection on the result and the result after linear transformation and multilayer perception, to obtain the output feature of the local sparse information aggregation Transformer.

[0021] The output feature of the front Transformer module is used as the input feature of the rear Transformer module.

[0022] The post-Transformer module performs the following steps: after sampling transformation is performed on the input features of the post-Transformer module, local sparse information aggregation attention maps are calculated for the sampling-transformed features, the local sparse information aggregation attention maps are connected in residual with the input features of the post-Transformer module, and then the result is connected in residual with the result after linear transformation and multi-layer perception, to obtain the output features of the local sparse information aggregation Transformer.

[0023] The sampling transformation includes: obtaining data-based sampling values from the input features of the post-Transformer module through a convolution layer; and performing bilinear interpolation sampling on the input features of the post-Transformer module by using the data-based sampling values, to obtain the sampling-transformed features.

[0024] Wherein, the local sparse information aggregation attention map is calculated, and the input features of the pre-Transformer module or the sampling-transformed input features of the post-Transformer module are taken as the current input features A; the following steps are adopted:

[0025] S1: performing window division on the current input features A to obtain window-divided feature maps.

[0026] S2: inputting the window-divided feature maps into an offset generation network to obtain an offset matrix required for calculating deformable attention.

[0027] S3: performing linear transformation on the window-divided feature maps to obtain a value matrix required for calculating deformable attention.

[0028] S4: performing linear transformation on the window-divided feature maps to obtain an attention weight matrix required for calculating deformable attention.

[0029] S5: performing bilinear interpolation sampling on the value matrix by using the offset matrix, and performing weighted summation on the sampling result by using the attention weight matrix, and then performing linear transformation to obtain the local sparse information aggregation attention map.

[0030] Further, the local sparse information aggregation attention map is represented as DeformAttn(z q , p q , x):

[0031]

[0032] Wherein, z q and x are two representations of the input features, p q is an arbitrary reference point on the features, Δp mqk is an offset, and A mpkW is the attention weight m W' is the learnable weight m W is the transpose of m M is the number of attention heads, and K is the number of sampling points.

[0033] Further, the patch fusion module includes: taking the values of the same positions in each calculation region of the output features of the dual-Transformer module to splice a new patch and connect to obtain the features after 2 times of downsampling.

[0034] Further, the input of the feature pyramid network is four features C1-C4 of different scales from shallow to deep.

[0035] The feature pyramid network processes the features C1-C4 as follows to obtain five fused features P1-P5 of different scales from shallow to deep: C4 directly obtains P4, P4 is downsampled to obtain P5, P4 is upsampled and fused with C3 to obtain P3, P3 is upsampled and fused with C2 to obtain P2, and P2 is upsampled and fused with C1 to obtain P1.

[0036] Further, the edge-guided shape enhancement module includes:

[0037] The shallowest fused feature output by the Transformer is fused with the coarse extracted edge image, and a sobel edge extraction operator is input to obtain a target edge prediction map.

[0038] The weighted cross-entropy loss between the target edge prediction map and the target edge real map is calculated.

[0039] The shallowest fused feature output by the Transformer is fused with the normalized target edge prediction map, and a convolutional network is input to obtain a target shape prediction map.

[0040] The binary classification loss and the Dice loss between the target shape prediction map and the target binary segmentation real map are calculated, and based on the above losses, the convolutional network parameters are optimized to enhance the features.

[0041] Further, the weighted cross-entropy loss between the target edge prediction map and the target edge real map is represented as Loss ce :

[0042]

[0043] where y i is the edge pixel value of the target edge real map, p i is the probability of the i-th pixel being classified as an edge pixel, and conversely, 1-y i is the background pixel value of the target edge real map, and 1-p iis the probability of the i-th pixel being classified as a background pixel; N c is the number of edge pixels in the target edge ground truth; N is all pixels in the target edge ground truth.

[0044] Further, the binary classification loss and the Dice loss between the target shape prediction map and the target binary segmentation ground truth are represented as:

[0045]

[0046]

[0047] wherein, Loss se is the binary classification loss between the target shape prediction map and the target binary segmentation ground truth; Loss Dice is the Dice loss between the target shape prediction map and the target binary segmentation ground truth; y i is the edge pixel value of the target edge ground truth, p i is the probability of the i-th pixel being classified as an edge pixel, and conversely, 1-y i is the background pixel value of the target edge ground truth, 1-p i is the probability of the i-th pixel being classified as a background pixel; and alpha determines the weight of the two losses.

[0048] Further, the anchor-free target detection head includes the detection head of FCOS, and the results of target detection classification and regression are obtained.

[0049] Beneficial effects:

[0050] 1. The SAR image ship target detection method based on explicit edge guidance local sparse information aggregation Transformer provided by the present application, for small-scale SAR ship targets, proposes a local sparse information aggregation Transformer based on the Swin Transformer architecture as the backbone network, and effectively fuses the effective information of small ships through the sparse attention mechanism of deformable attention.

[0051] 2. The SAR image ship target detection method based on explicit edge guidance local sparse information aggregation Transformer provided by the present application, when the deformable attention mechanism is used instead of the self-attention mechanism, a data-dependent offset generator is combined to obtain more significant small SAR ship target features.

[0052] 3. The SAR image ship target detection method based on explicit edge guidance local sparse information aggregation Transformer provided by the application, an explicit edge guidance shape enhancement module is proposed, which more effectively enhances the SAR ship with fuzzy contours in the features extracted by the Transformer and distinguishes them from the background interference. BRIEF DESCRIPTION OF DRAWINGS

[0053] Figure 1 The feature extraction network structure diagram of the SAR image ship target detection method based on explicit edge guidance local sparse information aggregation Transformer of the first embodiment of the application is shown in the figure.

[0054] Figure 2 The feature extraction network structure diagram of the SAR image ship target detection method based on explicit edge guidance local sparse information aggregation Transformer of the first embodiment of the application is shown in the figure.

[0055] Figure 3 The feature extraction network structure diagram of the SAR image ship target detection method based on explicit edge guidance local sparse information aggregation Transformer of the first embodiment of the application is shown in the figure.

[0056] Figure 4 The feature extraction network structure diagram of the SAR image ship target detection method based on explicit edge guidance local sparse information aggregation Transformer of the first embodiment of the application is shown in the figure.

[0057] Figure 5 The feature extraction network structure diagram of the SAR image ship target detection method based on explicit edge guidance local sparse information aggregation Transformer of the first embodiment of the application is shown in the figure. DETAILED DESCRIPTION

[0058] The application will be described in detail below with reference to the accompanying drawings and embodiments.

[0059] The SAR image ship target detection method based on explicit edge guidance local sparse information aggregation Transformer provided by the application is shown in the figure. Figure 1 First, the 4*4 pixel regions in the input image that do not overlap are divided into a patch, obtaining the patch-divided image, and inputting the image into a four-stage feature extraction backbone network composed of local sparse information aggregation Transformers, obtaining four different scale features from shallow to deep; then, the features are input into a feature pyramid network for feature fusion between different scales, obtaining five different scale features after fusion from shallow to deep; at the same time, according to the ship position label of the original image, a rough extraction edge image of the target is obtained; then, the shallowest layer of features and the rough extraction edge image are input into an edge-guided shape enhancement module to obtain enhanced shallowest layer features; finally, the features are input into an anchor-free target detection head to obtain the target detection result.

[0060] The specific implementation process of the scheme includes the following steps:

[0061] Step 1, the input original image is divided into patches to obtain a patch-divided image.

[0062] The 4x4 non-overlapping pixel regions in the input image are divided into a patch, that is, the input image with a size of HxWx3 is divided into 4x4 non-overlapping patches, and the feature dimension of each patch is 4x4x3=48, the number of patches is H / 4xW / 4, and a patch-divided image is obtained for subsequent structure;

[0063] Step 2: input the patch-divided image into a four-stage feature extraction backbone network composed of local sparse information aggregation Transformers to obtain four different scale features from shallow to deep;

[0064] The improved Swin Transformer feature extraction network is as shown in Figure 2 .

[0065] The basic component structure is based on the backbone network structure of Swin Transformer, which is divided into four stages, and is sequentially recorded as stage one, stage two, stage three and stage four, and sequentially outputs four different scale features from shallow to deep;

[0066] Stage one includes a linear embedding module and a double Transformer module connected in sequence; the linear embedding module is used for dimension transformation of the patch-divided image;

[0067] Stage two includes a patch fusion module and a double Transformer module connected in sequence;

[0068] Stage three includes a patch fusion module and three double Transformer modules connected in sequence;

[0069] Stage four includes a patch fusion module and a double Transformer module connected in sequence;

[0070] The double Transformer module includes two Transformer modules in front and back, wherein the front Transformer module performs the following steps:

[0071] The local sparse information aggregation attention map is calculated for the input feature of the front Transformer module, the local sparse information aggregation attention map and the input feature of the front Transformer module are residual connected, and then the result is residual linked with the result after linear transformation and multilayer perception to obtain the output feature of the local sparse information aggregation Transformer;

[0072] The output features of the previous Transformer module are used as the input features of the subsequent Transformer module;

[0073] The Transformer module then performs the following steps:

[0074] After sampling and transforming the input features of the post-Transformer module, a local sparse information aggregation attention map is calculated for the sampled and transformed features. The local sparse information aggregation attention map and the input features of the post-Transformer module are then residually linked. This result is then residually linked with the result after linear transformation and multilayer perceptron to obtain the output features of the local sparse information aggregation Transformer.

[0075] The sampling transformation includes: passing the input features of the post-Transformer module through a convolutional layer to obtain data-based sampled values; and using the data-based sampled values ​​to perform bilinear interpolation sampling on the input features of the post-Transformer module to obtain the sampled transformed features.

[0076] The calculation of the attention map by aggregating local sparse information uses either the input features of the previous Transformer module or the input features of the subsequent Transformer module after sampling and transformation as the current input feature A. The steps are as follows:

[0077] S1: Divide the current input feature A into windows of the same size and without overlap to obtain the feature map of the window division.

[0078] S2: Input the window-divided feature map into the offset generation network to obtain the offset matrix required for calculating deformable attention.

[0079] S3: Perform a linear transformation on the window-divided feature map to obtain the value matrix needed to calculate deformable attention.

[0080] S4: Perform a linear transformation on the window-divided feature map to obtain the attention weight matrix required for calculating deformable attention.

[0081] S5: Use the offset matrix to perform bilinear interpolation sampling on the value matrix, and use the attention weight matrix to perform weighted summation on the sampling results, and then perform linear transformation to obtain the local sparse information aggregation attention map.

[0082] The structure of the Transformer module for local sparse information aggregation is as follows: Figure 3 As shown.

[0083] The formula for calculating deformable attention is:

[0084]

[0085] where DeformAttn(z q ,p q ,x) is the attention map, z q and x are two representations of the input feature, p q is an arbitrary reference point on the feature, Δp mqk is the offset, A mpk is the attention weight, W m is the learnable weight, W′ m is the transpose of W m , M is the number of attention heads, and K is the number of sampling points.

[0086] The above attention map and input feature are connected in residual, and the result is connected in residual with the result after linear transformation and multi-layer perception, to obtain the output feature of local sparse information aggregation Transformer.

[0087] Since each two consecutive Transformer modules lack information interaction between windows, the feature map obtained by the previous Transformer module needs to be sampled and transformed, that is, the feature is input into a convolutional layer to obtain data-based sampling values, and then the sampling values are used for bilinear interpolation sampling of the feature, and then the calculation of the next Transformer module is performed.

[0088] The linear embedding module performs dimension transformation on the image after patch division.

[0089] The patch fusion module takes the values of the same position in each calculation area of the output feature of the Transformer, splices them into new patches, and connects them to obtain features after 2 times downsampling.

[0090] The output of the feature extraction network is four features of different scales from shallow to deep.

[0091] Step 3: input the four features of different scales into the feature pyramid network to fuse the features between different scales, and obtain five fused features of different scales from shallow to deep after fusion.

[0092] As shown in the feature fusion pyramid structure in Figure 5 , the input of the feature pyramid network is four features C1-C4 of different scales from shallow to deep; the feature pyramid network processes the features C1-C4 as follows to obtain five fused features P1-P5 of different scales from shallow to deep after fusion: C4 directly obtains P4, P4 is downsampled to obtain P5, P4 is upsampled and fused with C3 to obtain P3, P3 is upsampled and fused with C2 to obtain P2, and P2 is upsampled and fused with C1 to obtain P1.

[0093] Step 4: According to the ship position annotation of the original image, the target edge is extracted to obtain a coarse extraction edge image of the target.

[0094] Step 5: The shallowest fusion feature of the five different scale fusion features and the coarse extraction edge image are input into the edge-guided shape enhancement module to obtain the enhanced shallowest fusion feature.

[0095] The shallowest feature of the five different scale features and the coarse extraction edge image are input into the edge-guided shape enhancement module, that is, the shallowest feature is first fused with the coarse extraction edge image, and then input into the target edge prediction map obtained by using the sobel edge extraction operator, and the weighted cross-entropy loss between the target edge prediction map and the target edge real map is calculated; then the normalized target edge prediction map is used to fuse the weighted shallowest feature, and the target shape prediction map is obtained by inputting the convolution network, and the binary classification loss and Dice loss between the target shape prediction map and the target binary segmentation real map are calculated; finally, based on the above losses, the parameters are optimized by training the network to enhance the feature.

[0096] The calculation formula of the weighted cross-entropy loss between the target edge prediction map and the target edge real map is:

[0097]

[0098]

[0099] Wherein, y i is the edge pixel value of the target edge real map, p i is the probability of the i-th pixel being classified as an edge pixel, and conversely, 1-y i is the background pixel value of the target edge real map, and 1-p i is the probability of the i-th pixel being classified as a background pixel; N c is the number of edge pixels in the target edge real map; N is all pixels in the target edge real map.

[0100] The calculation formula of the binary classification loss and Dice loss between the target shape prediction map and the target binary segmentation real map is:

[0101]

[0102]

[0103] Wherein, Loss se is the binary classification loss between the target shape prediction map and the target binary segmentation real map; Loss Dice is the Dice loss between the target shape prediction map and the target binary segmentation real map; yi is the edge pixel value of the target edge ground truth, p i is the probability of the i-th pixel being classified as an edge pixel, and 1-y i is the background pixel value of the target edge ground truth, 1-p i is the probability of the i-th pixel being classified as a background pixel; a determines the weight of the two losses.

[0104] Step 6: input the enhanced shallowest layer fusion feature and the fusion features of the other four scales into the anchor-free target detection head to obtain the target detection result.

[0105] As shown in the detection head in Figure 5 , input the enhanced shallowest layer and the fusion features of the other four scales into the anchor-free target detection head of FCOS to obtain the target detection classification and regression result.

[0106] Those skilled in the art should understand that the steps and modules of the present application described in the above embodiments can be realized by general computing hardware and software, which can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. The modules realized by executable program codes can be stored in any other form of computer storage medium known in the technical field, such as random access memory (RAM), internal memory, read-only memory (ROM), hard disk, removable disk, CD-ROM, etc. In some cases, the steps shown or described can be executed in a different order from that shown here, or they can be made into individual integrated circuit modules, or multiple modules or steps can be made into a single integrated circuit module. Therefore, the present application is not limited to any specific combination of hardware and software.

[0107] In summary, the above is only a preferred embodiment of the present application, and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A SAR image ship target detection method based on a Transformer, characterized in that, The method comprises the following steps: Step 1: performing patch division on an input original image to obtain a patch-divided image; Step 2: inputting the patch-divided image into a four-stage feature extraction backbone network composed of a local sparse information aggregation Transformer to obtain four different scale features from shallow to deep; The four-stage feature extraction backbone network composed of the local sparse information aggregation Transformer comprises: The basic component structure is a Swin Transformer-based backbone network structure, which is divided into four stages and sequentially outputs four different scale features from shallow to deep; Stage one comprises a linear embedding module and a double Transformer module connected in sequence; the linear embedding module is used for dimension transformation of the patch-divided image; Stage two comprises a patch fusion module and a double Transformer module connected in sequence; Stage three comprises a patch fusion module and three double Transformer modules connected in sequence; Stage four comprises a patch fusion module and a double Transformer module connected in sequence; The double Transformer module comprises a front Transformer module and a rear Transformer module, wherein the front Transformer module performs the following steps: The local sparse information aggregation attention map is calculated for the input feature of the front Transformer module, the local sparse information aggregation attention map and the input feature of the front Transformer module are residual connected, and then the result is residual connected with the result after linear transformation and multilayer perception to obtain the output feature of the local sparse information aggregation Transformer; The output feature of the front Transformer module is used as the input feature of the rear Transformer module; The rear Transformer module performs the following steps: After the input feature of the rear Transformer module is sampled and transformed, the local sparse information aggregation attention map is calculated for the sampled and transformed feature, the local sparse information aggregation attention map and the input feature of the rear Transformer module are residual connected, and then the result is residual connected with the result after linear transformation and multilayer perception to obtain the output feature of the local sparse information aggregation Transformer; The sampling transformation comprises: obtaining a data-based sampling value through a convolution layer based on the input feature of the rear Transformer module; and performing bilinear interpolation sampling on the input feature of the rear Transformer module by using the data-based sampling value to obtain the sampled and transformed feature; Wherein, the local sparse information aggregation attention map is calculated, and the input feature of the front Transformer module or the input feature of the rear Transformer module after sampling transformation is used as the current input feature A; the following steps are adopted: S1: performing window division on the current input feature A to obtain a window-divided feature map; S2: inputting the window-divided feature map into an offset generation network to obtain an offset matrix required for calculating deformable attention; S3: performing linear transformation on the window-divided feature map to obtain a value matrix required for calculating deformable attention; S4: performing linear transformation on the window-divided feature map to obtain an attention weight matrix required for calculating deformable attention; S5: performing bilinear interpolation sampling on the value matrix by using the offset matrix, performing weighted summation on the sampling result by using the attention weight matrix, and then performing linear transformation to obtain a local sparse information aggregation attention map; Step 3: inputting the four features of different scales into a feature pyramid network to fuse the features of different scales, and obtaining five fused features of different scales from shallow to deep; Step 4: extracting a target edge according to a ship position label of the original image to obtain a coarse extraction edge image of the target; Step 5: inputting the shallowest fused feature of the five fused features of different scales and the coarse extraction edge image into an edge-guided shape enhancement module to obtain an enhanced shallowest fused feature; Step 6: inputting the enhanced shallowest fused feature and the other four fused features into an anchor-free target detection head to obtain a target detection result.

2. The SAR image ship target detection method based on the Transformer according to claim 1, wherein, The patch division on the input original image includes the following steps: Divide the input image of the size of HxWx3 into 4x4 non-overlapping patches, and the feature dimension of each patch is 4x4x3=48, and the number of patches is H / 4xW / 4. 3.The Transformer-based SAR image ship target detection method of claim 1 or 2, wherein, The local sparse information aggregation attention map is represented as : wherein, and are two representations of input features, is an arbitrary reference point on the feature, is an offset, is the attention weight, is a learnable weight, is is the transpose of is the number of attention heads, is the number of sampling points. 4.The Transformer-based SAR image ship target detection method of claim 1, wherein, The patch fusion module includes: taking the values of the same positions in each calculation region of the output feature of the double-Transformer module to splice a new patch and connect the new patch to obtain a feature after 2 times of downsampling. 5.The Transformer-based SAR image ship target detection method of claim 1, wherein, The input of the feature pyramid network is four features C1-C4 of different scales from shallow to deep; The feature pyramid network processes the features C1-C4 as follows to obtain five fused features P1-P5 of different scales from shallow to deep: C4 directly obtains P4, P4 is downsampled to obtain P5, P4 is upsampled and fused with C3 to obtain P3, P3 is upsampled and fused with C2 to obtain P2, and P2 is upsampled and fused with C1 to obtain P1. 6.The Transformer-based SAR image ship target detection method of claim 1, wherein, The edge-guided shape enhancement module includes: fuse the shallowest fused feature output by the Transformer with the coarse extraction edge image, and input the fused feature into a sobel edge extraction operator to obtain a target edge prediction map; calculate the weighted cross-entropy loss between the target edge prediction map and a target edge real map; fuse the shallowest fused feature output by the Transformer with the target edge prediction map after weighting the target edge prediction map by using the normalized target edge prediction map, and input the fused feature into a convolutional network to obtain a target shape prediction map; A binary classification loss and a Dice loss between a target shape prediction graph and a target binary segmentation real graph are calculated, and based on the above losses, the convolution network parameters are optimized to enhance the features.

7. The SAR image ship target detection method based on the Transformer according to claim 6, wherein, a weighted cross-entropy loss between the target edge prediction map and the target edge ground truth map, denoted as : in, These are the edge pixel values ​​of the target edge real image. It is the first The probability that a pixel is classified as an edge pixel, conversely, These are the background pixel values ​​of the true image of the target edge. It is the first The probability that a pixel is classified as a background pixel; is the number of edge pixels in the ground truth image of the target edge; N is the total number of pixels in the ground truth image of the target edge. 8.The Transformer-based SAR image ship target detection method of claim 6, wherein, The binary classification loss and the Dice loss between the target shape prediction graph and the target binary segmentation real graph are represented as: in, The binary classification loss is used to distinguish between the predicted shape image of the target and the true binary segmentation image of the target. The Dice loss is used to compare the predicted shape map of the target with the ground binary segmentation map of the target. These are the edge pixel values ​​of the target edge real image. It is the first The probability that a pixel is classified as an edge pixel, conversely, These are the background pixel values ​​of the true image of the target edge. It is the first The probability that a pixel is classified as a background pixel; This determines the weights of the two losses. 9.The Transformer-based SAR image ship target detection method of claim 1, wherein, The anchor-free target detection head includes a detection head of FCOS, and a target detection classification and regression result is obtained.