Ship instance segmentation method based on dynamic attention and multi-scale context awareness
By employing dynamic attention and multi-scale context awareness methods, combined with a multi-scale feature fusion module and a cross-level feature interaction module, the problem of low multi-scale ship accuracy in SAR image ship instance segmentation is solved, achieving high-precision ship segmentation and small ship differentiation, and supporting ship behavior analysis and size estimation in coastal and inland waterways.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUBEI LUOJIA LAB
- Filing Date
- 2025-11-27
- Publication Date
- 2026-05-01
AI Technical Summary
Existing SAR image ship instance segmentation methods have low accuracy when segmenting multi-scale ships in complex backgrounds, making it difficult to capture detailed hull contours and occlusion relationships. Furthermore, small ships are susceptible to noise, resulting in low segmentation performance.
A method based on dynamic attention and multi-scale context awareness is adopted. Through the multi-scale feature fusion module MSFFM and the cross-level feature interaction module CLFIM, the multi-scale context aggregation and cross-level feature map interaction are enhanced, thereby improving the performance of ship target detection and segmentation.
It achieves high-precision ship segmentation in complex near-shore scenarios, improves the detection and segmentation performance of multi-scale ship targets, enhances the distinguishability of small ships, and provides stable and efficient instance segmentation technology support.
Smart Images

