A method for detecting waterway ships and navigation marks based on improved YOLOv8s algorithm

By introducing GhostNetv2, C2fGhostv2, GSConv, CA attention mechanism and EIoU loss function in the YOLOv8s algorithm, the problem of insufficient recognition accuracy and speed of ships and navigation beacons in the existing technology is solved, and high-precision and high-speed ships and navigation beacons are realized.

CN118799622BActive Publication Date: 2025-05-02YANGTZE RIVER YICHANG WATERWAY BUREAU +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410770897.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2025-05-02
Estimated Expiration
2044-06-14

AI Technical Summary

Technical Problem

In the case of numerous ship types and high image quality, it is difficult to achieve fast and accurate ship and navigation beacon identification, and the large number of model parameters leads to slow operation and unsatisfactory results during deployment.

Method used

Based on the improved YOLOv8s algorithm, the identification accuracy and speed of the model are optimized by introducing the GhostNetv2 lightweight network model, C2fGhostv2 module, GSConv feature fusion module, CA attention mechanism and EIoU loss function into the YOLOv8s network.

Benefits of technology

It realizes high-precision and high-speed identification of ships and navigation beacons, reduces the rate of missed detection and misjudgment, and improves the lightweight and real-time detection capabilities of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118799622B_ABST
    Figure CN118799622B_ABST
Patent Text Reader

Abstract

A method for detecting waterway ships and navigation marks based on an improved YOLOv8s algorithm comprises the following steps: step S1: screening and collating the captured ship and navigation mark data sets of the target waterway; step S2: obtaining a complete data set through image preprocessing steps such as flipping, cropping, brightness adjustment, blurring, etc.; step S3: annotating the data set using Labelimg, and dividing it into a training set, a validation set, and a test set according to a certain ratio; step S4: constructing a GCE-YOLOv8s network; step S5: putting the obtained data set into a GCE-YOLOv8s model, combining the GCE-YOLOv8s model to recognize the acquired ship and navigation mark images, and using the recall rate, the average precision mean, and the number of frames transmitted per second as evaluation indicators; step S6, using the trained model to predict the image to be detected and accurately recognize it.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image recognition, and in particular to a method for detecting waterway ships and navigation marks based on an improved YOLOv8s algorithm. Background Art

[0002] For waterways with complex hydrological conditions and high navigation density, different types of ships often pass by. If ships and their navigation marks are inspected and classified manually, it will take a lot of manpower and material resources. Therefore, the use of ordinary neural network models to quickly and accurately identify ship images has been derived. This method is widely used in both military and civilian fields. With the increase in the number of ship types and the improvement in image quality, traditional convolutional neural networks for ship image recognition take a lot of time and are gradually being eliminated by the mainstream.

[0003] There are three difficulties in identifying ships and their navigation marks: the first is that there are many types of ships, and their external characteristics are obviously different, which greatly reduces the accuracy of ship detection. The second is that the speed of ship and navigation mark detection must meet the standard of real-time detection, which requires a very high speed of the algorithm. The third is that the number of parameters is too large, which indirectly leads to a serious decline in model occupancy and speed performance, resulting in slow system operation and unsatisfactory results during deployment.

[0004] In response to the above problems, Qin Lijiao proposed a cross-scale ship detection algorithm YOLO-CsShip based on YOLOv5s. This technology improves recognition accuracy by adding adaptive spatial parallel convolution modules and convolution self-attention hybrid modules. Lin Feng et al. proposed an improved YOLOv 5s (FMA-YOLOv 5s) algorithm for waterway floating object detection. This algorithm adds a feature map attention (FMA) layer at the end of the backbone network. During the training process, the mosaic data enhancement method is used to improve the detection effect of small targets, and it performs well in lightweight. Xu Xiaohua et al. proposed an improved YOLOv4-Tiny algorithm for river and lake ship detection, introducing the Sigmoid weighted linear unit (SiLU) activation function and the convolution block attention module to improve the detection frame rate. Xiao Zheng et al. proposed an inland waterway ship recognition method based on MSAM-YOKOv5, proposed a multi-scale attention module (MSAM), optimized the anchor frame parameters, and reduced the impact of complex background on recognition accuracy.

[0005] In response to the above three problems, the present invention starts with YOLOv8s and proposes a method and model for waterway ship and navigation mark detection based on YOLOv8s. Summary of the invention

[0006] The purpose of the present invention is to solve the technical problems that the existing technology for identifying ships and their navigation marks has obvious differences in external characteristics when there are many types of ships, which greatly reduces the accuracy of ship detection, the detection speed of the existing technology cannot meet the detection speed requirements of ships and their navigation marks, and the number of parameters in the existing technology is too large, which indirectly leads to a serious decline in model occupancy and speed performance, resulting in slow system operation and unsatisfactory results during deployment. A method and model for detecting waterway ships and navigation marks based on an improved YOLOv8s algorithm are proposed.

[0007] In order to solve the above technical problems, the technical solution adopted by the present invention is:

[0008] A method for detecting waterway ships and navigation marks based on an improved YOLOv8s algorithm comprises the following steps:

[0009] Step S1: Screening and sorting the captured ship and navigation mark data sets of the target waterway;

[0010] Step S2: After image preprocessing steps such as flipping, cropping, brightness adjustment, and blurring, a complete data set is obtained;

[0011] Step S3: Use Labelimg to annotate the dataset and divide it into training set, validation set, and test set according to a certain ratio;

[0012] Step S4: Build the GCE-YOLOv8s network;

[0013] Step S5: Put the obtained data set into the GCE-YOLOv8s model, combine the GCE-YOLOv8s model to identify the acquired ship and navigation mark images, and use the recall rate, average precision mean, and the number of frames per second as evaluation indicators;

[0014] Step S6: Use the trained model to perform image prediction on the image to be detected for accurate recognition.

[0015] In step S2, the data set is preprocessed to expand the original data set;

[0016] In step S3, the collected ships and different types of navigation marks are labeled using the labelimg image annotation tool, and the data set is divided according to a certain ratio to obtain the training set, verification set, and test set of the ship and navigation mark data set;

[0017] In step S4, the EIoU border loss function is used as the new border loss function of YOLOv8.

[0018] The EIoU border loss function used consists of three parts: overlap loss, center distance loss, and width and height loss. The calculation formula is:

[0019]

[0020] Where IoU is the ratio of the intersection area of ​​the predicted box and the real box to the combined area, b,b gt Respectively represent the center point of the predicted box and the center point of the real box, ρ 2 (b,b gt ) represents the Euclidean distance between the two center points of the predicted box and the true box, c represents the diagonal distance of the minimum closure area that contains both the predicted box and the true box, w,w gt Represent the predicted box width and the real box width, ρ 2 (w,w gt ) represents the Euclidean distance between the predicted box and the true box width, h,h gt Respectively represent the predicted box length and the real box length, ρ 2 (h,h gt ) represents the Euclidean distance between the predicted box and the true box length, C w and C h Indicates the width and length of the minimum bounding box covering the predicted box and the true box.

[0021] In step S5, the training set is put into the GCE-YOLOv8s model for training to obtain the detection results and obtain the best.pt file; the model is evaluated by evaluation indicators, and the best.pt file includes recall rate (recall, Rec), mean average precision (mean average precision, mAP), frames per second (frames per second, FPS) and parameters.

[0022] In step S6, the best.pt file obtained after training is used as the pre-training weight of the model in this paper, and the image to be tested is placed in it for detection and recognition.

[0023] In step S3, if Figure 2 As shown, the constructed GCE-YOLOv8s network includes the backbone network Backbone, the neck network Neck, and the detection head network Head, as follows:

