Underwater target detection method based on improved YOLOv8

By improving the underwater target detection method of YOLOv8, adopting the EfficientViT and RepGFPN modules, and combining the MLCA and SIOU loss functions, the real-time and accuracy problems of underwater target detection are solved, and more efficient underwater target detection is achieved.

CN119810631BActive Publication Date: 2025-10-03CHONGQING UNIV OF POSTS & TELECOMM
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411778823.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-05
Publication Date
2025-10-03
Estimated Expiration
2044-12-05

AI Technical Summary

Technical Problem

Existing underwater target detection algorithms have poor real-time performance and low detection accuracy when facing complex underwater environments, making it difficult to meet the needs of efficient detection.

Method used

The EfficientViT module is used as the backbone network, combined with the RepGFPN module as the Neck network, the hybrid local channel attention mechanism MLCA is introduced, and the SIOU loss function is used to enhance the feature extraction and bounding box regression capabilities.

Benefits of technology

It improves the accuracy and speed of underwater target detection, meets the requirements of real-time detection, and enhances the model's ability to perceive targets at different scales and resolutions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119810631B_ABST
    Figure CN119810631B_ABST
Patent Text Reader

Abstract

The present invention relates to an underwater target detection method based on an improved YOLOv8, belonging to the technical field of underwater target detection. The method uses the EfficientViT module as the backbone network of the improved YOLOv8 model and the RepGFPN module as the neck network of the improved model to perform the following steps: acquiring an underwater image, inputting it into the backbone network for feature extraction, and obtaining feature maps of several different scales; transferring the feature maps of different scales to the neck network for feature fusion and extracting feature information; using a hybrid local channel attention mechanism to fuse channel information, spatial information, local channel information, and global channel information to enhance feature representation capabilities; using a decoupled detection head to perform classification and positioning based on the enhanced feature information to obtain underwater target detection results; and designing a SIOU loss function to train the above process, which is then used for underwater target detection after training.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of underwater target detection and relates to an underwater target detection method based on improved YOLOv8. Background Art

[0002] With the development of the economy and technology, people are increasingly focusing on the development of marine resources, and underwater object detection has always been a key research direction. Underwater object detection is a complex field involving marine science, machine learning, and computer vision, and its challenges and technical requirements differ from those of object detection on land. Unlike terrestrial environments, the underwater environment is more complex. In particular, the following factors affect the images captured by underwater cameras: First, the optical properties of water cause light to scatter and absorb as it propagates through water, making underwater vision limited by depth and distance, resulting in low visibility. Second, underwater lighting is affected by factors such as natural light, suspended matter in the water, and water depth, often manifesting as uneven light intensity and large variations in light frequency. Third, underwater targets often have different visual characteristics than those on land, such as color depth, texture variations, and shape, which can vary depending on the underwater environment.

[0003] Deep learning-based object detection algorithms are a key research area in computer vision. Before the widespread adoption of deep learning technology, object detection primarily relied on hand-crafted features and traditional machine learning methods, such as support vector machines (SVMs) and random forests. These methods often require extensive feature engineering and manual tuning, making them difficult to adapt to complex scenarios and diverse object categories. Consequently, deep learning-based object detection algorithms have become widely used. Depending on whether or not candidate bounding boxes are generated, deep learning-based object detection methods are primarily categorized into two-stage and single-stage methods. Two-stage object detection methods include R-CNN, Fast R-CNN, and Faster R-CNN, while single-stage object detection algorithms include the YOLO (You Only Look Once) family of algorithms and the SSD (Single Shot MultiBox Detector) algorithm. The choice of deep learning object detection algorithm varies depending on user needs. When superior detection accuracy is required, two-stage object detection algorithms are generally preferred, while when faster detection accuracy is required, single-stage object detection algorithms are often used.

[0004] At present, underwater target detection usually uses a single-stage target detection method. In August 2020, Qiang Wei, He Yuyao and others proposed an underwater target detection algorithm based on improved SSD. The algorithm replaced the VGG convolutional neural network in SSD with the ResNet convolutional neural network, and used a deep deformable convolution module for feature extraction, thereby improving the accuracy and speed of underwater target detection in complex situations. In July 2022, Chen Yuliang, Dong Shaojiang and others proposed a real-time detection algorithm YOLOv5s-underwater based on YOLOv5s for underwater organisms under low-light conditions. It introduced restricted contrast adaptive histogram equalization and fast spatial pyramid pooling (SPPF) modules, which greatly improved the detection accuracy and greatly alleviated the problem of weak light attenuation in low-light underwater. In March 2024, Tao Yang, Zhu Teng, and others proposed an underwater target detection algorithm based on RepViTS-YOLOX to address the blur and occlusion issues in underwater target detection. This algorithm introduced a spatial and channel reconstruction module and a context decoupling head, which made the positioning and classification of underwater occluded targets more accurate. In June 2024, Li Dahai, Li Bingtao, and Wang Zhendong proposed the underwater target detection algorithm WCA-YOLOv8. While designing a feature fusion module and a downsampling enhancement module, they also introduced an FCA (FReLU Coordinate Attention) feature extraction module, achieving not only higher detection accuracy but also faster detection speed.

[0005] Although deep learning algorithms have played an important role in underwater target detection in recent years, they still have problems such as poor real-time performance and low detection accuracy in the face of complex underwater environments. Summary of the Invention

[0006] In view of this, the object of the present invention is to provide an underwater target detection method based on improved YOLOv8.

[0007] In order to achieve the above object, the present invention provides the following technical solutions:

