Underwater target detection method based on improved YOLOv8

By improving the YOLOv8 method, EfficientViT, RepGFPN and MLCA technologies were introduced, combined with the SIoU loss function, the problems of low real-time and accuracy in underwater target detection were solved, and more efficient and accurate underwater target detection was achieved.

CN119810631AActive Publication Date: 2025-04-11CHONGQING UNIV OF POSTS & TELECOMM

Patent Information

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

AI Technical Summary

Technical Problem

The existing underwater target detection technology has problems such as poor real-time performance and low detection accuracy in complex underwater environments.

Method used

The improved YOLOv8 method is adopted, and the feature extraction and information fusion capabilities are enhanced by introducing the EfficientViT module as the backbone network and the RepGFPN module as the neck network, and combining the hybrid local channel attention mechanism (MLCA) and SIoU loss function.

Benefits of technology

The detection accuracy and speed of underwater target detection are improved, the model's global feature extraction and cross-scale information fusion capabilities of underwater targets are enhanced, and the real-time requirements of underwater target detection are met.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119810631A_ABST
    Figure CN119810631A_ABST
Patent Text Reader

Abstract

The invention relates to an underwater target detection method based on improved YOLOv8, and belongs to the technical field of underwater target detection. According to the method, an OfficientViT module is adopted as a backbone network for improving a YOLOv8 model, and a RepGFPN module is adopted as a check network for improving the model, so that the following steps are executed: obtaining an underwater picture, and inputting the underwater picture into the backbone network for feature extraction to obtain a plurality of feature maps with different scales; transmitting the feature maps of different scales to a check network for feature fusion, and extracting feature information; a mixed local channel attention mechanism is adopted to fuse channel information, spatial information, local channel information and global channel information, and the feature representation capability is enhanced; performing classification and positioning according to the enhanced feature information through a decoupling detection head to obtain an underwater target detection result; and designing an SIOU loss function to train the above process, and using the training for underwater target detection after the training is completed.
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 economy and technology, people pay more and more attention to the development of marine resources, and underwater target detection has always been an important research direction. Underwater target detection is a complex field involving marine science, machine learning and computer vision. Its challenges and technical requirements are different from those of target detection on land. Unlike the terrestrial environment, the underwater environment is more complex, especially the following points affect the images collected by underwater cameras. First, the optical properties of water cause light to scatter and absorb when it propagates in water, so that underwater vision is limited by depth and distance, and visibility is low; second, underwater lighting is affected by factors such as natural light, suspended matter in water and water depth, which usually manifests as uneven light intensity and large changes in light frequency; third, underwater target objects usually have different visual characteristics from those on land, such as color depth, texture changes, shape, etc. These characteristics may vary depending on the underwater environment.

[0003] Object detection algorithms based on deep learning are one of the important research directions in the field of computer vision. Before the popularization of deep learning technology, object detection mainly relied on manually designed features and traditional machine learning methods, such as support vector machines (SVM) and random forests. These methods usually require a lot of feature engineering and manual adjustments, and are difficult to adapt to complex scenes and diverse target categories. Therefore, object detection algorithms based on deep learning are widely used. At the same time, according to whether candidate boxes need to be generated, object detection based on deep learning is mainly divided into two-stage detection methods and single-stage detection methods. Two-stage object detection mainly includes R-CNN, Fast R-CNN, Faster R-CNN, etc., while the representatives of single-stage object detection are YOLO (You Only Look Once) series algorithms and SSD (Single Shot MultiBox Detector) algorithms. At the same time, according to different user needs, the selected deep learning object detection algorithm is also different. When better detection accuracy is required, the two-stage object detection algorithm is usually given priority, and when faster detection accuracy is required, the single-stage object detection algorithm is usually 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 a ResNet convolutional neural network, and used a deep deformable convolution module for feature extraction, which improved 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 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 problems of underwater target detection. They introduced a spatial and channel reconstruction module and a context decoupling head to more accurately locate and classify underwater occluded targets. In June 2024, Li Dahai, Li Bingtao and Wang Zhendong proposed the underwater target detection algorithm WCA-YOLOv8. While designing the feature fusion module and the downsampling enhancement module, they introduced the FCA (FReLU Coordinate Attention) feature extraction module, which not only achieved higher detection accuracy, but also achieved 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 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 according to the enhanced feature information by decoupling the detection head, and obtaining the underwater target detection result;

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

