Underwater target detection method and system based on improved YOLOv8n
By improving the YOLOv8n model, employing a lightweight visual Transformer network and an online reparameterized convolution module, and combining a dynamic focusing loss function and an uncertainty-aware adaptive fusion mechanism, the problems of image quality, feature extraction, and multi-scale adaptability in underwater target detection are solved, achieving high-precision and efficient underwater target detection.
Patent Information
- Application Number
- CN202511389420.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-26
- Publication Date
- 2026-01-13
AI Technical Summary
Traditional YOLOv8n models suffer from problems in underwater environments, including image quality bottlenecks, insufficient backbone feature extraction capabilities, poor feature fusion efficiency and multi-scale adaptability, and weak adaptability of loss functions to underwater sample quality, resulting in low detection accuracy and poor real-time performance.
A lightweight visual Transformer network is used as the backbone feature extraction network. An online reparameterized convolutional module is used to replace the standard convolutional module. A dynamic focusing loss function and an uncertainty-aware adaptive fusion mechanism are introduced. Preprocessing is performed in conjunction with an underwater optical imaging physical model to optimize feature fusion and the detection head mechanism.
It significantly improves the accuracy and robustness of underwater target detection, while maintaining a lightweight model and enhancing real-time performance, enabling efficient and accurate target detection in complex underwater environments.
Smart Images