[0008] An underwater target detection method based on improved YOLOv8 is proposed. The method uses the EfficientViT module as the backbone network of the improved YOLOv8 model and the RepGFPN module as the neck network of the improved YOLOv8 model to perform the following steps:

[0009] S1. Obtain underwater images and input them into the EfficientViT module for feature extraction to obtain feature maps of several different scales.

[0010] S2, passing the feature maps of different scales to the RepGFPN module for feature fusion and extracting feature information;

[0011] S3, using the hybrid local channel attention mechanism MLCA to fuse channel information, spatial information, local channel information and global channel information to enhance feature representation capabilities;

[0012] S4, classifying and locating the underwater target based on the enhanced feature information by the decoupled detection head to obtain the underwater target detection result;

[0013] S5. Design the SIOU loss function to train the above process, and use it for underwater target detection after training.

[0014] Furthermore, in step S1, EfficientViT adopts a hierarchical structure consisting of multiple stages. Each stage is composed of multiple EfficientViT building blocks stacked together, gradually reducing the resolution of the feature map and increasing the number of channels. The input image is first converted into a series of tokens through overlapping block embedding layers;

[0015] EfficientViT consists of three stages. First, the original image of size H×W×3 is taken as input, where H represents the image height, W represents the image width, and "3" represents the RGB color channels of the image;

[0016] In the first stage, the original image is processed through the overlapping patch embedding module to generate a preliminary feature map, which is then processed through the L1 EfficientViT building blocks of the first stage to obtain a feature map of size Feature map, where C1 represents the number of channels of the feature map at this stage;

[0017] In the second stage, the feature map output from the first stage is taken as input and processed by L2 EfficientViT building blocks to obtain a size of feature map, where C2 represents the number of channels of the feature map at this stage;

[0018] In the third stage, the feature map output from the second stage is taken as input and processed by L3 EfficientViT building blocks to obtain a size of feature map, where C3 represents the number of channels of the feature map at this stage;

[0019] Finally, the feature map is processed by global average pooling and classifier to obtain the final feature map.

[0020] Furthermore, the EfficientViT building block adopts a "sandwich" layout, that is, a self-attention layer MHSA is inserted between two feed-forward network layers FFN, and each FFN layer is followed by a deep convolutional layer DWConv to introduce local structural information; among them, the calculation process of the EfficientViT building block is expressed as:

[0021]

[0022] where X i is the complete input feature of the i-th block, and the layout is X i Change to X i+1 , there are N FFN layers before and after a single self-attention layer, is a single self-attention, is the self-attention in the FFN layer;

[0023] The cascaded attention module CGA is also set in the EfficientViT building block, which provides different splits of the complete features for each attention head and explicitly decomposes the attention calculation between the heads. The process is expressed as:

[0024]

[0025] Among them, X ij is the input feature X i The jth split of , h is the total number of heads, It is a projection layer that maps the input features into different subspaces. Attn() is the attention calculation function. is the j-th head output; It is a linear layer that projects the connected output features to the same dimension as the input. Concat[] is a function that merges arrays. is the output feature.

[0026] Furthermore, in step S2, the RepGFPN module accepts inputs from multiple nodes through several CSPStage modules and simultaneously fuses image features of different scales from adjacent layers;

[0027] The CSPStage module continuously optimizes the feature fusion process and reduces inference time by introducing recursive operations and reparameterization mechanisms.

[0028] The CSPStage module first performs a concat operation on the input feature map, then performs channel dimensionality reduction through 1×1 convolution, and then uses multiple Rep3×3 convolutions and 3×3 convolutions to transform the features. Multiple layers are output simultaneously, and finally the final output is obtained through the concat operation.

[0029] The inference phase body of Rep consists only of 3×3 convolutions and ReLU stacks, which utilizes an over-parameterized network in the form of multiple branches during training, but identically fuses the branches into one during inference.

[0030] Furthermore, in step S3, in the hybrid local channel attention module MLCA, the following processing steps are specifically included:

[0031] S31, the input feature vector is a vector of shape 1*C*ks*ks, where C represents the number of channels and ks is the size of the local block into which it is divided;

[0032] S32, perform a local pooling operation on the converted vector, divide the feature map into ks*ks local blocks, and perform average pooling on each block;

[0033] S33, respectively, processing through the global information branch and the local information branch, wherein, for the global information branch, the input vector is processed by one branch, keeping the global information unchanged, and outputting a one-dimensional vector containing global channel information; for the local information branch, it processes the local spatial information and outputs a one-dimensional vector containing the local spatial information after local pooling;

[0034] S34. The outputs of both branches are processed by one-dimensional convolution Conv1d. The convolution kernel size k of the one-dimensional convolution is related to the number of channels C and is calculated according to the following formula:

[0035]

[0036] Where γ and b are hyperparameters, k is an odd number, Φ(·) represents the mapping relationship between channel dimension C and convolution kernel size, |·| odd Indicates an odd number;

[0037] S35, the vector after one-dimensional convolution is restored to the original resolution through the unpooling operation;

[0038] S36: The global information and local information processed by the two branches are fused by adding or weighted adding to obtain the final attention weight.

[0039] S37. The fused attention weights are applied to the original input feature map to perform weighted adjustment on the feature map, emphasizing important features and suppressing unimportant features.

[0040] Furthermore, in step S4, multiple decoupled detection heads are used to process feature maps of different scales, and each detection head is specifically responsible for detecting objects at a specific scale.

[0041] Further, in step S5, the SIoU loss function is used as the bounding box loss function of the improved YOLOv8 model, wherein the SIoU loss function includes angle loss, distance loss, shape loss and IOU loss, wherein the SIoU loss function is expressed as:

[0042]

