Underwater target detection method based on differential attention

By using a feature pyramid network with differential attention and dynamic scale awareness, the problems of feature extraction and multi-scale fusion in underwater target detection are solved, achieving high-precision and low-latency underwater target detection, which is suitable for resource-constrained underwater robot platforms.

CN121982508APending Publication Date: 2026-05-05DALIAN MARITIME UNIVERSITY
View PDF 0 Cites 1 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
DALIAN MARITIME UNIVERSITY
Filing Date
2026-02-06
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

Existing underwater target detection algorithms face challenges such as difficulty in feature extraction, failure of multi-scale fusion, and limited computing resources when dealing with complex underwater environments. This results in low detection accuracy and poor real-time performance, making it difficult to meet the needs of autonomous underwater robot operations.

Method used

A lightweight underwater target detection method based on differential attention is adopted. By using differential attention mechanism and dynamic scale-aware feature pyramid network, the signal-to-noise ratio is improved and multi-scale feature fusion is achieved. Combined with structure reparameterization technology, the computational overhead is reduced.

Benefits of technology

It significantly improves the accuracy and real-time performance of underwater target detection, adapts to complex underwater environments, meets the real-time detection needs of resource-constrained equipment, improves detection accuracy by 2.8%, and reduces computational load by 80%.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121982508A_ABST
    Figure CN121982508A_ABST
Patent Text Reader

Abstract

The invention discloses an underwater target detection method based on differential attention. The method comprises the following steps: acquiring an underwater image to be detected; based on the underwater image data set, constructing a lightweight underwater target detection network model based on a differential attention mechanism; constructing a joint loss function, and performing end-to-end training on the lightweight underwater target detection network model to obtain a trained lightweight underwater target detection network model; performing mathematical equivalence fusion on the lightweight underwater target detection network model to generate a lightweight reasoning model; and inputting the obtained underwater image to be detected into the lightweight reasoning model to realize target detection of the underwater image. According to the method, a differential attention feature interaction mechanism is introduced, common-mode noise is stripped through differential calculation, and the detection precision and real-time performance of an underwater fuzzy scene and a tiny target are remarkably improved in combination with a feature pyramid network integrating dynamic scale perception and semantic gating.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of target detection technology, specifically relating to an underwater target detection method based on differential attention. Background Technology

[0002] Underwater target detection is a core sensing technology for building seabed observation networks, enabling autonomous operation of underwater robots (AUVs / ROVs), and monitoring marine ecosystems. However, unlike the terrestrial atmospheric environment, water is a complex optically inhomogeneous medium. During underwater transmission, light waves are affected by the wavelength-selective absorption of water molecules, resulting in severe blue-green color shifts and brightness reduction in images. Simultaneously, the backscattering of light by suspended particles in the water creates a "curtain effect," leading to blurred images, extremely low contrast, and high-frequency background noise. This severe "domain shift" phenomenon poses a significant challenge to feature extraction in underwater scenarios for general detection models trained on terrestrial scenes.

[0003] Existing mainstream object detection algorithms (such as the YOLO series based on CNNs or the standard Transformer architecture) have significant limitations when processing such degraded images:

[0004] Feature extraction is affected by noise: Traditional convolutional networks are limited by local receptive fields and have difficulty distinguishing targets from noise using global information in turbid backgrounds; while Transformer-based detectors have strong global context capture capabilities, in the high-scattering underwater environment, this global modeling has a negative effect. High-energy backscattering noise dominates similarity calculation, causing attention to spread to the background and making it difficult to focus on the target signal, resulting in "attention distraction" and frequent false alarms.

[0005] Multi-scale fusion failure: Existing feature fusion networks (such as PANet and FPN) typically rely on static scale priors and simple linear superposition or splicing for cross-level interaction. However, in complex underwater scenes, this mechanism faces a double challenge: 1. Extreme scale changes amplified by refraction: Affected by shooting distance, target type, and complex underwater environment, the detected targets in underwater images exhibit extreme scale changes, and the refraction effect of underwater light causes distortion of the targets, exacerbating scale changes. The fixed receptive field of existing networks cannot dynamically adapt to such extreme multi-scale features, resulting in insufficient perception of small or distorted targets. 2. Accumulation and contamination of cross-level noise: Although the shallow features of underwater images contain geometric details, they are also filled with high-energy backscattering noise. Existing "coarse" fusion easily leads to the erroneous amplification of shallow high-frequency noise during cross-scale transmission, contaminating deep semantic features, causing the feature signals of weak targets to be annihilated during hierarchical transmission.

[0006] Furthermore, to cope with harsh imaging conditions, existing research often tends to improve accuracy by stacking deep networks or introducing complex image enhancement and preprocessing modules. However, this strategy leads to a surge in model parameters and computational overhead, introducing not only additional inference latency but also making it difficult to adapt to resource-constrained embedded computing platforms (such as the Jetson series) carried by underwater robots, failing to meet the stringent requirements of "high accuracy, low latency, and low power consumption" for autonomous underwater operations. Therefore, developing a target detection method that can combat underwater noise interference from the algorithmic level, efficiently fuse multi-scale features, and possess lightweight characteristics is a key technical challenge that urgently needs to be solved in the field of marine engineering.

[0007] With the deepening of marine exploration and development, underwater target detection has become a core supporting technology for key tasks such as seabed resource exploration, underwater engineering facility inspection, and marine ecological monitoring. However, due to the special physical mechanisms of underwater optical imaging, light waves undergo significant wavelength-selective absorption and non-uniform scattering effects during transmission through the water medium, inevitably resulting in severe color shift, contrast degradation, and detail blurring in the acquired underwater source images. Especially in turbid waters, backscattering noise generated by suspended particles overlaps with the foreground target signal, greatly compressing the signal-to-noise ratio of the image.

[0008] Faced with such severely degraded visual input, existing general-purpose object detection models often encounter the dual dilemma of "feature overload" and "background obfuscation" during the feature extraction stage: on the one hand, the texture and edge information of weak targets are difficult to capture effectively; on the other hand, strong scattering noise is easily misjudged as salient features. This directly leads to frequent false positives and false negatives in complex underwater scenarios, and their detection accuracy, environmental adaptability, and robustness are all insufficient to meet the actual engineering requirements for high-precision, automated operations of underwater robots.

[0009] To address the shortcomings of existing technologies, although existing methods attempt to improve detection performance by introducing attention mechanisms or feature pyramids (FPNs), these methods typically suffer from the following technical limitations: (1) Problem 1: The standard self-attention mechanism used in the prior art is usually calculated based on the global similarity between pixels. In turbid water, it is easily attracted by high-frequency background noise (such as light spots and suspended matter), resulting in "attention dispersion" and failing to effectively focus on the edge and texture features of the target, thus limiting the purity of feature extraction in strong interference environment.