[0024] The backbone network Backbone is specifically as follows: the image input is given to the first CBS convolution module, the first CBS convolution module is connected to the input of the first GBneckv2 module, the output of the first GBneckv2 module is connected to the input of the first C2fGhostv2 module, the output of the first C2fGhostv2 module is connected to the input of the second GBneckv2 module, the output of the second GBneckv2 module is connected to the input of the second C2fGhostv2 module, the output of the second C2fGhostv2 module is connected to the input of the third GBneckv2 module, the output of the third GBneckv2 module is connected to the input of the third C2fGhostv2, the output of the third C2fGhostv2 is connected to the input of the fourth GBneckv2 module, the output of the fourth GBneckv2 module is connected to the input of the fourth C2fGhostv2, the output of the fourth C2fGhostv2 is connected to the input of the CA attention mechanism, and the output of the CA attention mechanism is connected to the input of the SPPF spatial pyramid network;

[0025] The neck network Neck is specifically as follows: the output of the SPPF spatial pyramid network is divided into two branches, one output is connected to the input of the first GSConv module, and the other output is directly connected to the input of the first splicing layer module; the output of the first GSConv module is connected to the input of the first upsampling module, the output of the first upsampling module is connected to the second splicing layer, and the third C2fGhostv2 module is also connected to the second splicing layer module; the output of the second splicing layer module is passed to the input of the first C2f module, the output of the first C2f module is connected to the input of the second upsampling module, the output of the second upsampling module is connected to the input of the third splicing layer module, the output of the second C2fGhostv2 module and the output of the third upsampling module are jointly connected to the input of the third splicing layer module; the output of the third splicing layer module is connected to the input of the second C2f module;

[0026] The output of the second C2f module is connected to the input of the second GSConv module, the output of the second GSConv module is connected to the input of the fourth splicing layer module, the output of the fourth splicing layer module is connected to the input of the third C2f module; the output of the third C2f module is connected to the input of the third GSConv module, the output of the third GSConv module is connected to the input of the first splicing layer; the output of the first splicing layer is connected to the input of the fourth C2f module;

[0027] The detection head network Head is specifically as follows: the output of the second C2f module forms the first detection head; the output of the third C2f module forms the second detection head; and the output of the fourth C2f module forms the third detection head.

[0028] The first detection head is specifically: the output of the second C2f module forms two branches, namely the first detection head branch one and the first detection head branch two; the first detection head branch one is specifically: the output of the second C2f module is connected to the input of the first CBS module, the output of the first CBS module is connected to the input of the first Conv2d module, and the output of the first Conv2d module is connected to the first WIoU module and the first DFL module; the first detection head branch two is specifically: the output of the second C2f module is connected to the input of the second CBS module, the output of the second CBS module is connected to the input of the second Conv2d module, and the output of the second Conv2d module is connected to the second WIoU module and the second DFL module;

[0029] The second detection head is specifically: the output of the third C2f module forms two branches, namely the second detection head branch one and the second detection head branch two; the second detection head branch one is specifically that the output of the third C2f module is connected to the input of the third CBS module, the output of the third CBS module is connected to the input of the third Conv2d module, and the output of the third Conv2d module is connected to the third WIoU module and the third DFL module; the second detection head branch two is specifically that: the output of the third C2f module is connected to the input of the fourth CBS module, the output of the fourth CBS module is connected to the input of the fourth Conv2d module, and the output of the fourth Conv2d module is connected to the fourth WIoU module and the fourth DFL module;

[0030] The third detection head is specifically as follows: the output of the fourth C2f module forms two branches, namely the third detection head branch one and the third detection head branch two; the third detection head branch one is specifically as follows: the output of the third C2f module is connected to the input of the fifth CBS module, the output of the fifth CBS module is connected to the input of the fifth Conv2d module, and the output of the fifth Conv2d module is connected to the fifth WIoU module and the fifth DFL module; the third detection head branch two is specifically as follows: the output of the third C2f module is connected to the input of the sixth CBS module, the output of the sixth CBS module is connected to the input of the sixth Conv2d module, and the output of the sixth Conv2d module is connected to the sixth WIoU module and the sixth DFL module.

[0031] Figure 3 yes Figure 1 The GBneckv2 module in Figure 3 As shown, in Figure 3 There are three small structure diagrams in the figure, from left to right: the bottleneck structure diagram of GhostNetv2 when the step size is 1, the bottleneck structure diagram of GhostNetv2 when the step size is 2, and the structure diagram of the DFC Attention module.

[0032] The bottleneck structure of GhostNetv2 is divided into the bottleneck structure of GhostNetv2 when the step size is 1 and the bottleneck structure of GhostNetv2 when the step size is 2;

[0033] The bottleneck structure of GhostNetv2 when the step size is 1 is:

[0034] The input features are connected to the two branches, and the first branch of the output is connected to the DFC attention module and the first GhostModule module. The first GhostModule module is multiplied with the DFC attention after the BN normalization operation and the ReLU activation function; the output after the product operation is connected to the input of the DW convolution with a step size of 2, and the output of the DW convolution operation is connected to the input of the second Ghost Module; the result after the above operation is superimposed on the second branch of the input layer to obtain the output result;

[0035] The bottleneck structure of GhostNetv2 with a step size of 2 is:

[0036] The input features are connected to the two branches, and the first branch of the output is connected to the DFC attention module and the first GhostModule module. The first GhostModule module is multiplied with the DFC attention after the BN normalization operation and the ReLU activation function; the output after the product operation is connected to the input of the second GhostModule module; the output of the second GhostModule module is superimposed with the second branch of the input layer to obtain the output result.

[0037] The specific DFC attention module is as follows: after inputting the features, it is connected to the input of the downsampling module, the output of the downsampling module is connected to the input of the 1*1 convolution module, the output of the 1*1 convolution module is processed by the normalization module and connected to the input of the FC module, the output of the FC module is processed by the normalization module and connected to the input of the Sigmoid activation function operation, and the final result is obtained after the output of the Sigmoid activation function operation.

[0038] Figure 4 yes Figure 1 The C2fGhostv2 module in Figure 4 As shown, the details are as follows:

[0039] After inputting the features, the first CBS convolution module with a stride of 1 and a convolution kernel size of 1*1 is used as input. The output of the convolution module is connected to the input of the Spilt module, and the output of the Spilt module is divided into two branches for operation. Under one branch, the output of the Spilt module is directly connected to the input of the splicing layer. Under the other branch, the number of output modules of the Spilt module is accumulated in sequence, passing through 1, 2, 3, and up to N GhostNetv2 bottleneck modules in sequence, and each time it passes through a GhostNetv2 bottleneck module, its output is connected to the input of the splicing layer in sequence, superimposed, and spliced ​​N times in total. The total number of splicing times of the branches of the two spilt layers is N+1 times. The output of the splicing layer is connected to the input of the second CBS convolution module with a stride of 1 and a convolution kernel size of 1*1, and the result is output after passing through the second CBS convolution module.

[0040] Figure 5 yes Figure 1 The CA attention mechanism module in is as follows:

[0041] The input feature map is globally averaged pooled in both the width and height directions to obtain feature maps in both the width and height directions. The shape of the input feature layer is [H, W, C]. After average pooling in the width direction, the shape of the feature layer obtained is [H, 1, C]. At this time, the feature is mapped to the high dimension. After average pooling in the height direction, the shape of the feature layer obtained is [1, W, C]. At this time, the feature is mapped to the wide dimension.

[0042] Then merge the two parallel stages, transpose the width and height to the same dimension, and then stack them to merge the width and height features together. The feature layer obtained at this time is: [1,H+W,C]. After normalizing the ordinary convolution (Conv), connect the activation function to obtain the features; it should be noted that the number of convolution channels here is generally smaller, and scaling can reduce the number of parameters. The shape of the feature layer after convolution is [1,H+W,C / r], where r is the scaling factor;