[0043] Where IOU represents the intersection-over-union ratio between the real box and the predicted box, △ represents the distance loss, and Ω represents the shape loss;

[0044] The angle loss is expressed as:

[0045]

[0046]

[0047] Where, They are the center coordinates of the real box and the center coordinates of the predicted box respectively;

[0048] The distance loss is expressed as:

[0049]

[0050] Where, ρ x , ρ y 、 are intermediate parameters in the calculation process, c w , c h are the width difference and height difference between the center points of the real box and the predicted box, respectively, and Λ represents the angle loss;

[0051] The shape loss is expressed as:

[0052]

[0053] Where w gt , h gt , w, h are the width and height of the real box and the predicted box respectively, ω w 、ω h is an intermediate parameter in the calculation process.

[0054] The beneficial effects of the present invention are:

[0055] (1) This paper adopts EfficientViT (Efficient Vision Transformer) as the backbone network of YOLOv8 to enhance the model's ability to extract global features of underwater targets.

[0056] (2) The present invention introduces a reparameterized generalized-directional feature pyramid network (RepGFPN) as a path aggregation network in the Neck network to enhance the information exchange and integration capabilities between feature graphs and improve the model's perception of targets at different scales and resolutions.

[0057] (3) This paper introduces an attention mechanism: Mixed local channel attention for object detection (MLCA) to improve the network's expressiveness, thereby meeting the detection performance of underwater target detection. At the same time, SIOU is used as the loss function to improve YOLOv8, and auxiliary boundaries of different scales are used to accelerate the regression of the bounding box.

[0058] Other advantages, objects, and features of the present invention will be described in part in the following description and, in part, will be apparent to those skilled in the art upon examination of the following description or may be learned from practice of the present invention. The objects and other advantages of the present invention may be realized and obtained through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention will be described in detail below with reference to the accompanying drawings, in which:

[0060] Figure 1 This is a schematic diagram of the network structure of the existing YOLOv8 model;

[0061] Figure 2 This is a schematic diagram of the structure of the C2f module in the existing YOLOv8 model;

[0062] Figure 3 This is a schematic diagram of the network structure of the improved ERMS-YOLOv8 model of the present invention;

[0063] Figure 4 Schematic diagram of the structure of the EfficientViT backbone network in the ERMS-YOLOv8 model of the present invention;

[0064] Figure 5 Schematic diagram of the network structure of RepGFPN in the ERMS-YOLOv8 model of the present invention;

[0065] Figure 6 Schematic diagram of the structure of the CSPStage module in the RepGFPN module of the ERMS-YOLOv8 model of the present invention;

[0066] Figure 7 Schematic diagram of the structure of the Req network in the CSPStage module of the present invention;

[0067] Figure 8 This is an example comparing the detection results of the present invention and the existing YOLOv8 model, where: Figure 8 (a) is the original image, Figure 8 (b) is the detection image of YOLOv8, Figure 8 (c) is the detection image of the improved algorithm. DETAILED DESCRIPTION

[0068] The following describes the embodiments of the present invention by means of specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and the following embodiments and features in the embodiments can be combined with each other without conflict.

[0069] Among them, the accompanying drawings are only for illustrative purposes and represent only schematic diagrams rather than actual pictures, and should not be understood as limiting the present invention. In order to better illustrate the embodiments of the present invention, some parts of the accompanying drawings may be omitted, enlarged or reduced, and do not represent the dimensions of actual products. For those skilled in the art, it is understandable that some well-known structures and their descriptions may be omitted in the accompanying drawings.

[0070] The same or similar numbers in the drawings of the embodiments of the present invention correspond to the same or similar parts; in the description of the present invention, it should be understood that if there are terms such as "upper", "lower", "left", "right", "front", "back", etc. indicating directions or positional relationships, they are based on the directions or positional relationships shown in the drawings. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific direction, be constructed and operate in a specific direction. Therefore, the terms describing the positional relationship in the drawings are only used for illustrative purposes and cannot be understood as limiting the present invention. For ordinary technicians in this field, the specific meanings of the above terms can be understood according to specific circumstances.

[0071] See also Figures 3 to 8 , which is an underwater target detection method based on improved YOLOv8.

[0072] The present invention proposes an underwater target detection method based on an improved YOLOv8. In this embodiment, the improved YOLOv8 model is called ERMS-YOLOv8.

[0073] The current YOLOv8 algorithm is a major update to the YOLO series, released by Ultralytics in January 2023. Building on the success of the previous YOLO series, it incorporates the Darknet-53 network architecture and improves the C3 module in YOLOv5 to a C2f module. It also abandons the Anchor-Base architecture of previous generations of models, providing a new state-of-the-art model capable of detection, classification, and segmentation. YOLOv8 is available in five model sizes: n, s, m, l, and x. These differ primarily in their balance between model size and detection accuracy. n, s, and m are the three most commonly used model sizes in object detection.

[0074] Figure 1 The figure shows the network structure of the existing YOLOv8. The existing YOLOv8 is divided into four parts, including the input end, the backbone network (Backbone), the feature fusion network (Neck) and the detection head (Head). The existing YOLOv8 refers to the ELAN design concept of YOLOv7 in the Backbone and Neck parts. At the same time, the most important improvement is to replace the CSP (Cross Stage Partial) module of YOLOv5 with the C2f (Cross Stage Partial Network Fusion) module with richer gradient flow. The C2f module is composed of 2 CBS and multiple BottleNecks. The CBS is composed of a convolutional layer, a batch normalization layer and an activation function. The structure of C2f is as follows Figure 2 As shown in the figure, a major change in the head is the replacement with a decoupled detection head. The existing YOLOv8 uses multiple decoupled detection heads to process feature maps of different scales. Each detection head is responsible for detecting objects at a specific scale, which can effectively handle targets of different sizes and distances. At the same time, each decoupled detection head can focus on feature representation at different levels, from shallow to deep feature maps, to capture various details and contextual information of the target, which helps improve the model's ability to recognize targets.

