Underwater environment real-time lightweight target detection method and readable storage medium
By improving the C3K2 and C2PSA modules of the YOLOv11 model to C3-CPMSFA and C2SFA modules, configuring auxiliary head branches, and adopting the D-InterpIoU loss function, the problems of low recognition accuracy and high false detection rate in underwater target detection are solved, and efficient and stable underwater target detection is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SUZHOU UNIV
- Filing Date
- 2026-04-07
- Publication Date
- 2026-05-05
AI Technical Summary
Existing technologies cannot effectively focus on key targets in underwater target detection and ignore irregular shapes, resulting in low recognition accuracy and high false detection rate.
The YOLOv11 model was improved by replacing the C3K2 module with the C3-CPMSFA module and the C2PSA module with the C2SFA module, introducing the C-PMSFA and C-SFA modules, configuring auxiliary head branches, and using the D-InterpIoU loss function for training.
It improves the recognition accuracy and robustness of underwater target detection, reduces the false detection rate, meets the needs of real-time detection, and maintains efficient operation on devices with limited computing resources.
Smart Images

Figure CN121982509A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of underwater target detection technology, and in particular to a real-time lightweight target detection method and readable storage medium for underwater environments. Background Technology
[0002] Deep learning-based object detection algorithms are mainly divided into two categories: two-stage algorithms and single-stage algorithms. Two-stage algorithms offer high accuracy but are slower, making them suitable for scenarios requiring high precision; representative algorithms include the R-CNN series. Single-stage algorithms are faster and suitable for real-time detection, but their accuracy is slightly lower than that of two-stage algorithms; representative algorithms include the YOLO series and SSD. The YOLO series is widely used in object detection due to its powerful performance, with YOLOv11 demonstrating particularly impressive performance. However, despite its excellent performance, YOLOv11 still encounters problems such as image blurring and occlusion in underwater object detection.
[0003] The traditional YOLOv11 neck C2PSA module relies on clear color and texture features to activate spatial attention, but the degradation of underwater images weakens the effectiveness of this mechanism, causing the attention weight allocation for key targets to fail. The backbone C3k2 module focuses on lightweight design but does not introduce a dedicated feature enhancement module for low contrast, which may increase the false detection rate in underwater target detection environments. The aspect ratio consistency term of the loss function CIoU assumes that the shape distribution of the target is somewhat regular; when encountering elongated or irregular underwater targets, forcing a fit to the aspect ratio may hinder the model from learning the true boundaries of the object.
[0004] In summary, the traditional underwater target recognition method based on YOLOv11 suffers from low recognition accuracy and high false detection rate because it fails to focus on key underwater targets and ignores the irregular shapes of underwater targets during training. Summary of the Invention
[0005] Therefore, the technical problem to be solved by the present invention is to overcome the problems of low recognition accuracy and high false detection rate caused by the inability to focus on key underwater targets in the prior art and the neglect of the irregular shape of underwater targets during training.
[0006] To address the aforementioned technical problems, this invention provides a real-time lightweight target detection method for underwater environments, comprising: The underwater image is input into the improved YOLOv11n model, and after passing through the backbone network, neck network and detection network, the underwater target detection results are obtained. The improvement to the YOLOv11n model includes replacing the C3K2 module in the standard YOLOv11n model with the C3-CPMSFA module; the C3-CPMSFA module includes: The input features are convolved by a convolution unit and then segmented along the channels by a segmentation unit to obtain the first branch features and the second branch features. The first branch features are sequentially passed through multiple cascaded C-PMSFA modules, and the output of the last C-PMSFA module is obtained as the multi-scale feature. The C-PMSFA module divides the input features according to a preset channel ratio, uses context mixing dynamic convolution units of different scales to extract features of the corresponding scale, concatenates them, and then connects them with the input feature residuals for output. After concatenating the multi-scale features with the second branch features, the output is obtained through a 1×1 convolution.
[0007] Preferably, the C-PMSFA module includes: The input features are segmented into half channels of the current channel to obtain the half channel features, the first quarter channel features, and the second quarter channel features corresponding to the input features; Using context-mixed dynamic convolutional units with kernels of 3×3, 5×5, and 7×7 respectively, feature extraction is performed on 1 / 2 channel features, first 1 / 4 channel features, and second 1 / 4 channel features to obtain initial features at the corresponding scales; After concatenating the initial features corresponding to all scales, the concatenated features are obtained by passing them through a 1×1 convolutional unit. The fused and spliced features are residually connected with the input features to obtain the output features of the C-PMSFA module; The first C-PMSFA module inputs features that form the first branch, while the other C-PMSFA modules input features that form the output features of the previous C-PMSFA module.
[0008] Preferably, the improved YOLOv11n model further includes: replacing the C2PSA module in the backbone network with a C2SFA module; the C2SFA module includes: The input features are convolved by a convolutional unit and then segmented along the channels by a segmentation unit to obtain the third branch features and the fourth branch features. The third branch feature is passed through multiple cascaded SFA modules in sequence, and the output of the last SFA module is obtained as the enhanced feature; the SFA module extracts attention features and global context features from the input features. After concatenating the enhanced features with the fourth branch features, the output is obtained through a 1×1 convolution.
[0009] Preferably, the SFA module extracts attention features and global context features from the input features, including: The input features are processed through a self-attention mechanism to obtain attention features; The attention features are residually concatenated with the input features to obtain the spliced attention features. The concatenated attention features are then processed by the FFN module to extract global contextual features, thereby obtaining global attention features. The global attention features and the concatenated attention features are residually connected and used as the output of the SFA module.
[0010] Preferably, the FFN module in the SFA module is replaced with the ADFFN module, wherein the ADFFN module includes: The concatenated attention features of the input are partially convolved and depthwise separable convolved to obtain convolutional features; After applying linear activation to the convolutional features, multiply them element-wise to obtain fused convolutional features. After performing partial convolution on the fused convolutional features, the system is divided into two paths. The first path undergoes a fast Fourier transform to obtain high-channel features. The second path undergoes a series of global average pooling, lightweight MLP, and activation functions along the forward propagation direction to obtain a dynamic weight vector. The dynamic weight vector is multiplied element-wise with the high-channel features to obtain the weighted channel features; The weighted channel features are sequentially subjected to inverse fast Fourier transform and block reconstruction, and are used as the output of the ADFFN module.
[0011] Preferably, the lightweight MLP includes 1×1 convolutions, linear activations, and 1×1 convolutions sequentially connected in the forward propagation direction.
[0012] Preferably, the improved YOLOv11n model further includes configuring an auxiliary head branch in the detection network; the auxiliary head branch includes: The downsampled features output by the backbone network are sorted from largest to smallest according to the downsampling factor, and the top three downsampled features are used as the input of the auxiliary head branch. The first downsampled feature is subjected to a 1×1 convolution and a 2x upsampled feature to obtain the first upsampled feature. After performing a residual concatenation between the second downsampled feature and the first upsampled feature, perform upsampling by a factor of 2 to obtain the second upsampled feature; After performing a residual connection between the third downsampled feature and the second upsampled feature, the convolutional upsampled feature is obtained by performing a depthwise separable convolution. The convolutional upsampled features are input into the auxiliary head, and the predicted labels are output.
[0013] Preferably, improving the training of the YOLOv11n model includes: Obtain the predicted labels from the detection head and compare them with the true labels to construct a fine-grained loss function; Obtain the predicted labels from the auxiliary head and compare them with the true labels to construct a coarse-grained loss. Calculate the weighted sum of fine-grained loss and coarse-grained loss to obtain the total loss function, train the improved YOLOv11n model, and obtain the trained improved YOLOv11n model.
[0014] Preferably, the total loss function , is represented as: ; in, Indicates the branch number where the detection head is located. , Indicates the first Fine-grained loss of each detection head Indicates the first Predicted labels for each detection head. Indicates the true label; Indicates the auxiliary weight coefficient. This indicates the coarse-grained loss of the auxiliary head. This indicates the predicted label for the auxiliary head.
[0015] This embodiment provides a computer-readable storage medium storing a computer program thereon, which, when executed, implements the steps of the real-time lightweight target detection method for underwater environments as described above.
[0016] Compared with the prior art, the above-described technical solution of the present invention has the following advantages: The real-time lightweight target detection method for underwater environments described in this invention improves upon the standard YOLOv11n model by replacing the C3K2 module with the C3-CPMSFA module. The C3-CPMSFA module forcibly splits the input features into two parts: one part is directly retained to the lower layer through skip connections, while the other part enters the C-CPMSFA module for deep dynamic context blending extraction. This direct, cross-stage gradient flow ensures that the most original weak features are not swallowed up by complex dynamic operators, greatly improving the convergence speed and stability of the model on underwater datasets.
[0017] The top-down global guidance mechanism in the C-PMSFA module can effectively strip away target camouflage and eliminate the ambiguity of local features. At the same time, by using the Partial mechanism, ContMix dynamic convolution is applied only on half of the channels, so that the computationally expensive global context dynamic extraction is applied only to a very small proportion of the core feature maps. This achieves the technical effect of having the dynamic perception capability of a large model without slowing down the speed.
[0018] This invention introduces the C2SFA module into YOLOv11 to replace the original C2PSA module, achieving a key leap from single spatial perception to joint spatial-frequency adaptive perception. In real underwater environments, the C2SFA module extends feature processing to the frequency domain through its built-in ADFFN module, dynamically generating frequency domain masks using a global context-aware branch. This endows the network with the ability to adaptively adjust according to water turbidity, accurately filtering out specific frequency noise representing backscattering, effectively stripping low-frequency water background and enhancing weak target edge features. It achieves high-precision detail recovery even at extremely low contrast, greatly improving the model's robustness and generalization ability when dealing with targets of different scales, occlusion, and variable aquatic environments.
[0019] The auxiliary head of this invention starts with the feature with the largest downsampling ratio and performs two successive upsampling steps, sequentially connecting it with mid-level and shallow-level features via residuals. This achieves semantic alignment and complementary enhancement between features of different scales. This successive residual fusion strategy ensures that details that may be lost during downsampling are effectively compensated for, while avoiding semantic misalignment caused by direct splicing of multi-scale features, effectively improving the perception capability of multi-scale small targets. Furthermore, the use of a single auxiliary head for supervision eliminates the multi-head gradient conflict problem, providing an efficient and stable auxiliary supervision signal for underwater target detection. Attached Figure Description
[0020] To make the content of this invention easier to understand, the invention will be further described in detail below with reference to specific embodiments and accompanying drawings, wherein: Figure 1 This is a schematic diagram of the improved YOLOv11n model of the real-time lightweight target detection method for underwater environments of the present invention; Figure 2 This is a schematic diagram of the C3-CPMSFA module; Figure 3 This is a schematic diagram of the C2SFA module; Figure 4 This is a schematic diagram of the auxiliary head principle. Detailed Implementation
[0021] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. However, the embodiments described are not intended to limit the present invention.
[0022] Reference Figure 1 The diagram shows an improved YOLOv11n model of the real-time lightweight target detection method for underwater environments according to the present invention; specifically, the detection process includes: The underwater image is input into the improved YOLOv11n model, and after passing through the backbone network, neck network and detection network, the underwater target detection results are obtained. The improvement to the YOLOv11n model includes replacing the C3K2 module in the standard YOLOv11n model with the C3-CPMSFA module; the C3-CPMSFA module includes: The input features are convolved by a convolutional unit and then segmented along the channels by a segmentation unit (SPLIT) to obtain the first branch features and the second branch features. The first branch features are sequentially passed through multiple cascaded C-PMSFA modules, and the output of the last C-PMSFA module is obtained as the multi-scale feature. The C-PMSFA module divides the input features according to a preset channel ratio, uses context mixing dynamic convolution units of different scales to extract features of the corresponding scale, concatenates them, and then connects them with the input feature residuals for output. After concatenating the multi-scale features with the second branch features, the output is obtained through a 1×1 convolution.
[0023] In this embodiment, the Bottleneck module in the C3K2 module of standard YOLOv11, which is false when C3K=False, is replaced with the C-PMSFA (Context-aware Partial Multi-Scale Feature Aggregation) module, thus proposing the C3-CPMSFA (Cross-Stage Partial Context-aware Multi-Scale Feature Aggregation) module; refer to Figure 2 The diagram shows the structure of the C3-CPMSFA module. The C3-CPMSFA module introduces a spatial attention mechanism through partial convolution and feature fusion. It uses feature pooling to focus the model on key regions of the image, thereby enhancing the detection capability of small or occluded targets.
[0024] Specifically, the C-PMSFA module includes: The input features are segmented into half channels of the current channel to obtain the half channel features, the first quarter channel features, and the second quarter channel features corresponding to the input features; Using context-mixed dynamic convolutional units with kernels of 3×3, 5×5, and 7×7 respectively, feature extraction is performed on 1 / 2 channel features, first 1 / 4 channel features, and second 1 / 4 channel features to obtain initial features at the corresponding scales; After concatenating the initial features corresponding to all scales, the concatenated features are obtained by passing them through a 1×1 convolutional unit. The fused and spliced features are residually connected with the input features to obtain the output features of the C-PMSFA module; The first C-PMSFA module inputs features that form the first branch, while the other C-PMSFA modules input features that form the output features of the previous C-PMSFA module.
[0025] In this embodiment, the C-PMSFA module includes a 3x3, 5x5, and 7x7 ContMix module and a 1x1 convolutional module. The PartialConv module extracts multi-scale feature information from half of the input channels, with half read by the 3x3 branch, one-quarter by the 5x5 branch, and the remaining one-quarter by the 7x7 branch. Finally, the 1x1 convolutional module fuses the features at different scales and uses residual connections to add the input features to the processed features. The proportion of the convolutional portion can be adjusted according to actual needs; finally, the information at different scales is fused and residual connections are made by concatenating and adding the 1x1 convolutional module.
[0026] Specifically, due to severe light attenuation and color distortion in the underwater environment, benthic organisms such as sea cucumbers and sea urchins can appear extremely similar to the reefs they are attached to in terms of local texture and color. Traditional static 3x3, 5x5, and 7x7 convolutions can only perceive pixels within a fixed receptive field. In the extremely blurry underwater environment, local convolutions can easily background the target, leading to missed detections. However, the ContMix operator extracts global contextual information from the entire image before performing local convolution operations. This means that when the 3x3 branch processes a local patch of a suspected target, it already knows the surrounding water environment, light distribution, and seabed topology. This top-down global guidance mechanism can effectively strip away camouflage and eliminate ambiguity in local features. Furthermore, while one half of the channels performs multi-scale feature extraction, the other half remains unchanged to maintain the basic feature flow. This allows the model to achieve the extremely expensive "global dynamic perception" capability while maintaining strict control over the overall FLOPs and parameter count, fully meeting the requirements of real-time inference (i.e., high FPS) for underwater edge devices.
[0027] This embodiment nests the C-PMSFA dynamic multi-scale module into the standard YOLOv11 C3K2 architecture, replacing the Bottleneck module to form a completely new C3-CPMSFA module. Since targets in underwater images often have blurred edges and extremely low contrast, representing typical "weak features," ContMix, in the early stages of training, is still exploring global context weights, which can easily lead to gradient vanishing or destruction of these weak underwater bottom-layer features during backpropagation. The core of C3K2 is the CSP (Cross Stage Partial) architecture, where input features are forcibly split into two: one part is directly preserved to the lower level through skip connections, while the other part enters C-PMSFA for deep dynamic context mixing extraction. This direct cross-stage gradient flow ensures that the original weak features are not swallowed up by complex dynamic operators, and are directly preserved to the lower level through skip connections, preventing gradient vanishing of underwater lower-level features during backpropagation, greatly improving the model's convergence speed and stability on underwater datasets. Simultaneously, this nested architecture maximizes subtraction: first, the outer C3 architecture performs channel dimensionality reduction using 1×1 convolutions before entering Bottleneck; second, after entering the inner C-PMSFA, the Partial mechanism is used again to apply 3×3, 5×5, and 7×7 ContMix dynamic convolutions only on half of the channels. This means that the computationally expensive global context dynamic extraction is actually only applied to a very small proportion of the core feature maps. This structure allows the entire detector to possess the dynamic perception capabilities of a large model without slowing down.
[0028] Based on the above embodiments, in this embodiment of the invention, the improved YOLOv11n model further includes: replacing the C2PSA module in the backbone network with a C2SFA module; refer to Figure 3 The diagram shown is a schematic of the C2SFA module; the C2SFA module includes: The input features are convolved by a convolutional unit and then segmented along the channels by a segmentation unit to obtain the third branch features and the fourth branch features. The third branch feature is passed through multiple cascaded SFA modules in sequence, and the output of the last SFA module is obtained as the enhanced feature; the SFA module extracts attention features and global context features from the input features. After concatenating the enhanced features with the fourth branch features, the output is obtained through a 1×1 convolution.
[0029] The SFA module extracts attention features and global context features from the input features, including: The input features are processed through a self-attention mechanism to obtain attention features; The attention features are residually concatenated with the input features to obtain the spliced attention features. The concatenated attention features are then processed by the FFN module to extract global contextual features, thereby obtaining global attention features. The global attention features and the concatenated attention features are residually connected and used as the output of the SFA module.
[0030] Specifically, the traditional FFN in the PSA module of the original C2PSA module in standard YOLOv11 is insufficient for extracting high-frequency information, while underwater targets rely on such features. Furthermore, the mid-range Fast Fourier Transform (FFT) has a high computational burden and poor real-time performance when processing high-channel features. Therefore, for underwater target detection environments, the EDFFN approach is applied to YOLOv11. However, since the standard EDFFN uses a globally learned quantization matrix W to determine which frequency information to retain, the degradation degree varies drastically with depth and water quality in underwater scenarios. Therefore, this embodiment can extract spatial domain features before entering the FFT and dynamically generate the original quantization matrix W using a lightweight global context extraction branch. The specific process includes: After the second PConv in the original image and before the FFT, a bypass branch is introduced. At this point, the feature map contains spatial information that has undergone sufficient interaction. Global average pooling (GAP) is used to compress the spatial dimension of the feature map, stripping away local location information and retaining only the global distribution, i.e., the overall turbidity and illumination degradation features of the current image, outputting a channel vector. This vector is then input into a lightweight MLP, typically consisting of two 1x1 convolutions with a GELU activation function sandwiched in between, forming a bottleneck structure of dimensionality reduction and subsequent dimensionality enhancement to reduce the number of parameters. After passing through the MLP, the Sigmoid function is used to map the output to the (0,1) interval, forming a dynamic weight vector W. After the backbone features are transformed to the frequency domain by FFT, they are multiplied element-wise with this dynamically generated W (using a broadcast mechanism to extend to full resolution), adaptively suppressing frequency channels representing scattering noise and enhancing frequency channels representing target details.
[0031] In this embodiment, the improved EDFFN module with dynamically generated quantization matrix W is called ADFFN (Adaptive Discriminative Feed-Forward Network), the improved PSA module is called SFA (Spatial-Frequency Attention), and the final improved C2PSA module is called C2SFA (Cross-Stage Spatial-Frequency Attention).
[0032] In this embodiment, the FFN module in the SFA module is replaced with the ADFFN module, wherein the ADFFN module includes: The concatenated attention features of the input are partially convolved and depthwise separable convolved to obtain convolutional features; After applying linear activation to the convolutional features, multiply them element-wise to obtain fused convolutional features. After performing partial convolution on the fused convolutional features, the system is divided into two paths. The first path undergoes a fast Fourier transform to obtain high-channel features. The second path undergoes a series of global average pooling, lightweight MLP, and activation functions along the forward propagation direction to obtain a dynamic weight vector. The dynamic weight vector is multiplied element-wise with the high-channel features to obtain the weighted channel features; The weighted channel features are sequentially subjected to inverse fast Fourier transform and block reconstruction, and are used as the output of the ADFFN module.
[0033] The lightweight MLP includes 1×1 convolutions, linear activations, and 1×1 convolutions sequentially connected in the forward propagation direction.
[0034] Specifically, the C2SFA module was introduced into YOLOv11 to replace the original C2PSA, achieving a crucial leap from single spatial perception to joint spatial-frequency adaptive perception, perfectly addressing the complex physical degradation challenges faced by underwater target detection. In real underwater environments, severe light scattering and suspended particles generate dense backscattering noise, while light attenuation leads to extremely low contrast between the target and background, resulting in severely blurred edges. Traditional C2PSA, relying solely on spatial domain attention, struggles to effectively distinguish high-frequency edge features of the target from high-frequency noise from suspended matter, easily amplifying it and causing false positives or false negatives. In contrast, C2SFA extends feature processing to the frequency domain through its built-in ADFFN module, dynamically generating frequency domain masks using a global context-aware branch. This mechanism endows the network with the ability to adaptively adjust based on the current water turbidity, accurately filtering out specific frequency noise representing backscattering, effectively stripping away low-frequency water background, and enhancing weak target edge features, thereby achieving high-precision detail recovery even in extremely low contrast conditions. Furthermore, this spatial-frequency dual-domain joint perception mode, combining spatial attention localization with frequency-domain adaptive filtering, breaks through the limitations of a single information dimension, greatly improving the model's robustness and generalization ability when dealing with targets of different scales, occlusion, and variable aquatic environments. More importantly, C2SFA perfectly balances lightweight design and real-time requirements in its architecture; it abandons the traditional approach of performing high-cost Fourier transforms in the feature channel amplification stage, and innovatively performs frequency domain filtering at the end of the FFN. Moreover, the dynamic mask generation branch introduces only a very small number of parameters (global average pooling and 1x1 convolution). This allows C2SFA to achieve powerful underwater anti-interference and feature extraction capabilities while maintaining almost the same computational cost as the standard C2PSA, making it extremely suitable for deployment on edge devices such as underwater robots with strictly limited computing power to perform high-frame-rate real-time detection tasks.
[0035] Based on the above embodiments, in this embodiment of the invention, the improved YOLOv11n model further includes configuring an auxiliary head branch in the detection network; the auxiliary head branch includes: The downsampled features output by the backbone network are sorted from largest to smallest according to the downsampling factor, and the top three downsampled features are used as the input of the auxiliary head branch. The first downsampled feature is subjected to a 1×1 convolution and a 2x upsampled feature to obtain the first upsampled feature. After performing a residual concatenation between the second downsampled feature and the first upsampled feature, perform upsampling by a factor of 2 to obtain the second upsampled feature; After performing a residual connection between the third downsampled feature and the second upsampled feature, the convolutional upsampled feature is obtained by performing a depthwise separable convolution. The convolutional upsampled features are input into the auxiliary head, and the predicted labels are output.
[0036] Reference Figure 4 The diagram illustrates the principle of the auxiliary head. Specifically, underwater environments suffer from severe blue-green light absorption and forward / backward scattering, resulting in images filled with suspended objects and extremely low contrast. Simply porting the YOLOv7 auxiliary head to YOLOv11 is problematic because the auxiliary head only receives shallow features. Shallow networks easily misinterpret this optical noise as the edges or textures of the target, causing the original shallow auxiliary head to propagate a large number of erroneous noise gradients when generating coarse label losses. This embodiment overcomes the defect of simply porting multiple YOLOv7 auxiliary heads, which easily leads to shallow networks misinterpreting optical noise as target gradients. It reconstructs a single high-resolution auxiliary head, called the CSMS-Aux Head (Cross-Stage Multi-Scale Auxiliary Head). Specific improvements include: First, using 1x1 Conv for dimensionality reduction (32x and 16x channels are typically large); before fusion, a uniform 1x1 convolution is used to compress the number of channels to a small fixed value (e.g., 128), which is crucial for ensuring the lightweight nature of the entire module. Second, to maximize the supervision effect on small targets, this embodiment must uniformly upsample and align the fused features to a high-resolution scale of 8x. In object detection, 8x means the original image is reduced by 8 times. Compared to 16x and 32x, 8x retains the richest spatial geometric details. Underwater scenes (such as sea urchins and scallops) typically have extremely small and dense targets. On 16x or 32x feature maps, these small targets may only be less than one pixel, and the information is completely lost. Third, element-wise addition is used instead of the commonly used concat. Concat doubles the number of channels, leading to a surge in subsequent computation, while element-wise addition can perfectly maintain the thin feature dimension while fusing features. Fourth, depthwise convolution (DWConv) is finally used. Upsampling can cause aliasing. Adding a lightweight 3x3 depthwise convolution layer before the output to the single auxiliary head can smoothly fuse the features with almost no increase in parameters, completing the final semantic fusion.
[0037] This embodiment reconstructs the independent multi-auxiliary heads of the original YOLOv7 into a single CSMS-AuxHead under the YOLOv11 architecture, demonstrating a systematic performance leap in the field of lightweight underwater target detection. When dealing with severe underwater optical degradation (such as the "underwater snowflake" effect caused by light scattering and suspended matter), CSMS-Aux overcomes the limitation of traditional shallow auxiliary heads being prone to overfitting to environmental noise. It feeds back the global noise-resistant semantics of the deep network to the high-resolution shallow layer from top to bottom, achieving feature-level semantic denoising before gradient backpropagation, thus strongly guiding the backbone network to actively filter out background interference in the early stages of feature extraction. Secondly, considering the characteristics of underwater organisms such as sea cucumbers and sea urchins—small scale, dense distribution, and strong environmental camouflage—this structure performs cross-scale deep fusion of high-resolution fine textures, local contours, and low-resolution contextual logic; this joint global and local perception capability gives the model strong robustness in breaking through camouflage, significantly improving the recall rate for multi-scale small targets. At the underlying optimization mechanism level, CSMS-Aux perfectly resolves the multi-head label matching conflicts that are easily triggered by the YOLOv11 Task Alignment Allocator (TAL) when facing underwater blurred features. By converging the three parallel supervision constraints into a single super auxiliary head, the network completely eliminates the tearing and divergence of internal gradients, outputting highly unified and clear supervision signals, significantly accelerating the convergence process of the model on underwater datasets. Finally, from the perspective of hardware efficiency and practical deployment engineering requirements, CSMS-Aux relies on lightweight operators such as element-wise addition and depthwise separable convolution to completely prune redundant detection branches. This not only maintains zero additional computational burden on the inference side but also achieves a precipitous drop in memory overhead on the training side, enabling it to support model training and efficient iteration with large amounts of data even in laboratory server environments with limited computing power.
[0038] Specifically, improvements to the training of the YOLOv11n model include: Obtain the predicted labels from the detection head and compare them with the true labels to construct a fine-grained loss function; Obtain the predicted labels from the auxiliary head and compare them with the true labels to construct a coarse-grained loss. Calculate the weighted sum of fine-grained loss and coarse-grained loss to obtain the total loss function, train the improved YOLOv11n model, and obtain the trained improved YOLOv11n model.
[0039] Among them, the total loss function , is represented as: ; in, Indicates the branch number where the detection head is located. , Indicates the first Fine-grained loss of each detection head Indicates the first Predicted labels for each detection head. Indicates the true label; Indicates the auxiliary weight coefficient. This indicates the coarse-grained loss of the auxiliary head. This indicates the predicted label for the auxiliary head.
[0040] This embodiment uses the D-InterpIoU loss function instead of the CIoU loss function in YOLOv11. Due to its dynamic adaptive optimization mechanism, pure IoU maximization objective, and excellent gradient stability, this function offers advantages in handling small targets and irregular shapes, providing more accurate and stable localization capabilities for underwater detection models.
[0041] Based on the above embodiments, this embodiment provides a computer-readable storage medium storing a computer program thereon, which, when executed, implements the steps of the real-time lightweight target detection method for underwater environments as described above.
[0042] This invention proposes a real-time lightweight target detection algorithm (CUE-YOLO) for complex underwater environments based on an improved YOLOv11. Through multi-dimensional module reconstruction and innovation, it systematically overcomes the detection challenges caused by light attenuation, color distortion, and scattering from suspended objects in underwater images, achieving an effective balance between detection accuracy and inference speed. First, this invention constructs a C3-CPMSFA module in the feature extraction stage. By introducing the ContMix operator, which includes a global context-aware mechanism, it pre-acquires information about the surrounding water environment and light distribution before performing local feature extraction. This effectively removes the environmental camouflage of benthic organisms, eliminates the ambiguity of local features, and significantly reduces the false negative rate. Simultaneously, this module, combined with the Partial mechanism, performs dynamic multi-scale feature extraction only on certain channels. Combined with the cross-stage gradient flow of the CSP architecture, it not only strictly controls the overall computational load and parameter count to meet the real-time inference requirements of edge devices but also ensures that the extremely blurred original weak features underwater are not destroyed during backpropagation, greatly improving the model's convergence speed and stability. Secondly, to address the complex backscattering noise problem underwater, this invention designs a C2SFA module to replace the original C2PSA architecture, achieving a leap from single spatial perception to joint adaptive perception in both spatial and frequency domains. This module incorporates an Adaptive Discriminative Feedforward Network (ADFFN), which dynamically generates a frequency domain quantization matrix mask through global average pooling and a lightweight MLP, endowing the model with the ability to adaptively adjust according to water turbidity. This mechanism can accurately filter out specific frequency noise representing backscattering, while simultaneously stripping away low-frequency water background and enhancing weak target edge features, achieving high-precision detail recovery even at extremely low contrast, with computational costs almost identical to the original module. Furthermore, to further eliminate background interference and improve the recall rate of small, dense targets, this invention reconstructs the CSMS-Aux Head auxiliary detection head. This structure feeds back the global noise-resistant semantics of the deep network from top to bottom to the shallow high-resolution features, achieving semantic denoising in the early stages of feature extraction and effectively guiding the backbone network to actively filter out optical noise interference. Combined with a unified feature upsampling to an 8-fold high-resolution scale and an element-wise addition fusion strategy, this auxiliary head fully preserves the local spatial geometric details of extremely small targets. This not only eliminates the multi-head label matching conflict that the Task Alignment Allocator (TAL) is prone to triggering when facing ambiguous features, but also achieves a significant reduction in training memory overhead while maintaining zero additional inference computation burden. Finally, this invention uses the D-InterpIoU loss function instead of the traditional CIoU loss function, abandoning the forced fitting of regular shapes and avoiding the obstacle of aspect ratio consistency terms to learning the true boundaries of elongated or irregular underwater targets. With its dynamic adaptive optimization mechanism and excellent gradient stability, this loss function provides the underwater detection model with more accurate and stable localization capabilities.In summary, this invention endows a lightweight detector with powerful global dynamic perception and adaptive anti-interference capabilities without significantly increasing hardware computing power, and comprehensively improves the robustness and generalization performance of the model in complex and variable aquatic environments.
[0043] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0044] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0045] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0046] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0047] Obviously, the above embodiments are merely illustrative examples for clear explanation and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all possible implementations here. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.
Claims
1. A real-time lightweight target detection method for underwater environments, characterized in that, include: The underwater image is input into the improved YOLOv11n model, and after passing through the backbone network, neck network and detection network, the underwater target detection results are obtained. The improvement to the YOLOv11n model includes replacing the C3K2 module in the standard YOLOv11n model with the C3-CPMSFA module; the C3-CPMSFA module includes: The input features are convolved by a convolution unit and then segmented along the channels by a segmentation unit to obtain the first branch features and the second branch features. The first branch features are sequentially passed through multiple cascaded C-PMSFA modules, and the output of the last C-PMSFA module is obtained as the multi-scale feature. The C-PMSFA module divides the input features according to a preset channel ratio, uses context mixing dynamic convolution units of different scales to extract features of the corresponding scale, concatenates them, and then connects them with the input feature residuals for output. After concatenating the multi-scale features with the second branch features, the output is obtained through a 1×1 convolution.
2. The real-time lightweight target detection method for underwater environments according to claim 1, characterized in that, The C-PMSFA module includes: The input features are segmented into half channels of the current channel to obtain the half channel features, the first quarter channel features, and the second quarter channel features corresponding to the input features; Using context-mixed dynamic convolutional units with kernels of 3×3, 5×5, and 7×7 respectively, feature extraction is performed on 1 / 2 channel features, first 1 / 4 channel features, and second 1 / 4 channel features to obtain initial features at the corresponding scales; After concatenating the initial features corresponding to all scales, the concatenated features are obtained by passing them through a 1×1 convolutional unit. The fused and spliced features are residually connected with the input features to obtain the output features of the C-PMSFA module; The first C-PMSFA module inputs features that form the first branch, while the other C-PMSFA modules input features that form the output features of the previous C-PMSFA module.
3. The real-time lightweight target detection method for underwater environments according to claim 1, characterized in that, The improved YOLOv11n model also includes: replacing the C2PSA module in the backbone network with a C2SFA module; the C2SFA module includes: The input features are convolved by a convolutional unit and then segmented along the channels by a segmentation unit to obtain the third branch features and the fourth branch features. The third branch feature is passed through multiple cascaded SFA modules in sequence, and the output of the last SFA module is obtained as the enhanced feature; the SFA module extracts attention features and global context features from the input features. After concatenating the enhanced features with the fourth branch features, the output is obtained through a 1×1 convolution.
4. The real-time lightweight target detection method for underwater environments according to claim 3, characterized in that, The SFA module extracts attention features and global context features from the input features, including: The input features are processed through a self-attention mechanism to obtain attention features; The attention features are residually concatenated with the input features to obtain the spliced attention features. The concatenated attention features are then processed by the FFN module to extract global contextual features, thereby obtaining global attention features. The global attention features and the concatenated attention features are residually connected and used as the output of the SFA module.
5. The real-time lightweight target detection method for underwater environments according to claim 4, characterized in that, Replace the FFN module in the SFA module with the ADFFN module, wherein the ADFFN module includes: The concatenated attention features of the input are partially convolved and depthwise separable convolved to obtain convolutional features; After applying linear activation to the convolutional features, multiply them element-wise to obtain fused convolutional features. After performing partial convolution on the fused convolutional features, the system is divided into two paths. The first path undergoes a fast Fourier transform to obtain high-channel features. The second path undergoes a series of global average pooling, lightweight MLP, and activation functions along the forward propagation direction to obtain a dynamic weight vector. The dynamic weight vector is multiplied element-wise with the high-channel features to obtain the weighted channel features; The weighted channel features are sequentially subjected to inverse fast Fourier transform and block reconstruction, and are used as the output of the ADFFN module.
6. The real-time lightweight target detection method for underwater environments according to claim 5, characterized in that, The lightweight MLP comprises 1×1 convolutions, linear activations, and 1×1 convolutions sequentially connected in the forward propagation direction.
7. The real-time lightweight target detection method for underwater environments according to claim 1, characterized in that, The improved YOLOv11n model also includes configuring an auxiliary head branch in the detection network; The auxiliary head branch includes: The downsampled features output by the backbone network are sorted from largest to smallest according to the downsampling factor, and the top three downsampled features are used as the input of the auxiliary head branch. The first downsampled feature is subjected to a 1×1 convolution and a 2x upsampled feature to obtain the first upsampled feature. After performing a residual concatenation between the second downsampled feature and the first upsampled feature, perform upsampling by a factor of 2 to obtain the second upsampled feature; After performing a residual connection between the third downsampled feature and the second upsampled feature, the convolutional upsampled feature is obtained by performing a depthwise separable convolution. The convolutional upsampled features are input into the auxiliary head, and the predicted labels are output.
8. The real-time lightweight target detection method for underwater environments according to claim 7, characterized in that, Improvements to the training of the YOLOv11n model include: Obtain the predicted labels from the detection head and compare them with the true labels to construct a fine-grained loss function; Obtain the predicted labels from the auxiliary head and compare them with the true labels to construct a coarse-grained loss. Calculate the weighted sum of fine-grained loss and coarse-grained loss to obtain the total loss function, train the improved YOLOv11n model, and obtain the trained improved YOLOv11n model.
9. The real-time lightweight target detection method for underwater environments according to claim 8, characterized in that, Total loss function , is represented as: ; in, Indicates the branch number where the detection head is located. , Indicates the first Fine-grained loss of each detection head Indicates the first Predicted labels for each detection head. Indicates the true label; Indicates the auxiliary weight coefficient. This indicates the coarse-grained loss of the auxiliary head. This indicates the predicted label for the auxiliary head.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed, it implements the steps of the real-time lightweight target detection method for underwater environments as described in any one of claims 1 to 9.