[0043] Then it is divided into two parallel stages again, and the width and height are separated into: [1,H,C / r] and [1,W,C / r], and then transposed; two feature layers [H,1,C / r] and [1,W,C / r] are obtained;

[0044] Then, 1x1 convolution is used to adjust the number of channels and then sigmoid is taken to obtain the attention in the width and height dimensions. The first feature layer [H, 1, C / r] is expanded in width, and the second feature layer [1, W, C / r] is expanded in height. Then, the output of the above two feature layers is connected to the input of the Re-weight module. The output of the Re-weight module is the CA attention mechanism.

[0045] Figure 6 yes Figure 1 The GSConv structure in is as follows:

[0046] Input channel feature map, input a convolution downsampling operation, its output is divided into two branches, one branch with C / 2 channels is directly connected to the splicing layer, the other branch with C / 2 channels first passes through the depthwise separable convolution layer (DWConv), its output is subjected to the depthwise separable convolution (DSC) operation and then connected to the splicing layer; the output of the ordinary convolution Conv layer and the depthwise separable convolution layer DWConv layer is concatenated (Concat); the concatenated feature map is subjected to a shuffle operation to rearrange the feature channels and improve the information flow between features. The final output feature map has C2 channels.

[0047] The present invention also includes a GCE-YOLOv8s network, which includes a backbone network Backbone, a neck network Neck, and a detection head network Head, specifically:

[0048] The backbone network Backbone is specifically as follows: the image input is given to the first CBS convolution module, the first CBS convolution module is connected to the input of the first GBneckv2 module, the output of the first GBneckv2 module is connected to the input of the first C2fGhostv2 module, the output of the first C2fGhostv2 module is connected to the input of the second GBneckv2 module, the output of the second GBneckv2 module is connected to the input of the second C2fGhostv2 module, the output of the second C2fGhostv2 module is connected to the input of the third GBneckv2 module, the output of the third GBneckv2 module is connected to the input of the third C2fGhostv2, the output of the third C2fGhostv2 is connected to the input of the fourth GBneckv2 module, the output of the fourth GBneckv2 module is connected to the input of the fourth C2fGhostv2, the output of the fourth C2fGhostv2 is connected to the input of the CA attention mechanism, and the output of the CA attention mechanism is connected to the input of the SPPF spatial pyramid network;

[0049] The neck network Neck is specifically as follows: the output of the SPPF spatial pyramid network is divided into two branches, one output is connected to the input of the first GSConv module, and the other output is directly connected to the input of the first splicing layer module; the output of the first GSConv module is connected to the input of the first upsampling module, the output of the first upsampling module is connected to the second splicing layer, and the third C2fGhostv2 module is also connected to the second splicing layer module; the output of the second splicing layer module is passed to the input of the first C2f module, the output of the first C2f module is connected to the input of the second upsampling module, the output of the second upsampling module is connected to the input of the third splicing layer module, the output of the second C2fGhostv2 module and the output of the third upsampling module are jointly connected to the input of the third splicing layer module; the output of the third splicing layer module is connected to the input of the second C2f module;

[0050] The output of the second C2f module is connected to the input of the second GSConv module, the output of the second GSConv module is connected to the input of the fourth splicing layer module, the output of the fourth splicing layer module is connected to the input of the third C2f module; the output of the third C2f module is connected to the input of the third GSConv module, the output of the third GSConv module is connected to the input of the first splicing layer; the output of the first splicing layer is connected to the input of the fourth C2f module;

[0051] The detection head network Head is specifically as follows: the output of the second C2f module forms the first detection head; the output of the third C2f module forms the second detection head; and the output of the fourth C2f module forms the third detection head.

[0052] The first detection head is specifically: the output of the second C2f module forms two branches, namely the first detection head branch one and the first detection head branch two; the first detection head branch one is specifically: the output of the second C2f module is connected to the input of the first CBS module, the output of the first CBS module is connected to the input of the first Conv2d module, and the output of the first Conv2d module is connected to the first WIoU module and the first DFL module; the first detection head branch two is specifically: the output of the second C2f module is connected to the input of the second CBS module, the output of the second CBS module is connected to the input of the second Conv2d module, and the output of the second Conv2d module is connected to the second WIoU module and the second DFL module;

[0053] The second detection head is specifically: the output of the third C2f module forms two branches, namely the second detection head branch one and the second detection head branch two; the second detection head branch one is specifically that the output of the third C2f module is connected to the input of the third CBS module, the output of the third CBS module is connected to the input of the third Conv2d module, and the output of the third Conv2d module is connected to the third WIoU module and the third DFL module; the second detection head branch two is specifically that: the output of the third C2f module is connected to the input of the fourth CBS module, the output of the fourth CBS module is connected to the input of the fourth Conv2d module, and the output of the fourth Conv2d module is connected to the fourth WIoU module and the fourth DFL module;

[0054] The third detection head is specifically as follows: the output of the fourth C2f module forms two branches, namely the third detection head branch one and the third detection head branch two; the third detection head branch one is specifically as follows: the output of the third C2f module is connected to the input of the fifth CBS module, the output of the fifth CBS module is connected to the input of the fifth Conv2d module, and the output of the fifth Conv2d module is connected to the fifth WIoU module and the fifth DFL module; the third detection head branch two is specifically as follows: the output of the third C2f module is connected to the input of the sixth CBS module, the output of the sixth CBS module is connected to the input of the sixth Conv2d module, and the output of the sixth Conv2d module is connected to the sixth WIoU module and the sixth DFL module.

[0055] Figure 3 yes Figure 1 The GBneckv2 module in Figure 3 As shown, in Figure 3 There are three small structure diagrams in the figure, from left to right: the bottleneck structure diagram of GhostNetv2 when the step size is 1, the bottleneck structure diagram of GhostNetv2 when the step size is 2, and the structure diagram of the DFC Attention module.

[0056] The bottleneck structure of GhostNetv2 is divided into the bottleneck structure of GhostNetv2 when the step size is 1 and the bottleneck structure of GhostNetv2 when the step size is 2;

[0057] The bottleneck structure of GhostNetv2 when the step size is 1 is:

[0058] The input features are connected to the two branches, and the first branch of the output is connected to the DFC attention module and the first GhostModule module. The first GhostModule module is multiplied with the DFC attention after the BN normalization operation and the ReLU activation function; the output after the product operation is connected to the input of the DW convolution with a step size of 2, and the output of the DW convolution operation is connected to the input of the second Ghost Module; the result after the above operation is superimposed on the second branch of the input layer to obtain the output result;

[0059] The bottleneck structure of GhostNetv2 with a step size of 2 is:

[0060] The input features are connected to the two branches, and the first branch of the output is connected to the DFC attention module and the first GhostModule module. The first GhostModule module is multiplied with the DFC attention after the BN normalization operation and the ReLU activation function; the output after the product operation is connected to the input of the second GhostModule module; the output of the second GhostModule module is superimposed with the second branch of the input layer to obtain the output result.

[0061] The specific DFC attention module is as follows: after inputting the features, it is connected to the input of the downsampling module, the output of the downsampling module is connected to the input of the 1*1 convolution module, the output of the 1*1 convolution module is processed by the normalization module and connected to the input of the FC module, the output of the FC module is processed by the normalization module and connected to the input of the Sigmoid activation function operation, and the final result is obtained after the output of the Sigmoid activation function operation.

[0062] Figure 4 yes Figure 1 The C2fGhostv2 module in Figure 4 As shown, the details are as follows:

[0063] After inputting the features, the first CBS convolution module with a stride of 1 and a convolution kernel size of 1*1 is used as input. The output of the convolution module is connected to the input of the Spilt module, and the output of the Spilt module is divided into two branches for operation. Under one branch, the output of the Spilt module is directly connected to the input of the splicing layer. Under the other branch, the number of output modules of the Spilt module is accumulated in sequence, passing through 1, 2, 3, and up to N GhostNetv2 bottleneck modules in sequence, and each time it passes through a GhostNetv2 bottleneck module, its output is connected to the input of the splicing layer in sequence, superimposed, and spliced ​​N times in total. The total number of splicing times of the branches of the two spilt layers is N+1 times. The output of the splicing layer is connected to the input of the second CBS convolution module with a stride of 1 and a convolution kernel size of 1*1, and the result is output after passing through the second CBS convolution module.

[0064] Figure 5 yes Figure 1 The CA attention mechanism module in is as follows:

[0065] The input feature map is globally averaged pooled in both the width and height directions to obtain feature maps in both the width and height directions. The shape of the input feature layer is [H, W, C]. After average pooling in the width direction, the shape of the feature layer obtained is [H, 1, C]. At this time, the feature is mapped to the high dimension. After average pooling in the height direction, the shape of the feature layer obtained is [1, W, C]. At this time, the feature is mapped to the wide dimension.

[0066] Then merge the two parallel stages, transpose the width and height to the same dimension, and then stack them to merge the width and height features together. The feature layer obtained at this time is: [1,H+W,C]. After normalizing the ordinary convolution (Conv), connect the activation function to obtain the features; it should be noted that the number of convolution channels here is generally smaller, and scaling can reduce the number of parameters. The shape of the feature layer after convolution is [1,H+W,C / r], where r is the scaling factor;

[0067] Then it is divided into two parallel stages again, and the width and height are separated into: [1,H,C / r] and [1,W,C / r], and then transposed; two feature layers [H,1,C / r] and [1,W,C / r] are obtained;

[0068] Then, 1x1 convolution is used to adjust the number of channels and then sigmoid is taken to obtain the attention in the width and height dimensions. The first feature layer [H, 1, C / r] is expanded in width, and the second feature layer [1, W, C / r] is expanded in height. Then, the output of the above two feature layers is connected to the input of the Re-weight module. The output of the Re-weight module is the CA attention mechanism.

[0069] Figure 6 yes Figure 1 The GSConv structure in is as follows:

[0070] Input channel feature map, input a convolution downsampling operation, its output is divided into two branches, one branch with C / 2 channels is directly connected to the splicing layer, the other branch with C / 2 channels first passes through the depthwise separable convolution layer (DWConv), its output is subjected to the depthwise separable convolution (DSC) operation and then connected to the splicing layer; the output of the ordinary convolution Conv layer and the depthwise separable convolution layer DWConv layer is concatenated (Concat); the concatenated feature map is subjected to a shuffle operation to rearrange the feature channels and improve the information flow between features. The final output feature map has C2 channels.

[0071] Compared with the prior art, the present invention has the following technical effects:

[0072] The model of the invention is superior to the existing detection model in terms of accuracy, speed and lightness. It has lower missed detection rate and false positive rate for small targets and targets at a long distance, providing technical support for the Yangtze River Navigation Administration. The target detection model can accurately identify small targets and ships and navigation marks in complex backgrounds, and has a more obvious improvement effect on the baseline model. It can improve the recognition accuracy and speed on the basis of lightness, reduce false detection and missed detection, and has practical significance for deployment on the system side. BRIEF DESCRIPTION OF THE DRAWINGS

[0073] The present invention will be further described below in conjunction with the accompanying drawings and embodiments:

[0074] Figure 1 It is a flow chart of the present invention;

[0075] Figure 2 This is the GCE-YOLOv8s network diagram of the present invention;

[0076] Figure 3 Schematic diagram of the bottleneck structure of the GhostNetv2 model;

[0077] Figure 4 This is the C2fGhostv2 module structure diagram;

[0078] Figure 5 Schematic diagram of CA attention mechanism;

[0079] Figure 6 This is the schematic diagram of GSConv;

[0080] Figure 7 This is an example of the test results of the present invention. DETAILED DESCRIPTION

[0081] A method for detecting waterway ships and navigation marks based on an improved YOLOv8s algorithm comprises the following steps:

[0082] Step S1: Screening and sorting the captured ship and navigation mark data sets of the target waterway;

[0083] Step S2: After image preprocessing steps such as flipping, cropping, brightness adjustment, and blurring, a complete data set is obtained;

[0084] Step S3: Use Labelimg to annotate the dataset and divide it into training set, validation set, and test set according to a certain ratio;

[0085] Step S4: Build the GCE-YOLOv8s network;

[0086] Step S5: Put the obtained data set into the GCE-YOLOv8s model, combine the GCE-YOLOv8s model to identify the acquired ship and navigation mark images, and use the recall rate, average precision mean, and the number of frames per second as evaluation indicators;

[0087] Step S6: Use the trained model to perform image prediction on the image to be detected for accurate recognition.

[0088] In step S2, the data set is preprocessed to expand the original data set;

[0089] In step S3, the collected ships and different types of navigation marks are labeled using the labelimg image annotation tool, and the data set is divided according to a certain ratio to obtain the training set, verification set, and test set of the ship and navigation mark data set;

[0090] In step S4, the EIoU border loss function is used as the new border loss function of YOLOv8.

[0091] The EIoU border loss function used consists of three parts: overlap loss, center distance loss, and width and height loss. The calculation formula is:

[0092]

[0093] Where IoU is the ratio of the intersection area of ​​the predicted box and the real box to the combined area, b,b gt Respectively represent the center point of the predicted box and the center point of the real box, ρ 2 (b,b gt ) represents the Euclidean distance between the two center points of the predicted box and the true box, c represents the diagonal distance of the minimum closure area that contains both the predicted box and the true box, w,w gt Represent the predicted box width and the real box width, ρ 2 (w,w gt ) represents the Euclidean distance between the predicted box and the true box width, h,h gt Respectively represent the predicted box length and the real box length, ρ 2 (h,h gt ) represents the Euclidean distance between the predicted box and the true box length, C w and C h Indicates the width and length of the minimum bounding box covering the predicted box and the true box.

[0094] In step S5, the training set is put into the GCE-YOLOv8s model for training to obtain the detection results and obtain the best.pt file; the model is evaluated by evaluation indicators, and the best.pt file includes recall rate (recall, Rec), mean average precision (mean average precision, mAP), frames per second (frames per second, FPS) and parameters.

[0095] In step S6, the best.pt file obtained after training is used as the pre-training weight of the model in this paper, and the image to be tested is placed in it for detection and recognition.

[0096] In step S3, if Figure 2 As shown, the constructed GCE-YOLOv8s network includes the backbone network Backbone, the neck network Neck, and the detection head network Head, as follows:

[0097] The backbone network Backbone is specifically as follows: the image input is given to the first CBS convolution module, the first CBS convolution module is connected to the input of the first GBneckv2 module, the output of the first GBneckv2 module is connected to the input of the first C2fGhostv2 module, the output of the first C2fGhostv2 module is connected to the input of the second GBneckv2 module, the output of the second GBneckv2 module is connected to the input of the second C2fGhostv2 module, the output of the second C2fGhostv2 module is connected to the input of the third GBneckv2 module, the output of the third GBneckv2 module is connected to the input of the third C2fGhostv2, the output of the third C2fGhostv2 is connected to the input of the fourth GBneckv2 module, the output of the fourth GBneckv2 module is connected to the input of the fourth C2fGhostv2, the output of the fourth C2fGhostv2 is connected to the input of the CA attention mechanism, and the output of the CA attention mechanism is connected to the input of the SPPF spatial pyramid network;