[0014] Further, in step S1, EfficientViT adopts a hierarchical structure, which includes 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 three 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 used 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 segmentations 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 jth 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] Further, 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 different layers;

[0027] The CSPStage module continuously optimizes the feature fusion process and reduces the 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 dimension reduction through 1×1 convolution, and then uses multiple Rep3×3 convolutions and 3×3 convolutions to transform the features. It outputs multiple layers at the same time, and finally obtains the final output 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 the training phase, but identically fuses the branches into one during inference.

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

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

[0032] S32, performing a local pooling operation on the converted vector, dividing the feature map into ks*ks local blocks, and performing 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 through one branch, the global information is kept unchanged, and a one-dimensional vector is output, which contains the global channel information; for the local information branch, it processes the local spatial information and outputs a one-dimensional vector, which contains 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, which 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 It means taking 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] In the formula, 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] In the formula, 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] In the formula, ρ x , y , are all 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] In the formula, w gt ,h gt , w, h are the width and height of the real box and the predicted box respectively, ω w ,ω h It is an intermediate parameter in the calculation process.

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

[0055] (1) The present invention 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) The present invention introduces an attention mechanism: Mixed local channel attention for object detection (MLCA) to improve the expression effect of the network, thereby meeting the detection performance of underwater target detection. At the same time, SIOU is used as the loss function of the improved YOLOv8, and auxiliary boundaries of different scales are used to accelerate the regression of the border.

[0058] Other advantages, objectives and features of the present invention will be described in the following description to some extent, and to some extent, will be obvious to those skilled in the art based on the following examination and study, or can be taught from the practice of the present invention. The objectives and other advantages of the present invention can 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 in conjunction with the accompanying drawings, wherein:

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

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

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

[0063] Figure 4 It is a 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 It is a 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 It is a schematic diagram of the structure of the Req network in the CSPStage module of the present invention;

[0067] Figure 8 This is an example of comparing the detection results of the present invention with those of 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 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 only illustrate the basic concept of the present invention in a schematic manner, and the following embodiments and features in the embodiments can be combined with each other without conflict.

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