[0010] (2) Problem 2: Existing feature fusion networks (such as FPN and PANet) mainly rely on static scale priors and lack the ability to dynamically adapt to multi-scale transformations. In complex underwater light fields, the target scale fluctuates drastically and the background noise is complex due to the influence of refraction and distance. Due to the lack of a dynamic scale selection mechanism, existing networks cannot adaptively adjust the receptive field to match target changes, resulting in a significant decrease in the feature representation ability of extreme-scale targets (especially small targets), thus causing frequent missed detections; in addition, simple splicing and fusion are also difficult to effectively remove background scattering noise, which can easily introduce interference and thus limit the improvement of detection accuracy.

[0011] (3) Problem 3: In order to improve detection accuracy, existing methods often introduce complex feature processing modules, which leads to a surge in the number of model parameters and huge computational overhead. However, the computing power resources of the embedded computing platform carried by the equipment in the actual underwater application are extremely limited. Existing high-precision models are difficult to implement real-time inference on low-power devices, which limits the engineering deployment and application of the algorithm. Summary of the Invention

[0012] To address the problems existing in current technologies, this invention proposes an underwater target detection method based on differential attention, comprising the following steps: Acquire underwater images to be detected; Based on underwater image datasets, a lightweight underwater target detection network model based on differential attention mechanism is constructed. A joint loss function is constructed, and the lightweight underwater target detection network model is trained end-to-end to obtain the trained lightweight underwater target detection network model. A lightweight underwater target detection network model is mathematically equivalently fused to generate a lightweight inference model; The acquired underwater images to be detected are input into a lightweight inference model to achieve target detection in underwater images.

[0013] Furthermore: the lightweight underwater target detection network model includes Backbone Network: Based on the original image of the underwater image to be detected, it uses the HGNetv2 architecture, which is improved based on structural reparameterization, to extract multi-scale feature maps and outputs three feature maps of different scales, including a first feature map, a second feature map, and a third feature map; the size of the first feature map < the size of the second feature map < the size of the third feature map; Encoder: Used to receive the first feature map, second feature map and third feature map output by the backbone network, perform feature enhancement and multi-scale feature fusion processing on the three feature maps of different scales, suppress underwater environmental noise interference, establish cross-level context aggregation and semantic alignment between features of different scales, and finally output the enhanced multi-scale fused features. Decoder: Used to receive the fused multi-scale features transmitted by the encoder, and output the category and bounding box location information of the underwater target through the prediction head.

[0014] Further: the encoder includes: Noise-resistant feature coding network: used to receive the first feature map output by the backbone network, use differential attention mechanism to separate the signal and noise of the feature, and output the denoised first feature map; The AD-FPN module receives the denoised first feature map transmitted by the noise-resistant feature coding network and the second and third feature maps transmitted by the backbone network. It constructs a feature pyramid based on an aggregation-diffusion architecture, performs two aggregation and diffusion operations on the input multi-scale features, and repeatedly extracts global context information and distributes it to different scale branches to achieve cross-scale semantic alignment and feature enhancement. At the same time, it uses a semantically guided gating mechanism to dynamically filter effective information during feature fusion, suppresses the accumulation of background noise during cross-level fusion, and finally outputs fused features with scale robustness and high signal-to-noise ratio.

[0015] Furthermore: the backbone network includes feature modules including: The backbone network includes: a feature module and a structure-reparameterized convolutional module; The feature module includes: a Stem module, a first HG-Stage module, a second HG-Stage module, a third HG-Stage module, and a fourth HG-Stage module connected in sequence; The first HG-Stage module includes an HG-Block feature extraction unit; Both the second HG-Stage module and the fourth HG-Stage module include a downsampling unit and an HG-Block feature extraction unit connected in sequence; The third HG-Stage module includes sequentially connected downsampling units and two sequentially connected HG-Block feature extraction units. The downsampling units are used to reduce the spatial resolution of the feature map, and the HG-Block feature extraction units are used to extract and integrate deep semantic features. The HG-Block feature extraction unit is composed of multiple stacked structure-reparameterized convolutional modules; The reparameterized convolution module is configured to use different topologies and computational logics based on the current stage, and to construct multiple parallel branches, as detailed below: During the model training phase, a parallel branch structure is constructed, which includes 3×3 convolutional layers, 1×1 convolutional layers, and identity mapping branches. During the model inference stage, utilizing the principle of linear additivity of convolution operations, the identity mapping branch is first converted into a 1×1 convolution kernel, and zeros are padded around the 1×1 convolution kernel to transform it into a 3×3 convolution kernel. Finally, the convolution kernel weight matrices and bias vectors of all branches are added element-wise to generate unique 3×3 convolution weights and biases. During the model inference stage, a single-path convolution structure is constructed using the unique 3×3 convolution weights and biases to process and output the input feature map.

[0016] Furthermore, the noise-resistant feature coding network includes a differential attention feature interaction module. By introducing a channel-aware differential attention mechanism, it utilizes differential calculation to simulate the characteristics of a bandpass filter. By calculating the difference between two sets of attention weights, it automatically cancels low-frequency common-mode background noise in the feature map and enhances the high-frequency difference signal at the target edge, outputting a high signal-to-noise ratio coded feature.

[0017] Furthermore: the AD-FPN module includes a hole-selective aggregation module and a semantic-gated fusion module. The AD-FPN module adopts a parallel three-branch structure based on the aggregation-diffusion architecture. Taking the branch where the second feature map is located as the aggregation center, the module uses the hole selective aggregation module to extract and integrate global context information. The aggregated features are then diffused to the branches where the first and third feature maps are located through upsampling and downsampling operations. The diffused features are then weighted and fused with the features of the branches where the first and third feature maps are located to suppress noise accumulation. Then, another aggregation and diffusion operation is performed to finally output the fused multi-scale features.

[0018] The dilated selective aggregation module is configured to construct a dynamic multi-scale perception system. This module contains multiple parallel processing branches, one of which is an identity mapping branch, and the other branches are dilated convolution branches with different dilation rates, used to capture contextual information from different receptive fields from local to global. The attention weights of each branch are calculated using a global average pooling layer and a fully connected layer, and normalized using a Softmax function. The normalized weights are then weighted and summed with the output features of the corresponding branches to generate aggregated global contextual features. The semantic gating fusion module is configured to perform noise-resistant feature alignment by receiving semantic features from deep layers as guiding features and features to be processed from shallow layers. First, the semantic features are subjected to convolution and sigmoid activation to generate a spatial gating weight map with values ​​ranging from 0 to 1. Then, the weight map is multiplied element-wise with the features to be processed to suppress background noise. Finally, the result of the operation is added to the original features to be processed by residual addition to generate denoised shallow features. Then, the denoised shallow features are concatenated with the deep semantic features to output the fused features. Furthermore, the noise-resistant feature coding network achieves accurate separation of signal and noise through a differential attention mechanism, the process of which is as follows: Step 1-1: Input the first feature map extracted from the backbone network. After preliminary processing, it contains rich information from the image, as well as some noise caused by the underwater imaging environment. Steps 1-2: Logically divide the attention head into two complementary subspaces, H1 and H2; H1 is used to preserve the target signal, and H2 acts as a noise estimator, aiming to remove backscattered noise through subtraction operations. After introducing spatial location coding to enhance geometric perception, The differential attention feature interaction module calculates the attention responses of the two groups separately, using differential characteristics to suppress common-mode background. Given a query Q, key K, and value V, Define the attention output of H1 as O s The attention output corresponding to H2 is defined as O n ; dk is the dimension of the key, and the Softmax operation is used to calculate the attention score, focusing on the relevant region;