Figure CN121963104A_ABST
Abstract
Description
Ship instance segmentation method based on dynamic attention and multi-scale context awareness Technical Field
[0001] This application belongs to the field of remote sensing image instance segmentation technology, and more specifically, relates to a ship instance segmentation method based on dynamic attention and multi-scale context awareness. Background Technology
[0002] Spaceborne Synthetic Aperture Radar (SAR), a key technology in remote sensing, achieves Earth observation by actively transmitting microwave signals and receiving echoes. SAR possesses all-weather, all-time imaging capabilities, enabling stable acquisition of ocean and shoreline information under complex weather conditions. These characteristics make it an indispensable part of maritime surveillance, maritime traffic management, and environmental monitoring. Existing SAR target detection models can locate ships, but struggle to capture detailed hull contours and occlusion relationships, limiting ship behavior analysis and size estimation in coastal and inland waterways. Instance segmentation, by generating pixel-level masks to separate ships from cluttered backgrounds, provides crucial technical support for ship target analysis in SAR images. However, existing SAR image ship instance segmentation methods still face several challenges: unlike general instance segmentation, SAR instance segmentation has developed relatively slowly due to the scarcity of labeled data and its unique imaging mechanism. Specifically, two key challenges hinder the performance improvement of SAR instance segmentation methods. First, due to the limitations of SAR imaging resolution, ship targets exhibit multi-scale variations, with their size typically ranging from tens to hundreds of pixels. This makes it difficult to pre-define the anchor frame size and aspect ratio for anchor-frame-based instance segmentation methods, thus affecting model performance. Second, small vessels on water occupy only a few pixels and are susceptible to noise, resulting in lower SAR segmentation performance for small vessels.
[0003] Therefore, how to solve the problem of low accuracy of existing SAR image ship instance segmentation methods when segmenting multi-scale ships in complex backgrounds is a problem that urgently needs to be studied. Summary of the Invention
[0004] To address the shortcomings of existing technologies, this application aims to provide a ship instance segmentation method based on dynamic attention and multi-scale context awareness. This application can enhance multi-scale context aggregation and guided interaction across different levels of feature maps by leveraging a multi-scale feature fusion module inspired by self-attention and a cross-level feature interaction module inspired by cross-attention, thereby improving the detection and segmentation performance of multi-scale SAR ship targets and achieving optimal ship segmentation accuracy in complex nearshore scenarios.
[0005] To achieve the above objectives, in a first aspect, this application provides a ship instance segmentation method based on dynamic attention and multi-scale context awareness, comprising the following steps: S10, acquiring SAR images and performing cropping, annotation, and scaling operations on the SAR images, and then dividing the SAR image data into a training set and a test set; S20, performing horizontal flip enhancement and normalization on the preprocessed SAR image dataset; S30, training a pre-constructed DAMCP-Net ship instance segmentation model based on the enhanced SAR image training set; wherein, the DAMCP-Net model includes a backbone network, a multi-scale feature fusion module, and a cross-level feature interaction module, the multi-scale feature fusion module being used to fuse multi-level feature maps extracted by the backbone network, including using multi-branch large kernel deep convolution to capture and fuse contextual information at different scales, the cross-level feature interaction module using a cross-layer interaction mechanism to interact with the multi-level feature maps, using high-level semantic features to guide low-level features; S40, inputting the acquired SAR test image into the trained DAMCP-Net model to achieve instance segmentation inference.
[0006] The ship instance segmentation method based on dynamic attention and multi-scale context awareness provided in this application has the following advantages: This application proposes a multi-scale attention-guided FPN (MSAGFPN) composed of a multi-scale feature fusion module (MSFFM) and a cross-level feature interaction module (CLFIM) to achieve adaptive feature propagation, covering both top-down and bottom-up paths. MSFFM uses multi-branch depthwise convolutions of different sizes to simultaneously capture local details and global contours, achieving multi-scale context aggregation enhancement. CLFIM utilizes a cross-layer interaction mechanism to guide low-level features with high-level semantics, thereby enhancing the discriminability of small targets. Combining the above design, this application can complete ship instance segmentation of SAR images based on dynamic attention and multi-scale context awareness, providing stable and efficient instance segmentation technology support for ship behavior analysis and size estimation in coastal and inland waterways.
[0007] As a further preferred embodiment, step S10 specifically involves: performing cropping, annotation, and scaling based on bilinear interpolation on the acquired SAR image. The data undergoes preprocessing operations, including size adjustment, and the SAR image data is divided into training and testing sets in a 13:7 ratio. The source of the SAR image data is the HRSID dataset.
[0008] As a further preferred option, step S20 specifically involves: performing random horizontal flipping and image normalization on the preprocessed SAR image dataset with a probability of 0.5.
[0009] As a further preferred embodiment, in step S30, the multi-scale feature fusion module includes a channel response redistribution unit, a multi-branch large-kernel deep convolutional block, a feature fusion unit, and a channel transformation unit connected in sequence; the channel response redistribution unit includes Convolutional layers are used to redistribute channel responses and generate intermediate feature maps; the multi-branch large-kernel depthwise convolutional blocks include: Large-kernel depthwise convolutions are used to expand the receptive field and initially aggregate contextual information. Then, the structure uses five parallel branches to extract contextual information at different scales. Depthwise convolutions are used to capture local details. Depthwise convolution is used to model the global contour of a target. and Convolutions are used to capture different patterns in the vertical and horizontal directions; in addition, direct branches are used to avoid excessive transformation and preserve original information; the feature fusion unit includes: element-wise addition of the results extracted by multi-branch convolutions. Convolutional transformation and Hadamard product operations are used to adaptively adjust the contribution of spatial signals under different target scales and background clutter; the channel transformation unit includes a feedforward neural network (FFN) enhanced with GRN, used to implement nonlinear channel transformation and reduce feature collapse.
[0010] As a further preferred embodiment, in step S30, the cross-level feature interaction module includes a high-level semantic aggregation and refinement unit, a semantically guided low-level feature modulation unit, and an output integration unit; the high-level semantic aggregation and refinement unit includes: bilinear interpolation operation, used for high-level semantic feature scale unification; Convolutional layers are used for feature transformation; Feature Refinement Blocks (FRBs), inspired by the Transformer structure, are used to refine fused high-level features to form semantic priors.
[0011] The semantically guided low-level feature modulation unit employs a mutual attention modulation mechanism and mainly includes multiple components for transforming input features. Convolutional layers are used to perform feature modulation. The system includes a large-kernel deep convolutional layer and a Hadamard product operation for implementing mutual attention; the output integration unit includes an element-wise addition operation for feature fusion and subsequent operations. Convolutional layer.
[0012] As a further preferred embodiment, in step S30, the specific steps for constructing the DAMCP-Net model are as follows: Backbone network construction, where the backbone network is an EdgeNeXt network pre-trained on ImageNet, used to extract multi-level features of SAR images; Neck network construction, where the neck network is based on the lateral connections, top-down and bottom-up path design of PAFPN, and... The convolutional layers are replaced with a multi-scale feature fusion module (MSFFM) to achieve effective fusion of global and local multi-scale contextual information. A parallel cross-level feature interaction module (CLFIM) guides the interaction of high-level semantics with low-level features. MSFFM and CLFIM improve the segmentation performance of DAMCP-Net for multi-scale SAR ship targets. A region candidate network (RPN) is constructed, using RPN to process feature maps from each layer of the neck network. Based on anchor boxes with given scales and aspect ratios, a... Convolutional layers and two The convolutional layers perform initial screening of regions of interest, providing high-quality input for accurate classification, regression, and segmentation in the second stage. The detection head is constructed using a multi-stage cascaded HTC detection head, taking the predicted bounding boxes from the previous stage as input for the next stage's region of interest, progressively increasing the localization quality and sample matching difficulty. Within each stage, bounding box regression and classification are performed first, followed by mask prediction. Skip connections are used for mask features at each stage to enhance information flow and mitigate detail loss. By integrating the backbone network, neck network, region candidate network, and detection head, DAMCP-Net is constructed to achieve high-quality ship target localization and segmentation.
[0013] As a further preferred embodiment, in step S30, the training of the DAMCP-Net model specifically includes: data preprocessing, obtaining the enhanced input image, combining the input image with edge padding to meet the requirement that the length and width are divisible by 32, laying a data foundation for stable model training; model prediction output and loss calculation, inputting the preprocessed image into the DAMCP-Net network to predict bounding box regression results, category score results, and instance segmentation results, and calculating the loss through multi-task loss. The process involves calculating the loss between each result and its true value; backpropagation and parameter updates: after calculating the total loss, the gradient of the total loss with respect to each trainable parameter of the model is calculated using the chain rule; the adaptive optimizer AdamW is used to iteratively update the model parameters; the training set is divided into mini-batches according to the batch size, and the process is repeated multiple times until the model converges; validation, evaluation, and optimization: after the model training is completed, the model performance is evaluated on the validation set in the HRSID dataset to guide hyperparameter tuning and model optimization, prevent overfitting, and finally determine the DAMCP-Net model with the best segmentation performance.
[0014] As a further preferred option, the multi-task loss The calculation formula is:
[0015] in, Indicates the regional candidate network loss. Indicates loss of the detection head; The calculation formula is:
[0016] in, This represents the classification loss, and the binary cross-entropy loss function is used during training. This represents the bounding box regression loss, which uses the Smooth L1 loss function during training. The calculation formula is:
[0017] in, , and These represent classification loss, bounding box regression loss, and instance segmentation loss, respectively. During training, cross-entropy loss function, Smooth L1 loss function, and binary cross-entropy loss function are used respectively. and These represent the number of cascaded stages in the detection head and the weight coefficient of each stage, respectively.
[0018] As a further preferred option, step S40 specifically involves: after the model training is completed, loading the optimal weights, evaluating the performance of the DAMCP-Net using test set samples from the HRSID dataset, calculating core performance indicators, and visualizing the DAMCP-Net model instance segmentation results based on the input SAR image, thereby achieving efficient inference for instance segmentation.
[0019] In a second aspect, this application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method as described in any one of the above.
[0020] It is understandable that the beneficial effects of the second aspect mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description
[0021] Figure 1 is a flowchart of the SAR image ship instance segmentation method based on dynamic attention and multi-scale context awareness provided in the embodiments of this application; Figure 2 is a structural diagram of the DAMCP-Net model provided in the embodiments of this application; Figure 3 is a schematic diagram of the MSFFM module structure of DAMCP-Net provided in the embodiments of this application; Figure 4 is a schematic diagram of the CLFIM module structure of DAMCP-Net provided in the embodiments of this application; Figure 5 is the PR curve of DAMCP-Net provided in the embodiments of this application; Figure 6 is a schematic diagram of some test results of DAMCP-Net for SAR image ship instance segmentation provided in the embodiments of this application. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0023] The embodiments of this application provide a method for segmenting ship instances in SAR images based on dynamic attention and multi-scale context awareness.
[0024] Please refer to Figure 1. This embodiment of the application provides a SAR image ship instance segmentation method based on dynamic attention and multi-scale context awareness, including the following steps: Step S1: Crop, label, and scale the acquired SAR image, and divide the SAR image data into training set, validation set, and test set; Step S2: Horizontally flip and normalize the preprocessed SAR image dataset; Step S3: Construct a DAMCP-Net ship instance segmentation model based on the multi-scale feature fusion module MSFFM and the cross-level feature interaction module CLFIM; Step S4: Train the DAMCP-Net model based on the enhanced SAR image dataset; Step S5: Input the acquired SAR image into the trained DAMCP-Net model to achieve instance segmentation inference.
[0025] In this embodiment, step S1 includes: cropping, labeling, and scaling the acquired SAR image, and dividing the SAR image data into a training set, a validation set, and a test set. Specifically, this embodiment uses a sliding window to crop the image to meet the input requirements of the instance segmentation network, and labels the sub-images. Ship targets in the images are labeled using Labelme software combined with polygon labeling to form a standard label file for the MSCOCO dataset. The original image is uniformly scaled to a fixed size of 800×800 using bilinear interpolation to ensure a balance between the speed and performance of the detection network. Based on this, the sub-image data is divided into a training set, a validation set, and a test set according to their size. For the publicly available SAR instance segmentation dataset HRSID used in this embodiment, the ratio of the training set to the validation set (test set) is 13:7.
[0026] In this embodiment, step S2 includes: performing horizontal flip enhancement and normalization on the preprocessed SAR image dataset; specifically, in this embodiment, the training set data of the HRSID dataset is subjected to random horizontal flip and image normalization operations with a probability of 0.5.
[0027] In this embodiment, step S3 includes: S31: designing a multi-scale feature fusion module MSFFM based on large kernel deep convolution; S32: designing a cross-level feature interaction module CLFIM, and combining it with MSFFM to construct a feature pyramid network; S33: constructing a dynamic attention and multi-scale context-aware instance segmentation model DAMCP-Net based on the pre-trained EdgeNeXt backbone network and the designed feature pyramid network.
[0028] Specifically, the multi-scale feature fusion module MSFFM provided in this embodiment is shown in Figure 2. It includes a channel response redistribution unit, a multi-branch large kernel deep convolutional block, a feature fusion unit, and a channel transformation unit.
[0029] After receiving the input feature map, MSFFM first applies... Convolutional reassignment of channel responses and generation of intermediate feature maps This facilitates subsequent processing. Subsequently, MSFFM utilizes its multi-branch, large-kernel deep convolutional blocks to extract complementary spatial context from different receptive fields, as shown in Figure 2. In the initial stage, it uses... Large-kernel depthwise convolutions are used to expand the receptive field and aggregate contextual information. This structure is then divided into four parallel paths: Depthwise convolutions are used to capture fine local details; Depth convolution is used to model the global ship target contour; two and Strip convolutions are used to capture anisotropic patterns in the vertical and horizontal directions, respectively. Furthermore, direct connections are added to preserve original features and prevent over-transformation. The outputs of all branches are aggregated by element-wise summation, and then... Convolution is used for projection, resulting in rich multi-scale representations. A multi-branch depthwise convolution design can be described as follows:
[0030]
[0031]
[0032] in, It is an intermediate enhancement image. It is a multi-scale feature representation output.
[0033] To adaptively adjust the contribution of spatial signals under different target scales and background clutter, MSFFM further employs a Hadamard-gated residual mechanism, inspired by the self-attention mechanism, using cascaded large-kernel depthwise convolutions (theoretically receptive field is...). This is used to refine the spatial response and generate an attention mask. Then, the resulting feature representation output (not limited to...) Applying Hadamard product to feature maps Furthermore, gating features are obtained through... Convolution is projected and element-wise with... Add them together. The whole process can be described as:
[0034] in, Represents the enhanced feature map, This represents the Hadamard product. Furthermore, MSFFM employs an enhanced GRN feedforward network (FFN) to improve feature representation and generalization capabilities. During training, MSFFM maintains its multi-branch structure. During inference, the convolutions of all branches are reparameterized into a single... Deep convolution, as shown in Figure 2, accelerates inference without sacrificing performance. By combining multi-branch, large-kernel deep convolutional blocks with a dynamic Hadamard gated residual mechanism, MSFFM can capture the global contours and local details of the target, thus forming an effective multi-scale contextual information fusion module.
[0035] Specifically, the cross-level feature interaction module CLFIM provided in this embodiment is shown in Figure 3. It includes a high-level semantic aggregation and refinement unit, a semantically guided low-level feature modulation unit, and an output integration unit.
[0036] To improve cross-scale consistency and maintain fine-grained localization, CLFIM utilizes high-level semantics to modulate low-level features, providing cross-level, pixel-by-pixel guidance for SAR targets. The Feature Refinement Block (FRB) converts high-level semantics into a spatial gain map. This module then uses the spatial gain map to modulate low- and mid-level features via Hadamard product, preserving residual paths, ultimately achieving semantic spatial alignment before fusion.
[0037] Given the output feature map of the backbone network Each feature map is passed through The convolution is converted to 256 channels. CLFIM first constructs a matrix of size... Same interaction tensor . and Upsampled by bilinear The size of the value is calculated, and the sum is calculated pixel by pixel. The result is obtained by... Convolution and FRB are projected to generate This process can be described as follows:
[0038] Among them, FRB is a Transformer-style module, equipped with It consists of a dual-branch convolutional module (DBCM) with a large kernel depthwise convolution and an FFN for further refining and fusing high-level features. The channel dimensions in the DBCM and FFN are expanded by 2x and 4x, respectively.
[0039] Let each feature map be Parameter-sharing interactive tensor generator And adjust it to be consistent with Same size. Then, it goes through the BatchNorm layer, Convolution, GELU layer and one Large-kernel deep convolutional layers are used to capture the dependencies between neighboring pixels. The resulting high-level signals are then modulated with Hadamard product to enhance low-level features. This enables a cross-level attention mechanism. Furthermore, multiple... Convolutional layers are used to enable information exchange between channels. This mechanism can be described as follows:
[0040]
[0041] In the formula, This represents a high-level attention gain map. Indicates by The output result after inputting into the BN layer. This is the output of CLFIM. CLFIM Output At the same time, retain The changes remain unchanged. By converting high-level semantics into a spatial multiplicative gain map, CLFIM can determine where and to what extent the low-level response is amplified or suppressed.
[0042] Specifically, the DAMCP-Net model provided in this embodiment is shown in Figure 4. Its construction steps are as follows: Backbone network construction: For DAMCP-Net, the backbone network uses the EdgeNeXt model pre-trained on the ImageNet dataset to efficiently extract multi-scale hierarchical features of SAR images; Neck network construction: While retaining the bidirectional propagation and lateral connection framework of the path aggregation network, the standard... The convolutional layers are replaced with a multi-scale feature fusion module (MSFFM) to achieve global-local context awareness, and a parallel cross-level feature interaction module (CLFIM) is introduced to guide high-level semantic information across levels. MSFFM and CLFIM enhance the robustness of DAMCP-Net for feature representation and segmentation of multi-scale SAR ship targets. A region candidate network (RPN) is constructed, using the RPN to process the feature maps output from each layer of the neck network. Based on pre-defined anchor boxes of several scales and aspect ratios, a... Convolutional layers and two Convolutional layers perform initial screening of regions of interest (ROIs), providing high-quality input for subsequent accurate classification, regression, and segmentation tasks. The detection head is constructed using a multi-stage cascaded HTC detection head, where the predicted bounding boxes from the previous stage are used as inputs for the next stage's ROI, progressively increasing the localization quality and sample matching difficulty. Each stage sequentially performs bounding box regression, target classification, and mask prediction, leveraging cross-stage mask feature skip connections to enhance information retention and suppress detail loss. The construction of DAMCP-Net follows a technical workflow of feature extraction, fusion, candidate region generation, and refined prediction. By integrating the backbone network, neck network, region candidate network, and detection head, high-quality ship target localization and segmentation are ultimately achieved.
[0043] In this embodiment, step S4 includes: data preprocessing, obtaining the enhanced input image, combining the input image with edge padding to ensure that the length and width are divisible by 32, laying a data foundation for stable model training; model prediction output and loss calculation, inputting the preprocessed image into the DAMCP-Net network to predict bounding box regression results, category scores, and instance segmentation results, and calculating the loss through multi-task loss. The process involves calculating the loss between each result and its true value; backpropagation and parameter updates: after calculating the total loss, the gradient of the total loss with respect to each trainable parameter of the model is calculated using the chain rule; the adaptive optimizer AdamW is used to iteratively update the model parameters; the training set is divided into mini-batches according to the batch size, and the process is repeated multiple times until the model converges; validation, evaluation, and optimization: after the model training is completed, the model performance is evaluated on the validation set in the HRSID dataset to guide hyperparameter tuning and model optimization, prevent overfitting, and finally determine the DAMCP-Net model with the best segmentation performance.
[0044] Specifically, the AdamW optimizer provided in this embodiment is used to guide model training. The two-stage instance segmentation model includes three sub-tasks: classification, localization, and segmentation. The multi-task loss... The calculation formula is as follows:
[0045] in, Indicates the regional candidate network loss. This indicates a loss of the detection head. The calculation process is as follows:
[0046] in, The classification loss is represented by the binary cross-entropy loss function used during training, and its calculation process is as follows:
[0047] In the formula, This represents the number of samples in a batch that are used for loss calculation. Indicates the first The true label of each sample The model predicts the first... The probability that a sample belongs to the positive class. The bounding box regression loss is represented by the Smooth L1 loss function used during training, and its calculation process is as follows:
[0048]
[0049] In the formula, This represents the number of candidate regions considered as positive samples in a batch. The model is represented as the first The predicted number of samples One bounding box parameter, Indicates the first The first sample corresponds to the ground bounding box of the th sample. One parameter, This represents the error in the model's prediction. The calculation process is as follows:
[0050] in, , and These represent the classification loss, bounding box regression loss, and instance segmentation loss, respectively. During training, cross-entropy loss, Smooth L1 loss, and binary cross-entropy loss functions are used, respectively. and These represent the number of cascaded stages in the detector head and the weight coefficient of each stage, respectively. The calculation process for cross-entropy loss is as follows:
[0051] In the formula, This represents the number of samples in a batch. This represents the total number of categories in the classification task. Indicates the first The true category of each sample The model predicts the first... Each sample belongs to category The probability of.
[0052] Specifically, the DAMCP-Net network parameter settings provided in this embodiment are as follows. The momentum of the optimizer AdaamW is... The weight decay was 0.02. The base learning rate was 0.0001, adjusted using a cosine decay scheme. A linear warm-up strategy was used during the initial training phase. For the HRSID dataset, the batch size was set to 2. The network was trained for 12 epochs. Other hyperparameters remained at their default configurations. During the testing phase, the Non-Maximum Suppression (NMS) post-processing algorithm was used to reduce duplicate predictions in instance segmentation, with a threshold set to 0.5.
[0053] In this embodiment, step S5 includes: after the model training is completed, loading the optimal weights, evaluating the performance of DAMCP-Net using test set samples from the HRSID dataset, calculating core performance indicators, and visualizing the DAMCP-Net model instance segmentation results based on the input SAR image, thereby achieving efficient inference for instance segmentation.
[0054] Specifically, the model instance segmentation inference process provided in this embodiment is as follows: after the model training is completed, the model weight file with the best performance on the validation set is loaded, the DAMCP-Net model is set to inference mode to ensure the consistency of the inference results, the DAMCP-Net is systematically evaluated based on the test set samples of the HRSID dataset, the core evaluation index is calculated, and the filtered instance mask and category label are superimposed on the input SAR image to generate the final visualized segmentation map, thereby achieving efficient instance segmentation inference.
[0055] The embodiments use the publicly available SAR ship target instance segmentation dataset HRSID (as shown in Table 1) as an example to further describe the technical solution of the SAR image ship instance segmentation method based on dynamic attention and multi-scale context awareness provided in this application. These embodiments are for illustrative purposes only and are not intended to limit the application scope of this application; they are equally applicable to different regions or time periods.
[0056] Table 1 HRSID information for SAR instance segmentation dataset
[0057] In this embodiment, several performance metrics are selected to verify the effectiveness of the DAMCP-Net model. These metrics are from MS COCO and are mainly used for verifying the performance of instance segmentation networks. They are calculated based on IoU and defined as follows:
[0058] in, and These represent the predicted target area and its actual area, respectively. Average precision (AP) is calculated under different IoU thresholds and target sizes. The algorithm's performance is evaluated by calculating the area under the curve of precision and recall, using the following formula:
[0059] in, Indicates the accuracy of the target. Recall represents the target's precision. Precision and recall can be expressed as:
[0060]
[0061] In the formula, TP, FP, and FN represent the number of instances that the model predicts as positive and the actual situation is also positive (true positives), the number of instances that the model predicts as positive but the actual situation is negative (false positives), and the number of instances that the model misses (false negatives), respectively. All indicators and their calculation methods are summarized in Table 2.
[0062] Table 2 MS COCO Validation Metrics
[0063] To verify the effectiveness of the instance segmentation model proposed in this embodiment, we first conducted comparative experiments with ten other state-of-the-art instance segmentation methods on the public dataset HRSID. The test results of the network on the HRSID test set are shown in Table 3. It can be seen that the DAMCP-Net network in this embodiment achieved an AP of 62.6%, which is 3.5% higher than the second-best HTC+ and 6.8% higher than the HTC network. DAMCP-Net also achieved the best instance segmentation performance across various scale targets.
[0064] Table 3 Test Results of SAR Instance Segmentation Network
[0065] To further verify the performance of the DAMCP-Net network in complex nearshore scenes, this embodiment selected nearshore scenes from the HRSID test dataset and conducted tests. The results are shown in Table 4. In terms of AP (Average Performance), it outperformed the second-best GHIS-Net algorithm by 2.9%. Experimental results demonstrate that the DAMCP-Net instance segmentation network in this embodiment achieves excellent performance in multi-scale ship instance segmentation tasks in complex nearshore scenes of SAR images.
[0066] Table 4 Test results of SAR instance segmentation network in nearshore scenarios
[0067] To visually compare the performance of each method on the HRSID dataset, this embodiment plots the PR curves for object detection and instance segmentation, as shown in Figure 5. Overall, DAMCP-Net's PR curve consistently outperforms other methods at medium to high recall rates across different tasks, and the inflection point of the curve shifts significantly to the right, indicating that it maintains high precision even at high recall rates. These observations confirm the superior performance of the proposed model.
[0068] Figure 6 shows a visualization of some of the DAMCP-Net results for the HRSID dataset. As can be seen, in near-shore scenes and scenes with dense multi-scale ship distribution, the DAMCP-Net instance segmentation network used in this embodiment can segment almost all real ship targets with only a small number of false alarms. This indicates that DAMCP-Net can effectively integrate multi-scale contextual information through MSFFM to achieve accurate segmentation of ship targets of different sizes, and combined with the CLFIM modulation mechanism, it utilizes high-level semantics to guide low-level features, enhancing the network's ability to discriminate small ships, ultimately achieving high-performance SAR image ship instance segmentation.
[0069] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A ship instance segmentation method based on dynamic attention and multi-scale context awareness, characterized in that, Includes the following steps: S10: Acquire SAR images and perform cropping, annotation, and scaling operations on the SAR images, then divide the SAR image data into training and testing sets; S20: Perform horizontal flip enhancement and normalization on the preprocessed SAR image dataset; S30: Train the pre-built DAMCP-Net ship instance segmentation model based on the enhanced SAR image training set; wherein, the DAMCP-Net model includes a backbone network, a multi-scale feature fusion module, and a cross-level feature interaction module. The multi-scale feature fusion module is used to fuse the multi-level feature maps extracted by the backbone network, including using multi-branch large kernel depth convolution to capture and fuse contextual information at different scales. The cross-level feature interaction module uses a cross-layer interaction mechanism to interact with the multi-level feature maps, using high-level semantic features to guide low-level features; S40: Input the acquired SAR test image into the trained DAMCP-Net model to achieve instance segmentation inference.
2. The ship instance segmentation method based on dynamic attention and multi-scale context awareness as described in claim 1, characterized in that, Step S10 specifically involves: performing cropping, annotation, and scaling based on bilinear interpolation on the acquired SAR image. The data undergoes preprocessing operations, including size adjustment, and the SAR image data is divided into training and testing sets in a 13:7 ratio. The source of the SAR image data is the HRSID dataset.
3. The ship instance segmentation method based on dynamic attention and multi-scale context awareness as described in claim 1, characterized in that, Step S20 specifically involves performing random horizontal flipping and image normalization on the preprocessed SAR image dataset with a probability of 0.
5.
4. The ship instance segmentation method based on dynamic attention and multi-scale context awareness as described in claim 1, characterized in that, In step S30, the multi-scale feature fusion module includes a channel response redistribution unit, a multi-branch large-kernel deep convolutional block, a feature fusion unit, and a channel transformation unit connected in sequence; the channel response redistribution unit includes Convolutional layers are used to redistribute channel responses and generate intermediate feature maps; The multi-branch large-kernel depthwise convolutional block includes: Large-kernel depthwise convolutions are used to expand the receptive field and initially aggregate contextual information. Then, the structure uses five parallel branches to extract contextual information at different scales. Depthwise convolutions are used to capture local details. Depthwise convolution is used to model the global contour of a target. and Convolutions are used to capture different patterns in the vertical and horizontal directions; in addition, direct branches are used to avoid excessive transformation and preserve original information; the feature fusion unit includes: element-wise addition of the results extracted by multi-branch convolutions. Convolutional transformation and Hadamard product operations are used to adaptively adjust the contribution of spatial signals under different target scales and background clutter; the channel transformation unit includes a feedforward neural network (FFN) enhanced with GRN, used to implement nonlinear channel transformation and reduce feature collapse.
5. The ship instance segmentation method based on dynamic attention and multi-scale context awareness as described in claim 1, characterized in that, In step S30, the cross-level feature interaction module includes a high-level semantic aggregation and refinement unit, a semantically guided low-level feature modulation unit, and an output integration unit. The high-level semantic aggregation and refinement unit includes: bilinear interpolation operation, used for high-level semantic feature scale unification; Convolutional layers are used for feature transformation; Feature Refinement Blocks (FRBs), inspired by the Transformer structure, are used to refine the fused high-level features to form semantic priors. The semantically guided low-level feature modulation units employ a mutual attention modulation mechanism and mainly include multiple [unclear - possibly related to transforming input features]. Convolutional layers are used to perform feature modulation. The system includes a large-kernel deep convolutional layer and a Hadamard product operation for implementing mutual attention; the output integration unit includes an element-wise addition operation for feature fusion and subsequent operations. Convolutional layer.
6. The ship instance segmentation method based on dynamic attention and multi-scale context awareness as described in claim 1, characterized in that, In step S30, the specific steps for constructing the DAMCP-Net model are as follows: Backbone network construction: The backbone network is the EdgeNeXt network pre-trained on ImageNet, used to extract multi-level features of SAR images; Neck network construction: The neck network is based on the lateral connections, top-down and bottom-up path design of PAFPN, and... The convolutional layers are replaced with a multi-scale feature fusion module (MSFFM) to achieve effective fusion of global and local multi-scale contextual information. A parallel cross-level feature interaction module (CLFIM) guides the interaction of high-level semantics with low-level features. MSFFM and CLFIM improve the segmentation performance of DAMCP-Net for multi-scale SAR ship targets. A region candidate network (RPN) is constructed, using RPN to process feature maps from each layer of the neck network. Based on anchor boxes with given scales and aspect ratios, a... Convolutional layers and two The convolutional layers perform initial screening of regions of interest, providing high-quality input for accurate classification, regression, and segmentation in the second stage. The detection head is constructed using a multi-stage cascaded HTC detection head, taking the predicted bounding boxes from the previous stage as input for the next stage's region of interest, progressively increasing the localization quality and sample matching difficulty. Within each stage, bounding box regression and classification are performed first, followed by mask prediction. Skip connections are used for mask features at each stage to enhance information flow and mitigate detail loss. By integrating the backbone network, neck network, region candidate network, and detection head, DAMCP-Net is constructed to achieve high-quality ship target localization and segmentation.
7. The ship instance segmentation method based on dynamic attention and multi-scale context awareness as described in claim 1, characterized in that, In step S30, the training of the DAMCP-Net model specifically involves: data preprocessing to obtain the enhanced input image, and combining edge padding to ensure that the length and width are divisible by 32; model prediction output and loss calculation, where the preprocessed image is input into the DAMCP-Net network to predict bounding box regression results, category scores, and instance segmentation results, using multi-task loss. Calculate the loss between each result and its true value; Backpropagation and parameter update: After calculating the total loss, the gradient of the total loss with respect to each trainable parameter of the model is calculated using the chain rule. The adaptive optimizer AdamW is used to iteratively update the model parameters. The training set is divided into mini-batches according to the batch size, and the process is repeated multiple times until the model converges. Validation, evaluation and optimization: After the model training is completed, the model performance is evaluated on the validation set in the HRSID dataset to guide hyperparameter tuning and model optimization, prevent overfitting, and finally determine the DAMCP-Net model with the best segmentation performance.
8. The ship instance segmentation method based on dynamic attention and multi-scale context awareness as described in claim 7, characterized in that, Multi-task loss The calculation formula is: in, Indicates the regional candidate network loss. Indicates loss of the detection head; The calculation formula is: in, This represents the classification loss, and the binary cross-entropy loss function is used during training. This represents the bounding box regression loss, which uses the Smooth L1 loss function during training. The calculation formula is: in, , and These represent classification loss, bounding box regression loss, and instance segmentation loss, respectively. During training, cross-entropy loss function, Smooth L1 loss function, and binary cross-entropy loss function are used respectively. and These represent the number of cascaded stages in the detection head and the weight coefficient of each stage, respectively.
9. The ship instance segmentation method based on dynamic attention and multi-scale context awareness as described in claim 1, characterized in that, Step S40 specifically involves: after the model training is completed, loading the optimal weights, evaluating the performance of DAMCP-Net using test set samples from the HRSID dataset, calculating core performance indicators, and visualizing the DAMCP-Net model instance segmentation results based on the input SAR image, thereby achieving efficient inference for instance segmentation.
10. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 9.