[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 the terms "upper", "lower", "left", "right", "front", "rear", etc. indicate the orientation or position relationship, they are based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation. Therefore, the terms describing the position 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 Figure 3 to Figure 8 , which is an underwater target detection method based on improved YOLOv8.

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

[0073] The existing YOLOv8 algorithm is a major update of the YOLO series released by Ultralytics in January 2023. It is based on the success of the previous YOLO series, combines the Darknet-53 network structure idea and improves the C3 module in YOLOv5 to the C2f module, while abandoning the Anchor-Base of previous generations of models, providing a new SOTA model that can complete detection, classification, and segmentation tasks. YOLOv8 is divided into five model sizes: n, s, m, l, and x. The main difference between them is the balance between model size and detection accuracy, and n, s, and m are the three commonly used model sizes in target 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 convolution layer, a batch normalization layer and an activation function. The structure of C2f is as follows Figure 2 As shown in the figure, a relatively big change in the Head part 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 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 targets.

[0075] The loss function of YOLOv8 is mainly used to train the neural network so that it can accurately predict the location and category of objects in the image. The loss function usually contains multiple parts, including: coordinate regression loss (Regression Loss), classification loss (Classification Loss), and bounding box loss (Bounding Box Loss).

[0076] In the classification loss, binary cross entropy (BCE) is used as the classification loss. Each category is judged whether it is this category and the confidence is output, 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 in 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, the 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 "prediction value" and "near prediction value" output by the network. i ,y i+1 The actual value, label integral value, and adjacent label integral value of the label.

[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] Among them, α is a positive trade-off parameter, v is the aspect ratio consistency, IOU is the intersection over union ratio, and the calculation formulas of α and v are shown in formula (5) and formula (6):

[0087]

[0088] IOU is a common indicator for measuring 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 of IOU is shown in formula (7):

[0089]

[0090] Among them, Area of ​​Intersection is defined as the area of ​​the overlap between the bounding box predicted by the model and the true bounding box. Area of ​​Union is defined as the total area covered by the bounding box predicted by the model and the true bounding box, that is, the sum of the areas of the two bounding boxes minus the intersection area. The value range of IOU is between 0 and 1. If IOU is close to 1, it means that the bounding box predicted by the model highly overlaps with the true bounding box, and the prediction accuracy is high; if IOU is close to 0, it means that the bounding box predicted by the model has almost no overlap with the true bounding box, and the prediction accuracy is low.

[0091] In the present invention, 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 in the figure. Figure 3 As shown in the figure, the backbone network of ERMS-YOLOv8 is the EfficientViT (Efficient Vision Transformer) module, which can enhance the ERMS-YOLOv8 model's ability to extract underwater organisms and reduce feature information loss. Secondly, the RepGFPN (Reparameterized Generalized-directional Feature Pyramid Network) network module is used in the Neck part to enhance the ERMS-YOLOv8 model's ability to extract and fuse high-level semantics and low-level spatial features of underwater organisms, so that the ERMS-YOLOv8 model can obtain richer feature information. Subsequently, the MLCA (Mixed local channel attention for object detection) mixed local channel attention mechanism is introduced, so that the ERMS-YOLOv8 model can simultaneously fuse channel information, spatial information, local channel information and global channel information, and enhance the representation ability of the ERMS-YOLOv8 model. Finally, the SIOU loss function is introduced to enhance the model's ability to extract target boundary information, thereby further improving the detection accuracy.

[0092] On the basis of the established improved ERMS-YOLOv8 model, an underwater target detection method based on improved YOLOv8 of the present invention comprises 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 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 according to the enhanced feature information by decoupling the detection head, and obtaining the underwater target detection result;

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

[0098] In step S1 of this embodiment, the input of ERMS-YOLOv8 is an underwater picture. 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, which includes 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 the Overlapping Patch Embedding layer. By stacking multiple building blocks, EfficientViT is able to gradually extract deep features of the image. The Overlapping Patch Embedding layer enhances the model's ability in learning low-level visual representations.

[0100] In this embodiment, EfficientViT includes three stages. First, the original image with a size of H×W×3 is taken as input, where H represents the image height, W represents the image width, and "3" represents the three 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 increases to capture more detailed features.

[0102] In the second stage, the feature map output from the first stage is used as input and processed by L2 EfficientViT building blocks to obtain a size of The feature map of the original image is further reduced to the original image size. The number of channels C2 increases 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. The number of channels C3 increases 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 local feature extraction capability of the model. 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, is the self-attention in the FFN layer. This design reduces the memory 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 segmentations 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 jth 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] Redistribute parameters to improve parameter efficiency. Redistribute parameters in the network by expanding the channel width of key modules and reducing the channel width of unimportant modules. Specifically, set small channel dimensions for Q and K projections at all stages of each head mentioned above, and allow the same dimension as the input embedding for V projection. With this method, important modules have more channels in high-dimensional space to learn representations, avoiding the loss of feature information. At the same time, remove redundant parameters in unimportant modules, speed up inference, and improve 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 high-level semantics and low-level spatial information exchange. 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 5 CSPStage modules, and fuses image features of different scales from adjacent layers, while ensuring a certain amount of computation, to enhance feature reuse and feature expression capabilities, and improve the accuracy of target detection. The CSPStage module continuously optimizes the feature fusion process and reduces the 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 dimension reduction through 1×1 convolution, and then uses multiple Rep3×3 convolutions and 3×3 convolutions to transform the features, outputs multiple layers at the same time, and finally obtains the final output through the Concat operation.