[0098] The neck network Neck is specifically as follows: the output of the SPPF spatial pyramid network is divided into two branches, one output is connected to the input of the first GSConv module, and the other output is directly connected to the input of the first splicing layer module; the output of the first GSConv module is connected to the input of the first upsampling module, the output of the first upsampling module is connected to the second splicing layer, and the third C2fGhostv2 module is also connected to the second splicing layer module; the output of the second splicing layer module is passed to the input of the first C2f module, the output of the first C2f module is connected to the input of the second upsampling module, the output of the second upsampling module is connected to the input of the third splicing layer module, the output of the second C2fGhostv2 module and the output of the third upsampling module are jointly connected to the input of the third splicing layer module; the output of the third splicing layer module is connected to the input of the second C2f module;

[0099] The output of the second C2f module is connected to the input of the second GSConv module, the output of the second GSConv module is connected to the input of the fourth splicing layer module, the output of the fourth splicing layer module is connected to the input of the third C2f module; the output of the third C2f module is connected to the input of the third GSConv module, the output of the third GSConv module is connected to the input of the first splicing layer; the output of the first splicing layer is connected to the input of the fourth C2f module;

[0100] The detection head network Head is specifically as follows: the output of the second C2f module forms the first detection head; the output of the third C2f module forms the second detection head; and the output of the fourth C2f module forms the third detection head.

[0101] The first detection head is specifically: the output of the second C2f module forms two branches, namely the first detection head branch one and the first detection head branch two; the first detection head branch one is specifically: the output of the second C2f module is connected to the input of the first CBS module, the output of the first CBS module is connected to the input of the first Conv2d module, and the output of the first Conv2d module is connected to the first WIoU module and the first DFL module; the first detection head branch two is specifically: the output of the second C2f module is connected to the input of the second CBS module, the output of the second CBS module is connected to the input of the second Conv2d module, and the output of the second Conv2d module is connected to the second WIoU module and the second DFL module;

[0102] The second detection head is specifically: the output of the third C2f module forms two branches, namely the second detection head branch one and the second detection head branch two; the second detection head branch one is specifically that the output of the third C2f module is connected to the input of the third CBS module, the output of the third CBS module is connected to the input of the third Conv2d module, and the output of the third Conv2d module is connected to the third WIoU module and the third DFL module; the second detection head branch two is specifically that: the output of the third C2f module is connected to the input of the fourth CBS module, the output of the fourth CBS module is connected to the input of the fourth Conv2d module, and the output of the fourth Conv2d module is connected to the fourth WIoU module and the fourth DFL module;

[0103] The third detection head is specifically as follows: the output of the fourth C2f module forms two branches, namely the third detection head branch one and the third detection head branch two; the third detection head branch one is specifically as follows: the output of the third C2f module is connected to the input of the fifth CBS module, the output of the fifth CBS module is connected to the input of the fifth Conv2d module, and the output of the fifth Conv2d module is connected to the fifth WIoU module and the fifth DFL module; the third detection head branch two is specifically as follows: the output of the third C2f module is connected to the input of the sixth CBS module, the output of the sixth CBS module is connected to the input of the sixth Conv2d module, and the output of the sixth Conv2d module is connected to the sixth WIoU module and the sixth DFL module.

[0104] Figure 3 yes Figure 1 The GBneckv2 module in Figure 3 As shown, in Figure 3 There are three small structure diagrams in the figure, from left to right: the bottleneck structure diagram of GhostNetv2 when the step size is 1, the bottleneck structure diagram of GhostNetv2 when the step size is 2, and the structure diagram of the DFC Attention module.

[0105] The bottleneck structure of GhostNetv2 is divided into the bottleneck structure of GhostNetv2 when the step size is 1 and the bottleneck structure of GhostNetv2 when the step size is 2;

[0106] The bottleneck structure of GhostNetv2 when the step size is 1 is:

[0107] The input features are connected to the two branches, and the first branch of the output is connected to the DFC attention module and the first GhostModule module. The first GhostModule module is multiplied with the DFC attention after the BN normalization operation and the ReLU activation function; the output after the product operation is connected to the input of the DW convolution with a step size of 2, and the output of the DW convolution operation is connected to the input of the second Ghost Module; the result after the above operation is superimposed on the second branch of the input layer to obtain the output result;

[0108] The bottleneck structure of GhostNetv2 with a step size of 2 is:

[0109] The input features are connected to the two branches, and the first branch of the output is connected to the DFC attention module and the first GhostModule module. The first GhostModule module is multiplied with the DFC attention after the BN normalization operation and the ReLU activation function; the output after the product operation is connected to the input of the second GhostModule module; the output of the second GhostModule module is superimposed with the second branch of the input layer to obtain the output result.

[0110] The specific DFC attention module is as follows: after inputting the features, it is connected to the input of the downsampling module, the output of the downsampling module is connected to the input of the 1*1 convolution module, the output of the 1*1 convolution module is processed by the normalization module and connected to the input of the FC module, the output of the FC module is processed by the normalization module and connected to the input of the Sigmoid activation function operation, and the final result is obtained after the output of the Sigmoid activation function operation.

[0111] Figure 4 yes Figure 1 The C2fGhostv2 module in Figure 4 As shown, the details are as follows:

[0112] After inputting the features, the first CBS convolution module with a stride of 1 and a convolution kernel size of 1*1 is used as input. The output of the convolution module is connected to the input of the Spilt module, and the output of the Spilt module is divided into two branches for operation. Under one branch, the output of the Spilt module is directly connected to the input of the splicing layer. Under the other branch, the number of output modules of the Spilt module is accumulated in sequence, passing through 1, 2, 3, and up to N GhostNetv2 bottleneck modules in sequence, and each time it passes through a GhostNetv2 bottleneck module, its output is connected to the input of the splicing layer in sequence, superimposed, and spliced ​​N times in total. The total number of splicing times of the branches of the two spilt layers is N+1 times. The output of the splicing layer is connected to the input of the second CBS convolution module with a stride of 1 and a convolution kernel size of 1*1, and the result is output after passing through the second CBS convolution module.

[0113] Figure 5 yes Figure 1 The CA attention mechanism module in is as follows:

[0114] The input feature map is globally averaged pooled in both the width and height directions to obtain feature maps in both the width and height directions. The shape of the input feature layer is [H, W, C]. After average pooling in the width direction, the shape of the feature layer obtained is [H, 1, C]. At this time, the feature is mapped to the high dimension. After average pooling in the height direction, the shape of the feature layer obtained is [1, W, C]. At this time, the feature is mapped to the wide dimension.

[0115] Then merge the two parallel stages, transpose the width and height to the same dimension, and then stack them to merge the width and height features together. The feature layer obtained at this time is: [1,H+W,C]. After normalizing the ordinary convolution (Conv), connect the activation function to obtain the features; it should be noted that the number of convolution channels here is generally smaller, and scaling can reduce the number of parameters. The shape of the feature layer after convolution is [1,H+W,C / r], where r is the scaling factor;

[0116] Then it is divided into two parallel stages again, and the width and height are separated into: [1,H,C / r] and [1,W,C / r], and then transposed; two feature layers [H,1,C / r] and [1,W,C / r] are obtained;

[0117] Then, 1x1 convolution is used to adjust the number of channels and then sigmoid is taken to obtain the attention in the width and height dimensions. The first feature layer [H, 1, C / r] is expanded in width, and the second feature layer [1, W, C / r] is expanded in height. Then, the output of the above two feature layers is connected to the input of the Re-weight module. The output of the Re-weight module is the CA attention mechanism.

[0118] Figure 6 yes Figure 1 The GSConv structure in is as follows:

[0119] Input channel feature map, input a convolution downsampling operation, its output is divided into two branches, one branch with C / 2 channels is directly connected to the splicing layer, the other branch with C / 2 channels first passes through the depthwise separable convolution layer (DWConv), its output is subjected to the depthwise separable convolution (DSC) operation and then connected to the splicing layer; the output of the ordinary convolution Conv layer and the depthwise separable convolution layer DWConv layer is concatenated (Concat); the concatenated feature map is subjected to a shuffle operation to rearrange the feature channels and improve the information flow between features. The final output feature map has C2 channels.