[0019] Introducing a learnable channel attenuation vector Differential fusion is performed, and the final differential attention output is O. d Defined as:

[0020] in Let λ represent the Hadamard product along the channel dimension. λ is a learnable channel decay vector used to adjust the strength of noise suppression. Its value is constrained within the interval [0.05, 0.95] to ensure gradient stability. It can adaptively adjust the signal-to-noise ratio of different feature channels such as color and texture based on their respective signal-to-noise ratios. n The intensity of background noise suppression is increased, thereby highlighting O. s High-frequency target details; Steps 1-3: Pure target features are generated through the differential attention mechanism. Next, the DAFI module uses a residual structure to ensure the feature reconstruction capability of the deep network. The output of the differential attention feature interaction module first passes through residual connections and layer normalization, and then is fed into the feedforward neural network for nonlinear transformation. The computation process of the entire DAFI module is formalized as follows.

[0021]

[0022] Furthermore: the parallel three-branch pyramid network based on the aggregation-diffusion architecture uses the branch containing the second feature map as the aggregation center, extracts and integrates global context information using a dilated selective aggregation module, and diffuses the aggregated features to the branches containing the first and third feature maps through upsampling and downsampling operations; the diffused features are then weighted and fused with the features of the branches containing the first and third feature maps to suppress noise accumulation, followed by another aggregation and diffusion operation, and finally outputs the fused multi-scale features as follows: Step 2-1: The AD-FPN module receives the multi-scale feature map transmitted by the backbone network and the noise-resistant feature coding network, wherein the first feature map is denoised by the DAFI module and contains clean features of the target signal; Step 2-2: In the feature aggregation stage, in order to extract features from multi-scale feature maps... To reconstruct a scale-robust global context, a DSA module was designed, and a dynamic multi-scale sensing system was constructed.

[0023] Aligned input features The mapping is a multi-level feature set containing 5 branches.

[0024] in: The branch retains the original reference signal. Branches capture multi-scale context from local to global through an increasing void ratio; A dynamic scale selection mechanism is introduced. First, global average pooling is used to extract the global statistic s. Then, s is directly projected onto the multi-branch feature space through the weights W of the fully connected layer, and the result is obtained by Softmax normalization. Channel weights of each branch :

[0025] in, The projection matrix is ​​learnable. Indicates the corresponding number in the projection result Slices of each branch, obtaining aggregated features Weighted sum of each branch and convolutioned pointwise After transformation, the output is connected via a global residual:

[0026] Steps 2-3: In the feature diffusion stage, output the DSA module. The signal is broadcast in reverse as a "semantic seed" and a collaborative reconstruction mechanism is constructed to establish a high-frequency retention path across scales. This path directly injects the shallow raw input Raw P3 into the output through identity mapping, which is equivalent to embedding an all-pass filter in the network to force the retention of the high-frequency position information of the raw input.

[0027]

[0028] Secondly, to prevent shallow noise from contaminating deep semantics, a semantically guided gating fusion (SGF) unit is introduced at the fusion point. The SGF utilizes deep semantic features. Generate spatial gating mask For shallow features Perform adaptive filtering: in For the Sigmoid function, Acting as a spatially selective filter: it approaches 1 in the target region to allow high-frequency details to pass through, and approaches 0 in the background region to block scattering noise. Finally, the refined features semantic features of alignment splicing output; Steps 2-4: After completing the initial aggregation based on the DSA module and the initial diffusion fusion based on the SGF module, the features of each branch are fed back to the aggregation center for a second dynamic aggregation. The global context information after the second aggregation is then diffused a second time to guide the feature fusion of each branch. Through this two-stage deep interaction, cross-scale semantic depth alignment and hierarchical suppression of background noise are achieved, and finally, a fused feature map with high signal-to-noise ratio and scale robustness is output.

[0029] This invention also provides an underwater target detection method based on differential attention. The purpose of this invention is to provide an underwater target detection method based on differential attention. This method aims to solve the problem of attention divergence caused by high-energy backscattering in underwater imaging, as well as the problems of scale uncertainty caused by underwater refraction and background noise accumulation in cross-level fusion. This invention introduces a differential attention feature interaction mechanism to remove common-mode noise using differential computation, and combines it with a feature pyramid network that includes dynamic scale awareness and semantic gating. While ensuring an extremely low number of model parameters (lightweight) to adapt to resource-constrained edge devices, it significantly improves the detection accuracy and real-time performance of blurred underwater scenes and small targets. The above problems are effectively solved through the following methods: (1) Solution to Problem 1: This invention introduces a differential attention strategy in the feature encoding stage and constructs a differential attention feature interaction module. By calculating the difference between the two sets of attention weights, the characteristics of a bandpass filter are simulated, which automatically cancels low-frequency common-mode noise in the background environment and significantly amplifies the high-frequency difference signal at the target edge, thereby improving the signal-to-noise ratio and focusing ability of the feature from the source in the feature encoding stage.

[0030] (2) Solution to Problem 2: This invention designs and constructs an aggregation-diffusion feature pyramid network. It abandons the traditional unidirectional fusion path and instead adopts an "aggregation-diffusion" topology, which integrates a hole-selective aggregation unit to adapt to the scale uncertainty of underwater targets and a semantically guided gating fusion unit to suppress the accumulation of feature fusion noise.

[0031] (3) Solution to Problem 3: This invention uses structural reparameterization technology to design a lightweight overall model architecture. During the training phase, a complex topological structure with multiple branches in parallel is constructed to enhance nonlinear expression capabilities. During the inference phase, multiple branches are fused into a single-path convolution through mathematical equivalence transformation. This significantly reduces memory usage and computational latency without sacrificing detection accuracy, thus meeting the real-time detection requirements of underwater embedded devices.

[0032] Compared with the prior art, the present invention has the following significant advantages: (1) The optimized overall network architecture of this invention exhibits stronger robustness in complex underwater scenarios, and achieves simultaneous improvement in detection precision and recall, effectively solving the problem of easy missed detection and false detection in the detection of weak underwater targets by existing algorithms.

[0033] (2) The present invention introduces a channel-aware differential attention (CADA) mechanism in the encoder, which automatically cancels the common-mode noise caused by the scattering of suspended particles and uneven illumination that are widely present in underwater images from a mathematical perspective, thereby improving the purity of features and signal-to-noise ratio from the source.