[0115] The structure of Rep is as follows Figure 7 As shown in the figure, the main body of the inference phase of the structure is only composed of 3×3 convolutions and ReLU stacks. In the training phase, a multi-branch over-parameterized network is used, and the branches are merged into one branch in the inference process. It is precisely because the advantages of the multi-branch architecture are all used for training, and the disadvantage is that it is not desirable to be used for inference, so the decoupling of the training time and inference time structure is achieved through the structural reparameterization technology.

[0116] In step S3 of the present embodiment, the attention mechanism is one of the most widely used components in computer vision, which can help the neural network highlight important elements and suppress irrelevant elements. Existing attention modules are mainly concentrated in the channel domain or the spatial domain, and 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 a spatial attention map. Therefore, this neglect of spatial feature information leads to poor model representation effect or target detection performance. At the same time, spatial attention modules are often complex and expensive, resulting in that although some attention processes do contain spatial information, the computational workload and parameter requirements are too large to directly incorporate this information into the lightweight network model. When they are added to the network, there is often a reduction in channel size, 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 target detection network. The module can contain channel information and spatial information, as well as local information and global information, and adopts a one-dimensional convolution acceleration method to reduce the amount of calculation and the number of parameters to improve the expression effect of the network.

[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 into which it is divided (ks=5 in the figure). This step is to extract local spatial information.

[0120] S32, Local Pooling: Perform local pooling on the converted 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 a branch that keeps the global information unchanged. 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: In order to reduce the amount of calculation 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, which 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 capture local cross-channel interaction information.

[0125] S35, Anti-Pooling: The vector after one-dimensional convolution is restored to the 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 addition or weighted addition to obtain the final attention weight. This step implements the hybrid attention mechanism, taking into account 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 improving accuracy, it also has some disadvantages, especially in processing target boxes of different sizes. The ERMS-YOLOv8 model of the present invention introduces SIoU as a new bounding box loss function.

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

[0131]

[0132] In the formula, 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] Among them, the angle loss is shown in formula (12) and formula (13):

[0134]

[0135] In the formula, 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] In the formula, ρ x , y , are all 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 It is an intermediate parameter in the calculation process.

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

[0143] The dataset used in the experiment of this embodiment is the URPC2021 public underwater dataset of the 2021 National Underwater Robot Competition. The dataset contains 6575 images and corresponding annotation files. The detection targets include four underwater creatures: sea urchins, starfish, shells, and scallops, covering real underwater detection scenes. This embodiment divides the dataset into 8:2 ratios, with 4585 images as training sets and 1990 images as validation sets.

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

[0145] Table 1

[0146]

[0147] In this embodiment, mean Average Precision (MAP) is used 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] Among them, 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 that the target recognition is successful. On the contrary, if the IoU is lower than the threshold, the detection is classified as a false positive (FP), indicating an identification error. Samples correctly predicted as negative are called false negatives (FN), while samples incorrectly predicted are called true negatives (TN).

[0152] At the same time, in order to verify whether the improved algorithm meets the real-time requirements of underwater target detection, this embodiment will determine the model calculation amount (floating point operations, FLOPs) and frame rate per second (Frame per Second, FPS). Among them, the larger 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 underwater target detection algorithms based on YOLOv8 improvement under the same experimental equipment and data sets. 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] From the comparative results in Table 2, we can see that the algorithm proposed in the present invention has increased the amount of floating point calculations and network parameters compared to the basic model YOLOv8, but has increased mAP50 by 2.9% and mAP50-95 by 3.3%. At the same time, through experiments, it can be found that the FPS of the algorithm of the present invention has reached 230. Although the time cost of processing image features has been sacrificed to a certain extent, it still meets the real-time requirements.

