Lightweight overwater ship target detection method in complex navigation environment
By improving the YOLOv8 model, integrating the ECA attention module and combining GELAN and PANet's neck network, and introducing the MPDIoU loss function, the problem of difficult to balance the detection accuracy and speed of water ships in complex navigation environments is solved, and efficient and accurate ship detection results are achieved.
Patent Information
- Application Number
- CN202411683790.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-03-14
AI Technical Summary
Existing water ship detection methods are difficult to balance detection accuracy and speed in complex navigation environments, and there are problems of missed and missed inspections, especially when ship targets of different sizes or ships block each other.
An enhanced and lightweight ship detection model EGM-YOLOv8 based on improved YOLOv8 is proposed. By integrating an efficient ECA attention module and a neck network combining GELAN and PANet, the feature extraction and fusion capabilities are enhanced, and the minimum distance loss function MPDIoU based on ship geometric features is introduced to optimize the regression results of the model.
It realizes improving the accuracy and efficiency of ship detection in complex navigation environments, reducing the number of parameters of the model, improving the real-time and accuracy of detection, and reducing the situation of missed and missed detection.
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] The invention belongs to the field of fully automated products and relates to a method for detecting a lightweight water vessel target in a complex navigation environment. Background Art
[0002] Inland waterway transportation is an important part of the comprehensive transportation system, and plays an important role in promoting urban development, optimizing resource allocation, and promoting exchanges and cooperation. In coastal environments such as urban inland waters or ports, there are various types of ships. The rise of high-speed and intelligent autonomous ships has exacerbated safety issues, especially in the case of dense distribution of ships and complex navigation areas, where a series of marine accidents such as ship collisions occur frequently. Ship detection is an important part of improving water transportation safety. Early, accurate and rapid monitoring of ships near the coast can effectively reduce the occurrence of marine accidents and thus improve navigation safety and the effectiveness of port management. However, due to the influence of factors such as waves and special weather, in complex and changeable marine environments, existing detection methods still have the problem of not being able to balance model accuracy, speed and parameters well. In addition, when different scales of ship targets appear in the same scene or when ships occlude each other, since the existing models pay more attention to large ship targets and ignore smaller ship targets, missed detection and false detection often occur.
[0003] In recent years, with the development of deep learning technology, methods based on convolutional neural networks (CNN) have rapidly achieved success in the field of object detection. Representative two-stage methods such as R-CNN, Fast R-CNN, and Faster R-CNN have improved detection accuracy, but they generate a large number of predefined candidate suggestion boxes, which consumes a lot of time, so they cannot achieve real-time detection. Single-stage detection methods have emerged, and representative methods include YOLO, SSD, and RetinaNet. Although these methods have improved detection speed, they also have certain shortcomings in detection accuracy.
[0004] In order to better achieve the balance between ship detection accuracy and detection speed, in this work, we propose an enhanced and lightweight ship detection model based on improved YOLOv8, EGM-YOLOv8, to solve the problem of real-time ship detection. First, the efficient ECA attention module is integrated into the backbone network for feature extraction to achieve enhanced feature extraction capabilities; secondly, the lightweight GELAN is combined with PANet in the feature fusion stage to construct a lighter and more efficient neck network, which can better fuse different levels of ship information, maximize the retention of global information of ship features, and further improve the accuracy of ship detection; in addition, we introduce an accurate minimum distance loss function MPDIoU based on ship geometric features, which can achieve faster convergence and obtain more accurate regression results.
[0005] In most of the current water ship detection tasks, capturing multi-scale ship detail features remains a challenge due to the diversity of ship categories and large differences in ship sizes. Although current detection methods have achieved remarkable results in the field of ship detection, it is still difficult to achieve a balance between detection accuracy and detection model complexity. Summary of the invention
[0006] In order to solve the problem that in most current water ship detection tasks, due to the diversity of ship categories and large differences in ship sizes, capturing multi-scale ship detail features is still a challenge. Although the current detection method has achieved remarkable results in the field of ship detection, it is still difficult for the current ship detection method to achieve a balance between detection accuracy and detection model complexity. The technical solution adopted by the present invention is: a lightweight water ship target detection method in a complex navigation environment, comprising the following steps:
[0007] Obtain images of ships to be detected to form a data set;
[0008] Divide the dataset into training and testing sets;
[0009] Based on the improved YOLOv8 network, an enhanced and lightweight ship detection model is built;
[0010] Based on the training set data, the enhanced and lightweight ship detection model is trained to obtain a trained enhanced and lightweight ship detection model;
[0011] The test set data is input into the trained enhanced and lightweight ship detection model to realize the detection of water ship targets in complex navigation environments.
[0012] Further: the enhanced and lightweight ship detection model includes;
[0013] Backbone network, used to extract features of input images;
[0014] The neck network, based on the features extracted by the backbone network, captures multi-level ship features and enhances the feature diversity in the fusion process;
[0015] The head network obtains the category and location information of the target based on the features fused by the neck network, thereby realizing the detection of the ship target.
[0016] Further: the backbone network includes: a first CBS module, a second CBS module, a first C2f_ECA module, a third CBS module, a second C2f_ECA module, a fourth CBS module, a third C2f_ECA module, a fifth CBS module, a fourth C2f_ECA module and an SPPF module;
[0017] The first CBS module, the second CBS module, the first C2f_ECA module, the third CBS module, the second C2f_ECA module, the fourth CBS module, the third C2f_ECA module, the fifth CBS module, the fourth C2f_ECA module and the SPPF module are connected in sequence.
[0018] Further: the first C2f_ECA module, the second C2f_ECA module, the third C2f_ECA module, and the fourth C2f_ECA module have the same structure;
[0019] The first C2f_ECA module includes: a header CBS module, n Bottleneck blocks with ECA mechanism, and a tail CBS module;
[0020] The n Bottleneck blocks with the ECA mechanism include the first Bottleneck block with the ECA mechanism, the second Bottleneck block with the ECA mechanism...the nth Bottleneck block with the ECA mechanism;
[0021] The head CBS module is connected to the first Bottleneck block with the ECA mechanism by segmentation, and the first Bottleneck block with the ECA mechanism, the second Bottleneck block with the ECA mechanism...the nth Bottleneck block with the ECA mechanism are connected in sequence; the nth Bottleneck block with the ECA mechanism is connected to the tail CBS module by splicing.
[0022] Further: the neck network includes a first neck sub-network and a second neck sub-network;
[0023] The first neck subnetwork includes a first upsampling module, a first GELAN module, a second upsampling module, and a second GELAN module;
[0024] The first upsampling module is connected by splicing one end of the first GELAN module; the splicing is also connected to the third C2f_ECA module;
[0025] The other end of the second GELAN module is connected to one end of the second upsampling module;
[0026] The other end of the second upsampling module is connected to one end of the second GELAN module through splicing, and the splicing is also connected to the third C2f_ECA module;
[0027] The components of the first neck sub-network are sequentially connected according to a path aggregation network;
[0028] The second neck sub-network includes a fifth CBS module, a third GELAN module, a sixth CBS module and a fourth GELAN module;
[0029] The fifth CBS module is connected to one end of the third GELAN module by splicing, and the splicing is also connected to the second GELAN module;
[0030] The other end of the third GELAN module is connected to one end of the sixth CBS module, and the other end of the sixth CBS module is connected to the fourth GELAN module by splicing;
[0031] The components of the second neck sub-network are sequentially connected according to a path aggregation network.
[0032] Further: The loss function of the enhanced and lightweight ship detection model adopts the following formula:
[0033] L MPDIoU =1-MPDIoU
[0034] in:
[0035]
[0036] Where: w and h represent the width and height of the input image respectively, A gt Represents the area of the true bounding box, A pred represents the area of the predicted bounding box, and I represents the overlapping area of the true bounding box and the predicted bounding box.
[0037] Further: the feature graph processing process of the first C2f_ECA module is as follows:
[0038] Input feature map After performing global average pooling and cross-channel interaction, the aggregated feature F is obtained. g , where GAP(·) represents the global average pooling operation, represents cross-channel interaction, as shown in Formula 1 below:
[0039]
[0040] For a given aggregate feature Without dimensionality reduction, channel attention is expressed as:
[0041] ω=σ(WF g ) (2)
[0042] Where σ represents the sigmoid function, and W is a diagonal matrix involving C parameters, or a full matrix involving C×C parameters, as shown below:
[0043]
[0044] Using a frequency band matrix W k To learn channel attention, ECA captures local cross-channel interactions by considering the interactions between the features of each channel and its k neighboring channels, W k As shown below:
[0045]
[0046] For each aggregate feature F gi , only considering its interaction with k neighbors, as shown in the following formula:
[0047]
[0048] Where: σ is the sigmoid function, Indicated as F gi The set of k neighbor channels of gi The weight of is calculated as follows:
[0049]
[0050] Since the ECA module aims to properly capture local cross-channel interactions, it is necessary to determine the coverage of the interaction, that is, the kernel size k of the one-dimensional convolution. ECA introduces an adaptive method to determine the value. It is reasonable that the coverage of the interaction (that is, the kernel size k of the one-dimensional convolution) is proportional to the channel dimension C, that is, there may be a mapping φ between k and C, as shown in the following formula:
[0051] C=φ(k) (7)
[0052] The simplest mapping is a linear function, i.e., φ(k) = γ*kb. The channel dimension C, i.e., the number of filters, is usually set to a power of 2. Therefore, a possible solution is introduced by generalizing the linear function φ(k) = γ*kb to a nonlinear function, as shown in the following formula (8):
[0053] C=φ(k)=2 (γ*k-b) (8)
[0054] At the same time, given the channel dimension C, the convolution kernel size k can be adaptively determined as shown in the following formula (9):
[0055]
[0056] Where: |t odd Indicates the nearest odd number to t, sets the values of γ and b to 2 and 1 respectively, and outputs the feature F out Calculated by formula 10.
[0057]
[0058] A lightweight water vessel target detection device in a complex navigation environment, comprising:
[0059] Acquisition module: used to acquire images of ships to be detected to form a data set;
[0060] Partition module: used to divide the data set into training set and test set;
[0061] Building module: used to build an enhanced and lightweight ship detection model based on the improved YOLOv8 network;
[0062] Training module: used to train the enhanced and lightweight ship detection model based on the training set data to obtain the trained enhanced and lightweight ship detection model;
[0063] The test set data is input into the trained enhanced and lightweight ship detection model to realize the detection of water ship targets in complex navigation environments.
[0064] The invention provides a lightweight water ship target detection method in a complex navigation environment, which has the following advantages: an enhanced and lightweight ship detection model based on improved YOLOv8, EGM-YOLOv8, is used to solve the problem of real-time ship detection. First, the efficient ECA attention module is integrated into the backbone network for feature extraction to achieve enhanced feature extraction capabilities; secondly, the lightweight GELAN is combined with PANet in the feature fusion stage to construct a lighter and more efficient neck network, which can better fuse ship information at different levels, maximize the retention of global information of ship features, and further improve the accuracy of ship detection; in addition, we introduce an accurate minimum distance loss function MPDIoU based on ship geometric features, which can achieve faster convergence and obtain more accurate regression results.
[0065] The present invention improves the original YOLOv8 model, reduces the number of model parameters while ensuring the detection accuracy of the model, and improves the detection efficiency.
[0066] The present invention improves the backbone network and neck network of the original YOLOv8 respectively, designs a new feature extraction module C2f_ECA, and enhances the feature extraction capability of the network. The GELAN module is combined with the original PANet network to design a more efficient and lightweight neck network to achieve more efficient feature fusion. In addition, the MPDIOU loss function is used to optimize the model gradient gain allocation strategy, so that the network converges faster. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0068] Figure 1 It is a structural diagram of an enhanced and lightweight ship detection model;
[0069] Figure 2 (a) is the structure diagram of the C2f_ECA module, (b) is the structure diagram of the CBS module, and (c) is the structure diagram of the Bottleneck block with the ECA mechanism;
[0070] Figure 3 It is the specific structure of the ECA module;
[0071] Figure 4(a) is the specific structure of the GELAN module, (b) is the specific structure of the RepCSP module; (c) is the structural diagram of Rep_Bottleneck;
[0072] Figure 5 It is the calculation factor graph of MPDIoU;
[0073] Figure 6 (a) is the detection result diagram of the EGM-YOLOv8 model, and (b) is the detection result diagram of the model of this application. DETAILED DESCRIPTION
[0074] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0075] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. The following description of at least one exemplary embodiment is actually only illustrative and is by no means intended to limit the present invention and its application or use. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0076] A method for detecting a lightweight watercraft target in a complex navigation environment, characterized in that it comprises the following steps:
[0077] Obtain images of ships to be detected to form a data set;
[0078] Divide the dataset into training and testing sets;
[0079] Based on the improved YOLOv8 network, an enhanced and lightweight ship detection model is built;
[0080] Based on the training set data, the enhanced and lightweight ship detection model is trained to obtain a trained enhanced and lightweight ship detection model;
[0081] The test set data is input into the trained enhanced and lightweight ship detection model to detect water ship targets in complex navigation environments.
[0082] This method is applicable to ship detection in different scenarios; for example, two ships block each other, or a large ship and a small ship appear together, and the small ship is ignored, etc.
[0083] Figure 1It is a structural diagram of an enhanced and lightweight ship detection model;
[0084] Further: the enhanced and lightweight ship detection model includes;
[0085] Backbone network, used to extract features of input images;
[0086] The ultra-lightweight ECA attention mechanism is introduced into the backbone network, and the feature extraction module C2f_ECA is constructed to replace the original C2f module, which enhances the network's feature extraction capability and improves the model's ability to distinguish between target and background information, thus improving the model's detection performance with negligible computational overhead;
[0087] The neck network, based on the features extracted by the backbone network, captures multi-level ship features and enhances the feature diversity in the fusion process;
[0088] The neck network combines GELAN and PANet in the feature fusion stage to construct a lighter and more efficient neck network, which can effectively reduce false detections and missed detections in ship identification.
[0089] The head network, based on the fused features of the neck network, obtains the category and location information of the ship target again to realize the detection of the ship target.
[0090] MPDIOU is used to replace the original bounding box regression loss function, optimize the gradient gain allocation strategy, enhance the adaptability of the detection model to multi-scale target changes, improve the generalization ability of the model, make the model converge faster and obtain more accurate prediction results.
[0091] Figure 2 (a) is the structure diagram of the C2f_ECA module, (b) is the structure diagram of the CBS module, and (c) is the structure diagram of the Bottleneck block with the ECA mechanism;
[0092] The backbone network includes: a first CBS module, a second CBS module, a first C2f_ECA module, a third CBS module, a second C2f_ECA module, a fourth CBS module, a third C2f_ECA module, a fifth CBS module, a fourth C2f_ECA module and an SPP module;
[0093] The first CBS module, the second CBS module, the first C2f_ECA module, the third CBS module, the second C2f_ECA module, the fourth CBS module, the third C2f_ECA module, the fifth CBS module, the fourth C2f_ECA module and the SPP module are connected in sequence.
[0094] The first C2f_ECA module, the second C2f_ECA module, the third C2f_ECA module, and the fourth C2f_ECA module have the same structure;
[0095] The first C2f_ECA module includes: a header CBS module, n Bottleneck blocks with ECA mechanism, and a tail CBS module;
[0096] The n Bottleneck blocks with the ECA mechanism include the first Bottleneck block with the ECA mechanism, the second Bottleneck block with the ECA mechanism...the nth Bottleneck block with the ECA mechanism;
[0097] The head CBS module is connected to the first Bottleneck block with the ECA mechanism by segmentation, and the first Bottleneck block with the ECA mechanism, the second Bottleneck block with the ECA mechanism...the nth Bottleneck block with the ECA mechanism are connected in sequence; the nth Bottleneck block with the ECA mechanism is connected to the tail CBS module by splicing.
[0098] The original YOLOv8 backbone network consists of CBS module, C2f module and SPPF module. In the improved model, the C2f module of the backbone network is integrated with the efficient channel attention module (ECA), and the C2f_ECA module is obtained, which replaces the original module that focuses on the ship during feature extraction, and can realize the interaction of cross-channel information, so that unimportant background information can be suppressed and the ship area can be effectively identified.
[0099] ECA mainly includes cross-channel interaction and one-dimensional convolution with adaptive convolution kernels. Cross-channel interaction represents a new feature combination method that enhances the expression of specific semantics. Figure 3 It is the specific structure of the ECA module;
[0100] Input feature map After performing global average pooling (GAP) and cross-channel interaction, the aggregated feature F is obtained. g ,in represents cross-channel interaction, as shown in the following formula (1):
[0101]
[0102] For a given aggregate feature Without dimensionality reduction, channel attention can be expressed as:
[0103] ω=σ(WF g ) (2)
[0104] Where W is a diagonal matrix involving C parameters, or a full matrix involving C×C parameters, as shown in the following formula (3):
[0105]
[0106] However, the cross-channel interaction requires a large number of parameters, resulting in high model complexity. In ECA, a frequency band matrix W is used k To learn channel attention, ECA captures local cross-channel interactions by considering the interactions between the features of each channel and its k neighboring channels, W k As shown in the following formula (4):
[0107]
[0108] For each aggregate feature F gi , only considering the interaction between it and its k neighbors, as shown in the following formula (5):
[0109]
[0110] Where σ is the sigmoid function, Indicated as F gi An effective method is to let all channels share the same learning parameters, avoiding the use of one-dimensional convolution for dimensionality reduction and effectively realizing multi-channel interaction, where the feature F gi The weight of can be calculated as follows:
[0111]
[0112] As can be seen from the above formula, all channels have the same inclination parameter, so the model will be more effective. Since the ECA module aims to properly capture local cross-channel interactions, it is necessary to determine the coverage of the interaction (i.e., the kernel size k of the one-dimensional convolution). In different CNN architectures, the optimized interaction coverage can be manually adjusted for convolution blocks with different numbers of channels. Then, manual tuning through cross-validation will consume a lot of computing resources. ECA introduces an adaptive method to determine the size of the value. Specifically, it is reasonable that the coverage of the interaction (i.e., the kernel size k of the one-dimensional convolution) is proportional to the channel dimension C, that is, there may be a mapping φ between k and C, as shown in the following formula (7):
[0113] C=φ(k) (7)
[0114] The simplest mapping is a linear function, i.e., φ(k) = γ*kb. However, the relationship represented by a linear function is too limited. On the other hand, it is well known that the channel dimension C (i.e., the number of filters) is usually set to a power of 2. Therefore, a possible solution is introduced by generalizing the linear function φ(k) = γ*kb to a nonlinear function, as shown in the following formula (8):
[0115] C=φ(k)=2 (γ*k-b) (8)
[0116] At the same time, given the channel dimension C, the convolution kernel size k can be adaptively determined as shown in the following equation (9):
[0117]
[0118] where |t odd represents the odd number closest to t. According to the experimental results of ECA, the values of γ and b are determined to be 2 and 1 respectively. Finally, the output feature F of the ECA module is out It can be calculated by formula 10.
[0119]
[0120] EGM-YOLOv8 integrates the ECA attention mechanism in the C2f module, which increases the weight of the ship-dense areas in the ship image during the feature extraction process, so that the network focuses more on capturing ship-related features and provides more valuable feature representation for the subsequent feature fusion stage. It increases the number of parameters to a negligible amount while improving the model's feature extraction capability and enhancing the recognizability of ships.
[0121] The original YOLOv8's neck uses the path aggregation feature pyramid network (PANet). In the improved model, a lightweight network structure based on gradient path planning, the generalized efficient layer aggregation network (GELAN), is used. By combining CSPNet and ELAN, two neural network architectures designed with gradient path planning, the accuracy is maximized while minimizing the parameters. GELAN is combined with the original PANet, retaining two fusion paths to form a new efficient and lightweight neck structure. Figure 4 (a) is the specific structure of the GELAN module, (b) is the specific structure of the RepCSP module; (c) is the structural diagram of Rep_Bottleneck;
[0122] The neck network includes a first neck sub-network and a second neck sub-network;
[0123] The first neck subnetwork includes a first upsampling module, a first GELAN module, a second upsampling module, and a second GELAN module;
[0124] The first upsampling module is connected by splicing one end of the first GELAN module; the splicing is also connected to the third C2f_ECA module;
[0125] The other end of the second GELAN module is connected to one end of the second upsampling module;
[0126] The other end of the second upsampling module is connected to one end of the second GELAN module through splicing, and the splicing is also connected to the third C2f_ECA module;
[0127] The components of the first neck sub-network are sequentially connected according to a path aggregation network PANet;
[0128] The second neck sub-network includes a fifth CBS module, a third GELAN module, a sixth CBS module and a fourth GELAN module;
[0129] The fifth CBS module is connected to one end of the third GELAN module by splicing, and the splicing is also connected to the second GELAN module;
[0130] The other end of the third GELAN module is connected to one end of the sixth CBS module, and the other end of the sixth CBS module is connected to the fourth GELAN module by splicing;
[0131] The components of the second neck sub-network are connected in sequence according to the path aggregation network PANet.
[0132] The bounding box regression (BBR) loss function is an important component of the target detection loss function and has a significant impact on the performance of the target detection model. A good loss function can accelerate the convergence of the network and improve the accuracy of the network. IoU loss is a metric used to measure the degree of overlap between two bounding boxes. In the target detection task, IoU loss has advantages such as intuitiveness and robustness. However, it also has disadvantages, including poor smoothness, sensitivity to thresholds, and high computational complexity. The IoU loss formula is defined as the ratio of the intersection area of the predicted bounding box and the ground truth bounding box to the union area, as shown in the following formula 11:
[0133]
[0134] In the original YOLOv8 model, CIoU loss was selected as the bounding box loss function. CIoU loss includes the overlap of bounding boxes, the distance between center points, and the aspect ratio between the predicted box and the ground truth box. However, it cannot converge well for some anchor boxes with low annotation quality. CIOU is shown in the following formula 12:
[0135]
[0136] Where: IoU is the overlap between the predicted box and the ground truth box, ρ is the Euclidean distance between the center points of the predicted and true bounding boxes, b and b gt Denote the boundary center points of the predicted box and the ground truth box, respectively, and c is the diagonal length of the smallest enclosing box that contains both the predicted box and the true bounding box. α is the weight function, and v represents the parameter for quantifying aspect ratio consistency. α and v are defined as follows:
[0137]
[0138] Where: w gt and h gt is the width and height of the ground truth bounding box, and w and h are the width and height of the predicted bounding box. As shown in formula (14), when the aspect ratio of the predicted box is the same as that of the real box, v = 0. In this case, the aspect ratio penalty term does not work. However, when the object detection dataset contains a large number of low-quality samples, the regression of the CIoU loss function to multiple enhanced bounding boxes for low-quality samples will harm the improvement of the model detection performance, and the penalty function will degenerate and fail, hindering the convergence of the model. Therefore, this consideration provides an advantage in solving the gradient smoothing problem and has a positive impact on the gradient descent optimization algorithm. However, most existing loss functions represented by CIoU do not involve image size, which makes them unable to optimize the situation where the predicted box and the ground truth box have the same aspect ratio but have completely different width and height values.
[0139] The loss function of the enhanced and lightweight ship detection model proposed in this application is the same as the loss function of YOLOv8, which consists of two parts: regression loss and classification loss. The regression component belongs to the regression parameter of the feature point, which determines the category of the object appearing on the feature point. Taking into account the advantages and disadvantages of the existing bounding box regression loss function, and combined with the actual task of ship target detection, a new bounding box similarity comparison metric MPDIoU based on the minimum point distance is introduced to replace the CIoU loss, which is inspired by the geometric features of the bounding box. MPDIoU is an efficient and accurate bounding box regression loss function that includes all relevant factors considered in the existing loss function. MPDIoU simplifies the calculation process by minimizing the distance between the upper left and lower right corners of the predicted bounding box and the annotated bounding box, thereby achieving accurate and efficient bounding box regression. The calculation process of MPDIoU is as follows:
[0140] B pred and B gt are the predicted bounding box and the true bounding box of the target, which can be expressed as: in and Represents the point coordinates of the upper left and lower right corners of the predicted bounding box, and They represent the coordinates of the upper left corner and lower right corner of the ground-truth bounding box, respectively, and w and h represent the width and height of the input image, respectively.
[0141]
[0142] Calculate B gt The area is as follows:
[0143]
[0144] Similarly, calculate B pred The area is as follows:
[0145]
[0146] Calculate B pred and B gt The overlapping area I is as follows:
[0147]
[0148] Among them: meet The calculation formula of IoU is shown in formula 20, and the calculation method of MPDIOU is shown in formula (21);
[0149]
[0150] Finally, this application defines the loss function based on MPDIOU as shown in the following formula (22): Figure 5 The calculation factors of the MPDIoU loss function are shown.
[0151] L MPDIoU =1-MPDIoU (22)
[0152] A lightweight water vessel target detection device in a complex navigation environment, comprising:
[0153] Acquisition module: used to acquire images of ships to be detected to form a data set;
[0154] Partition module: used to divide the data set into training set and test set;
[0155] Building module: used to build an enhanced and lightweight ship detection model based on the improved YOLOv8 network;
[0156] Training module: used to train the enhanced and lightweight ship detection model based on the training set data to obtain the trained enhanced and lightweight ship detection model;
[0157] The test set data is input into the trained enhanced and lightweight ship detection model to detect water ship targets.
[0158] Example 1: Using the Seaships dataset, it is divided into training set, validation set and test set in a ratio of 8:1:1. The training data is used to train an enhanced and lightweight ship detection model. The trained enhanced and lightweight ship detection model is loaded, and reasoning and prediction are performed on the test set. It is compared with the current common detection method to verify the effectiveness of the proposed EGM-YOLOv8 model in the ship detection task.
[0159] On the Seaships dataset, the proposed EGM-YOLOv8 model is compared with the current mainstream object detection algorithms, including Faster R-CNN, YOLOv6, YOLOv7, YOLOv8, TPH-YOLOv5, and TPH-YOLOv5++. Table 1 shows the quantitative experimental results.
[0160] Table 1. Comparison of detection performance between the model proposed in this application and the currently used CNN-based methods
[0161]
[0162] Through the quantitative analysis of Table 1, Faster R-CNN achieved a recall rate of 97.2%, with good detection capabilities, but its reasoning time is much greater than 40ms, which does not meet the real-time requirements of ship detection. Although YOLOv6 and TPH-YOLOv5 have basically reached the real-time standard, their detection accuracy is far inferior to EGM-YOLOv8. Compared with YOLOv8 and TPH-YOLOv5++, although the EGM-YOLOv8 model is not as fast as them when the number of parameters is similar, it is much higher than them in other evaluation indicators. In terms of recall, the EGM-YOLOv8 model is improved by 1.13% compared with YOLOv8, 0.40% on mAP@0.5, and 0.47% on mAP@0.5:0.95. In terms of average precision mAP@0.5:0.95, the EGM-YOLOv8 model is 5.86% higher than TPH-YOLOv5++. The EGM-YOLOv8 model achieves a considerable balance between detection accuracy and speed, achieving 98.3% in recall rate and 84.8% in average precision mAP@0.5:0.95, achieving the best results, and the number of parameters is also reduced by 5.21M compared to the original YOLOv8 model.
[0163] Qualitative analysis on the Seaships dataset, Figure 6 (a) is the detection result diagram of the EGM-YOLOv8 model, and (b) is the detection result diagram of the model of this application.
[0164] from Figure 6 It can be found that compared with the original YOLOv8, the EGM-YOLOv8 model has higher detection accuracy for each ship category and can provide relatively accurate location information.
[0165] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting lightweight watercraft targets in a complex navigation environment, characterized by: The following steps are involved: Obtain images of ships to be detected to form a data set; Divide the dataset into training and testing sets; Based on the improved YOLOv8 network, an enhanced and lightweight ship detection model is built; Based on the training set data, the enhanced and lightweight ship detection model is trained to obtain a trained enhanced and lightweight ship detection model; The test set data is input into the trained enhanced and lightweight ship detection model to realize the detection of water ship targets in complex navigation environments.
2. The method for detecting a lightweight watercraft target in a complex navigation environment according to claim 1, characterized in that: The enhanced and lightweight ship detection model includes: Backbone network, used to extract features of input images; The neck network, based on the features extracted by the backbone network, captures multi-level ship features and enhances the feature diversity in the fusion process; The head network obtains the category and location information of the target based on the features fused by the neck network, thereby realizing the detection of the ship target.
3. The method for detecting a lightweight watercraft target in a complex navigation environment according to claim 2, characterized in that: The backbone network includes: a first CBS module, a second CBS module, a first C2f_ECA module, a third CBS module, a second C2f_ECA module, a fourth CBS module, a third C2f_ECA module, a fifth CBS module, a fourth C2f_ECA module and an SPPF module; The first CBS module, the second CBS module, the first C2f_ECA module, the third CBS module, the second C2f_ECA module, the fourth CBS module, the third C2f_ECA module, the fifth CBS module, the fourth C2f_ECA module and the SPPF module are connected in sequence.
4. The method for detecting a lightweight watercraft target in a complex navigation environment according to claim 3, characterized in that: The first C2f_ECA module, the second C2f_ECA module, the third C2f_ECA module, and the fourth C2f_ECA module have the same structure; The first C2f_ECA module includes: a header CBS module, n Bottleneck blocks with ECA mechanism, and a tail CBS module; The n Bottleneck blocks with the ECA mechanism include the first Bottleneck block with the ECA mechanism, the second Bottleneck block with the ECA mechanism...the nth Bottleneck block with the ECA mechanism; The head CBS module is connected to the first Bottleneck block with the ECA mechanism by segmentation, and the first Bottleneck block with the ECA mechanism, the second Bottleneck block with the ECA mechanism...the nth Bottleneck block with the ECA mechanism are connected in sequence; the nth Bottleneck block with the ECA mechanism is connected to the tail CBS module by splicing.
5. The method for detecting a lightweight watercraft target in a complex navigation environment according to claim 2, characterized in that: The neck network includes a first neck sub-network and a second neck sub-network; The first neck subnetwork includes a first upsampling module, a first GELAN module, a second upsampling module, and a second GELAN module; The first upsampling module is connected by splicing one end of the first GELAN module; the splicing is also connected to the third C2f_ECA module; The other end of the second GELAN module is connected to one end of the second upsampling module; The other end of the second upsampling module is connected to one end of the second GELAN module through splicing, and the splicing is also connected to the third C2f_ECA module; The components of the first neck sub-network are sequentially connected according to a path aggregation network; The second neck sub-network includes a fifth CBS module, a third GELAN module, a sixth CBS module and a fourth GELAN module; The fifth CBS module is connected to one end of the third GELAN module by splicing, and the splicing is also connected to the second GELAN module; The other end of the third GELAN module is connected to one end of the sixth CBS module, and the other end of the sixth CBS module is connected to the fourth GELAN module by splicing; The components of the second neck sub-network are connected according to the secondary path aggregation network.
6. The method for detecting a lightweight watercraft target in a complex navigation environment according to claim 1, characterized in that: The loss function of the enhanced and lightweight ship detection model adopts the following formula: L MPDIoU =1-MPDIoU in: Where: w and h represent the width and height of the input image respectively, A gt Represents the area of the true bounding box, A pred represents the area of the predicted bounding box, and I represents the overlapping area of the true bounding box and the predicted bounding box.
7. The method for detecting a lightweight watercraft target in a complex navigation environment according to claim 3, characterized in that: The feature graph processing process of the first C2f_ECA module is as follows: Input feature map After performing global average pooling and cross-channel interaction, the aggregated feature F is obtained. g , where GAP(·) represents the global average pooling operation, represents cross-channel interaction, as shown in Formula 1 below: For a given aggregate feature Without dimensionality reduction, channel attention is expressed as: ω=σ(WF g ) (2) Where σ represents the sigmoid function, and W is a diagonal matrix involving C parameters, or a full matrix involving C×C parameters, as shown below: Using a frequency band matrix W k To learn channel attention, ECA captures local cross-channel interactions by considering the interactions between the features of each channel and its k neighboring channels, W k As shown below: For each aggregate feature F gi , only considering its interaction with k neighbors, as shown in the following formula: Where: σ is the sigmoid function, Indicated as F gi The set of k neighbor channels of gi The weight of is calculated as follows: Since the ECA module aims to properly capture local cross-channel interactions, it is necessary to determine the coverage of the interaction, that is, the kernel size k of the one-dimensional convolution. ECA introduces an adaptive method to determine the value. It is reasonable that the coverage of the interaction (that is, the kernel size k of the one-dimensional convolution) is proportional to the channel dimension C, that is, there may be a mapping φ between k and C, as shown in the following formula: C=φ(k) (7) The simplest mapping is a linear function, i.e., φ(k) = γ*kb. The channel dimension C, i.e., the number of filters, is usually set to a power of 2. Therefore, a possible solution is introduced by generalizing the linear function φ(k) = γ*kb to a nonlinear function, as shown in the following formula (8): C=φ(k)=2 (γ*k-b) (8) At the same time, given the channel dimension C, the convolution kernel size k can be adaptively determined as shown in the following formula (9): Where: |t odd Indicates the nearest odd number to t, sets the values of γ and b to 2 and 1 respectively, and outputs the feature F out Calculated by formula 10.
8. A lightweight watercraft target detection device in a complex navigation environment, characterized in that: include: Acquisition module: used to acquire images of ships to be detected to form a data set; Partition module: used to divide the data set into training set and test set; Building module: used to build an enhanced and lightweight ship detection model based on the improved YOLOv8 network; Training module: used to train the enhanced and lightweight ship detection model based on the training set data to obtain the trained enhanced and lightweight ship detection model; The test set data is input into the trained enhanced and lightweight ship detection model to realize the detection of water ship targets in complex navigation environments.
Citation Information
Cited By
Fresh corn appearance detection method based on image fusion and deep learning
CN120997627A
Lightweight high-robustness marine target detection method under complex sea condition
CN121392518A