[0034] (3) The aggregation-diffusion feature pyramid (AD-FPN) constructed in this invention adopts an innovative collaborative mechanism of void selective aggregation (DSA) and semantically guided gating fusion (SGF). Among them, the void selective aggregation unit effectively calibrates the target geometric uncertainty amplified by underwater refraction by dynamically adjusting the receptive field weight, and realizes dynamic perception of targets at extreme scales; at the same time, the semantically guided gating fusion unit uses deep semantic priors to generate spatial gating masks, and realizes adaptive blocking of shallow high-energy scattering noise in the cross-level feature fusion process, fundamentally suppressing the problems of noise accumulation and deep semantic pollution in multi-scale interactions.

[0035] (4) Through the full-link structural reparameterization design, this invention ensures that the model has the powerful representation capabilities of deep networks while realizing a simplified single-path architecture in the inference stage, which significantly reduces memory usage and inference time, and is perfectly adapted to underwater embedded devices with limited computing power.

[0036] The present invention has the following beneficial effects: (1) Significant Improvement in Detection Accuracy and Robustness: The underwater target detection method based on differential attention proposed in this invention effectively solves the problem of low feature signal-to-noise ratio and extreme scale changes caused by high-energy underwater scattering and aggravated refraction through the deep synergy between the differential denoising mechanism of the differential attention feature interaction module and the dynamic scale reconstruction mechanism of the aggregation-diffusion feature pyramid. Extensive validation on four mainstream public underwater datasets has demonstrated the superior performance of this invention: on the DUO dataset, the average detection accuracy (AP) reaches 66.1%, and on the highly challenging small target detection metric (AP_S), it reaches 61.5%, significantly outperforming advanced detectors such as YOLO13, D-Fine, and DEIM; on the RUOD, UDD, and UODD datasets, the AP reaches 61.5%, 31.2%, and 53.4%, respectively. Comprehensive experiments show that the average detection accuracy of this invention is improved by 2.8% compared to the baseline model, fully verifying the strong robustness and advanced nature of this method in handling underwater low-contrast and extreme scale change scenarios.

[0037] (2) Excellent lightweight characteristics and real-time performance: Through deep structural reparameterization design and network architecture optimization, this invention significantly reduces the computational burden of the model while maintaining high accuracy. The model has only 4.5M parameters and only 10.5G floating-point operations (FLOPs). Compared with traditional high-precision general-purpose detectors such as Faster R-CNN and DINO, the parameter size and computational load of this invention are reduced by more than 80%. On resource-constrained underwater edge computing devices such as Jetson AGX Xavier, this invention can achieve a real-time inference speed of about 45 FPS, which far exceeds the running efficiency of conventional algorithms, greatly meeting the engineering deployment requirements of underwater robots and other platforms for low latency and high real-time performance in target detection tasks. Attached Figure Description

[0038] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0039] Figure 1This is a flowchart of an underwater target detection method based on differential attention; Figure 2 The diagram shows the network structure of the underwater target detection model DFR-Net, including the DAFI module and the AD-FPN network. Figure 3 This is a structural diagram of the backbone network; Figure 4 The diagram shows the structure of the DSA and SGF modules in AD-FPN; where (a) is the hole-selective aggregation module and (b) is the semantic gated fusion module. Figure 5 The image shows the attention heatmap of the DAFI module of this invention compared to the baseline model; where (a) is the original image, (b) is the attention heatmap of the baseline model, and (c) is the attention heatmap of the network proposed in this invention. Figure 6 The results show a comparison between the baseline model and the DFR-Net detection results, where (a) is the baseline detection result and (b) is the DFR-Net detection result. Detailed Implementation

[0040] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0041] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0042] Figure 1 This is a flowchart of an underwater target detection method based on differential attention; An underwater target detection method based on differential attention includes the following steps: S1: Acquire the underwater image to be detected; S2: Based on underwater image datasets, construct a lightweight underwater target detection network model based on differential attention mechanism; S3: Construct a joint loss function and perform end-to-end training on the lightweight underwater target detection network model to obtain the trained lightweight underwater target detection network model; S4: Perform mathematical equivalence fusion on the trained lightweight underwater target detection network model to generate a lightweight inference model; the multi-branch reparameterized convolutional unit is used for mathematical equivalence fusion. S5: Input the acquired underwater image to be detected into the lightweight inference model to achieve target detection in the underwater image.

[0043] The lightweight inference model and the trained lightweight underwater target detection network model are mathematically equivalent transformations of each other; they are completely equivalent in mathematical function, that is, for any identical input image, the output feature values ​​of the two are the same, but there are differences in the network topology. The specific conversion relationship is as follows: The trained lightweight underwater target detection network model adopts a multi-branch parallel topology, including 3×3 convolution, 1×1 convolution, and identity mapping branches, to optimize training convergence and feature extraction by utilizing overparameterization. The lightweight inference model adopts a single-path serial topology, which is generated by mathematically fusing the weights and bias parameters of the multiple branches in the training model based on the linear additivity principle of convolution operations. This inference model removes redundant branch structures in the training model, significantly reducing the number of model parameters and memory usage while maintaining detection accuracy, thus accelerating the inference process.

[0044] Figure 2 The diagram shows the network structure of the underwater target detection model DFR-Net, including the DAFI module and the AD-FPN network. Furthermore: the lightweight underwater target detection network model includes Backbone Network: Based on the original image of the underwater image to be detected, it uses the HGNetv2 architecture, which is improved based on structural reparameterization, to extract multi-scale feature maps and outputs three feature maps of different scales, including a first feature map, a second feature map, and a third feature map; the size of the first feature map < the size of the second feature map < the size of the third feature map; Encoder: Used to receive the first feature map, second feature map and third feature map output by the backbone network, perform feature enhancement and multi-scale feature fusion processing on the three feature maps of different scales, suppress underwater environmental noise interference, establish cross-level context aggregation and semantic alignment between features of different scales, and finally output the enhanced multi-scale fused features. Decoder: Used to receive the fused multi-scale features transmitted by the encoder, and output the category and bounding box location information of the underwater target through the prediction head.

[0045] Further: the encoder includes: Noise-resistant feature coding network: used to receive the first feature map output by the backbone network, use differential attention mechanism to separate the signal and noise of the feature, and output the denoised first feature map; The AD-FPN module receives the denoised first feature map transmitted by the noise-resistant feature coding network and the second and third feature maps transmitted by the backbone network. It constructs a feature pyramid based on an aggregation-diffusion architecture, performs two aggregation and diffusion operations on the input multi-scale features, and repeatedly extracts global context information and distributes it to different scale branches to achieve cross-scale semantic alignment and feature enhancement. At the same time, it uses a semantically guided gating mechanism to dynamically filter effective information during feature fusion, suppresses the accumulation of background noise during cross-level fusion, and finally outputs fused features with scale robustness and high signal-to-noise ratio.