[0075] YOLOv8's loss function is primarily used to train a neural network to accurately predict the location and category of objects in an image. This loss function typically consists of several components: regression loss, classification loss, and bounding box loss.

[0076] In the classification loss, binary cross entropy (BCE) is used as the classification loss. Each category judges whether it is this category and outputs the confidence, as shown in formula (1):

[0077]

[0078] Among them, y i , p i They represent the integral value of the sample label and the probability that the sample is predicted to be a positive class.

[0079] At the same time, since the object loss is removed, the "object confidence" is also removed from the output. Therefore, the "confidence score" of each category is directly output, and then the maximum value is calculated and used as the confidence of the anchor box.

[0080] In the regression loss, Distribution Focal Loss (DFL) is first used to quickly focus the predicted position near the target position, as shown in formula (2):

[0081] DFL(S i ,S i+1 )=-((y i+1 -y)log(S i )+(yy i )log(S i+1 )) (2)

[0082] Among them, S i , S i+1 is the "predicted value" and "nearest predicted value" output by the network. i ,y i+1 The actual value, label integral value, and adjacent label integral value of the label are shown in Figure 2.

[0083] When the predicted position is clustered near the target, the CIOU loss function is used to further refine the position. The specific formula of the CIOU loss function is shown in formula (3) and formula (4):

[0084]

[0085] LOSS CIOU =1-CIOU (4)

[0086] Where α is a positive weight parameter, v is the aspect ratio consistency, and IOU is the intersection-over-union ratio. The calculation formulas for α and v are shown in formulas (5) and (6):

[0087]

[0088] IOU is a common metric used to measure the accuracy of target detection algorithms. It is very useful in evaluating the degree of overlap between the model's predicted bounding box and the true bounding box. The specific formula for IOU is shown in formula (7):

[0089]

[0090] The Area of ​​Intersection (AoI) is defined as the area of ​​overlap between the model's predicted bounding box and the true bounding box. The Area of ​​Union (AoU) is defined as the total area covered by the model's predicted bounding box and the true bounding box, which is the sum of the areas of the two bounding boxes minus the intersection area. The IOU value ranges from 0 to 1. If IOU is close to 1, it means that the model's predicted bounding box highly overlaps with the true bounding box, and the prediction accuracy is high. If IOU is close to 0, it means that the model's predicted bounding box has almost no overlap with the true bounding box, and the prediction accuracy is low.

[0091] In this paper, a target detection method ERMS-YOLOv8 is proposed to improve the low detection accuracy caused by underwater target blur. The network structure diagram of ERMS-YOLOv8 is shown as follows: Figure 3 As shown in the figure, the backbone network of ERMS-YOLOv8 is the EfficientViT (Efficient Vision Transformer) module, which enhances the ERMS-YOLOv8 model's feature extraction capabilities for underwater organisms and reduces feature information loss. Secondly, the RepGFPN (Reparameterized Generalized-directional Feature Pyramid Network) network module is used in the Neck component to enhance the ERMS-YOLOv8 model's ability to extract and fuse high-level semantic and low-level spatial features of underwater organisms, thereby enabling the ERMS-YOLOv8 model to obtain richer feature information. Subsequently, the MLCA (Mixed local channel attention for object detection) mechanism is introduced, allowing the ERMS-YOLOv8 model to simultaneously fuse channel information, spatial information, local channel information, and global channel information, enhancing the ERMS-YOLOv8 model's representation capabilities. Finally, the SIOU loss function is introduced to improve the model's ability to extract object boundary information, further enhancing detection accuracy.

[0092] Based on the established improved ERMS-YOLOv8 model, an underwater target detection method based on improved YOLOv8 of the present invention includes the following steps:

[0093] S1. Obtain underwater images and input them into the EfficientViT module for feature extraction to obtain feature maps of several different scales.

[0094] S2, passing the feature maps of different scales to the RepGFPN module for feature fusion and extracting feature information;

[0095] S3, using the hybrid local channel attention mechanism MLCA to fuse channel information, spatial information, local channel information and global channel information to enhance feature representation capabilities;

[0096] S4, classifying and locating the underwater target based on the enhanced feature information by the decoupled detection head to obtain the underwater target detection result;

[0097] S5. Design the SIOU loss function to train the above process, and use it for underwater target detection after training.

[0098] In step S1 of this embodiment, the input of ERMS-YOLOv8 is an underwater image. First, feature extraction is performed in the EfficientViT module to obtain four feature maps of different scales.

[0099] The overall network structure of EfficientViT is as follows Figure 4 As shown in the figure, EfficientViT adopts a hierarchical structure consisting of multiple stages. Each stage is composed of multiple stacked EfficientViT building blocks, gradually reducing the resolution of the feature map and increasing the number of channels. The input image is first converted into a series of tokens through the Overlapping Patch Embedding layer. By stacking multiple building blocks, EfficientViT is able to gradually extract deep-level features of the image. The Overlapping Patch Embedding layer enhances the model's ability to learn low-level visual representations.

[0100] In this embodiment, EfficientViT includes three stages. First, the original image of size H×W×3 is taken as input, where H represents the image height, W represents the image width, and "3" represents the RGB color channels of the image; in this embodiment, the height and width of the original image are preferably 640×640 resolution.