[0120] The present invention also includes a GCE-YOLOv8s network, which includes a backbone network Backbone, a neck network Neck, and a detection head network Head, specifically:

[0121] The backbone network Backbone is specifically as follows: the image input is given to the first CBS convolution module, the first CBS convolution module is connected to the input of the first GBneckv2 module, the output of the first GBneckv2 module is connected to the input of the first C2fGhostv2 module, the output of the first C2fGhostv2 module is connected to the input of the second GBneckv2 module, the output of the second GBneckv2 module is connected to the input of the second C2fGhostv2 module, the output of the second C2fGhostv2 module is connected to the input of the third GBneckv2 module, the output of the third GBneckv2 module is connected to the input of the third C2fGhostv2, the output of the third C2fGhostv2 is connected to the input of the fourth GBneckv2 module, the output of the fourth GBneckv2 module is connected to the input of the fourth C2fGhostv2, the output of the fourth C2fGhostv2 is connected to the input of the CA attention mechanism, and the output of the CA attention mechanism is connected to the input of the SPPF spatial pyramid network;

[0122] The neck network Neck is specifically as follows: the output of the SPPF spatial pyramid network is divided into two branches, one output is connected to the input of the first GSConv module, and the other output is directly connected to the input of the first splicing layer module; the output of the first GSConv module is connected to the input of the first upsampling module, the output of the first upsampling module is connected to the second splicing layer, and the third C2fGhostv2 module is also connected to the second splicing layer module; the output of the second splicing layer module is passed to the input of the first C2f module, the output of the first C2f module is connected to the input of the second upsampling module, the output of the second upsampling module is connected to the input of the third splicing layer module, the output of the second C2fGhostv2 module and the output of the third upsampling module are jointly connected to the input of the third splicing layer module; the output of the third splicing layer module is connected to the input of the second C2f module;

[0123] The output of the second C2f module is connected to the input of the second GSConv module, the output of the second GSConv module is connected to the input of the fourth splicing layer module, the output of the fourth splicing layer module is connected to the input of the third C2f module; the output of the third C2f module is connected to the input of the third GSConv module, the output of the third GSConv module is connected to the input of the first splicing layer; the output of the first splicing layer is connected to the input of the fourth C2f module;

[0124] The detection head network Head is specifically as follows: the output of the second C2f module forms the first detection head; the output of the third C2f module forms the second detection head; and the output of the fourth C2f module forms the third detection head.

[0125] The first detection head is specifically: the output of the second C2f module forms two branches, namely the first detection head branch one and the first detection head branch two; the first detection head branch one is specifically: the output of the second C2f module is connected to the input of the first CBS module, the output of the first CBS module is connected to the input of the first Conv2d module, and the output of the first Conv2d module is connected to the first WIoU module and the first DFL module; the first detection head branch two is specifically: the output of the second C2f module is connected to the input of the second CBS module, the output of the second CBS module is connected to the input of the second Conv2d module, and the output of the second Conv2d module is connected to the second WIoU module and the second DFL module;

[0126] The second detection head is specifically: the output of the third C2f module forms two branches, namely the second detection head branch one and the second detection head branch two; the second detection head branch one is specifically that the output of the third C2f module is connected to the input of the third CBS module, the output of the third CBS module is connected to the input of the third Conv2d module, and the output of the third Conv2d module is connected to the third WIoU module and the third DFL module; the second detection head branch two is specifically that: the output of the third C2f module is connected to the input of the fourth CBS module, the output of the fourth CBS module is connected to the input of the fourth Conv2d module, and the output of the fourth Conv2d module is connected to the fourth WIoU module and the fourth DFL module;

[0127] The third detection head is specifically as follows: the output of the fourth C2f module forms two branches, namely the third detection head branch one and the third detection head branch two; the third detection head branch one is specifically as follows: the output of the third C2f module is connected to the input of the fifth CBS module, the output of the fifth CBS module is connected to the input of the fifth Conv2d module, and the output of the fifth Conv2d module is connected to the fifth WIoU module and the fifth DFL module; the third detection head branch two is specifically as follows: the output of the third C2f module is connected to the input of the sixth CBS module, the output of the sixth CBS module is connected to the input of the sixth Conv2d module, and the output of the sixth Conv2d module is connected to the sixth WIoU module and the sixth DFL module.

[0128] Figure 3 yes Figure 1 The GBneckv2 module in Figure 3 As shown, in Figure 3 There are three small structure diagrams in the figure, from left to right: the bottleneck structure diagram of GhostNetv2 when the step size is 1, the bottleneck structure diagram of GhostNetv2 when the step size is 2, and the structure diagram of the DFC Attention module.

[0129] The bottleneck structure of GhostNetv2 is divided into the bottleneck structure of GhostNetv2 when the step size is 1 and the bottleneck structure of GhostNetv2 when the step size is 2;

[0130] The bottleneck structure of GhostNetv2 when the step size is 1 is:

[0131] The input features are connected to the two branches, and the first branch of the output is connected to the DFC attention module and the first GhostModule module. The first GhostModule module is multiplied with the DFC attention after the BN normalization operation and the ReLU activation function; the output after the product operation is connected to the input of the DW convolution with a step size of 2, and the output of the DW convolution operation is connected to the input of the second Ghost Module; the result after the above operation is superimposed on the second branch of the input layer to obtain the output result;

[0132] The bottleneck structure of GhostNetv2 with a step size of 2 is:

[0133] The input features are connected to the two branches, and the first branch of the output is connected to the DFC attention module and the first GhostModule module. The first GhostModule module is multiplied with the DFC attention after the BN normalization operation and the ReLU activation function; the output after the product operation is connected to the input of the second GhostModule module; the output of the second GhostModule module is superimposed with the second branch of the input layer to obtain the output result.

[0134] The specific DFC attention module is as follows: after inputting the features, it is connected to the input of the downsampling module, the output of the downsampling module is connected to the input of the 1*1 convolution module, the output of the 1*1 convolution module is processed by the normalization module and connected to the input of the FC module, the output of the FC module is processed by the normalization module and connected to the input of the Sigmoid activation function operation, and the final result is obtained after the output of the Sigmoid activation function operation.

[0135] Figure 4 yes Figure 1 The C2fGhostv2 module in Figure 4 As shown, the details are as follows:

[0136] After inputting the features, the first CBS convolution module with a stride of 1 and a convolution kernel size of 1*1 is used as input. The output of the convolution module is connected to the input of the Spilt module, and the output of the Spilt module is divided into two branches for operation. Under one branch, the output of the Spilt module is directly connected to the input of the splicing layer. Under the other branch, the number of output modules of the Spilt module is accumulated in sequence, passing through 1, 2, 3, and up to N GhostNetv2 bottleneck modules in sequence, and each time it passes through a GhostNetv2 bottleneck module, its output is connected to the input of the splicing layer in sequence, superimposed, and spliced ​​N times in total. The total number of splicing times of the branches of the two spilt layers is N+1 times. The output of the splicing layer is connected to the input of the second CBS convolution module with a stride of 1 and a convolution kernel size of 1*1, and the result is output after passing through the second CBS convolution module.

[0137] Figure 5 yes Figure 1 The CA attention mechanism module in is as follows:

[0138] The input feature map is globally averaged pooled in both the width and height directions to obtain feature maps in both the width and height directions. The shape of the input feature layer is [H, W, C]. After average pooling in the width direction, the shape of the feature layer obtained is [H, 1, C]. At this time, the feature is mapped to the high dimension. After average pooling in the height direction, the shape of the feature layer obtained is [1, W, C]. At this time, the feature is mapped to the wide dimension.