[0046] Figure 3 This is a structural diagram of the backbone network; The backbone network includes: a feature module and a structure-reparameterized convolutional module; The feature module includes: a Stem module, a first HG-Stage module, a second HG-Stage module, a third HG-Stage module, and a fourth HG-Stage module connected in sequence; The first HG-Stage module includes an HG-Block feature extraction unit; The second HG-Stage module and the fourth HG-Stage module have the same structure. The second HG-Stage module includes a downsampling unit and an HG-Block feature extraction unit connected in sequence. The third HG-Stage module includes sequentially connected downsampling units and two sequentially connected HG-Block feature extraction units.

[0047] The downsampling unit is used to reduce the spatial resolution of the feature map, and the HG-Block feature extraction unit is used to extract and integrate deep semantic features. The HG-Block feature extraction unit is composed of multiple stacked structure-reparameterized convolutional modules; The reparameterized convolution module is configured to use different topologies and computational logics based on the current stage, and to construct multiple parallel branches, as detailed below: During the model training phase, a parallel branch structure is constructed, which includes 3×3 convolutional layers, 1×1 convolutional layers, and identity mapping branches. During the model inference stage, utilizing the principle of linear additivity of convolution operations, the identity mapping branch is first converted into a 1×1 convolution kernel, and zeros are padded around the 1×1 convolution kernel to transform it into a 3×3 convolution kernel. Finally, the convolution kernel weight matrices and bias vectors of all branches are added element-wise to generate unique 3×3 convolution weights and biases. During the model inference stage, a single-path convolution structure is constructed using the unique 3×3 convolution weights and biases to process and output the input feature map.

[0048] The noise-resistant feature coding network includes a differential attention feature interaction module. By introducing a channel-aware differential attention mechanism, it uses differential calculation to simulate the characteristics of a bandpass filter. By calculating the difference between two sets of attention weights, it automatically cancels low-frequency common-mode background noise in the feature map and enhances the high-frequency difference signal at the target edge, outputting a high signal-to-noise ratio coded feature.

[0049] Figure 4 The diagram shows the structure of the DSA and SGF modules in AD-FPN; where (a) is the hole-selective aggregation module and (b) is the semantic gated fusion module. Furthermore: the AD-FPN module includes a hole-selective aggregation module and a semantic-gated fusion module. The AD-FPN module adopts a parallel three-branch structure based on the aggregation-diffusion architecture. Taking the branch where the second feature map is located as the aggregation center, the module uses the hole selective aggregation module to extract and integrate global context information. The aggregated features are then diffused to the branches where the first and third feature maps are located through upsampling and downsampling operations. The diffused features are then weighted and fused with the features of the branches where the first and third feature maps are located to suppress noise accumulation. Then, another aggregation and diffusion operation is performed to finally output the fused multi-scale features.

[0050] The dilated selective aggregation module is configured to construct a dynamic multi-scale perception system. This module contains multiple parallel processing branches, one of which is an identity mapping branch, and the other branches are dilated convolution branches with different dilation rates, used to capture contextual information from different receptive fields from local to global. The attention weights of each branch are calculated using a global average pooling layer and a fully connected layer, and normalized using a Softmax function. The normalized weights are then weighted and summed with the output features of the corresponding branches to generate aggregated global contextual features. The semantic gating fusion module is configured to perform noise-resistant feature alignment by receiving semantic features from deep layers as guiding features and features to be processed from shallow layers. First, the semantic features are subjected to convolution and sigmoid activation to generate a spatial gating weight map with values ​​ranging from 0 to 1. Then, the weight map is multiplied element-wise with the features to be processed to suppress background noise. Finally, the result of the operation is added to the original features to be processed by residual addition to generate denoised shallow features. Then, the denoised shallow features are concatenated with the deep semantic features to output the fused features. The lightweight underwater target detection network model inputs the preprocessed image into the backbone network. The backbone network uses the HGNetv2 architecture based on structural reparameterization to extract multi-scale feature maps. It designs and introduces a structural reparameterization convolutional layer (Rep-Conv layer) to replace the original standard convolutional layer. During the training phase, a multi-branch parallel topology structure is used to enhance the non-linear expressive power of feature extraction. During the inference phase, the multi-branch structure is equivalently converted into a single-path convolutional structure to reduce computational latency. The preprocessing stage involves performing data augmentation operations such as photometric distortion, random downscaling, IoU cropping, and horizontal flipping on the original image to improve generalization ability. The image is then uniformly scaled to 640×640 resolution, and pixel data is normalized to floating-point levels, while bounding box coordinates are normalized to center points. Finally, a standardized tensor conforming to the backbone network input is constructed. The first feature map output from the backbone network is input into the noise-resistant feature coding network. A differential attention feature interaction module (DAFI) is designed, and a channel-aware differential attention (CADA) mechanism is introduced. The differential calculation is used to simulate the characteristics of a bandpass filter. By calculating the difference between the two sets of attention weights, the low-frequency common-mode background noise in the feature map is automatically canceled, and the high-frequency difference signal of the target edge is enhanced, resulting in the output of a high signal-to-noise ratio coding feature. The AD-FPN module constructs a parallel three-branch pyramid network based on an aggregation-diffusion architecture, serving as the neck feature fusion network. It performs cross-scale feature fusion on the denoised first feature map output by the DAFI module and the second and third feature maps output by the backbone network. A dilated selective aggregation (DSA) unit is designed, using the branch containing the second feature map as the aggregation center. It extracts and integrates global contextual information and diffuses the aggregated features to the branches containing the first and third feature maps through upsampling and downsampling operations. The diffused features are then weighted and fused with the features from the branches containing the first and third feature maps. The SGF unit is configured to perform semantically guided feature filtering. It uses feature maps with deeper semantic levels among the received features as gating signals to generate spatially gated weight maps. These maps dynamically filter and gating feature maps carrying shallow details to suppress water scattering noise in shallow features while preserving high-frequency details. Then, another aggregation and diffusion operation is performed, ultimately outputting multi-scale features with high signal-to-noise ratio and scale robustness.

[0051] Example 1 In practical implementation, the proposed Differential Feature Refinement Network (DFR-Net) was tested using publicly available datasets DUO, RUOD, UDD, and UODD. Ablation analysis experiments were conducted on the DAFI and AD-FPN modules, and performance comparisons were performed with current mainstream object detection methods to demonstrate the effectiveness and superiority of the present invention.

[0052] An underwater target detection method based on differential attention, characterized by the following steps: Acquire underwater images to be detected; Based on underwater image datasets, a lightweight underwater target detection network model based on differential attention mechanism is constructed. A joint loss function is constructed, and the lightweight underwater target detection network model is trained end-to-end to obtain the trained lightweight underwater target detection network model. A lightweight underwater target detection network model is mathematically equivalently fused to generate a lightweight inference model; The acquired underwater images to be detected are input into a lightweight inference model to achieve target detection in underwater images.