[0101] In the first stage, the original image is processed through the overlapping patch embedding module to generate a preliminary feature map, which is then processed through the L1 EfficientViT building blocks of the first stage to obtain a feature map of size The feature map of the original image is reduced to the spatial size of the original image. The number of channels is increased to capture more detailed features.

[0102] In the second stage, the feature map output from the first stage is taken as input and processed by L2 EfficientViT building blocks to obtain a size of The feature map of the stage is further reduced to the original image’s spatial size. The number of channels C2 is increased compared to C1, extracting higher-level features.

[0103] In the third stage, the feature map output from the second stage is taken as input and processed by L3 EfficientViT building blocks to obtain a size of The feature map of this stage is further reduced to the original image’s spatial size. The number of channels C3 is increased compared to C2 to further refine the image features.

[0104] Finally, the feature map is processed by global average pooling and classifier to obtain the final feature map.

[0105] The EfficientViT building block adopts a "sandwich" layout, that is, a self-attention layer (MHSA) is inserted between two feed-forward network (FFN) layers. Each FFN layer is followed by a deep convolution (DWConv) layer to introduce local structural information. The sandwich layout improves memory efficiency by reducing memory-intensive operations such as tensor reshaping and element-by-element operations in MHSA. The FFN layer promotes information communication between different channels, while the MHSA layer is responsible for the mixing of spatial information. The DWConv layer enhances the model's local feature extraction capability. The computational process of the building block can be expressed as:

[0106]

[0107] where X i is the complete input feature of the i-th block, and the layout is X i Change to X i+1 , there are N FFN layers before and after a single self-attention layer, is a single self-attention, This design reduces the memory and time loss caused by the self-attention layer in the model and uses more FFN layers to achieve efficient communication between different feature channels.

[0108] At the same time, EfficientViT uses a cascaded group attention module (CGA) to solve the problem of inefficient computation caused by redundant attention heads in MHSA. It provides different splits of the complete features for each head, thereby explicitly decomposing the attention calculation between heads. This attention can be expressed as follows:

[0109]

[0110] Among them, X ij is the input feature X i The jth split of , h is the total number of heads, It is a projection layer that maps the input features into different subspaces. Attn() is the attention calculation function. is the j-th head output; It is a linear layer that projects the connected output features to the same dimension as the input. Concat[] is a function that merges arrays. is the output feature.

[0111] Parameters are redistributed to improve parameter efficiency. This approach redistributes network parameters by increasing the channel width of key modules and reducing it in less important ones. Specifically, the Q and K projections at all stages of each head are set to small channel dimensions, while the V projections are allowed to have the same dimensionality as the input embedding. This approach allows more channels to learn representations in a high-dimensional space for important modules, preventing loss of feature information. Furthermore, redundant parameters in less important modules are removed, accelerating inference and improving model efficiency.

[0112] In step S2 of this embodiment, these four feature maps are sent to the neck network of RepGFPN for feature fusion. In the feature pyramid network, the purpose of multi-scale feature fusion is to extract features of different resolutions from the backbone network for aggregation. Most feature pyramid networks use traditional CNN-based networks as the backbone to extract multi-scale feature maps. However, with the development of CNN, the computational cost of using CNN is getting higher and higher. Subsequently, researchers found that compared to CNN, FPN emphasizes the exchange of high-level semantics and low-level spatial information. Therefore, FPN is generally used in target detection models.

[0113] The present invention adopts the RepGFPN network structure as the neck network to further improve the target detection capability. Figure 5 As shown in the figure, the RepGFPN module accepts more node inputs through five CSPStage modules, simultaneously fusing image features of different scales from adjacent layers. This enhances feature reuse and expression capabilities while ensuring a certain computational load, improving object detection accuracy. The CSPStage module continuously optimizes the feature fusion process and reduces model inference time by introducing recursive operations and reparameterization mechanisms.

[0114] CSPStage modules such as Figure 6As shown in the figure, the CSPStage module first performs a Concat operation on the input feature map, then performs channel dimensionality reduction through 1×1 convolution, and then uses multiple Rep3×3 convolutions and 3×3 convolutions for feature transformation. At the same time, multiple layers are output, and finally the final output is obtained through the Concat operation.

[0115] The structure of Rep is as follows Figure 7 As shown in the figure, the main structure of the inference phase of this structure consists only of 3×3 convolutions and ReLU stacks. During the training phase, a multi-branch over-parameterized network is used, and the branches are fused into a single branch during inference. Precisely because the advantages of multi-branch architectures are all used for training, but the disadvantage is that they are not suitable for inference, the decoupling of training time and inference time is achieved through structural reparameterization technology.

[0116] In step S3 of this embodiment, the attention mechanism is one of the most widely used components in computer vision, which can help neural networks highlight important elements and suppress irrelevant elements. Existing attention modules mainly focus on the channel domain or the spatial domain. These two attention mechanisms completely correspond to the feature-based attention and space-based attention in the human brain. However, most channel attention mechanisms only contain channel feature information and ignore spatial feature information, which is crucial for constructing spatial attention maps. Therefore, this neglect of spatial feature information leads to poor model representation or target detection performance. At the same time, spatial attention modules are often complex and expensive, resulting in some attention processes that do contain spatial information, but the computational complexity and parameter requirements are too large to directly incorporate this information into lightweight network models. When they are added to the network, the channel size is often reduced, so their use is usually accompanied by a reduction in accuracy due to the reduction in channel size.

[0117] Therefore, the present invention adopts a lightweight hybrid local channel attention (MLCA) module to improve the performance of the object detection network. This module can simultaneously include channel information and spatial information, as well as local information and global information, and uses a one-dimensional convolution acceleration method to reduce the amount of computation and the number of parameters to improve the network's expressive effect.