[0139] Then merge the two parallel stages, transpose the width and height to the same dimension, and then stack them to merge the width and height features together. The feature layer obtained at this time is: [1,H+W,C]. After normalizing the ordinary convolution (Conv), connect the activation function to obtain the features; it should be noted that the number of convolution channels here is generally smaller, and scaling can reduce the number of parameters. The shape of the feature layer after convolution is [1,H+W,C / r], where r is the scaling factor;

[0140] Then it is divided into two parallel stages again, and the width and height are separated into: [1,H,C / r] and [1,W,C / r], and then transposed; two feature layers [H,1,C / r] and [1,W,C / r] are obtained;

[0141] Then, 1x1 convolution is used to adjust the number of channels and then sigmoid is taken to obtain the attention in the width and height dimensions. The first feature layer [H, 1, C / r] is expanded in width, and the second feature layer [1, W, C / r] is expanded in height. Then, the output of the above two feature layers is connected to the input of the Re-weight module. The output of the Re-weight module is the CA attention mechanism.

[0142] Figure 6 yes Figure 1 The GSConv structure in is as follows:

[0143] Input channel feature map, input a convolution downsampling operation, its output is divided into two branches, one branch with C / 2 channels is directly connected to the splicing layer, the other branch with C / 2 channels first passes through the depthwise separable convolution layer (DWConv), its output is subjected to the depthwise separable convolution (DSC) operation and then connected to the splicing layer; the output of the ordinary convolution Conv layer and the depthwise separable convolution layer DWConv layer is concatenated (Concat); the concatenated feature map is subjected to a shuffle operation to rearrange the feature channels and improve the information flow between features. The final output feature map has C2 channels.

[0144] Example:

[0145] The present invention adds the GhostNetv2 lightweight network model to the YOLOv8s backbone network, improves the original C2f module by using the C2fGhostv2 module; adds GSConv to replace the original C2f module in the feature fusion part; integrates the CA attention mechanism into the backbone network; and finally uses the EIoU loss function as the loss function of the model proposed by the present invention. Its structure is as follows Figure 2 shown.

[0146] GhostNetv2 is a SOTA lightweight network model, whose main component is the Ghost convolution module, and introduces a new attention mechanism: decoupled fully connected attention (DFC). By combining Ghost convolution with the new attention mechanism, this network model can greatly improve the detection speed without losing accuracy.

[0147] The bottleneck module (GBneckv2) of GhostNetv2 is used to replace part of the convolution structure in Backbone. Figure 3As shown in the figure. The bottleneck structure of the GhostNetv2 model is divided into two structures with a step size of 2 and a step size of 1. When the step size is 2, the channel size of the input feature is first adjusted through the Ghostv2 convolution module, and then the size of the input feature is adjusted through the depthwise separable convolution (Dwconv), and the number of channels is adjusted using Ghost convolution and the final addition operation is performed to obtain the output feature; when the step size is 1, the input feature only needs to pass through the Ghostv2 convolution module and the depthwise separable convolution operation once to obtain the output feature.

[0148] At the same time, the present invention improves the C2f structure in Backbone to obtain the C2fGhostv2 module, whose structure diagram is shown in FIG. Figure 4 The main improvement is to replace the n Bottleneck modules in the C2f structure with the GhostNetv2 Bottleneck module, extract features through the feature map generated by ordinary convolution, normalization and SiLU activation function, and finally concatenate with another ordinary convolution to obtain the output feature map.

[0149] The CBS convolution structure in the feature fusion module of YOLOv8s will lead to a deeper number of channels, which will lead to an increase in the number of model parameters and a slower model training speed. In view of the above problems, the present invention replaces the original CBS convolution structure with the GSConv convolution module.

[0150] GSConv combines three parts: standard convolution (SC), depthwise separable convolution (DSC) and channel shuffle. First, ordinary convolution reduces the dimension of data by downsampling the input, thereby reducing computational complexity and helping the model capture features in a larger range; secondly, deep convolution is an operation that processes the downsampled results. Deep convolution can increase the depth of the network while keeping the number of parameters unchanged, thereby improving the expressive power of the model; then use the splicing operation to merge the results of ordinary convolution and depthwise separable convolution, so that the model can use the features extracted by ordinary convolution and depthwise convolution at the same time; finally, use the Shuffle operation to rearrange the spliced ​​results, so that the corresponding number of channels of the previous two convolutions are connected together, thereby increasing the diversity of features. Considering that the main task of the backbone network is feature extraction, the present invention embeds GSConv into the Neck network, and its structure diagram is shown as follows: Figure 6 shown.

[0151] like Figure 5As shown in the figure, the present invention embeds the CA attention mechanism into the last convolution layer of the backbone network to enhance the feature extraction capability of the model of the present invention. The attention mechanism can obtain the precise position information of the height and width of the detected image and encode it, so that it can pay more attention to the ship and the beacon itself when identifying the beacon target, while reducing the impact of the complex background.

[0152] First, the input feature map is divided into two directions, X and Y, to obtain feature information in two different directions, and then average pooling operations are performed on them respectively; secondly, through a Concat and ordinary convolution, the feature map size is changed to C / r, and after normalization and nonlinear operations, the feature information in two directions is obtained again, and then the feature weights in different directions are obtained through the Sigmoid activation function; finally, the features in two different directions are fused through weighted calculation to obtain the final output feature map.

[0153] The CIoU loss function originally used by YOLOv8s may cause the model to be unable to distinguish the relationship between relative positions when the aspect ratio of the predicted box and the true target box is the same, and may also cause divergence problems during training.

[0154] Since target detection is mainly based on bounding box regression to predict and locate targets in images, CIoU may have a gradient vanishing problem, which slows down the convergence speed and leads to low detection accuracy. To solve the above problem, the present invention uses EIoU as the loss function of the present invention, and its formula is as follows:

[0155]

[0156] Among them, b and b gt Represent the center points of the predicted box and the real box respectively, ρ represents the Euclidean distance between the two center points, c represents the diagonal distance of the minimum closure area that can contain both the predicted box and the real box, C w and C h are the width and height of the closure of the two rectangles respectively. Compared with the CIoU loss function, the EIoU loss function. In summary, the EIoU loss function used in the present invention can increase the model's positioning ability for navigation targets, which is better than the CIoU loss function.

[0157] The present invention selects precision (Precision, P), recall (Recall), mean Average Precision (mAP) and frame rate (Frame Per Second, FPS) as evaluation indicators of the model.

[0158] The average precision is determined by precision and recall, and its expression is as follows.

[0159]

[0160] Where TP represents the number of samples that are positive and predicted as positive. FP represents the number of samples that are negative but predicted as positive. FN represents the number of samples that are positive but predicted as negative. TN represents the number of samples that are negative and predicted as negative.

[0161] The mAP value is the average value calculated by the model after identifying each type of object. Its expression is as follows.

[0162]

[0163] In the formula, n represents the number of categories, AP i Represents the average precision value of the i-th category.

[0164] The hardware and software used in the experiment of the embodiment of the present invention are shown in Table 1.

[0165] Table 1 Selection of Software and Hardware

[0166]

[0167] In addition, the image input size of the model of the present invention is 640×640; the number of training rounds is 200; the batch size used in training is 16; the learning rate is 0.01; the optimizer uses SGD; and no pre-trained weights are used.

[0168] In order to verify the effectiveness of the GhostNetv2 lightweight network model, C2fGhostv2 module, feature fusion module GSConv, CA attention mechanism, and EIoU loss function design, the present invention conducted an ablation experiment, and the relevant experimental results are shown in Table 2.

[0169] Table 2 Ablation experiment results

[0170] Table 2 Results of ablation experiments