[0053] The construction and training steps of a lightweight underwater target detection network model based on differential attention mechanism are as follows: Step 1, Construction of the Differential Attention Feature Interaction (DAFI) Module: This module is constructed as a dedicated noise-resistant attention module, designed to replace the standard self-attention layer. It abandons the global similarity metric, which is susceptible to high-energy background interference, and instead employs a noise-resistant feature aggregation strategy. This strategy aims to remove background noise from contaminated observation data through a feature difference mechanism, separating the pure target direct component.

[0054] Step 2, Construction of the AD-FPN Network: An AD-FPN network was designed in the neck area to replace the traditional feature fusion network. This module integrates the Diffuse Selective Aggregation (DSA) and Semantic Guided Gated Fusion (SGF) units. DSA utilizes multiple receptive fields to address the extreme scale variations of underwater targets exacerbated by refraction, while SGF effectively suppresses noise accumulation during feature fusion by guiding the stitching of feature maps at different scales through high-level semantics.

[0055] Step 3 involves constructing a complex multi-branch parallel topology during the training phase to enhance nonlinear expressive power. Subsequently, during the inference phase, the multi-branch structure is fused into a single-path convolution through mathematical equivalence transformation, achieving a significant reduction in memory usage and computational latency without sacrificing detection accuracy.

[0056] Step 4, Dataset Preparation: Specific experiments were conducted using publicly available underwater target detection datasets, such as DUO and RUOD. These datasets cover multiple typical underwater target categories. The experiments divided the datasets into training, validation, and test sets with a ratio of 7:2:1, followed by network training and performance validation.

[0057] Step 5, Model Training and Deployment: DFR-Net was implemented using PyTorch on an NVIDIA RTX 4090 GPU. The model was trained using the AdamW optimizer with an initial learning rate of 8e-4 and weight decay of 1e-4. The batch size was set to 4, and the number of training epochs was set to 180. All input images were resized to 640 × 640. For fair comparison, all baseline methods were retrained under the same settings. After training, the structural reparameterization modules in the network were mathematically equivalently fused to generate a lightweight inference model, which was then deployed to an edge computing platform for underwater robots such as Jetson for target detection using real-time acquired underwater images.

[0058] This invention proposes a Differential Feature Refinement Network (DFR-Net) for underwater target detection, the architecture of which is as follows: Figure 2As shown, the network includes a Rep-HGNetv2 feature extraction module, a DAFI module for denoising and feature enhancement, an AD-FPN module for multi-scale feature fusion, and a decoding output module. The main contribution of this invention is the proposal of the DAFI module and the AD-FPN module. This network system can not only ensure the detection effect of normal-sized targets, but also improve the detection performance of small-sized underwater targets, while significantly reducing the number of model parameters and computational complexity.

[0059] Figure 3 The diagram illustrates the structure of the DSA and SGF components in the AD-FPN module. The DSA module uses a dynamic scale selection mechanism to dynamically adapt to the extreme changes in the scale of underwater targets amplified by light refraction, thereby enhancing the fusion of multi-scale features. The SGF module uses semantic guidance to finely fuse features at different levels, especially preserving more details in the target region while suppressing noise in the background region, thus effectively suppressing noise accumulation in feature fusion.

[0060] The DAFI module mentioned in step 1 receives the first feature map (i.e., the smallest feature map) output from the backbone network as input. It then uses the CADA mechanism to suppress common-mode background noise in underwater images by calculating the difference between two sets of attention maps. Its network structure is... Figure 2 There is a display of it.

[0061] The noise-resistant feature coding network achieves accurate separation of signal and noise through a differential attention mechanism, and the implementation process is as follows: Step 1-1: Input the first feature map extracted from the backbone network (Rep-HGNetv2) in the previous stage. After preliminary processing, the feature map contains rich information from the image, but may also contain some noise caused by the underwater imaging environment (such as scattering, refraction, etc.).

[0062] Steps 1-2: Logically divide the attention head into two complementary subspaces, H1 and H2. H1 is primarily responsible for preserving the target signal, while H2 acts as a noise estimator, aiming to remove backscattered noise through subtraction. After introducing spatial location encoding to enhance geometric perception, CDA does not directly aggregate features but instead computes the attention responses of the two groups separately, utilizing differential characteristics to suppress common-mode background. Specifically, given a query Q, key K, and value V, we define the attention outputs corresponding to H1 and H2 as O1 and O2, respectively. s and O n :

[0063] d kThis is the dimension of the key. The Softmax operation is used to calculate the attention score, allowing the model to focus on relevant regions.

[0064] To eliminate common-mode noise, we introduce a learnable channel attenuation vector. Perform differential fusion. The final differential attention output is O. d Defined as:

[0065] in This represents the Hadamard product of the channel dimension. It is a learnable channel decay vector used to adjust the strength of noise suppression. Its value is constrained within the interval [0.05, 0.95] to ensure gradient stability. It can adaptively adjust the signal-to-noise ratio of different feature channels such as color and texture based on the signal-to-noise ratio of O. n The intensity of background noise suppression is increased, thereby highlighting O. s Details of high-frequency targets.

[0066] Steps 1-3: Through the differential attention mechanism, the CADA module can effectively separate the target signal from background noise, generating clean target features. Next, the DAFI module uses a residual structure to ensure the feature reconstruction capability of the deep network. The CADA output first undergoes residual connections and layer normalization, and then is fed into a feedforward neural network (FFN) for nonlinear transformation. The entire computational flow of the DAFI module can be formalized as follows:

[0067] This design implicitly suppresses low-frequency common-mode scattering components through differential reconstruction of the feature domain. Combined with two-level normalization and nonlinear mapping of FFN, it effectively maintains gradient stability and enhances semantic representation, achieving robust feature focusing under complex underwater light fields.

[0068] In step 2, the AD-FPN module receives the denoised multi-scale feature map and then enhances the fusion capability of multi-scale features in the underwater image through DSA and SGF mechanisms to address the problem of extreme scale variations in underwater targets. The network structure of this module is as follows: Figure 2 As shown in the diagram, the structures of the DSA and SGF modules are as follows: Figure 3 As shown, The parallel three-branch pyramid network based on the aggregation-diffusion architecture uses the branch containing the second feature map as the aggregation center. It extracts and integrates global context information using a dilated selective aggregation module, and then diffuses the aggregated features to the branches containing the first and third feature maps through upsampling and downsampling operations. The diffused features are then weighted and fused with the features from the branches containing the first and third feature maps to suppress noise accumulation. Finally, another aggregation and diffusion operation is performed, and the fused multi-scale features are output. The process is as follows: Step 2-1: The AD-FPN module receives multi-scale feature maps from the previous few layers of the network, where the first feature map is denoised by the DAFI module and contains clean features of the target signal.