Figure CN121330477A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer vision and artificial intelligence, in particular to an underwater target detection method and system based on improved YOLOv8n, which can be applied to marine engineering exploration, underwater ecological monitoring, underwater rescue operation, underwater equipment operation and maintenance, etc. scenes, for realizing high-precision and high-efficiency automatic detection of underwater targets (such as marine organisms, engineering components, obstacles, rescue targets, etc.). BACKGROUND
[0002] Underwater target detection is a core supporting technology for marine development and underwater operation, which extracts target features in underwater images through computer vision algorithms to realize target positioning, classification and state judgment, directly affecting the efficiency of marine resource exploration, ecological protection accuracy and underwater operation safety. With the development of deep learning technology, real-time target detection models based on the YOLO (You Only Look Once) series have become the mainstream technology solution for underwater target detection due to their consideration of speed and accuracy. Among them, YOLOv8n, as a lightweight model, is more suitable for the hardware limitations of underwater embedded devices (such as underwater robots and portable detection devices) due to its small parameter quantity and low computational overhead.
[0003] However, the special underwater environment (light attenuation, water scattering, color distortion) and the defects of existing technologies result in the following key problems of the traditional YOLOv8n model in underwater scenes, which are difficult to meet the actual application requirements:
[0004] Underwater image quality bottleneck leads to weak detection foundation: after underwater light is absorbed and scattered by water, the image is prone to problems such as low contrast, color shift (such as blue-green color shift), and blurred details; existing preprocessing methods either rely only on physical models (such as dark channel prior) to estimate transmission maps and background light, ignoring the dynamic difference of water scattering, or rely on ordinary convolutional neural networks (CNN) for enhancement, without targeted optimization of severely scattered areas, resulting in images after preprocessing still unable to effectively preserve target features.
[0005] The backbone feature extraction capability and the lightweight demand are imbalanced: the traditional YOLOv8n uses CNN as the backbone network, which is lightweight but lacks the ability to capture global features of underwater blurred targets, easily losing key features of small targets (such as small marine organisms) or low-contrast targets (such as engineering components similar in color to the background); if a heavy visual Transformer network is used to improve feature extraction capability, it will significantly increase computational overhead, which cannot adapt to the power limitations of underwater embedded devices.
[0006] Feature fusion efficiency and multi-scale adaptability are insufficient: the underwater target has the characteristics of "large scale difference" (such as from centimeter-level organisms to meter-level equipment) and "serious feature overlap" (such as target overlap with water grass and sediment), the feature fusion network of the traditional YOLOv8n adopts a standard convolution module, which has problems of parameter redundancy and poor dynamic feature fusion, and cannot efficiently integrate target features of different scales, resulting in uneven multi-scale target detection accuracy.
[0007] The loss function is weakly adapted to the quality of the underwater sample: the target in the underwater image is easy to form "ordinary quality samples" (such as partially occluded and edge blurred targets) due to scattering and occlusion, the boundary box regression loss function (such as CIoU, DIoU) used by the traditional YOLOv8n has too high gradient distribution weight for high-quality samples (clear and complete targets), and pays insufficient attention to ordinary quality samples, resulting in low detection accuracy of the model for non-ideal samples commonly seen in underwater environments.
[0008] Multi-scale feature reliability is not included in the detection head optimization: the traditional YOLOv8n detection head uses fixed weight fusion for multi-scale feature maps output by the backbone network and the feature fusion network, without considering the reliability differences of different scale feature maps (such as small scale feature maps being easily disturbed by noise and large scale feature maps easily losing details), resulting in a decline in the effectiveness of the fused features, which further affects the accuracy of target classification and boundary box regression.
[0009] To solve the above problems, the prior art has not formed a solution that fully adapts to underwater scenes. Therefore, it is urgent to build an underwater target detection technology based on improved YOLOv8n, which optimizes the preprocessing method, backbone network, feature fusion module, loss function and detection head mechanism to realize high-precision and high-efficiency detection of underwater targets and meet the actual needs of marine engineering, ecological monitoring and other scenes. SUMMARY
[0010] The present application provides an underwater target detection method and system based on improved YOLOv8n, which can more effectively extract deep semantic features of underwater target images by using a lightweight visual Transformer network as a backbone feature extraction network; uses an online reparameterization convolution module to replace the standard convolution module in the feature fusion network, which can improve the inference speed while maintaining the model accuracy; uses a dynamic focus loss function as the boundary box regression loss function, which can better focus on difficult example samples and improve the boundary box regression accuracy. The improved YOLOv8n underwater target detection method and system can realize efficient and accurate detection of targets in complex underwater environments.
[0011] The present application aims at the technical pain point of low target detection accuracy and poor real-time performance caused by complex underwater environment, and proposes a systematic improvement scheme. This method is not an isolated improvement of YOLOv8n, but through the coordinated design and linkage optimization of preprocessing, backbone network, feature fusion, loss function and detection head mechanism, it solves a series of related problems such as poor underwater image quality, target scale diversity, uneven sample quality, and feature reliability fluctuation, and finally significantly improves the detection accuracy and robustness while keeping the model lightweight. Specifically, for the single defect of existing preprocessing methods, the present application combines the prior knowledge of the physical model and the adaptive correction ability of lightweight CNN in the preprocessing stage, and solves the problem of underwater image quality through three-image adaptive fusion; the backbone network adopts EfficientformerV2_S0, which solves the problem of imbalance between feature extraction capability and lightweight; the feature fusion network adopts C2f_OREPA structure, which solves the problem of insufficient multi-scale adaptability; the loss function adopts Wise-IoUv3, which solves the problem of insufficient attention to ordinary quality samples; the detection head introduces an uncertainty perception mechanism, which solves the problem of unoptimized multi-scale feature reliability.
[0012] The present application provides an underwater target detection method based on improved YOLOv8n, comprising:
[0013] Obtaining the preprocessed underwater target image, the preprocessing at least includes underwater image enhancement;
[0014] Using the improved YOLOv8n network model to perform feature extraction and target detection on the underwater target image; wherein the improved YOLOv8n network model is constructed by the following ways: using a lightweight visual Transformer network as the backbone feature extraction network of the improved YOLOv8n network model; using an online reparameterization convolution module to replace a standard convolution module in the feature fusion network of the improved YOLOv8n network model; using a dynamic focusing loss function as the bounding box regression loss function of the improved YOLOv8n network model; introducing an uncertainty perception adaptive fusion mechanism in the detection head part of the improved YOLOv8n network model to perform fusion processing on the multi-scale feature maps;
[0015] Outputting the target detection result.
[0016] Further, obtaining the preprocessed underwater target image comprises the following steps:
[0017] Based on an underwater optical imaging physical model, input an original image, estimate a background light vector and a transmission map of the original image, and obtain a model generated image; the method for estimating the background light vector is: in the brightest pixel area in the image, the average brightness and the standard deviation of the image block are calculated to obtain the background light vector through screening; the method for estimating the transmission map is: based on the dark channel priori and / or the fog line theory, the transmission map is inversely deduced;
[0018] Input the background light vector and the transmission map into a lightweight convolutional neural network (CNN) for optimization correction to obtain corrected physical parameters; based on the corrected physical parameters, color correction is performed through reverse physical model reconstruction to obtain a color corrected image; the lightweight convolutional neural network (CNN) adopts an attention mechanism and focuses on optimizing the areas in the image that are severely affected by scattering; the attention mechanism is a convolution block attention module;
[0019] Adaptive weighted fusion is performed on the original image, the model generated image and the color corrected image to generate an underwater target image.
[0020] Further, the lightweight visual Transformer network is an EfficientformerV2_S0 network.
[0021] Further, the backbone feature extraction network comprises a feature preprocessing unit (Stem) module, a Stage0 module, a feature embedding unit (Embedding) module, a Stage1 module, an Embedding module, a Stage2 module, an Embedding module, a Stage3 module and a pooling operation unit (SPPF) module connected in sequence.
[0022] The Stage0 module and the Stage1 module each comprise two uniform FFN sub-modules; the Stage2 module comprises four uniform FFN sub-modules and two AttnFFN sub-modules; and the Stage3 module comprises two uniform FFN sub-modules and two AttnFFN sub-modules.
[0023] The feature preprocessing unit (Stem) module is used for preliminary convolution and down-sampling; the feature embedding unit (Embedding) module is used for down-sampling and channel number adjustment; the uniform FFN sub-module is used for local feature extraction through a feedforward network; and the AttnFFN sub-module is used for feature extraction by combining a self-attention mechanism with a feedforward network.
[0024] Furthermore, the feature fusion network adopts the C2f_OREPA structure. The C2f_OREPA structure introduces an online reparameterized convolution module on the basis of the standard C2f module. The C2f_OREPA structure is used to improve the dynamics and efficiency of feature fusion by dynamically fusing multiple branches of the online reparameterized convolution module. The online reparameterized convolution module is the OREPA convolution, which consists of an input 1×1 convolutional layer, multiple branches of OREPA convolution, a concat layer for feature concatenation, and a final 1×1 convolutional fusion layer. The branches of the multiple OREPA convolutions include depthwise separable convolution branches and prior convolution branches. There are three branches of the multiple OREPA convolutions. The OREPA convolution generates an equivalent convolution kernel by dynamically combining the weights of the multiple branches of the convolution, and performs weighted fusion of the original convolution weights, 1×1 convolution, depthwise separable convolution, and prior convolution during the training phase.
[0025] Furthermore, the dynamic focusing loss function is the Wise-IoUv3 loss function, which is used to dynamically adjust the gradient assignment based on the quality of the anchor box to enhance the model's attention to samples of ordinary quality.
[0026] Furthermore, the feature extraction process of the unified FFN module includes:
[0027] Receive input features;
[0028] Multi-layer convolution operations and activation function processing are applied to the input features to extract local features;
[0029] Residual connections are made between local features and input features to achieve feature fusion;
[0030] Output the enhanced features after feature fusion.
[0031] Furthermore, the feature extraction process of the AttnFFN module includes:
[0032] Obtain input features;
[0033] The input features are fed into a multi-head self-attention module for attention mechanism processing to obtain the first feature;
[0034] The input features are fed into the feedforward network to extract local features, thus obtaining the second feature;
[0035] The first feature and the second feature are fused together using residual connection to obtain the output feature.
[0036] Furthermore, an uncertainty-aware adaptive fusion mechanism is used to fuse the multi-scale feature maps generated by the backbone feature extraction network and the feature fusion network, specifically including:
[0037] For each scale of feature map, a small uncertainty estimation sub-network is used to predict an uncertainty score representing the reliability of the feature map at that scale. The small uncertainty estimation sub-network consists of two consecutive 1×1 convolutional layers and a global average pooling layer connected in sequence. The structure of the small uncertainty estimation sub-network and the main detection network of the improved YOLOv8n network model are jointly trained in an end-to-end manner. The loss function of the small uncertainty estimation sub-network is supervised by the total target detection loss function of the improved YOLOv8n network model.
[0038] The Softmax function is used to normalize the uncertainty scores for all scales, and each uncertainty score is converted into a corresponding adaptive weight.
[0039] The feature maps at each scale are multiplied element-wise with their corresponding adaptive weights, and then all the multiplication results are summed to obtain the final fused feature map.
[0040] The fused feature map is input into the final classification convolutional layer and regression convolutional layer of the detection head to perform object classification and bounding box regression prediction.
[0041] An underwater target detection system based on an improved YOLOv8n, used to implement an underwater target detection method based on an improved YOLOv8n, includes:
[0042] The image acquisition module is used to acquire preprocessed underwater target images, and the preprocessing includes at least underwater image enhancement.
[0043] The processing module includes an improved YOLOv8n network model, which includes: a backbone feature extraction network based on a lightweight visual Transformer network, a feature fusion network including an online reparameterized convolution module, and a detection head optimized using a dynamic focusing loss function; the detection head part introduces an uncertainty-aware adaptive fusion mechanism.
[0044] The output module is used to output the target detection results.
[0045] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0046] Firstly, regarding underwater target detection accuracy, by using a lightweight visual Transformer network as the backbone feature extraction network, the global contextual information and long-distance dependencies of underwater targets can be effectively captured, compensating for the shortcomings of traditional convolutional neural networks in global feature modeling. This allows the network to extract more detailed features and overall contour features of targets in complex underwater scenes. Simultaneously, the application of online reparameterized convolutional modules in the feature fusion network improves the model's operating efficiency while maintaining detection accuracy, solving the problem of insufficient ability to express complex features in the feature fusion process of standard convolutional modules. The introduction of a dynamic focusing loss function effectively improves the model's detection accuracy for small underwater targets, blurred targets, and occluded targets, reducing the sensitivity of traditional loss functions to bounding box localization errors in complex scenes. Furthermore, the uncertainty-aware adaptive fusion mechanism in the detection head enables dynamic optimization and fusion of multi-scale features, avoiding the feature information redundancy or loss problems that may occur with traditional fixed-weight fusion methods, further improving the localization accuracy and classification accuracy of target detection.
[0047] Secondly, regarding model lightweighting and real-time performance, the backbone feature extraction network adopts a lightweight visual Transformer network. While ensuring feature extraction performance, it effectively reduces the computational complexity and number of parameters by optimizing the network structure and parameter count. The online reparameterized convolution module merges multi-branch structures into a single convolution during the inference stage, reducing the computational load and memory consumption of the model, enabling it to run efficiently on platforms with limited computing resources, such as embedded devices or underwater robots. Meanwhile, the lightweight convolutional neural network (CNN) used in the preprocessing stage optimizes and corrects the background light vector and transmission map, achieving color correction while avoiding the computational burden caused by complex network structures, thus ensuring the efficiency of the preprocessing process.
[0048] Furthermore, regarding the preprocessing effect of underwater images, the preprocessing method based on the underwater optical imaging physical model combined with lightweight CNN can accurately estimate the background light vector and transmission map of the original image, and perform color correction through inverse physical model reconstruction, effectively solving the problems of color distortion, low contrast and blurred details caused by factors such as scattering and absorption in underwater images.
[0049] Finally, regarding the robustness and adaptability of the algorithm, the dynamic focusing loss function can dynamically adjust the loss weights according to the different states of underwater targets (such as clarity, degree of occlusion, etc.), enhancing the model's ability to learn from target samples of different quality. This allows the model to maintain stable detection performance even in complex environments such as changes in underwater lighting, varying water turbidity, and diverse target shapes. Improvements to the backbone feature extraction network and feature fusion network enhance the model's ability to express underwater target features and resist interference, effectively addressing issues such as low contrast between targets and backgrounds, blurred target edges, and interference from a large number of suspended particles in underwater scenes. Color correction and image fusion in the preprocessing stage further reduce the impact of underwater environmental factors on image quality, enabling the model to accurately detect targets under different underwater environmental conditions. This demonstrates strong environmental adaptability and robustness, expanding the application scope of the algorithm.
[0050] Other features and advantages of the invention will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the written description and the accompanying drawings.
[0051] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0052] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0053] Figure 1 This is a schematic diagram illustrating the steps of an underwater target detection method based on an improved YOLOv8n.
[0054] Figure 2 A schematic diagram illustrating the steps of a unified feature extraction process for the FFN module;
[0055] Figure 3 This is a schematic diagram of an underwater target detection system based on an improved YOLOv8n. Detailed Implementation
[0056] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.
[0057] This invention provides an underwater target detection method based on an improved YOLOv8n, such as... Figure 1As shown, it includes: acquiring preprocessed underwater target images. The preprocessing includes at least underwater image enhancement. For example, for underwater images with severe noise, a dehazing algorithm based on dark channel prior combined with the Retinex enhancement algorithm is used to improve image contrast and details, such as enhancing underwater low-light, blurry coral images into clear, color-realistic images.
[0058] An improved YOLOv8n network model is used for feature extraction and target detection of underwater target images. The improved YOLOv8n network model is constructed as follows: a lightweight visual Transformer network, such as MobileViT, is used as the backbone feature extraction network. While maintaining lightweight design, the Transformer module captures long-range dependent features of underwater targets (such as fish and submersibles). In the feature fusion network of the improved YOLOv8n network model, online reparameterized convolutional modules replace standard convolutional modules. For example, in the upsampling or downsampling path of the PANet structure, the 3x3 standard convolution is replaced with the reparameterized convolutional block from RepVGG-B1g2. During training, a multi-branch structure is used to enhance feature extraction capabilities, and during inference, the features are fused into a single convolution. Acceleration; using the dynamic focusing loss function as the bounding box regression loss function of the improved YOLOv8n network model; introducing an uncertainty-aware adaptive fusion mechanism in the detection head of the improved YOLOv8n network model to fuse multi-scale feature maps. For example, for sea turtles with varied underwater postures, the dynamic focusing loss dynamically adjusts the weights based on the IoU between the predicted and ground truth boxes, assigning higher loss weights to difficult-to-detect samples (such as partially occluded sea turtles); introducing an uncertainty-aware adaptive fusion mechanism in the detection head to fuse multi-scale feature maps; outputting target detection results, for example, in complex underwater scene images containing fish, corals, and shipwreck debris, outputting the category (such as "tropical fish" and "brain coral"), confidence (such as 0.92 and 0.88), and bounding box coordinates (such as (x1, y1, x2, y2) = (50, 80, 120, 160)) of each target.
[0059] The working principle of the above technical solution is as follows: In order to realize the underwater target detection method based on the improved YOLOv8n, the present invention first acquires underwater target images and preprocesses them, among which underwater image enhancement is a key step in preprocessing; the underwater environment has problems such as insufficient light, color distortion, and water scattering. Image enhancement can improve image quality, make image details clearer, contrast higher, and colors more natural, providing a better image foundation for subsequent target detection and improving the detection model's ability to recognize target features;
[0060] In the construction and use of the improved YOLOv8n network model, a lightweight visual Transformer network is used as the backbone feature extraction network. Traditional convolutional neural networks (CNNs) perform well in processing local features, but have limitations in capturing long-range dependencies and global information. The lightweight visual Transformer network, with its self-attention mechanism at its core, can better process global information and capture long-range dependencies between different regions in the image, thus enabling the model to better understand the contextual information of the target. By using a lightweight visual Transformer network, while ensuring feature extraction capabilities, the computational load and model parameter count can be reduced, improving the model's running efficiency in underwater target detection tasks and meeting real-time detection requirements.
[0061] In feature fusion networks, online reparameterized convolutional modules are used to replace standard convolutional modules. Online reparameterized convolutional modules can convert complex convolutional structures into simple convolutional structures through specific structural designs and parameterization methods during the training phase, while using simple structures for computation during the inference phase. This can increase the complexity of the model during training and improve its learning ability, while reducing the amount of computation during inference, speeding up inference, and improving the overall performance and efficiency of the model.
[0062] In underwater target detection, the ratio of positive to negative samples is often unbalanced, which can easily lead to model training bias towards a large number of negative samples, affecting the detection accuracy of positive samples (i.e., targets). Using the dynamic focusing loss function as the bounding box regression loss function, the dynamic focusing loss function can automatically adjust the attention to difficult and simple samples by setting different weights for different samples, focusing more on samples that are difficult to classify, thereby improving the accuracy of the model's bounding box regression of underwater targets and improving the accuracy of target detection.
[0063] The detection head incorporates an uncertainty-aware adaptive fusion mechanism to fuse multi-scale feature maps. This mechanism dynamically adjusts the fusion weights of features at different scales by calculating the prediction uncertainty of feature maps at different scales during target detection. This allows the network to adaptively allocate fusion weights based on the actual scale of the target and the clarity of the features. For high-resolution feature maps containing small targets or detailed features, higher fusion weights are assigned if their prediction uncertainty is low (i.e., the feature representation is more reliable). Conversely, for low-resolution feature maps covering large targets or global semantic information, the weights are appropriately reduced when the uncertainty is high. This effectively integrates the advantages of multi-scale features, reduces the problem of missed or false detections caused by insufficient features at a single scale, and further improves the robustness and accuracy of target detection in complex underwater environments.
[0064] The improved YOLOv8n network model is used to extract features from the preprocessed underwater target image. Feature vectors containing target information are extracted from the image. Then, target detection is performed based on these features to determine whether a target exists in the image and the target's location and category. Finally, the target detection results are output to inform the user of the target category, location, and other information detected in the underwater image, thus completing the underwater target detection task.
[0065] The beneficial effects of the above technical solution are as follows: the solution provided in this embodiment can effectively improve the overall performance of underwater target detection. While improving the accuracy of underwater target detection, it ensures the real-time performance and lightweight characteristics of the model, and can better adapt to the target detection task requirements in complex underwater environments. It provides reliable technical support for practical application scenarios such as underwater resource exploration, underwater security, and marine engineering.
[0066] In one embodiment, acquiring a preprocessed underwater target image includes the following steps:
[0067] Based on an underwater optical imaging physical model, the original image is input (e.g., an RGB original image of coral reefs taken in turbid nearshore waters, which appears bluish-green and has blurred details due to water scattering). The background light vector and transmission map of the original image are estimated to obtain the model-generated image. The method for estimating the background light vector is as follows: in the brightest pixel region of the image (e.g., selecting the top 0.1% of the pixel regions in the original image as candidate regions), the average brightness and standard deviation of the image blocks are calculated for selection (e.g., dividing the candidate regions into 32×32 image blocks and calculating the average brightness and standard deviation of each image block). Average brightness and standard deviation are used to remove image blocks with average brightness below a threshold (e.g., 220) or standard deviation that are too small (e.g., less than 5). The RGB value of the center pixel of the image block with the highest average brightness among the remaining image blocks is used as the background light vector. Assuming the background light vector is [240, 235, 220], the transmission map estimation method is as follows: based on the dark channel prior and / or fog line theory, the transmission map value of the pixel is initially deduced to be 0.3. (For example, using the dark channel prior, the dark channel value of each pixel in the original image is calculated. Assuming the dark channel value of a certain pixel is 0.15, combined with the estimated background light vector, the transmission map value of the pixel is initially deduced to be 0.3).
[0068] Background light vectors and transmission maps are input into a lightweight convolutional neural network (CNN) for optimization and correction to obtain corrected physical parameters. Based on the corrected physical parameters, color correction is performed through inverse physical model reconstruction to obtain a color-corrected image. The lightweight CNN employs an attention mechanism to focus on optimizing regions in the image that are severely affected by scattering (e.g., the boundary between coral reef edges and water bodies, and blurred areas in the distance of the image). The attention mechanism is a convolutional block attention module (e.g., this module performs channel attention and spatial attention calculations on the input feature map, assigning higher weights to the feature channels and spatial locations of severely scattered regions, such as enhancing the weights of feature map regions with values below 0.2 in the original transmission map, thereby focusing on adjusting the transmission map values of these regions during optimization, assuming that the transmission map value of a certain edge region is corrected from 0.25 to 0.4).
[0069] The original image, the model-generated image, and the color-corrected image are adaptively weighted and fused to generate an underwater target image (for example, the fusion weights are set as follows: the original image has a weight of 0.1, the model-generated image has a weight of 0.3, and the color-corrected image has a weight of 0.6; for the clear central area of the coral reef in the image, the original image retains a certain detail weight, while for the blurred edge area, the color-corrected image has a higher weight. In the final fused underwater target image, the color of the coral reef is closer to the real color, and the edge details are clearer).
[0070] The working principle of the above technical solution is as follows: The underwater optical imaging physical model describes the process of light propagation and imaging underwater. After inputting the original image, the model is used to estimate the background light vector and transmission map of the original image. The background light vector refers to the ambient light intensity uniformly distributed in the underwater environment, while the transmission map reflects the attenuation of light during underwater propagation. Both are key parameters for restoring the true color and detail of the underwater scene. By accurately estimating these two elements, the module can effectively eliminate problems such as color cast, blurring, and low contrast in underwater images, improving the visual effect and usability of subsequent analysis. The background light vector is estimated as: the brightest pixel in the image... The transmission map is filtered by calculating the average brightness and standard deviation of image patches. In underwater images, the brightest areas are often associated with background light; calculating the average brightness and standard deviation effectively removes outliers, selecting pixel regions that accurately represent the background light, thus obtaining the background light vector. The transmission map estimation method is based on inverse reasoning using dark channel priors and / or fog line theory. The dark channel prior assumes that in most non-sky local regions, at least one color channel contains some pixels with very low values; this characteristic can be used to estimate the transmission map. Fog line theory is based on the scattering characteristics of underwater imaging, using the color and brightness information of image pixels to estimate the transmission map. The transmission map, derived from these theories, characterizes the attenuation of light during underwater propagation. This results in the model-generated image.
[0071] CNNs possess powerful feature extraction capabilities, enabling them to learn features from input data. Background light vectors and transport maps are input into a lightweight convolutional neural network (CNN). This lightweight CNN employs convolutional block attention modules as its attention mechanism. This mechanism allows the network to focus on optimizing regions in the image that are severely affected by scattering. In underwater images, scattering causes blurring and reduced contrast. By focusing on scatter-affected areas through the attention mechanism, relevant features can be extracted more effectively. Ultimately, corrective physical parameters are obtained and used for image correction.
[0072] Reconstruction using inverse physics models involves applying corrected physical parameters to the image. Inverse physics models refer to a class of modeling methods that infer the inherent laws, parameters, or initial conditions of a physical system from known observation data or system output. Inverse physics models are the opposite of underwater optical imaging physical models. By correcting physical parameters, they adjust the image color to compensate for color loss and deviation during underwater light propagation, thus obtaining a color-corrected image.
[0073] Different images contain different useful information. The original image retains complete initial information, the model-generated image reflects the background light and transmission characteristics estimated based on the physical model, and the color-corrected image improves color deviation. By adaptively weighting and fusing the original image, the model-generated image, and the color-corrected image, the weights are dynamically adjusted according to the features of each part of the image, so that the fused image can not only retain the original details, but also optimize the background light, transmission, and color correction effects, and finally generate an underwater target image.
[0074] The beneficial effects of the above technical solution are as follows: By adopting the solution provided in this embodiment, underwater image enhancement technology significantly improves the image quality problem caused by the complexity of the underwater environment, lays a high-quality data foundation for feature extraction of the subsequent network model, and enables the model to capture the detailed features of the target more accurately.
[0075] In one embodiment, the lightweight visual Transformer network is the EfficientformerV2_S0 network.
[0076] The working principle of the above technical solution is as follows: The EfficientformerV2_S0 network, as a lightweight visual Transformer, achieves accurate feature extraction of underwater target images while maintaining low computational resource consumption through a hierarchical hybrid attention mechanism and an efficient local windowing strategy. The network first segments the input underwater target image into fixed-size image blocks, transforms them into feature vector sequences through an embedding layer, and then uses stacked Transformer encoder modules to perform deep processing on the features. The attention mechanism in the encoder can adaptively focus on key information in the target region of the image, effectively suppressing underwater background noise and complex environmental interference. At the same time, the local windowing design significantly reduces the amount of computation, enabling it to run efficiently on resource-constrained devices. The feature vectors extracted by the EfficientformerV2_S0 network not only retain the detailed texture features of the target but also integrate contextual semantic information, providing high-quality feature support for the subsequent target localization and classification by the YOLOv8n detection head, thereby improving the real-time performance and accuracy of the entire underwater target detection system.
[0077] The beneficial effects of the above technical solution are as follows: The backbone feature extraction network adopts a lightweight visual Transformer, which makes up for the shortcomings of traditional CNN in capturing global information, while taking into account the lightweight requirements of the model, ensuring that the feature extraction capability is improved without excessively increasing the computational burden.
[0078] In one embodiment, the backbone feature extraction network includes a feature preprocessing unit (Stem) module, a Stage0 module, a feature embedding unit (Embedding) module, a Stage1 module, an Embedding module, a Stage2 module, an Embedding module, a Stage3 module, and a pooling operation unit (SPPF) module connected in sequence.
[0079] The Stage0 and Stage1 modules each include two unified FFN sub-modules; the Stage2 module includes four unified FFN sub-modules and two AttnFFN sub-modules; the Stage3 module includes two unified FFN sub-modules and two AttnFFN sub-modules; the unified FFN sub-modules consist of a fully connected layer, an activation function, and a dropout layer.
[0080] The Feature Preprocessing Unit (Stem) module is used for initial convolution and downsampling; the Feature Embedding Unit (Embedding) module is used for downsampling and channel number adjustment; the Unified FFN submodule is used for local feature extraction through a feedforward network; and the AttnFFN submodule is used for feature extraction by combining a self-attention mechanism with a feedforward network.
[0081] The improved YOLOv8n network model's data augmentation methods during the training phase include Mosaic stitching and random color transformation. Mosaic stitching involves randomly selecting four training images, scaling and cropping them according to random proportions and positions, and then stitching them together to form a new image. For example, four training images are randomly selected, scaled by 0.5-1.5 times, cropped to a size of 640×640 pixels, and augmented using random flipping (horizontal flip probability 0.5) and color gamut dithering (brightness ±15%, saturation ±20%). Random color transformation involves randomly adjusting the brightness, contrast, saturation, and hue of the underwater target image.
[0082] Before training, the acquired underwater target images were divided into training set, validation set and test set in a ratio of 7:2:1.
[0083] The working principle of the above technical solution is as follows: The input data first enters the feature preprocessing unit (Stem) module. This module extracts the basic features in the data through preliminary convolution operation, and at the same time uses downsampling to reduce the amount of data, reduce the computational load of subsequent processing, and make the data scale more suitable for subsequent modules to process.
[0084] Data processed by the Stem module flows into the Stage0 module, which includes two unified FFN sub-modules. Each unified FFN sub-module extracts local features from the data through a feedforward network, mining feature information from different local regions. The parallel and sequential processing of these two sub-modules further enriches and refines the local features.
[0085] The data processed by the Stage0 module enters the first feature embedding module. The first feature embedding module performs a downsampling operation to further reduce the data dimensionality and adjust the number of channels, transforming the data into a feature representation that is more suitable for the next stage of processing, so that the features are more in line with the needs of subsequent modules in terms of dimensionality and channel information.
[0086] Next, the data comes to the Stage1 module, which also includes two unified FFN sub-modules. It continues to use the feedforward network to deeply mine the local features of the data, further strengthen and refine the existing local features, and improve the expressive power of the features.
[0087] The data processed by the Stage 1 module enters the feature embedding module again, where it is downsampled and the number of channels is adjusted again to further optimize the data feature representation and prepare for more complex feature extraction in the future.
[0088] The data enters the Stage2 module, which includes four unified FFN sub-modules and two AttnFFN sub-modules. The four unified FFN sub-modules first fully mine local features from different local regions to enrich feature information. On this basis, the two AttnFFN sub-modules combine self-attention mechanism and feedforward network to not only consider local features, but also capture global feature information through self-attention mechanism, combining local and global features to greatly improve the richness and accuracy of features.
[0089] The data processed by the Stage 2 module enters the feature embedding module again for further downsampling and channel number adjustment to optimize feature representation and better adapt to the final stage of processing.
[0090] The data enters the Stage3 module, which includes two unified FFN sub-modules and two AttnFFN sub-modules. The unified FFN sub-modules further extract local features, and the AttnFFN sub-modules again combine the self-attention mechanism with the feedforward network to perform final optimization and integration of the features, resulting in features containing rich local and global information.
[0091] After being processed by the Stage3 module, the data enters the Pooling Operation Unit (SPPF) module. This module further downsamples and compresses the data through pooling operations, and finally outputs representative features. These features can be used for subsequent tasks such as object detection and classification. The entire backbone feature extraction network continuously optimizes the feature representation of the data through this progressive and staged feature extraction and processing method to meet the feature requirements of different tasks.
[0092] The beneficial effects of the above technical solution are as follows: by adopting the solution provided in this embodiment, the basic features of the data can be quickly extracted and the data scale optimized through the preliminary convolution and downsampling of the feature preprocessing unit (Stem) module, laying an efficient foundation for subsequent processing.
[0093] In one embodiment, the feature fusion network adopts a C2f_OREPA structure. The C2f_OREPA structure introduces an online reparameterized convolution module on the basis of the standard C2f module. The C2f_OREPA structure is used to improve the dynamics and efficiency of feature fusion by dynamically fusing multiple branches of the online reparameterized convolution module. The online reparameterized convolution module is an OREPA convolution, which consists of an input 1×1 convolutional layer, multiple branches of OREPA convolution, a concat layer for feature concatenation, and a final 1×1 convolutional fusion layer. The multiple branches of OREPA convolution include depthwise separable convolution branches and prior convolution branches. There are three branches of multiple OREPA convolutions. The OREPA convolution generates an equivalent convolution kernel by dynamically combining the weights of multiple branches of convolution, and performs weighted fusion of the original convolution weights, 1×1 convolution, depthwise separable convolution, and prior convolution during the training phase.
[0094] The working principle of the above technical solution is as follows: The C2f_OREPA structure is an improvement on the standard C2f module. It optimizes the feature fusion network by introducing an online reparameterized convolution module (i.e., OREPA convolution). This improvement aims to enhance the network's ability to process features and can enhance network performance from different dimensions (such as improving accuracy and speeding up processing).
[0095] The 1×1 convolutional layer of OREPA convolution is located in the input part. Its function is to perform preliminary feature mapping on the input data. It can adjust the number of channels, perform linear transformation on the data without changing the feature map size, integrate information between different channels, and prepare for subsequent multi-branch convolution.
[0096] Depthwise separable convolution decomposes conventional convolution into depthwise convolution and pointwise convolution. Depthwise convolution performs convolution operations on each channel independently, only considering feature extraction in the spatial dimension, and has a relatively small computational cost. Pointwise convolution, on the other hand, fuses the output channels of depthwise convolution through 1×1 convolution, maintaining a certain feature extraction capability while reducing computational cost. The depthwise separable convolution branch can effectively extract features from the spatial dimension and contribute to the overall feature fusion with a small computational cost.
[0097] Prior convolution utilizes prior knowledge to perform convolution operations on input features. Prior knowledge may be based on a prior understanding of the task and data features. This branch integrates prior knowledge into the features through convolution operations, helping the network to better capture specific feature patterns and making the network more targeted during training and inference. The number of branches is set to 3, with different branches processing features from different angles. The parallel operation of multiple branches can enrich the diversity of features, and the output features of different branches complement each other in the subsequent splicing and fusion process, which helps to improve the expressiveness of the overall features.
[0098] The Concat layer concatenates the features output by multiple OREPA convolutional branches along the channel dimension. This integrates the features extracted from different branches from different angles, forming a feature set containing richer information, and providing a more comprehensive data foundation for subsequent fusion and processing.
[0099] The 1×1 convolutional fusion layer fuses the concatenated features. It integrates information between channels through 1×1 convolution operations, deeply fuses the features of different branches after concatenation, and generates the final equivalent convolutional kernel. This allows the features of different branches to work together better and provides more representative feature representations for subsequent network layers.
[0100] During the training phase, OREPA convolution dynamically combines the weights of the original convolutional branches, 1×1 convolutions, depthwise separable convolutions, and prior convolutions to generate equivalent convolutional kernels. This weighted fusion method can adaptively adjust the contribution of different convolutional branches according to the characteristics of the training data and the network's learning progress, enabling the network to better adapt to different data distributions and task requirements. For example, when facing certain types of data features, the weight of the prior convolutional branches may be increased to better utilize prior knowledge; when more detailed spatial feature extraction is required, the weight of the depthwise separable convolutional branches may be increased. By dynamically combining weights to generate equivalent convolutional kernels, the network can continuously optimize its feature extraction and processing capabilities during training, thereby improving overall performance.
[0101] The beneficial effects of the above technical solution are as follows: By adopting the solution provided in this embodiment, OREPA convolution, through multi-branch structure design, combines the efficient computational characteristics of depthwise separable convolution with the knowledge guidance of prior convolution, enabling the network to extract more discriminative features from multiple dimensions when dealing with common interference factors in underwater images such as uneven lighting and water turbidity. Without significantly increasing the consumption of computing resources, it effectively improves the feature fusion network's accuracy and expressive ability for capturing target features in complex underwater environments.
[0102] In one embodiment, the dynamic focusing loss function is the Wise-IoUv3 loss function, which is used to dynamically adjust the gradient assignment based on the quality of the anchor box to enhance the model's attention to samples of average quality.
[0103] The working principle of the above technical solution is as follows: The dynamic focusing loss function uses the Wise-IoUv3 loss function, which dynamically adjusts the gradient allocation based on the anchor box quality. In object detection tasks, anchor boxes are used to predict the position and size of targets. Different anchor boxes have different degrees of matching (i.e., quality) with the real targets. For high-quality anchor boxes, model learning is relatively easy; while anchor boxes of ordinary quality are more critical to improving model performance but are often overlooked. The Wise-IoUv3 loss function dynamically adjusts the gradient allocation, allowing the model to give more attention to ordinary quality samples during training, thereby optimizing the model's ability to detect targets corresponding to anchor boxes of different quality and improving overall detection performance.
[0104] The beneficial effects of the above technical solution are as follows: By adopting the solution provided in this embodiment, the application of the dynamic focusing loss function specifically solves the problems of positive and negative sample imbalance and difficult sample classification in underwater target detection. By dynamically adjusting the sample weights, the accuracy of bounding box regression and target detection precision are effectively improved.
[0105] In one embodiment, such as Figure 2 As shown, the feature extraction process of the unified FFN module includes:
[0106] Receive input features;
[0107] Multi-layer convolution operations and activation function processing are applied to the input features to extract local features;
[0108] Residual connections are made between local features and input features to achieve feature fusion;
[0109] Output the enhanced features after feature fusion.
[0110] The working principle of the above technical solution is as follows: First, the input features are received, which are the starting data for the entire processing flow. Then, the data is processed through multi-layer convolution operations and activation functions. Convolution operations can extract key features of the data in local regions. Different convolution kernels can capture different patterns. Activation functions introduce non-linear factors to enhance the model's ability to express complex data. The combination of the two allows for the extraction of local features. Subsequently, the local features are residually connected to the input features. Residual connections aim to solve the gradient vanishing or exploding problem in deep network training, making the model easier to learn. Here, the local features are added and fused with the original input features, which can retain the original feature information while incorporating newly extracted local features, thus improving feature richness. Finally, the enhanced features after feature fusion are output. These enhanced features combine the original information and key local features for subsequent task processing, such as classification and regression, to improve the accuracy and effectiveness of task execution.
[0111] The beneficial effects of the above technical solution are as follows: By adopting the solution provided in this embodiment, local key patterns in the input features are effectively extracted through the combination of multi-layer convolution and activation functions. At the same time, the local features are fused with the original input features by means of residual connections. This not only preserves the integrity of the original information, but also enhances the richness of feature expression, alleviates the gradient problem in deep network training, improves the model's learning ability and feature extraction accuracy on complex data, and provides higher quality enhanced feature inputs for subsequent classification, regression and other tasks, which helps to improve the overall task execution accuracy and performance stability.
[0112] In one embodiment, the feature extraction process of the AttnFFN module includes:
[0113] Obtain input features;
[0114] The input features are fed into a multi-head self-attention module for attention mechanism processing to obtain the first feature;
[0115] The input features are fed into the feedforward network to extract local features, thus obtaining the second feature;
[0116] The first feature and the second feature are fused together using residual connection to obtain the output feature.
[0117] The working principle of the above technical solution is as follows: First, the input features are acquired, which are the starting data for the entire processing flow. Then, the input features are sent to two different paths for processing. On the one hand, the input is fed into a multi-head self-attention module. In the multi-head self-attention mechanism, by calculating the attention weights of different heads, each head focuses on different aspects of the input features, thereby capturing the global dependencies in long sequence data and obtaining the first feature. This feature contains the key information representation of the input features from a global perspective. On the other hand, the input features are fed into a feedforward network. The feedforward network is generally composed of fully connected layers. Through multiple nonlinear transformations, local features are extracted from the input features to obtain the second feature, which focuses on the local patterns and information in the input features. Finally, the first feature and the second feature are fused through residual connections. The principle of residual connections is to directly add the features from different paths (here, the multi-head self-attention module and the feedforward network). This method helps to solve the gradient vanishing or gradient exploding problem in deep network training, enabling the network to learn and optimize better, and finally obtain the output feature. This output feature integrates global and local feature information, which is more conducive to the execution of subsequent tasks.
[0118] The beneficial effects of the above technical solution are as follows: by adopting the solution provided in this embodiment, it is possible to capture both global dependencies and local pattern information in the input features through the parallel processing structure of the multi-head self-attention module and the feedforward network.
[0119] In one embodiment, the detection head portion of the improved YOLOv8n network model introduces an uncertainty-aware adaptive fusion mechanism. This mechanism is used to fuse multi-scale feature maps generated by the backbone feature extraction network and the feature fusion network (e.g., the three typical output scales typically involved in YOLOv8n: a large-scale feature map F1 of 80×80×C1, a medium-scale feature map F2 of 40×40×C2, and a small-scale feature map F3 of 20×20×C3, where C1, C2, and C3 are the number of channels in each feature map). The uncertainty-aware adaptive fusion mechanism performs the following steps:
[0120] For each feature map at each scale (F1, F2, F3), a small uncertainty estimation sub-network is used to predict an uncertainty score representing the reliability of the feature map at that scale. (For example, for F1, its small uncertainty estimation sub-network first uses a 1×1 convolutional layer to adjust the number of channels C1 to C1 / 2, with ReLU activation function, then uses a second 1×1 convolutional layer to further adjust the number of channels to 1, and then uses a global average pooling layer to obtain a scalar value u1, which is the uncertainty score of F1; similarly, F2 obtains an uncertainty score u2 after being processed by its corresponding small uncertainty estimation sub-network, and F3 obtains u3). The small uncertainty estimation sub-network consists of two consecutive 1×1 convolutional layers and a global average pooling layer connected sequentially. The structure of the small uncertainty estimation sub-network is jointly trained with the main detection network of the improved YOLOv8n network model in an end-to-end manner. The loss function of the small uncertainty estimation sub-network is supervised by the total target detection loss function of the improved YOLOv8n network model (usually including classification loss, regression loss, etc.).
[0121] The Softmax function is used to normalize the uncertainty scores (u1, u2, u3) for all scales, and each uncertainty score is converted into a corresponding adaptive weight (for example, calculate w1 = exp(u1) / (exp(u1) + exp(u2) + exp(u3)), w2 = exp(u2) / (exp(u1) + exp(u2) + exp(u3)), w3 = exp(u3) / (exp(u1) + exp(u2) + exp(u3)), where w1, w2, and w3 are the adaptive weights of F1, F2, and F3, respectively, and w1 + w2 + w3 = 1).
[0122] The feature maps at each scale are multiplied element-wise with their corresponding adaptive weights, and then all the multiplication results are summed to obtain the final fused feature map (for example, F2 and F3 are first upsampled to the same spatial size 80×80 as F1, and the upsampled feature maps are F2' and F3', and then the fused feature map F_fused = w1*F1 + w2*F2' + w3*F3' is calculated, where "*" means element-wise multiplication and "+" means element-wise addition).
[0123] The fused feature map F_fused is input into the final classification convolutional layer (e.g., a 3×3 convolutional layer followed by a 1×1 convolutional layer, outputting the number of categories) and regression convolutional layer (e.g., a 3×3 convolutional layer followed by a 1×1 convolutional layer, outputting 4+1=5 channels, where 4 is the bounding box coordinate offset and 1 is the target confidence) of the detection head to perform target classification and bounding box regression prediction.
[0124] The working principle of the above technical solution is as follows: The improved YOLOv8n network model introduces an uncertainty-aware adaptive fusion mechanism in the detection head part. For each scale feature map generated by the backbone feature extraction network and the feature fusion network, a small uncertainty estimation sub-network is used to predict the uncertainty score of its reliability. This small uncertainty estimation sub-network has a simple structure, consisting of two consecutive 1×1 convolutional layers and a global average pooling layer connected in sequence. This structure can effectively extract relevant features of the feature map to evaluate its reliability. At the same time, the small uncertainty estimation sub-network and the main detection network are jointly trained in an end-to-end manner, and its loss function is supervised by the total loss function of object detection. This ensures that the training of the small uncertainty estimation sub-network is closely related to the entire object detection task and can better adapt to the detection requirements.
[0125] After obtaining the uncertainty scores of feature maps at each scale, the Softmax function is used to normalize the uncertainty scores of all scales. The role of the Softmax function is to convert these scores into a probability distribution form with a sum of 1, that is, to convert each uncertainty score into a corresponding adaptive weight. In this way, each feature map at each scale has a weight related to its reliability.
[0126] The feature maps at each scale are multiplied element-wise with their corresponding adaptive weights. This means that feature maps with high reliability (high weight) will contribute more to the fusion process, while feature maps with low reliability (low weight) will contribute relatively less. Then, all the multiplication results are summed to obtain the final fused feature map. This fusion process integrates the information of feature maps at different scales and is reasonably weighted according to their reliability.
[0127] The fused feature map is input into the final classification and regression convolutional layers of the detection head. By leveraging the powerful feature extraction and classification / regression capabilities of the convolutional layers, target classification and bounding box regression prediction are performed to achieve accurate detection of target objects in the image.
[0128] The beneficial effects of the above technical solution are as follows: By adopting the solution provided in this embodiment, the reliability information of feature maps at different scales can be dynamically evaluated and utilized through the uncertainty-aware adaptive fusion mechanism; through the optimized feature fusion process, the improved YOLOv8n network model is enhanced in both target classification accuracy and bounding box regression accuracy, especially in complex scenes where it performs better in detecting multi-scale, small or occluded targets, thus improving the overall detection robustness and generalization ability of the model.
[0129] An underwater target detection system based on an improved YOLOv8n is provided to implement an underwater target detection method based on the improved YOLOv8n, such as... Figure 3 As shown, it includes:
[0130] The image acquisition module is used to acquire preprocessed underwater target images, and the preprocessing includes at least underwater image enhancement.
[0131] The processing module includes an improved YOLOv8n network model, which includes: a backbone feature extraction network based on a lightweight visual Transformer network, a feature fusion network including an online reparameterized convolution module, and a detection head optimized using a dynamic focusing loss function; the detection head part introduces an uncertainty-aware adaptive fusion mechanism.
[0132] The output module is used to output the target detection results;
[0133] To verify the effectiveness of this invention, comparative experiments were conducted on the publicly available underwater datasets URPC2021 and UTDAC2020. Performance comparison data of the improved YOLOv8n model and mainstream detection models on the two underwater datasets were obtained, along with ablation experiment data on the URPC2021 dataset based on the baseline YOLOv8n. Details are shown in Tables 1, 2, and 3. The training, validation, and test sets were divided in a 7:2:1 ratio. The model was trained using the SGD optimizer with an initial learning rate of 0.01, a batch size of 16, and a total of 300 epochs.
[0134]
[0135]
[0136] Table 1: Performance Comparison with Mainstream Detection Models on Underwater Datasets
[0137]
[0138] Table 2: Ablation experiments (based on baseline YOLOv8n)
[0139]
[0140]
[0141] Table 3: Performance comparison with mainstream detection models on the UTADC2020 dataset
[0142] As shown in Table 1, the method of this invention achieves 76.8% mAP@0.5 with a similar number of parameters to the baseline model, representing an improvement of 11.6 percentage points compared to the mainstream YOLOv5s model and a significant improvement of 8.3 percentage points compared to the baseline YOLOv8n model. This indicates that the method of this invention has a clear advantage in the accuracy of underwater target detection. Meanwhile, the method of this invention has only 3.5M parameters, a small increase compared to the baseline YOLOv8n's 3.2M, maintaining the model's lightweight characteristics. The frame rate per second is 118, slightly lower than the baseline YOLOv8n's 120, but still at a high level, meeting the requirements of real-time detection. In summary, the method of this invention achieves a good balance between detection accuracy, model size, and detection speed, making it more suitable for target detection tasks in complex underwater environments.
[0143] The ablation experiment data in Table 2 further analyzes the contribution of each improved module to the performance. The addition of the image preprocessing module improved mAP@0.5 by 2.8%, indicating that preprocessing underwater images can effectively improve the detection effect. After introducing the EfficientFormerV2 backbone, the performance improved by 5.1% compared with the baseline, indicating that the backbone network is superior to the original network in feature extraction capability. The addition of the C2f_OREPA module brought a 6.6% improvement, verifying its role in enhancing feature fusion and expression. The combination of Wise-IoUv3 and uncertainty fusion improved the performance to 8.3%, fully demonstrating the effectiveness of these modules in optimizing bounding box regression accuracy and fusing multi-scale feature information. The synergistic effect of each module contributes to the excellent performance of the method of this invention.
[0144] The experimental results in Table 3 demonstrate that the lightweight model provided by this invention exhibits superior overall performance on complex underwater datasets such as UTDAC2020. Compared to existing technologies, this invention achieves a maximum mAP@50 of 84.9% with only 5.1M parameters and 11.7G of floating-point operations per second at a low cost. It also reaches a level similar to the optimal model in the mAP@50:95 metric (49.4% vs 50.0%). At the same time, the number of parameters and computational cost are significantly reduced by approximately 29% and 56%, respectively. The method of this invention increases the number of parameters to 5.1M due to the introduction of the EfficientformerV2_S0 backbone and the OREPA convolution module, but it still maintains a lightweight design compared to other models (such as YOLOv5s 7.1M). The model of this invention also maintains a high inference speed of 109.5 frames per second, successfully achieving a better balance between accuracy, speed, and resource consumption. It is particularly suitable for edge computing and complex underwater environments with high requirements for both real-time performance and accuracy.
[0145] The working principle of the above technical solution is as follows: First, the image acquisition module acquires pre-processed (including underwater image enhancement) underwater target images to improve underwater image quality. Next, the improved YOLOv8n network model in the processing module processes the images. The backbone feature extraction network uses a lightweight visual Transformer network to efficiently extract deep image features. The feature fusion network introduces an online reparameterized convolution module to enhance feature fusion capabilities and model inference speed. The detection head improves detection accuracy through dynamic focusing loss function optimization and uses an uncertainty-aware adaptive fusion mechanism to adjust the fusion based on different regions. The reliability of features is dynamically adjusted to optimize the fusion strategy, thereby improving target localization and classification. Finally, the output module outputs the final underwater target detection results. For example, in a turbid underwater environment, image enhancement preprocessing improves the clarity of blurry fish images, a lightweight visual Transformer effectively captures the overall contour features of the fish, online reparameterized convolution accelerates the fusion of fish features at different depths, an uncertainty perception mechanism dynamically adjusts the weights of regions in the image where features are unstable due to light refraction, and a dynamic focusing loss function is used to optimize the localization error of small fish that are difficult to detect. Finally, the number, location, and category information of the fish are accurately output.
[0146] The beneficial effects of the above technical solution are as follows: The solution provided in this embodiment improves the blurring and low contrast issues caused by light scattering and absorption in underwater images through underwater image enhancement preprocessing, providing high-quality input for subsequent feature extraction; the backbone feature extraction network adopts a lightweight visual Transformer, which enhances the ability to capture global semantic information and subtle features of underwater targets while ensuring lightweight design, overcoming the limitations of the local receptive field of traditional convolutional networks; the feature fusion network introduces an online reparameterized convolution module, achieving a balance between multi-branch feature learning during training and rapid deployment of a single branch during inference, enhancing the fusion effect of features at different levels while improving the model's inference speed to meet real-time detection requirements; the detection head, combined with a dynamic focusing loss function, can adaptively optimize focusing on difficult-to-detect targets (such as small targets, blurred targets, and occluded targets), while the uncertainty-aware adaptive fusion mechanism dynamically adjusts the fusion weights according to the reliability of the feature region, effectively reducing the impact of feature instability caused by factors such as light changes and water turbidity in the underwater environment on the detection results, further improving the accuracy of target localization and classification.
[0147] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. An underwater target detection method based on an improved YOLOv8n, characterized in that, include: Acquire preprocessed underwater target images, where preprocessing includes at least underwater image enhancement. An improved YOLOv8n network model is used for feature extraction and target detection of underwater target images. The improved YOLOv8n network model is constructed as follows: a lightweight visual Transformer network is used as the backbone feature extraction network; in the feature fusion network of the improved YOLOv8n network model, an online reparameterized convolutional module is used to replace the standard convolutional module; a dynamic focusing loss function is used as the bounding box regression loss function of the improved YOLOv8n network model; and an uncertainty-aware adaptive fusion mechanism is introduced into the detection head of the improved YOLOv8n network model to fuse multi-scale feature maps. Output the target detection results.
2. The underwater target detection method based on the improved YOLOv8n as described in claim 1, characterized in that, Obtaining preprocessed underwater target images includes the following steps: Based on the underwater optical imaging physical model, the background light vector and transmission map of the original image are estimated to obtain the model-generated image. The background light vector is estimated by filtering the brightest pixel regions in the image by calculating the average brightness and standard deviation of the image blocks. The transmission map is estimated by back-calculating based on dark channel priors and / or fog line theory. The background light vector and transmission map are input into a lightweight convolutional neural network (CNN) for optimization and correction to obtain the corrected physical parameters. Based on the corrected physical parameters, color correction is performed by reconstructing the inverse physical model to obtain the color-corrected image. The lightweight convolutional neural network (CNN) adopts an attention mechanism to focus on optimizing the regions in the image that are severely affected by scattering. The attention mechanism is a convolutional block attention module. The original image, the model-generated image, and the color-corrected image are adaptively weighted and fused to generate an underwater target image.
3. The underwater target detection method based on the improved YOLOv8n as described in claim 1, characterized in that, The lightweight visual Transformer network is the EfficientformerV2_S0 network.
4. The underwater target detection method based on the improved YOLOv8n as described in claim 3, characterized in that, The backbone feature extraction network consists of a feature preprocessing unit (Stem) module, a Stage0 module, a feature embedding unit (Embedding) module, a Stage1 module, an Embedding module, a Stage2 module, an Embedding module, a Stage3 module, and a pooling operation unit (SPPF) module connected in sequence. The Stage0 and Stage1 modules each include two unified FFN sub-modules; the Stage2 module includes four unified FFN sub-modules and two AttnFFN sub-modules; and the Stage3 module includes two unified FFN sub-modules and two AttnFFN sub-modules. The Feature Preprocessing Unit (Stem) module is used for initial convolution and downsampling; the Feature Embedding Unit (Embedding) module is used for downsampling and channel number adjustment; the Unified FFN submodule is used for local feature extraction through a feedforward network; and the AttnFFN submodule is used for feature extraction by combining a self-attention mechanism with a feedforward network.
5. The underwater target detection method based on the improved YOLOv8n as described in claim 1, characterized in that, The feature fusion network adopts the C2f_OREPA structure. The C2f_OREPA structure introduces an online reparameterized convolution module on the basis of the standard C2f module. The C2f_OREPA structure is used to improve the dynamism and efficiency of feature fusion by dynamically fusing multiple branches of the online reparameterized convolution module. The online reparameterized convolution module is the OREPA convolution, which consists of an input 1×1 convolutional layer, multiple branches of OREPA convolution, a concat layer for feature concatenation, and a final 1×1 convolutional fusion layer. The branches of the multiple OREPA convolutions include depthwise separable convolution branches and prior convolution branches. There are 3 branches in total. The OREPA convolution generates an equivalent convolution kernel by dynamically combining the weights of the multiple branches of the convolution, and performs weighted fusion of the original convolution weights, 1×1 convolution, depthwise separable convolution, and prior convolution during the training phase.
6. The underwater target detection method based on the improved YOLOv8n as described in claim 1, characterized in that, The dynamic focusing loss function is the Wise-IoUv3 loss function, which is used to dynamically adjust the gradient assignment based on the quality of the anchor box to enhance the model's attention to samples of ordinary quality.
7. The underwater target detection method based on the improved YOLOv8n as described in claim 4, characterized in that, The feature extraction process of the unified FFN module includes: Receive input features; Multi-layer convolution operations and activation function processing are applied to the input features to extract local features; Residual connections are made between local features and input features to achieve feature fusion; Output the enhanced features after feature fusion.
8. The underwater target detection method based on the improved YOLOv8n as described in claim 4, characterized in that, The feature extraction process of the AttnFFN module includes: Obtain input features; The input features are fed into a multi-head self-attention module for attention mechanism processing to obtain the first feature; The input features are fed into the feedforward network to extract local features, thus obtaining the second feature; The first feature and the second feature are fused together using residual connection to obtain the output feature.
9. The underwater target detection method based on the improved YOLOv8n as described in claim 1, characterized in that, An uncertainty-aware adaptive fusion mechanism is used to fuse multi-scale feature maps generated by the backbone feature extraction network and the feature fusion network, specifically including: For each scale of feature map, a small uncertainty estimation sub-network is used to predict an uncertainty score representing the reliability of the feature map at that scale. The small uncertainty estimation sub-network consists of two consecutive 1×1 convolutional layers and a global average pooling layer connected in sequence. The structure of the small uncertainty estimation sub-network and the main detection network of the improved YOLOv8n network model are jointly trained in an end-to-end manner. The loss function of the small uncertainty estimation sub-network is supervised by the total target detection loss function of the improved YOLOv8n network model. The Softmax function is used to normalize the uncertainty scores for all scales, and each uncertainty score is converted into a corresponding adaptive weight. The feature maps at each scale are multiplied element-wise with their corresponding adaptive weights, and then all the multiplication results are summed to obtain the final fused feature map. The fused feature map is input into the final classification convolutional layer and regression convolutional layer of the detection head to perform object classification and bounding box regression prediction.
10. An underwater target detection system based on an improved YOLOv8n, used to implement the underwater target detection method based on an improved YOLOv8n as described in any one of claims 1-9, characterized in that, include: The image acquisition module is used to acquire preprocessed underwater target images, and the preprocessing includes at least underwater image enhancement. The processing module includes an improved YOLOv8n network model, which includes: a backbone feature extraction network based on a lightweight visual Transformer network, a feature fusion network including an online reparameterized convolution module, and a detection head optimized using a dynamic focusing loss function. An uncertainty-aware adaptive fusion mechanism is introduced into the detection head section; The output module is used to output the target detection results.