[0171]

[0172] After adding GhostNetv2+C2fGhostv2 to the baseline model, its mAP50 dropped by 1.1%, but its parameters were reduced by 13.3% and the recognition speed increased by 12.5%, indicating that GhostNetv2+C2fGhostv2 can improve the recognition speed and reduce the model parameters under the premise of slightly reducing the accuracy; after adding GSConv, its mAP50 increased by 1.3%, the recognition speed increased by 23.1%, and the parameters were also reduced by 14.4%. GSConv can improve the accuracy and recognition speed while reducing the model parameters; the addition of CA attention mechanism increased the mAP50 by 0.5% and the detection speed by 8.3%, respectively, so that the model can focus on the detection targets in complex backgrounds; the addition of EIoU loss function increased the mAP50 by 2.5% and the detection speed by 20.1%, which can make the model pay more attention to the detection accuracy of small targets. The experimental results show that the improvements in each part have improved the performance of the model.

[0173] In order to verify the advantages of the model of the present invention, the present invention compares SSD, Faster R-CNN, YOLOv5, YOLOv7, and YOLOv8s with the model of the present invention. Each model uses the same hyperparameters and data sets. The comparative experimental results are shown in Table 3. As can be seen from the table, the model proposed in the present invention has the highest accuracy and detection rate compared to the SSD, Faster R-CNN, YOLOv5, YOLOv7, and YOLOv8s models. Compared with the original YOLOv8s model, the improved YOLOv8s model proposed in the present invention can improve the mAP value by 3.2% while reducing the number of parameters by 27.8%. The detection speed reaches 334.8 frames·s-1, which shows that the improved method proposed in the present invention has good practicality. Some experimental detection images are as follows. Figure 7 shown.

[0174] Table 3 Comparison of different models

[0175] Table 3 Comparison of Different Models

[0176] Model Precision / % mAP0.5 / % <![CDATA[FPS / frames per second -1 > Params / MB SSD 79.2 77.4 78.7 109.10 Faster RCNN 84.1 83.6 89.3 91.50 YOLOv5 93.6 91.8 109.9 7.02 YOLOv7 91.8 88.3 120.5 36.50 YOLOv8s 96.9 94.3 185.2 11.17 Model of the present invention 97.2 97.5 334.8 8.07

[0177] In order to realize the rapid and accurate detection of different types of ships and navigation marks in the complex environment of inland waterways, the present invention proposes a GCE-YOLOv8s model based on YOLOv8s. By adding the GhostNetv2 lightweight network model to the YOLOv8s backbone network, and improving the original C2f module by the C2fGhostv2 module, the ship and navigation mark detection model can reduce the number of parameters and improve the ship detection speed; secondly, GSConv is added to the feature fusion part to replace the original C2f structure, reduce the model complexity, and realize real-time detection of ships and navigation marks; then the CA attention mechanism is added, so that the model can reduce the interference of the complex waterway background and be more focused on ships and navigation marks; finally, EIoU is used as the loss function of the model of the present invention to fully focus on the spatial information of ships and navigation marks in the complex waterway background. The experimental results of the data set of the present invention show that compared with the YOLOv8s model, the model proposed by the present invention can accurately identify waterway ships and navigation marks. The present invention subsequently applies the model to mobile devices for application testing to further study its applicability.

Claims

1. A method for detecting waterway ships and navigation marks based on an improved YOLOv8s algorithm, characterized in that: The following steps are involved: Step S1: Screening and sorting the captured ship and navigation mark data sets of the target waterway; Step S2: After image preprocessing steps such as flipping, cropping, brightness adjustment, and blurring, a complete data set is obtained; Step S3: Use Labelimg to annotate the dataset and divide it into training set, validation set, and test set according to a certain ratio; Step S4: Build the GCE-YOLOv8s network; Step S5: Put the obtained data set into the GCE-YOLOv8s model, combine the GCE-YOLOv8s model to identify the acquired ship and navigation mark images, and use the recall rate, average precision mean, and the number of frames per second as evaluation indicators; Step S6: Use the trained model to perform image prediction on the image to be detected for accurate recognition; In step S4, the constructed GCE-YOLOv8s network includes the backbone network Backbone, the neck network Neck, and the detection head network Head, as follows: The backbone network Backbone is specifically as follows: the first CBS convolution module is connected to the input of the first GBneckv2 module, the output of the first GBneckv2 module is connected to the input of the first C2fGhostv2 module, the output of the first C2fGhostv2 module is connected to the input of the second GBneckv2 module, the output of the second GBneckv2 module is connected to the input of the second C2fGhostv2 module, the output of the second C2fGhostv2 module is connected to the input of the third GBneckv2 module, the output of the third GBneckv2 module is connected to the input of the third C2fGhostv2, the output of the third C2fGhostv2 is connected to the input of the fourth GBneckv2 module, the output of the fourth GBneckv2 module is connected to the input of the fourth C2fGhostv2, the output of the fourth C2fGhostv2 is connected to the input of the CA attention mechanism, and the output of the CA attention mechanism is connected to the input of the SPPF spatial pyramid network; The neck network Neck is specifically: the output of the SPPF spatial pyramid network is divided into two branches, one output is connected to the input of the first GSConv module, and the other output is directly connected to the input of the first splicing layer module; The output of the first GSConv module is connected to the input of the first upsampling module, the output of the first upsampling module is connected to the second splicing layer, and the third C2fGhostv2 module is also connected to the second splicing layer module; the output of the second splicing layer module is passed to the input of the first C2f module, the output of the first C2f module is connected to the input of the second upsampling module, the output of the second upsampling module is connected to the input of the third splicing layer module, the output of the second C2fGhostv2 module and the output of the third upsampling module are jointly connected to the input of the third splicing layer module; the output of the third splicing layer module is connected to the input of the second C2f module; The output of the second C2f module is connected to the input of the second GSConv module, the output of the second GSConv module is connected to the input of the fourth splicing layer module, the output of the fourth splicing layer module is connected to the input of the third C2f module; the output of the third C2f module is connected to the input of the third GSConv module, the output of the third GSConv module is connected to the input of the first splicing layer; the output of the first splicing layer is connected to the input of the fourth C2f module; The detection head network Head is specifically as follows: the output of the second C2f module forms the first detection head; the output of the third C2f module forms the second detection head; and the output of the fourth C2f module forms the third detection head.

2. The method according to claim 1, characterized in that: In step S2, the data set is preprocessed to expand the original data set; In step S3, the collected ships and different types of navigation marks are labeled using the labelimg image annotation tool, and the data set is divided according to a certain ratio to obtain the training set, verification set, and test set of the ship and navigation mark data set; In step S4, the EIoU border loss function is used as the new border loss function of YOLOv8.

3. The method according to claim 2, characterized in that The EIoU border loss function used consists of three parts: overlap loss, center distance loss, and width and height loss. The calculation formula is: Where IoU is the ratio of the intersection area of ​​the predicted box and the real box to the combined area, b,b gt Respectively represent the center point of the predicted box and the center point of the real box, ρ 2 (b,b gt ) represents the Euclidean distance between the two center points of the predicted box and the true box, c represents the diagonal distance of the minimum closure area that contains both the predicted box and the true box, w,w gt Represent the predicted box width and the real box width, ρ 2 (w,w gt ) represents the Euclidean distance between the predicted box and the true box width, h,h gt Respectively represent the predicted box length and the real box length, ρ 2 (h,h gt ) represents the Euclidean distance between the predicted box and the true box length, C w and C h Indicates the width and length of the minimum bounding box covering the predicted box and the true box.

Citation Information

Patent Citations

  • High-resolution remote sensing ship detection method based on improved YOLOv4

    CN115205264A

  • Marine ship detection method based on synthetic aperture radar data

    CN116665148A