[0069] Step 2-2: In the feature aggregation stage, in order to extract features from multi-scale feature maps... To reconstruct a scale-robust global context, we designed a DSA module. This module follows a "split-transform-merge" paradigm to construct a dynamic multi-scale sensing system.

[0070] First, the aligned input features The mapping is a multi-level feature set containing 5 branches.

[0071]

[0072] in The branch retains the original reference signal, while Branches capture multi-scale context from local to global by increasing void ratios.

[0073] To dynamically select the optimal receptive field and suppress local scattering, a dynamic scale selection mechanism is introduced. First, global average pooling (GAP) is used to extract the global statistic s. Then, s is directly projected onto the multi-branch feature space through the weights W of the fully connected layer, and then normalized using Softmax to obtain the th... Channel weights of each branch :

[0074] in, The projection matrix is ​​learnable. Indicates the corresponding number in the projection result Slices of each branch. The resulting aggregated features. Weighted sum of each branch and convolutioned pointwise After transformation, the output is connected via a global residual:

[0075] Through this design, DSA not only adapts to extreme changes in the scale of underwater targets by utilizing a dynamic scale selection mechanism, but also ensures high-fidelity signal propagation through identity branches and residual connections, providing robust global priors for subsequent stages.

[0076] Steps 2-3: In the feature diffusion stage, to address the loss of detail caused by downsampling, we will... As a "semantic seed," we conducted reverse broadcasting and constructed a collaborative reconstruction mechanism. First, we established a cross-scale high-frequency preservation path. This path directly injects the shallow raw input (Raw P3) into the output through identity mapping, which is equivalent to embedding an all-pass filter in the network to force the preservation of the high-frequency position information of the raw input.

[0077] Secondly, to prevent shallow noise from contaminating deep semantics, we introduced a semantically guided gating fusion (SGF) unit at the fusion point. SGF utilizes deep semantic features. Generate spatial gating mask For shallow features Perform adaptive filtering:

[0078]

[0079] in: This is the Sigmoid function. Acting as a spatially selective filter: it approaches 1 in the target region to allow high-frequency details to pass through, and approaches 0 in the background region to block scattering noise. Ultimately, the refined features... semantic features of alignment The spliced ​​output effectively suppresses the accumulation of feature fusion noise while significantly enhancing the edge and texture representation of weak targets.

[0080] Steps 2-4: After processing by the DSA and SGF modules, AD-FPN fuses features from multiple scales. This feature fusion is achieved through weighted fusion of shallow and deep features. The output feature map contains richer object details and contextual information, which can be used for subsequent object detection, segmentation, or other tasks.

[0081] To evaluate the generalization ability and robustness of DFR-Net, we conducted comprehensive experiments on four challenging underwater datasets: DUO, RUOD, UDD, and UODD. These datasets cover diverse underwater scenarios with varying turbidity, lighting conditions, and high-density small targets. For fair comparison, all baseline methods were retrained under the same settings.

[0082] Experiment 1, Comparative Experiment: We compared DFR-Net with representative detectors, including CNN-based methods (e.g., Faster R-CNN, TOOD, Yolov11, Yolov13) and state-of-the-art Transformer-based models (e.g., DINO, D-Fine, DEIM). The experimental results are shown in Tables I and II below:

[0083] Table II. Comparison of cutting-edge methods on the RUOD, UDD, and UODD datasets

[0084] Overall performance on the DUO dataset: Table I presents a detailed comparison on the main benchmark DUO, with all metrics evaluated using the COCO standard. DFR-Net achieves highly competitive performance across all metrics, demonstrating the proposed method's significant cross-scale robustness and its ability to consistently improve feature representation and prediction quality under complex degradation conditions. Particularly for challenging small targets, the model achieves 61.4%, significantly outperforming TOOD (+7.0%) and DEIM (+9.6%). This significant performance improvement confirms that DFR-Net effectively overcomes the feature annihilation problem in deep networks, accurately recovering minute biological geometric details obscured by background noise.

[0085] Generalization ability and computational efficiency: As shown in Table II, DFR-Net achieved the best AP accuracy on three different datasets: RUOD, UDD, and UODD (e.g., leading DEIM by 2.8% on RUOD), validating the strong robustness of the proposed method in various complex underwater scenarios. Furthermore, the model achieves an excellent balance between accuracy and efficiency: with only 4.5 M parameters and 10.5 G FLOPs, its computational cost is far lower than DINO (approximately 1 / 10), and it achieves superior overall detection accuracy compared to the lightweight YOLO13 with a small computational increment, demonstrating good potential for practical deployment.

[0086] Experiment 2, Ablation Experiment: To verify the effectiveness of each component, we conducted the ablation experiment shown in Table III below: Table III shows the ablation experiments of the proposed components on the DUO dataset.

[0087] The effect of DAFI: Integrating DAFI into the baseline improved AP by 1.1% (from 62.8% to 63.9%). This confirms that the differential attention mechanism effectively suppresses common-mode backscattering noise and enhances feature purity.

[0088] The effect of AD-FPN: Replacing the standard FPN with AD-FPN significantly improved AP by 3.1% (from 62.8% to 65.9%) and APs by 2.1%. This improvement demonstrates that the fusion of DSA cells and SGF-guided arrays is crucial for correcting scale distortion in the spatial domain and preserving high-frequency geometric details.

[0089] Synergistic effect: The combination of the two modules (DFR-Net) achieves optimal performance, with an AP of 66.1% and APs of 61.5%. This significant gain demonstrates the complementary nature of feature domain denoising and spatial domain reconstruction, where the noise suppression of CADA clears the way for AD-FPN to more effectively recover fine-grained details.

[0090] Figure 5 The image shows the attention heatmap of the DAFI module of this invention compared to the baseline model; where (a) is the original image, (b) is the attention heatmap of the baseline model, and (c) is the attention heatmap of the network proposed in this invention. Figure 6 The results show a comparison between the baseline model and the DFR-Net detection results, where (a) is the baseline detection result and (b) is the DFR-Net detection result.

[0091] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0092] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.

[0093] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0094] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0095] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. An underwater target detection method based on differential attention, characterized in that: Includes the following steps: Acquire underwater images to be detected; Based on underwater image datasets, a lightweight underwater target detection network model based on differential attention mechanism is constructed. A joint loss function is constructed, and the lightweight underwater target detection network model is trained end-to-end to obtain the trained lightweight underwater target detection network model. A lightweight underwater target detection network model is mathematically equivalently fused to generate a lightweight inference model; The acquired underwater images to be detected are input into a lightweight inference model to achieve target detection in underwater images.