[0118] In the hybrid local channel attention module MLCA, the following processing steps are specifically included:

[0119] S31. Input feature vector conversion: The input feature vector is first converted into a vector of shape 1*C*ks*ks, where C represents the number of channels and ks is the size of the local block (ks=5 in the figure). This step is to extract local spatial information.

[0120] S32. Local Pooling: Perform local pooling on the transformed vector. Local pooling divides the feature map into ks*ks local blocks and performs average pooling on each block. This step helps capture information in local areas.

[0121] S33. Branch Processing: Global Information Branch: The input vector is processed through one branch, which preserves global information. The output of this branch is a one-dimensional vector containing global channel information. Local Information Branch: Another branch processes local spatial information. The output of this branch is also a one-dimensional vector, but contains local spatial information after local pooling.

[0122] S34, one-dimensional convolution acceleration: To reduce the amount of computation and the number of parameters, the outputs of both branches are processed by one-dimensional convolution (Conv1d). The convolution kernel size k of one-dimensional convolution is related to the number of channels C and is calculated according to the following formula:

[0123]

[0124] Where γ and b are hyperparameters with default values ​​of 2, and k is an odd number. Φ(·) represents the mapping relationship between the channel dimension C and the convolution kernel size. |·| odd This step helps to capture local cross-channel interaction information.

[0125] S35, Anti-Pooling: The vector after one-dimensional convolution is restored to its original resolution through the anti-pooling operation. Anti-pooling is an upsampling technique that uses adaptive pooling to restore the size of the feature map to its original size.

[0126] S36, Information Fusion: The information processed by the two branches (global information and local information) is fused by adding or weighted addition to obtain the final attention weight. This step implements a hybrid attention mechanism that considers both global and local information.

[0127] S37, output feature adjustment: The fused attention weights are applied to the original input feature map to perform weighted adjustment on the feature map, thereby emphasizing important features and suppressing unimportant features.

[0128] In step S4 of this embodiment, multiple decoupled detection heads are also used to process feature maps of different scales. Each detection head is responsible for detecting objects at a specific scale, which can effectively process targets of different sizes and distances. At the same time, each decoupled detection head can focus on feature representations at different levels, from shallow to deep feature maps, to capture various details and contextual information of the target, which helps to improve the model's ability to recognize the target.

[0129] In step S5 of this embodiment, YOLOv8 uses CIoU as the bounding box regression loss function. Although CIoU contributes to improved accuracy, it also has some drawbacks, especially poor performance when processing object boxes of different sizes. The ERMS-YOLOv8 model of the present invention introduces SIoU as a new bounding box loss function.

[0130] SIoU is generally composed of four parts, including angle loss, distance loss, shape loss and IOU loss. The definition of SIoU is shown in formula (11):

[0131]

[0132] Where IOU represents the intersection-over-union ratio between the real box and the predicted box, △ represents the distance loss, and Ω represents the shape loss;

[0133] The angle loss is shown in formula (12) and formula (13):

[0134]

[0135] Where, They are the center coordinates of the real box and the center coordinates of the predicted box respectively;

[0136] The distance loss is shown in formula (14) and formula (15):

[0137]

[0138] Where, ρ x , ρ y 、 are intermediate parameters in the calculation process, c w , c h are the width difference and height difference between the center points of the real box and the predicted box, respectively, and Λ represents the angle loss;

[0139] The shape loss is shown in formula (16) and formula (17):

[0140]

[0141] in, are the center coordinates of the real frame and the center coordinates of the predicted frame respectively; w gt , h gt , w, h are the width and height of the real box and the predicted box respectively. ω w 、ω h is an intermediate parameter in the calculation process.

[0142] This embodiment experiments and analyzes the underwater target detection method based on the improved YOLOv8 proposed in the present invention.

[0143] The dataset used in this experiment is the URPC2021 public underwater dataset from the 2021 National Underwater Robot Competition. This dataset contains 6,575 images and corresponding annotation files. The detection targets include four underwater creatures: sea urchins, starfish, shells, and scallops, covering real-world underwater detection scenarios. This example partitions the dataset into two parts: 8:2, with 4,585 images used as a training set and 1,990 images used as a validation set.

[0144] The experimental environment of this embodiment is shown in Table 1. When training the dataset, this embodiment uses stochastic gradient descent (SGD) as the optimization model, with an input image size of 640×640, a batch size of 16, and a training cycle of 300 rounds.

[0145] Table 1

[0146]

[0147] This embodiment uses mean average precision (MAP) as an evaluation index for testing the underwater target detection method improved based on YOLOv8 of the present invention. The definition formula of mean average precision is shown in formula (18) and formula (19):

[0148]

[0149] The definitions of recall and precision are as follows:

[0150]

[0151] When the IoU (Intersection over Union) value between the detection result and the true value exceeds a predefined threshold, the detection is considered a true positive (TP), indicating successful target recognition. Conversely, if the IoU is below the threshold, the detection is classified as a false positive (FP), indicating an incorrect recognition. Samples correctly predicted as negative are called false negatives (FN), while samples incorrectly predicted as true negatives (TN).

[0152] At the same time, to verify whether the improved algorithm meets the real-time requirements of underwater target detection, this embodiment will determine the model's computational load (floating point operations, FLOPs) and frame rate (frame per second, FPS). Among them, the higher the FPS, the faster the detection speed.

[0153] In addition, model parameters are also an important indicator to measure the quality of the target detection module.