[0160] At the same time, in order to verify the effectiveness of MLCA, this embodiment 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 embodiment also conducts an ablation experiment based on the YOLOv8 algorithm as the basic model, including changing only the backbone network to EfficientViT, only changing the neck network to RepGFPN, only adding the MLCA attention mechanism, and only changing the loss function to SIOU. The ablation experiment results are shown in Table 4.

[0165] Table 4

[0166]

[0167]

[0168] It can be concluded from Table 4 that Experiment 1 is the experimental result of the unimproved YOLOv8. Experiment 2 replaces the YOLOv8 backbone network with EfficientViT, which increases the mAP50 by 0.6% and mAP50-95% by 0.4% compared with YOLOv8. The backbone network is replaced with EfficientViT, which enhances the overall feature extraction capability of the model. Experiment 3 replaces the neck network of YOLOv8 with RepGFPN. Compared with YOLOv7, mAP50 increases by 1.0% and mAP50-95 increases by 0.6%. The backbone network is replaced with RepGFPN to enhance multi-scale feature fusion and improve the multi-scale detection capability of the model, achieving higher accuracy without bringing additional huge computational burden. Experiment 4 adds the MLCA attention mechanism to the backbone network, which increases the 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, and mAP is slightly improved. Experiments 6, 7, and 8 show that combining these improvements together will significantly improve the object detection effect.

[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 image of the improved algorithm. Figure 8It can be seen that the YOLOv8 algorithm has problems such as missed detection and false detection when detecting underwater targets, resulting in low detection accuracy, and poor detection effect when targets are piled up. On the contrary, the improved algorithm of the present invention effectively improves these problems, while maintaining the real-time performance of underwater detection, and improving the detection accuracy of the model for underwater targets.

[0170] In view of the situation that underwater targets are blurred due to the complex underwater environment, 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 losing the amount of calculation, and effectively improves 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 the amount of calculation have increased, the detection accuracy is improved by 2.9 percentage points compared with 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 solution of the present invention rather than to limit it. 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 solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution, which should 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 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 according to the enhanced feature information by decoupling the detection head, and obtaining the underwater target detection result; S5. Design the SIOU loss function to train the above process, and after training, use it for underwater target detection.

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 tags through an overlapping block embedding layer; 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 three 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 The feature map of the stage, 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 used 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, and each FFN layer is followed by a deep convolution 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 segmentations 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 jth 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 the 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 dimension reduction through 1×1 convolution, and then uses multiple Rep3×3 convolutions and 3×3 convolutions to transform the features. It outputs multiple layers at the same time, and finally obtains the final output 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 the training phase, 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 mixed local channel attention module MLCA, the following processing steps are specifically included: S31, transforming the input feature vector into a vector of shape 1*C*ks*ks, where C represents the number of channels and ks is the size of the local blocks into which it is divided; S32, performing a local pooling operation on the converted vector, dividing the feature map into ks*ks local blocks, and performing 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 through one branch, the global information is kept unchanged, and a one-dimensional vector is output, which contains the global channel information; for the local information branch, it processes the local spatial information and outputs a one-dimensional vector, which contains 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 It means taking 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: In the formula, 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: In the formula, They are the center coordinates of the real box and the center coordinates of the predicted box respectively; The distance loss is expressed as: In the formula, ρ x , y , are all 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: In the formula, w gt ,h gt , w, h are the width and height of the real box and the predicted box respectively, ω w ,ω h It 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

  • Underwater biological target detection method based on YOLOv8 model

    CN118097393A

  • Privacy small target detection method based on automatic driving perception environment

    CN118552925A

  • Improved target detection method in automatic driving scene based on RT-DETR

    CN118644824A

Cited By

  • Mine small target detection method based on deformable convolution and residual structure

    CN120451656A

  • Improved YOLO11-based water hyacinth target rapid detection method

    CN120635395A

  • Underwater target detection method, system, equipment and medium

    CN120808131A

  • Method and system for positioning constructors in tunnel based on machine vision

    CN120912674A

  • Machine Vision-Based Method and System for Locating Construction Personnel Inside Tunnels

    CN120912674B