2. The underwater target detection method based on differential attention according to claim 1, characterized in that: The lightweight underwater target detection network model includes Backbone Network: Based on the original image of the underwater image to be detected, it uses the HGNetv2 architecture, which is improved based on structural reparameterization, to extract multi-scale feature maps and outputs three feature maps of different scales, including a first feature map, a second feature map, and a third feature map; the size of the first feature map < the size of the second feature map < the size of the third feature map; Encoder: Used to receive the first feature map, second feature map and third feature map output by the backbone network, perform feature enhancement and multi-scale feature fusion processing on the three feature maps of different scales, suppress underwater environmental noise interference, establish cross-level context aggregation and semantic alignment between features of different scales, and finally output the enhanced multi-scale fused features. Decoder: Used to receive the fused multi-scale features transmitted by the encoder, and output the category and bounding box location information of the underwater target through the prediction head.

3. The underwater target detection method based on differential attention according to claim 1, characterized in that: The encoder includes: Noise-resistant feature coding network: used to receive the first feature map output by the backbone network, use differential attention mechanism to separate the signal and noise of the feature, and output the denoised first feature map; The AD-FPN module receives the denoised first feature map transmitted by the noise-resistant feature coding network and the second and third feature maps transmitted by the backbone network. It constructs a feature pyramid based on an aggregation-diffusion architecture, performs two aggregation and diffusion operations on the input multi-scale features, and repeatedly extracts global context information and distributes it to different scale branches to achieve cross-scale semantic alignment and feature enhancement. At the same time, it uses a semantically guided gating mechanism to dynamically filter effective information during feature fusion, suppresses the accumulation of background noise during cross-level fusion, and finally outputs fused features with scale robustness and high signal-to-noise ratio.

4. The underwater target detection method based on differential attention according to claim 1, characterized in that: The backbone network includes: a feature module and a structure-reparameterized convolutional module; The feature module includes: a Stem module, a first HG-Stage module, a second HG-Stage module, a third HG-Stage module, and a fourth HG-Stage module connected in sequence; The first HG-Stage module includes an HG-Block feature extraction unit; Both the second HG-Stage module and the fourth HG-Stage module include a downsampling unit and an HG-Block feature extraction unit connected in sequence; The third HG-Stage module includes sequentially connected downsampling units and two sequentially connected HG-Block feature extraction units; The downsampling unit is used to reduce the spatial resolution of the feature map, and the HG-Block feature extraction unit is used to extract and integrate deep semantic features. The HG-Block feature extraction unit is composed of multiple stacked structure-reparameterized convolutional modules; The reparameterized convolution module is configured to use different topologies and computational logics based on the current stage, and to construct multiple parallel branches, as detailed below: During the model training phase, a parallel branch structure is constructed, which includes 3×3 convolutional layers, 1×1 convolutional layers, and identity mapping branches. During the model inference stage, utilizing the principle of linear additivity of convolution operations, the identity mapping branch is first converted into a 1×1 convolution kernel, and zeros are padded around the 1×1 convolution kernel to transform it into a 3×3 convolution kernel. Finally, the convolution kernel weight matrices and bias vectors of all branches are added element-wise to generate unique 3×3 convolution weights and biases. During the model inference stage, a single-path convolution structure is constructed using the unique 3×3 convolution weights and biases to process and output the input feature map.

5. The underwater target detection method based on differential attention according to claim 1, characterized in that: The noise-resistant feature coding network includes a differential attention feature interaction module. By introducing a channel-aware differential attention mechanism, it uses differential calculation to simulate the characteristics of a bandpass filter. By calculating the difference between two sets of attention weights, it automatically cancels low-frequency common-mode background noise in the feature map and enhances the high-frequency difference signal at the target edge, outputting a high signal-to-noise ratio coded feature.

6. The underwater target detection method based on differential attention according to claim 1, characterized in that: The AD-FPN module includes a hole-selective aggregation module and a semantic-gated fusion module. A parallel three-branch structure based on the aggregation-diffusion architecture is adopted. The branch where the second feature map is located is used as the aggregation center. The hole selective aggregation module is used to extract and integrate global context information, and the aggregated features are diffused to the branch where the first feature map is located and the branch where the third feature map is located through upsampling and downsampling operations. The diffused features are weighted and fused with the features of the branches containing the first and third feature maps to suppress noise accumulation. Then, an aggregation and diffusion operation is performed again to finally output the fused multi-scale features. The dilated selective aggregation module is configured to construct a dynamic multi-scale perception system. This module contains multiple parallel processing branches, one of which is an identity mapping branch, and the other branches are dilated convolution branches with different dilation rates, used to capture contextual information from different receptive fields from local to global. Attention weights for each branch are calculated using global average pooling layers and fully connected layers, and then normalized using the Softmax function. The normalized weights are then weighted and summed with the output features of the corresponding branches to generate aggregated global context features. The semantic gating fusion module is configured to perform noise-resistant feature alignment. It receives semantic features from deep layers as guiding features and features to be processed from shallow layers. First, it performs convolution and sigmoid activation on the semantic features to generate a spatial gating weight map with values ​​ranging from 0 to 1. Then, it performs element-wise multiplication on the weight map and the features to be processed to suppress background noise. Finally, it adds the result of the operation to the original features to be processed by adding the residual to generate denoised shallow features. Then, it concatenates the denoised shallow features with the deep semantic features to output the fused features.

7. The underwater target detection method based on differential attention according to claim 5, characterized in that: The noise-resistant feature coding network achieves accurate separation of signal and noise through a differential attention mechanism, and the implementation process is as follows: Step 1-1: Input the first feature map extracted from the backbone network. After preliminary processing, it contains rich information from the image, as well as some noise caused by the underwater imaging environment. Steps 1-2: Logically divide the attention head into two complementary subspaces, H1 and H2; H1 is used to preserve the target signal, and H2 acts as a noise estimator, aiming to remove backscattered noise through subtraction operations. After introducing spatial location coding to enhance geometric perception, The differential attention feature interaction module calculates the attention responses of the two groups separately, using differential characteristics to suppress common-mode background. Given a query Q, key K, and value V, Define the attention output of H1 as O s The attention output corresponding to H2 is defined as O n ; dk is the dimension of the key, and the Softmax operation is used to calculate the attention score, focusing on the relevant region; Introducing a learnable channel attenuation vector Differential fusion is performed, and the final differential attention output is O. d Defined as: in Let λ represent the Hadamard product along the channel dimension. λ is a learnable channel decay vector used to adjust the strength of noise suppression. Its value is constrained within the interval [0.05, 0.95] to ensure gradient stability. It can adaptively adjust the signal-to-noise ratio of different feature channels such as color and texture based on their respective signal-to-noise ratios. n The intensity of background noise suppression is increased, thereby highlighting O. s High-frequency target details; Steps 1-3: Pure target features are generated through the differential attention mechanism. Next, the DAFI module uses a residual structure to ensure the feature reconstruction capability of the deep network. The output of the differential attention feature interaction module first passes through residual connections and layer normalization, and then is fed into a feedforward neural network for nonlinear transformation. The entire computational flow of the DAFI module can be formalized as follows: 。

Citation Information

Cited By

  • A construction site personnel intrusion detection method based on an improved YOLO model

    CN122244805A