[0154] This example uses the performance of different algorithms on the URPC2021 dataset as comparative experimental data to verify the effectiveness of the target detection algorithm of the present invention.

[0155] First, by comparing the mAP@0.5, GFLOPS, FPS, and parameter evaluation indicators of Faster-RCNN and different versions of the YOLO series algorithms on the URPC2021 dataset. YOLOv8 achieved 81.0% on mAP@0.5 with only 3.0M parameters and 8.1GFLPOs of computational effort, becoming the best basic model. At the same time, in order to verify the superiority of the algorithm proposed in this embodiment, comparative experiments were conducted with some proposed improved underwater target detection algorithms based on YOLOv8 using the same experimental equipment and datasets. The selected target detection algorithms include the WCA-YOLOv8 algorithm proposed by Li Dahai et al. in November 2023, and the IEMAyoloViT algorithm proposed by Shi Kequan et al. in December 2023.

[0156] Table 2 compares the experimental results of different algorithms under URPC2021:

[0157] Table 2

[0158]

[0159] The comparative results in Table 2 show that, despite the increased floating-point computational overhead and network parameter count compared to the base model YOLOv8, the proposed algorithm improves mAP50 by 2.9% and mAP50-95 by 3.3%. Furthermore, experiments show that the proposed algorithm achieves an FPS of 230. While this sacrifices some time in processing image features, it still meets real-time requirements.

[0160] At the same time, in order to verify the effectiveness of MLCA, this example will use MLCA and some commonly used attention mechanisms to conduct comparative experiments on YOLOv8. Table 3 shows the experimental results of YOLOv8 introducing different attention mechanisms under URPC2021:

[0161] Table 3

[0162]

[0163] As shown in the experimental results in Table 3, when MLCA is added, YOLOv8 shows excellent performance on the URPC2021 dataset, improving the accuracy of target detection without significantly increasing the scale of model parameters.

[0164] This example also conducted ablation experiments using the YOLOv8 algorithm as the base model. This included changing only the backbone network to EfficientViT, only the neck network to RepGFPN, adding only the MLCA attention mechanism, and changing only the loss function to SIOU. The ablation test results are shown in Table 4.

[0165] Table 4

[0166]

[0167]

[0168] As shown in Table 4, Experiment 1 shows the experimental results of the unmodified YOLOv8. Experiment 2 replaces the YOLOv8 backbone network with EfficientViT, which improves mAP50 by 0.6% and mAP50-95% by 0.4% compared to YOLOv8. Replacing the backbone network with EfficientViT enhances the model's overall feature extraction capabilities. Experiment 3 replaces the YOLOv8 neck network with RepGFPN, which improves mAP50 by 1.0% and mAP50-95 by 0.6% compared to YOLOv7. Replacing the backbone network with RepGFPN enhances multi-scale feature fusion, improving the model's multi-scale detection capabilities and achieving higher accuracy without incurring a significant additional computational burden. Experiment 4 adds the MLCA attention mechanism to the backbone network, improving mAP50 by 0.4% and mAP50-95 by 0.2%. MLCA improves the ability to extract target information. Experiment 5 replaces the loss function CIOU with SIOU, which slightly improves mAP. Experiments 6, 7, and 8 show that combining these improvements can significantly improve the performance of object detection.

[0169] In order to more clearly demonstrate the detection effect of the improved algorithm of the present invention, this embodiment will select some photos for comparison and verification. Figure 8 As shown, Figure 8 (a) is the original image, Figure 8 (b) is the detection image of YOLOv8, Figure 8 (c) is the detection graph of the improved algorithm. Figure 8As can be seen, the YOLOv8 algorithm suffers from low detection accuracy due to missed detections and false detections when detecting underwater targets, and its detection performance is poor when targets are piled up. In contrast, the improved algorithm in this paper effectively improves these problems, maintaining the real-time performance of underwater detection while increasing the model's detection accuracy for underwater targets.

[0170] In view of the situation that underwater targets appear blurred due to complex underwater environments, the present invention proposes an improved YOLOv8 target detection algorithm to improve the detection accuracy of underwater targets. This method introduces the EfficientViT backbone network, the RepGFPN neck network and the MLCA attention mechanism to enhance the model's feature extraction ability for underwater target organisms and the ability to fuse cross-scale information, effectively improving the detection accuracy of underwater blurred targets. At the same time, the model loss function is replaced with SIOU, which improves the model's ability to extract boundary information without sacrificing computational complexity, effectively improving the accuracy of target detection. Through a series of comparative experiments and ablation experiments, this embodiment verifies the effectiveness of the proposed algorithm. Although the model parameters and computational complexity have increased, the detection accuracy is improved by 2.9 percentage points compared to the basic model YOLOv8 while maintaining the real-time detection.

[0171] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not limiting. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solutions, which should all be included in the scope of the claims of the present invention.

Claims

1. An underwater target detection method based on improved YOLOv8, characterized by: The method uses the EfficientViT module as the backbone network of the improved YOLOv8 model and the RepGFPN module as the neck network of the improved YOLOv8 model to perform the following steps: S1. Obtain underwater images and input them into the EfficientViT module for feature extraction to obtain feature maps of several different scales. S2, passing the feature maps of different scales to the RepGFPN module for feature fusion and extracting feature information; S3, using the hybrid local channel attention mechanism MLCA to fuse channel information, spatial information, local channel information and global channel information to enhance feature representation capabilities; S4, classifying and locating the underwater target based on the enhanced feature information by the decoupled detection head to obtain the underwater target detection result; S5. Design the SIOU loss function to train the above process, and use it for underwater target detection after training.

