YOLOv8 algorithm-based ship detection model training method and ship detection method
By integrating the variability convolution module and the coordinate attention mechanism into the ship detection model, and defining a new target frame loss function LInner-PIoUv2, the problem of low detection accuracy of the YOLOv8 algorithm in ship detection is solved, and the Higher detection accuracy and model performance.
Patent Information
- Application Number
- CN202411381305.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-09-29
AI Technical Summary
The YOLOv8 algorithm has little accuracy in detecting ships with huge differences in size and profile, and it is difficult to effectively classify 100,000-ton cruise ships and 100-ton fishing boats, or submarines and ordinary ships.
By integrated the variability convolutional module and coordinate attention mechanism in the ship detection model, and set the Neck layer in the model to define the new target box loss function Linner-Piouv2. , Optimize the edge of the predictive border.
The ship detection model improves the detection accuracy of different ships, enhances the detection ability of medium-quality anchor points, and adapts to auxiliary bounding boxes of different sizes, improving the performance of the model.
Smart Images

Figure CN119360320A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of deep learning technology, and in particular to a ship detection model training method and a ship detection method based on the YOLOv8 algorithm. Background Art
[0002] Synthetic Aperture Radar (SAR image) is a remote sensing image that uses a radar system to transmit and receive electromagnetic wave signals to obtain surface information.
[0003] In the development of marine resources, fishery management and maritime traffic management, in order to prevent and reduce maritime traffic accidents, it is necessary to monitor, dispatch and warn ships sailing at sea.
[0004] SAR images have the characteristics of all-weather and high resolution, so they are also widely used in the field of maritime traffic management.
[0005] As deep neural networks become more mature in the field of image processing, the recognition of SAR images of ships through pre-trained deep neural networks can effectively manage maritime traffic through recognition results. Among them, the YOLOv8 model is currently the most advanced image target detection model. Its integration into the ship detection system can automatically and quickly detect and identify ships.
[0006] There are two main methods for image target detection: two-step method and one-step method, which are used to extract features and identify the detected targets.
[0007] The Region-CNN algorithm and the YOLOv8 algorithm are target detection algorithms based on CNN networks that use a two-step method and a one-step method respectively.
[0008] Among them, the Region-CNN algorithm first divides the image into grids and then detects the target in the grid. This two-step method has high detection accuracy but slow detection speed.
[0009] The YOLOv8 algorithm combines feature extraction and target recognition into one step, which improves the detection speed but reduces the detection accuracy.
[0010] In maritime traffic management, due to the real-time movement of ships, higher detection speed is required for ships. Therefore, the YOLOv8 algorithm is more widely used in ship monitoring systems.
[0011] Because of the one-step method, the YOLOv8 algorithm is not as accurate as the Region-CNN algorithm in detecting ships with huge size and contour differences. For example, the size difference or contour difference between a 100,000-ton cruise ship and a 100-ton fishing boat, or a submarine and an ordinary ship in SAR images will cause the YOLOv8 algorithm to be unable to effectively classify the two.
[0012] In order to improve the detection accuracy of different ships in SAR images by the ship monitoring system based on the existing YOLOv8 algorithm, this application provides a ship detection method and a ship detection model training method based on the YOLOv8 algorithm. Summary of the invention
[0013] In order to overcome the problems existing in the related art, the first aspect of the present application provides a ship detection model training method based on the YOLOv8 algorithm, comprising:
[0014] S1. Acquire a ship remote sensing image dataset, and divide the ship remote sensing image dataset into a ship remote sensing image training set and a ship remote sensing image test set;
[0015] S2. Building a ship detection model based on the YOLOv8 algorithm; the ship detection model integrates a variability convolution module and a coordinate attention mechanism;
[0016] S3, setting a Neck layer in the ship detection model;
[0017] S4. Define a target box loss function. The target box loss function formula is:
[0018]
[0019] Among them, L Inner-PIoUv2 is the target box loss function, L Inner-PIoU It is a fusion of the PIoU loss function and the nner-IoU loss function; λ is a single hyperparameter; q is a penalty factor, defined as q = e -P , q∈(0,1], P is the distance between the anchor box and the target box;
[0020] S5. Training the ship detection model.
[0021] In one implementation, the target box loss function is composed of a PIoU loss function and an Inner-IoU loss function, specifically including:
[0022] The fusion formula of the PIoU loss function and the Inner-IoU loss function is:
[0023]
[0024] L Inner-IoU =1-IoU inner
[0025] L Inner-PIoU ∈[0,2]
[0026] Among them, IoU inner is the IoU loss function, and P is the distance between the anchor box and the target box.
[0027] In one implementation, the distance between the anchor box and the target box is calculated as follows:
[0028]
[0029] Among them, dw1 and dw2 are the absolute values of the distances between the two wide sides of the anchor box and the two wide sides of the target box, dh1 and dh2 are the absolute values of the distances between the two high sides of the anchor box and the two high sides of the target box, and W gt is the width of the target box, h gt The height of the target box.
[0030] In one implementation, the IoU loss function formula is:
[0031]
[0032] Among them, inter is the overlapping area of the anchor box and the target box, and union is the area of the union of the anchor box and the target box. The calculation formula is:
[0033]
[0034] union=(w gt *h gt )*(ratio) 2 +(w*h)*(ratio) 2 -inter
[0035] in, and Indicates the horizontal coordinates of the left and right borders of the target box. and Indicates the vertical coordinates of the upper and lower borders of the target box, b l and b r Indicates the horizontal coordinates of the left and right borders of the anchor box, b t and b b Indicates the vertical coordinates of the top and bottom borders of the anchor box.
[0036] In one embodiment, λ∈[0.5, 1.5].
[0037] In one embodiment, after acquiring the ship remote sensing image dataset, the method further includes:
[0038] The input image size of the ship remote sensing image dataset is converted into a preset pixel size.
[0039] In one embodiment, after training the ship detection model, the method further includes:
[0040] The model performance is evaluated based on the classification accuracy and classification recall of the ship detection model.
[0041] The second aspect of the present application provides a ship detection method based on the YOLOv8 algorithm, comprising:
[0042] Acquire remote sensing images of ships;
[0043] Preprocessing the ship remote sensing image;
[0044] The ship target in the ship remote sensing image is detected by using a pre-trained ship detection model.
[0045] The technical solution provided by this application may have the following beneficial effects:
[0046] This application improves the target box loss function of the ship detection model by integrating the PIoU loss function and the Inner-IoU loss function. The new target box loss function L Inner-PIoUv2 It can optimize the edge alignment of the predicted bounding box, and at the same time, correct the generation of the predicted bounding box through the auxiliary bounding box and the scale factor. The target box loss function redefined in this application can quickly and accurately calculate the distance between the predicted bounding box and the real bounding box in the training of the ship detection model. On the one hand, it can enhance the detection ability of medium-quality anchor points; on the other hand, it can also apply auxiliary bounding boxes of different sizes to adapt to different ship data sets for training.
[0047] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The above and other objects, features and advantages of the present application will become more apparent through a more detailed description of exemplary embodiments of the present application in conjunction with the accompanying drawings, wherein the same reference numerals generally represent the same components in the exemplary embodiments of the present application.
[0049] Figure 1 A schematic diagram of the process of the ship detection model training method shown in the embodiment of the present application;
[0050] Figure 2Another schematic diagram of the process of the ship detection model training method shown in the embodiment of the present application;
[0051] Figure 3 This is a comparison diagram of the F1 score curve and the PR curve of the ship detection model shown in the embodiment of the present application;
[0052] Figure 4 A comparison diagram of the predicted structure of the ship detection model shown in the embodiment of the present application;
[0053] Figure 5 A schematic diagram of the network structure of a ship detection model shown in an embodiment of the present application. DETAILED DESCRIPTION
[0054] The preferred embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the preferred embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided to make the present application more thorough and complete, and to fully convey the scope of the present application to those skilled in the art.
[0055] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0056] It should be understood that although the terms "first", "second", "third", etc. may be used in this application to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0057] Embodiment 1
[0058] In order to improve the detection accuracy of different ships in SAR images by a ship monitoring system based on the existing YOLOv8 algorithm, the present application provides a ship detection method and a ship detection model training method based on the YOLOv8 algorithm, comprising the following steps:
[0059] S1. Acquire a ship remote sensing image dataset, and divide the ship remote sensing image dataset into a ship remote sensing image training set and a ship remote sensing image test set;
[0060] S2. Building a ship detection model based on the YOLOv8 algorithm; the ship detection model integrates a variability convolution module and a coordinate attention mechanism;
[0061] S3, setting a Neck layer in the ship detection model;
[0062] In the YOLOv8 algorithm, the YOLOv8 algorithm directly predicts multiple bounding boxes for the ship remote sensing image at the same time, and divides and detects the ship through the predicted bounding boxes. Based on the characteristics of the YOLOv8 algorithm, the closer the predicted bounding box is to the real bounding box, the more accurate the target detection is. Therefore, in the YOLOv8 algorithm and other algorithms based on YOLO, defining the target box loss function directly determines the accuracy of the predicted bounding box.
[0063] S4. Define the target box loss function;
[0064] In the embodiment of the present application, based on the existing PIoU loss function and Inner-IoU loss function, a target box loss function is defined for the model trained in the embodiment of the present application.
[0065] The target box loss function formula is:
[0066]
[0067] Among them, L Inner-PIoUv2 is the target box loss function, L Inner-PIoU It is a fusion of the PIoU loss function and the Inner-IoU loss function; λ is a single hyperparameter that controls the non-monotonic attention mechanism; q is the penalty parameter of the target box.
[0068] The PIoU loss function (i.e. Powerful Intersection over Union) is a variant of the IoU loss function (i.e. Intersection over Union). The PIoU loss function takes into account the position, size, and shape of the bounding box, introduces a penalty term that considers the size of the target box, and a mechanism to adjust the gradient based on the quality of the anchor box, effectively optimizing the edge alignment of the anchor box, thereby improving the accuracy of the model's predicted box.
[0069] The PIoU loss function not only speeds up the alignment of the anchor box to the target box, but also is faster and more effective in improving the performance of the target detection model compared to the traditional IoU-based loss function.
[0070] The Inner-IoU loss function is another variant of the IoU loss function (i.e. Intersection over Union). The Inner-IoU loss function introduces variables of auxiliary bounding boxes and scale factors into the formula. By adjusting the size of the auxiliary bounding box through the scale factor, it can effectively solve the problem of insufficient generalization ability and slow convergence speed of the IoU loss function in different object detection tasks.
[0071] The embodiment of the present application improves the target box loss function of the ship detection model in the embodiment of the present application by integrating the PIoU loss function and the Inner-IoU loss function. The new target box loss function L Inner-PIoUv2 It can optimize the edge alignment of the predicted bounding box, and at the same time, correct the generation of the predicted bounding box through auxiliary bounding boxes and scale factors.
[0072] The target box loss function redefined in the embodiment of the present application can quickly and accurately calculate the distance between the predicted bounding box and the real bounding box in the training of the ship detection model. On the one hand, it can enhance the detection capability of medium-quality anchor points; on the other hand, it can also apply auxiliary bounding boxes of different sizes to adapt to different ship data sets for training.
[0073] S5. Training the ship detection model.
[0074] Embodiment 2
[0075] Based on the first embodiment of the present application, in order to clearly illustrate the structure of each layer of the ship detection model and the definition principle of the target box loss function, the embodiment of the present application provides a ship detection model training method based on the YOLOv8 algorithm, such as Figure 1 As shown, the following steps are included:
[0076] S201, obtaining a ship remote sensing image dataset, and dividing the ship remote sensing image dataset into a ship remote sensing image training set and a ship remote sensing image test set;
[0077] Specifically, the model training in the embodiment of the present application uses two public ship SAR image datasets, namely the SSDD dataset and the RSDD-SAR dataset.
[0078] Among them, the SSDD dataset contains 1,160 SAR images and 2,456 ship targets, with multi-mode and multi-resolution characteristics, suitable for testing model robustness. The RSDD-SAR dataset contains 7,000 512*512 images, covering HH and HV polarization modes, with a resolution of 2 to 20 meters, including 10,263 ship instances and 6,146 small targets accounting for 59.88%.
[0079] At the same time, the RSDD-SAR dataset is a slant frame detection dataset, which can verify the generalization ability of the model. In SAR images, ships are not necessarily arranged in a vertical or horizontal direction. In fact, due to the different directions of ships traveling or mooring, the images of ships will have rotation angles.
[0080] Therefore, training with the RSDD-SAR dataset can improve the model's ability to detect ships at different rotation angles.
[0081] Furthermore, since the label format of the SSDD dataset and the RSDD-SAR dataset is VOC XML, which is incompatible with the YOLO format, step S202 needs to be performed.
[0082] S202, converting the label format of the ships in the data set into the label format corresponding to the YOLOv8 algorithm;
[0083] The ship label format records the location, size, and attributes of the target in the image.
[0084] S203, constructing a ship detection model based on the YOLOv8 algorithm; the ship detection model integrates a variability convolution module and a coordinate attention mechanism;
[0085] S204, setting a Neck layer in the ship detection model;
[0086] In the application of visual deep learning, the backbone network of the YOLOv8 network is responsible for extracting features from the input image and converting the image into a feature representation with rich semantic information. The neck is an intermediate layer used to fuse features from the backbone network to improve the performance of the model. The task head is the last layer of the model, and its structure varies depending on the task.
[0087] For example, in the ship detection model of the present application, the task head includes a bounding box regressor and a classifier, which are used to select and classify each ship in the SAR image.
[0088] Further, such as Figure 5 As shown, the embodiment of the present application is based on the YOLOv8 network structure, and the neck (ie, Neck) between the backbone network (ie, backbone) and the task head (ie, head) is structurally improved.
[0089] like Figure 5 As shown, the input of the neck is the 2nd, 4th, 6th, 8th and 9th layers of the backbone network; the 26th, 27th, 28th, 29th and 30th layers of the neck are connected to the task head.
[0090] Compared with the original YOLOv8 network, this application adds a connection to the neck in the second layer of the backbone network. Because in the output of the second layer of the backbone network, the number of feature map convolutions is small, the feature map size of the second layer is large, and more information about small-sized ship targets is retained. Outputting the second layer of the backbone network to the neck can reduce the number of parameters while improving the accuracy of small target ships. The mAP is improved while the number of parameters is reduced by nearly 1 / 6.
[0091] Further, if Figure 5 As shown, the C2f-DCNv2-Dynamic module is added to the backbone network and the neck for feature extraction. Specifically, the module is set in the 4th and 8th layers of the backbone network and the 20th layer of the neck.
[0092] In the embodiment of the present application, the C2f-DCNv2-Dynamic module integrates the DCNv2 (Deformable convnetsv2) and CA (Coordinate Attention) attention mechanisms, which can better fit ships of various shapes, integrate the position information in the feature map into the channel attention, and improve the detection performance.
[0093] S205, define a target frame loss function; the target frame loss function formula is:
[0094]
[0095] Among them, L Inner-PIoUv2 is the target box loss function, L Inner-PIoU It is a fusion of the PIoU loss function and the nner-IoU loss function; λ is a single hyperparameter that controls the non-monotonic attention mechanism; q is the penalty parameter of the target box.
[0096] Specifically, as shown in the target frame loss function formula in step S4, the target frame loss function L in the embodiment of the present application is Inner-PIoUv2 According to L Inner-PIoU Calculated, and L Innwr-PIou According to L Inner-IoU Loss Function and L PIoU The loss function is integrated to obtain L Inner-IoU Loss Function and L PIoU The loss function is calculated using the traditional IoU algorithm.
[0097] Furthermore, the target box loss function L in step S205 Inner-PIoUv2 The steps for deriving the formula are as follows:
[0098] S301: Based on the PIoU algorithm, determine L PIoU The calculation formula is as follows:
[0099]
[0100] 0≤L PIoU ≤2
[0101] S302: Determine L according to the Inner-IoU algorithm Inner-IoU The calculation formula is:
[0102] L Inner-IoU =1-IoU inner
[0103] Among them, L Inner-IoU The calculation formulas for each item are as follows.
[0104]
[0105] union=(w gt *h gt )*(ratio) 2 +(w*h)*(ratio) 2 -inter
[0106] Specifically, in the IOU loss function, inter is the overlapping area of the anchor box and the target box, and union is the area of the union of the anchor box and the target box.
[0107] in, and Indicates the horizontal coordinates of the left and right borders of the target box. and Indicates the vertical coordinates of the upper and lower borders of the target box, b l and b r Indicates the horizontal coordinates of the left and right borders of the anchor box, b t and b b Represents the vertical coordinates of the upper and lower borders of the anchor box. ratio is a variable representing a proportional factor, and its value range is usually between 0.5 and 1.5.
[0108] In the present embodiment, (x c ,y c ) is the coordinate of the center point of the anchor box, and the vertex of the upper left corner of the target box is used as the origin of the coordinate system. The formula for calculating the coordinates of the target box and the anchor box is:
[0109]
[0110] According to L Inner-IoU The calculation formula and L PIoU The calculation formula to determine L Inner-PIoU The calculation formula is as follows:
[0111]
[0112] Among them, L Inner-PIoU The calculation formulas are:
[0113]
[0114] Specifically, dw1 and dw2 are the absolute values of the distances between the two wide sides of the anchor box and the two wide sides of the target box, dh1 and dh2 are the absolute values of the distances between the two high sides of the anchor box and the two high sides of the target box, and W gt is the width of the target box, h gt The height of the target box.
[0115] S304: According to L Inner-PIoU The calculation formula determines the target box loss function L Inner-PIoUv2 .
[0116] Specifically, when determining L Inner-PIoU Finally, the PIoUv2 algorithm in the embodiment of the present application is based on the PIoU algorithm and enhances the detection capability of medium-quality anchor points by introducing a single hyperparameter λ that controls the non-monotonic attention mechanism, thereby improving the target detection performance.
[0117] The specific calculation formula is:
[0118]
[0119] For example, the single hyperparameter λ is set to 1.1, and the parameter q = e -P2 , where q∈(0,1].
[0120] S206: Training the ship detection model.
[0121] In the embodiment of the present application, the training parameters of the ship detection model are defined as shown in Table 4.
[0122]
[0123] Table 4 After completing the model training, the training results of the ship detection model described in the embodiment of the present application are shown in Tables 1, 2 and 3.
[0124] Among them, Table 1 is the ablation experiment results of the SSDD dataset, Table 2 is the ablation experiment results of the RSDD-SAR dataset, and Table 3 is the test results of the model.
[0125]
[0126] Table 1
[0127]
[0128] Table 2
[0129]
[0130]
[0131] Table 3
[0132] In Table 1, Table 2 and Table 3, the definitions of each evaluation index are:
[0133] (1) Params: This metric represents the number of parameters, reflecting the total number of all trainable parameters in the model, including the weights and biases of the convolutional layers. This metric is directly related to the model's storage size, computing requirements, resource consumption, generalization effect, overfitting risk, and deployment complexity. An increase in the number of parameters may improve model performance, but it will also increase computing costs and deployment difficulty, especially in resource-constrained environments.
[0134] (2) P index (precision): indicates the classification accuracy, and the calculation formula is:
[0135]
[0136] (3) R index (i.e., Recall rate): the ratio of the number of correctly classified positive examples to the number of all positive examples, that is, the ratio of the number of positive examples correctly classified by the classifier to the number of all positive examples.
[0137]
[0138] (4) Map index (i.e. Average Precision): represents the average precision of all queries, and the calculation formula is:
[0139]
[0140] In the above formula, TP represents true positive examples, that is, the number of positive examples correctly classified; TN represents true negative examples, that is, the number of negative examples correctly classified; FP represents false positive examples, that is, the number of negative examples mistakenly classified as positive examples; FN represents false negative examples, that is, the number of positive examples mistakenly classified as negative examples; AP is the area under the curve of recall and precision; Q is the total number of queries, and AP(q) is the average precision of the qth query.
[0141] Among them, DCNv2-Dynamic in the table is the backbone of C2f-DCNv2-Dynamic improvement, that is, the second layer and the fourth layer of the model of this application. ASF-P2 is the neck.
[0142] It should be distinguished that the detection head of the network structure of the RSDD-SAR dataset uses the OBB detection head of the YOLOv8 network, and the rest are consistent with the network of the SSDD dataset.
[0143] It can be seen from AI in Table 1 and AI in Table 2 that the mAP50 of the C2f-DCNv2-Dynamic module is improved by 0.2% on the SSDD dataset and by 0.1% on the RSDD-SAR dataset.
[0144] S207. Evaluate model performance according to the classification accuracy and classification recall rate of the ship detection model.
[0145] like Figure 3 As shown, the F1 scores of the ship detection model under different thresholds are fitted through the indicators in Tables 1, 2 and 3.
[0146] The calculation formula of F1 score is:
[0147]
[0148] In the embodiment of the present application, by changing the classification threshold, different combinations of precision and recall can be obtained, thereby calculating the corresponding F1 score. The F1 curve can help us find the best classification threshold to maximize the F1 score.
[0149] from Figure 3 It can be seen that in the model verification step, whether it is the SSDD dataset or the RSDD-SAR dataset, the highest point of the F1 curve of the ship detection model in the embodiment of the present application is higher than the curve of the YOLOv8 network, showing better performance.
[0150] It can be clearly seen from the PR curve that the ship detection model of the embodiment of the present application can completely cover the original YOLOv8n network curve and has a higher mAP.
[0151] Embodiment 3
[0152] Based on the first embodiment, the present application embodiment provides a ship detection method based on the YOLOv8 algorithm, including:
[0153] S401, acquiring remote sensing images of ships;
[0154] S402, preprocessing the ship remote sensing image;
[0155] S403: Detect the ship target in the ship remote sensing image using a pre-trained ship detection model.
[0156] Figure 4 It is a comparison chart of the detection results of the ship detection model shown in the embodiment of the present application.
[0157] Depend on Figure 4 It can be seen that there are 3x3 SAR images distributed from top to bottom. Columns (a) and (b) are SAR images near the coast, and column (c) is a SAR image of the open sea. The ours row is the output of the ship detection model shown in the embodiment of the present application, the YOLOv8n row is the output of the original network model compared with the present application, and the true value row is the labeled SAR image.
[0158] Depend on Figure 4 It can be seen that in the near-coast image, the original YOLOv8 network has a false detection, detecting the coast as a ship, and the model shown in the embodiment of the present application can greatly suppress this situation. In the offshore image, although there is no missed detection or false detection, the model of the embodiment of the present application has a higher IOU loss function value than the original network, which means higher accuracy.
[0159] Therefore, it can be seen that the model of the embodiment of the present application can avoid false detection in complex environments and improve accuracy in simple environments.
[0160] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated again here.
[0161] The embodiments of the present application have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A ship detection model training method based on the YOLOv8 algorithm, characterized in that: include: S1. Acquire a ship remote sensing image dataset, and divide the ship remote sensing image dataset into a ship remote sensing image training set and a ship remote sensing image test set; S2. Building a ship detection model based on the YOLOv8 algorithm; the ship detection model integrates a variability convolution module and a coordinate attention mechanism; S3, setting a Neck layer in the ship detection model; S4. Define a target box loss function. The target box loss function formula is: Among them, L Inner-PIoUv2 is the target box loss function, L Inner-PIoU It is a fusion of the PIoU loss function and the nner-IoU loss function; λ is a single hyperparameter; q is a penalty factor, defined as q = e -P , q∈(0,1], P is the distance between the anchor box and the target box; S5. Training the ship detection model.
2. According to a ship detection model training method based on the YOLOv8 algorithm according to claim 1, it is characterized in that: The target box loss function is composed of the PIoU loss function and the Inner-IoU loss function, specifically including: The fusion formula of the PIoU loss function and the Inner-IoU loss function is: L Inner-IoU =1-IoU inner L Inner-PIoU ∈[0,2] Among them, IoU inner is the IoU loss function, and P is the distance between the anchor box and the target box.
3. According to a ship detection model training method based on the YOLOv8 algorithm according to claim 2, it is characterized in that: The calculation formula of the distance between the anchor box and the target box is: Among them, dw1 and dw2 are the absolute values of the distances between the two wide sides of the anchor box and the two wide sides of the target box, dh1 and dh2 are the absolute values of the distances between the two high sides of the anchor box and the two high sides of the target box, and W gt is the width of the target box, h gt The height of the target box.
4. According to a ship detection model training method based on the YOLOv8 algorithm according to claim 2, it is characterized in that: The IoU loss function formula is: Among them, inter is the overlapping area of the anchor box and the target box, and union is the area of the union of the anchor box and the target box. The calculation formula is: union=(w gt *h gt )*(ratio) 2 +(w*h)*(ratio) 2 -inter in, and Indicates the horizontal coordinates of the left and right borders of the target box. and Indicates the vertical coordinates of the upper and lower borders of the target box, b I and b r Indicates the horizontal coordinates of the left and right borders of the anchor box, b t and b b Indicates the vertical coordinates of the upper and lower borders of the anchor box.
5. The ship detection model training method based on the YOLOv8 algorithm according to claim 1 is characterized in that: λ∈[0.5,1.5].
6. The ship detection model training method based on the YOLOv8 algorithm according to claim 1 is characterized in that: After obtaining the ship remote sensing image dataset, the method further includes: The input image size of the ship remote sensing image dataset is converted into a preset pixel size.
7. The ship detection model training method based on the YOLOv8 algorithm according to claim 1 is characterized in that: After training the ship detection model, the method further includes: The model performance is evaluated based on the classification accuracy and classification recall of the ship detection model.
8. A ship detection method based on the YOLOv8 algorithm, characterized in that: include: Acquire remote sensing images of ships; Preprocessing the ship remote sensing image; The ship target in the ship remote sensing image is detected by using a pre-trained ship detection model.
Citation Information
Patent Citations
Marine ship target identification method based on SAR image and YOLOv5s network
CN116994151A
Improved YOLOv8-based SAR image ship target detection method, medium and device
CN117689870A
High body seriola quinqueradiata detection method based on YOLOv8 network structure
CN118279935A
YOLOv8-based optical remote sensing image ship detection method and device
CN118608758A
Training method and training apparatus for rotating-ship target detection model, and storage medium
WO2023116631A1