2. The underwater target detection method based on improved YOLOv8 according to claim 1, characterized in that: In step S1, EfficientViT adopts a hierarchical structure consisting of multiple stages. Each stage is composed of multiple EfficientViT building blocks stacked together, gradually reducing the resolution of the feature map and increasing the number of channels. The input image is first converted into a series of tokens through overlapping block embedding layers. EfficientViT consists of three stages. First, it takes the original image of size H×W×3 as input, where H represents the image height, W represents the image width, and "3" represents the RGB color channels of the image. In the first stage, the original image is processed through the overlapping patch embedding module to generate a preliminary feature map, which is then processed through the L1 EfficientViT building blocks of the first stage to obtain a feature map of size Feature map, where C1 represents the number of channels of the feature map at this stage; In the second stage, the feature map output from the first stage is taken as input and processed by L2 EfficientViT building blocks to obtain a size of feature map, where C2 represents the number of channels of the feature map at this stage; In the third stage, the feature map output from the second stage is taken as input and processed by L3 EfficientViT building blocks to obtain a size of feature map, where C3 represents the number of channels of the feature map at this stage; Finally, the feature map is processed by global average pooling and classifier to obtain the final feature map.

3. The underwater target detection method based on improved YOLOv8 according to claim 2, characterized in that: The EfficientViT building block inserts a self-attention layer MHSA between two feed-forward network layers FFN. Each FFN layer is followed by a deep convolutional layer DWConv to introduce local structural information. The calculation process of the EfficientViT building block is expressed as: where X i is the complete input feature of the i-th block, and the layout is X i Change to X i+1 , there are N FFN layers before and after a single self-attention layer, is a single self-attention, is the self-attention in the FFN layer; The cascaded attention module CGA is also set in the EfficientViT building block, which provides different splits of the complete features for each attention head and explicitly decomposes the attention calculation between the heads. The process is expressed as: Among them, X ij is the input feature X i The jth split of , h is the total number of heads, It is a projection layer that maps the input features into different subspaces. Attn() is the attention calculation function. is the j-th head output; It is a linear layer that projects the connected output features to the same dimension as the input. Concat[] is a function that merges arrays. is the output feature.

4. The underwater target detection method based on improved YOLOv8 according to claim 2, characterized in that: In step S2, the RepGFPN module accepts inputs from multiple nodes through several CSPStage modules and simultaneously fuses image features of different scales from adjacent layers; The CSPStage module continuously optimizes the feature fusion process and reduces inference time by introducing recursive operations and reparameterization mechanisms; The CSPStage module first performs a concat operation on the input feature map, then performs channel dimensionality reduction through 1×1 convolution, and then uses multiple Rep3×3 convolutions and 3×3 convolutions to transform the features. Multiple layers are output simultaneously, and finally the final output is obtained through the concat operation. The inference phase body of Rep consists only of 3×3 convolutions and ReLU stacks, which utilizes an over-parameterized network in the form of multiple branches during training, but identically fuses the branches into one during inference.

5. The underwater target detection method based on improved YOLOv8 according to claim 4, characterized in that: In step S3, in the hybrid local channel attention module MLCA, the following processing steps are specifically included: S31, the input feature vector is a vector of shape 1*C*ks*ks, where C represents the number of channels and ks is the size of the local block into which it is divided; S32, perform a local pooling operation on the converted vector, divide the feature map into ks*ks local blocks, and perform average pooling on each block; S33, respectively, processing through the global information branch and the local information branch, wherein, for the global information branch, the input vector is processed by one branch, keeping the global information unchanged, and outputting a one-dimensional vector containing global channel information; for the local information branch, it processes the local spatial information and outputs a one-dimensional vector containing the local spatial information after local pooling; S34. The outputs of both branches are processed by one-dimensional convolution Conv1d. The convolution kernel size k of the one-dimensional convolution is related to the number of channels C and is calculated according to the following formula: Where γ and b are hyperparameters, k is an odd number, Φ(·) represents the mapping relationship between channel dimension C and convolution kernel size, |·| odd Indicates an odd number; S35, the vector after one-dimensional convolution is restored to the original resolution through the unpooling operation; S36: The global information and local information processed by the two branches are fused by adding or weighted adding to obtain the final attention weight. S37. The fused attention weights are applied to the original input feature map to perform weighted adjustment on the feature map, emphasizing important features and suppressing unimportant features.

6. The underwater target detection method based on improved YOLOv8 according to claim 5, characterized in that: In step S4, multiple decoupled detection heads are used to process feature maps of different scales, and each detection head is responsible for detecting objects at a specific scale.

7. The underwater target detection method based on improved YOLOv8 according to claim 6, characterized in that: In step S5, the SIoU loss function is used as the bounding box loss function of the improved YOLOv8 model, wherein the SIoU loss function includes angle loss, distance loss, shape loss and IOU loss, wherein the SIoU loss function is expressed as: Where IOU represents the intersection-over-union ratio between the real box and the predicted box, △ represents the distance loss, and Ω represents the shape loss; The angle loss is expressed as: Where, They are the center coordinates of the real box and the center coordinates of the predicted box respectively; The distance loss is expressed as: Where, ρ x , ρ y 、 are intermediate parameters in the calculation process, c w , c h are the width difference and height difference between the center points of the real box and the predicted box, respectively, and Λ represents the angle loss; The shape loss is expressed as: Where w gt , h gt , w, h are the width and height of the real box and the predicted box respectively, ω w 、ω h is an intermediate parameter in the calculation process.

Citation Information

Patent Citations

  • Target detection method based on improved YOLOv4 network

    CN115731392A

  • Improved YOLOv7 unmanned aerial vehicle aerial photography small target detection method

    CN117037001A