Ship detection model training method and ship detection method based on YOLOv8 algorithm
By fusing PIOU and Inner-IoU loss functions into the YOLOv8 algorithm, and combining variable convolution modules and coordinate attention mechanisms, the target box loss function is optimized, solving the problem of low accuracy of the YOLOv8 algorithm in ship detection, and achieving efficient detection of ships of different sizes and angles.
Patent Information
- Application Number
- CN202411381305.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2044-09-29
AI Technical Summary
The existing YOLOv8 algorithm has the problem of low detection accuracy in ship detection, especially when it is difficult to effectively classify ships with huge differences in size and outline.
By fusing the PIOU and Inner-IoU loss functions, the target box loss function LInner-PIoUv2 is redefined. A variable convolution module and coordinate attention mechanism are introduced into the ship detection model to optimize the edge alignment of the predicted bounding boxes and adapt to ship datasets of different sizes.
It improves the accuracy and speed of ship detection, enhances the detection capability of medium-mass anchor points, adapts to ship targets of different sizes and rotation angles, and improves the detection accuracy and generalization ability of the model.
Smart Images

Figure CN119360320B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of deep learning, in particular to a ship detection model training method and a ship detection method based on a YOLOv8 algorithm. BACKGROUND
[0002] A synthetic aperture radar image (i.e., SAR image) is a remote sensing image obtained by using a radar system to emit and receive electromagnetic wave signals to obtain ground 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 the ships sailing on the sea.
[0004] Since SAR images have the characteristics of all-weather and high resolution, SAR images are also widely used in maritime traffic management.
[0005] With the development of deep neural networks in the field of image processing becoming more and more mature, the SAR images of ships can be recognized by using a pre-trained deep neural network, which can effectively manage maritime traffic through the recognition results. Among them, the YOLOv8 model is the most advanced image target detection model at present, which can automatically and quickly detect and recognize ships when integrated into a ship detection system.
[0006] In the image target detection method, there are mainly two-step method and one-step method to extract features and recognize targets.
[0007] Region-CNN algorithm and YOLOv8 algorithm are CNN network-based target detection algorithms using two-step method and one-step method respectively.
[0008] Among them, the Region-CNN algorithm first divides the image grid and then detects the target in the grid in the image target detection, which has high detection accuracy but slow detection speed.
[0009] The YOLOv8 algorithm combines feature extraction and target detection 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, the detection speed of ships is required to be higher, and therefore the YOLOv8 algorithm is more widely used in ship monitoring systems.
[0011] Also because of the reason of adopting one-step method, the detection accuracy of the YOLOv8 algorithm between ships with huge size and contour differences is not as good as that of the Region-CNN algorithm. For example, the size difference or contour difference between a 100,000-ton cruise ship and a 100-ton fishing boat, or between a submarine and an ordinary ship, will cause the YOLOv8 algorithm to fail to effectively classify the two.
[0012] In order to improve the detection accuracy of different ships in SAR images of the ship monitoring system based on the existing YOLOv8 algorithm, the application provides a ship detection method based on the YOLOv8 algorithm and a ship detection model training method SUMMARY
[0013] To overcome the problems in the related art, the first aspect of the application provides a ship detection model training method based on the YOLOv8 algorithm, comprising:
[0014] S1, acquiring 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;
[0015] S2, constructing 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, defining a target frame loss function; the formula of the target frame loss function is:
[0018]
[0019] Wherein, L Inner-PIoUv2 is the target frame loss function, L Inner-PIoU is the 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 frame and the target frame;
[0020] S5, training the ship detection model.
[0021] In an embodiment, the target frame loss function is composed of a PIoU loss function and an Inner-IoU loss function, specifically comprising:
[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] wherein, IoU inner is the IoU loss function, and P is the distance between the anchor box and the target box.
[0027] In an embodiment, the distance between the anchor box and the target box is calculated by the following formula:
[0028]
[0029] wherein, dw1 and dw2 are the absolute values of the distance 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 distance between the two high sides of the anchor box and the two high sides of the target box, W gt is the width of the target box, and h gt is the height of the target box.
[0030] In an embodiment, the IoU loss function is calculated by the following formula:
[0031]
[0032] wherein, inter is the area of the overlapping region of the anchor box and the target box, and union is the area of the union set of the anchor box and the target box, which is calculated by the following formula:
[0033]
[0034] union = (w gt *h gt ) * (ratio) 2 + (w * h) * (ratio) 2 -inter
[0035] wherein, and are the horizontal coordinates of the left and right edges of the target box, and are the vertical coordinates of the top and bottom edges of the target box, b l and b r are the horizontal coordinates of the left and right edges of the anchor box, b t and b b are the vertical coordinates of the top and bottom edges of the anchor box.
[0036] In an embodiment, λ ∈ [0.5, 1.5].
[0037] In an implementation, after the ship remote sensing image dataset is acquired, the method further includes:
[0038] Converting an input image size of the ship remote sensing image dataset to a preset pixel size.
[0039] In an implementation, after the ship detection model is trained, the method further includes:
[0040] Evaluating model performance according to a classification precision and a classification recall rate of the ship detection model.
[0041] The second aspect of the application provides a ship detection method based on a YOLOv8 algorithm, including:
[0042] Acquiring a ship remote sensing image;
[0043] Preprocessing the ship remote sensing image;
[0044] Detecting a ship target of the ship remote sensing image by a pre-trained ship detection model.
[0045] The technical solution provided by the application can include the following beneficial effects:
[0046] The application re-improves the target frame loss function of the ship detection model by fusing a PIoU loss function and an Inner-IoU loss function, and a new target frame loss function L Inner-PIoUv2 The edge alignment of the predicted bounding box can be optimized, and the generation of the predicted bounding box can be corrected by the auxiliary bounding box and the scale factor. The re-defined target frame loss function 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, which can enhance the detection capability of the medium-quality anchor point on the one hand, and can also apply auxiliary bounding boxes of different sizes to adapt to different ship datasets for training.
[0047] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the application. BRIEF DESCRIPTION OF DRAWINGS
[0048] The above and other objects, features and advantages of the present application will become more apparent from the following detailed description when taken in conjunction with the accompanying drawings, in which like reference characters refer to like parts throughout the several views, and in which:
[0049] Figure 1 A flowchart of a ship detection model training method shown in the embodiments of the application;
[0050] Figure 2Another flowchart of a ship detection model training method shown in an embodiment of the present application;
[0051] Figure 3 An F1 score curve and a PR curve comparison diagram of a ship detection model shown in an embodiment of the present application;
[0052] Figure 4 A prediction structure comparison diagram of a ship detection model shown in an embodiment of the present application;
[0053] Figure 5 A network structure diagram 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 detail below with reference to the accompanying drawings. Although the preferred embodiments of the present application are shown in the 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 the present application are merely for the purpose of describing specific embodiments and are not intended to limit the present application. The singular forms "a", "an" and "the" used in the present application and the appended claims are also intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein means 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" and the like can be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information without departing from the scope of the present application. Therefore, the features defined with "first", "second" can explicitly or implicitly include one or more of the features. In the description of the present application, the meaning of "a plurality of" is two or more, unless otherwise specifically limited.
[0057] Embodiment one
[0058] In order to improve the detection accuracy of different ships in SAR images of the ship monitoring system on the basis of the existing YOLOv8 algorithm, the present application provides a ship detection method and a ship detection model training method based on the YOLOv8 algorithm, which includes the following steps:
[0059] S1, obtain 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, construct a ship detection model based on a YOLOv8 algorithm; the ship detection model integrates a variability convolution module and a coordinate attention mechanism;
[0061] S3, set a Neck layer in the ship detection model;
[0062] In the YOLOv8 algorithm, the YOLOv8 algorithm directly predicts multiple boundary boxes for the ship remote sensing image at the same time, divides and detects the ship through the predicted boundary box. Based on the characteristics of the YOLOv8 algorithm, the closer the predicted boundary box is to the real boundary box, the more accurate the target detection is. Therefore, in the YOLOv8 algorithm and other algorithms based on YOLO, defining a target box loss function directly determines the accuracy of the predicted boundary box.
[0063] S4, define a target box loss function;
[0064] In the embodiment of the application, based on the existing PIoU loss function and Inner-IoU loss function, the target box loss function of the model trained in the embodiment of the application is defined.
[0065] The formula of the target box loss function is:
[0066]
[0067] Wherein, L Inner-PIoUv2 is the target box loss function, L Inner-PIoU is a fusion of the PIoU loss function and the Inner-IoU loss function; λ is a single hyperparameter for controlling the non-monotonic attention mechanism; q is a penalty term parameter of the target box.
[0068] The PIoU loss function (Powerful Intersection over Union) is a variant of the IoU loss function (Intersection over Union). The PIoU loss function considers the position, size and shape of the boundary box, introduces a penalty term considering the size of the target box and a mechanism adjusting the gradient based on the quality of the anchor box, effectively optimizes the edge alignment of the anchor box, and thus improves the accuracy of the predicted box of the model.
[0069] The PIoU loss function not only speeds up the alignment of the anchor box to the target box, but also is more rapid and effective in improving the performance of the target detection model compared with 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 an auxiliary bounding box and a scale factor in the formula, and adjusts the size of the auxiliary bounding box through the scale factor, which can effectively solve the problems of insufficient generalization ability and slow convergence speed of the IoU loss function in different target detection tasks.
[0071] The embodiments of the present application fuse the PIoU loss function and the Inner-IoU loss function, and improve the target box loss function of the ship detection model of the embodiments of the present application. The new target box loss function L Inner-PIoUv2 The edge alignment of the predicted bounding box can be optimized, and the generation of the predicted bounding box can be corrected through the auxiliary bounding box and the scale factor.
[0072] The redefined target box loss function of the embodiments 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, which can enhance the detection ability of the medium-quality anchor point on one hand, and 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 two
[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 embodiments of the present application provide a ship detection model training method based on the YOLOv8 algorithm on the other hand, as shown in Figure 1 The method comprises the following steps:
[0076] S201, acquiring a ship remote sensing image data set, and dividing the ship remote sensing image data set into a ship remote sensing image training set and a ship remote sensing image test set;
[0077] Specifically, the model training of the embodiments of the present application uses two public ship SAR image data sets, which are the SSDD data set and the RSDD-SAR data set.
[0078] The SSDD data set contains 1160 SAR images and 2456 ship targets, has multi-mode and multi-resolution characteristics, and is suitable for testing the robustness of the model. The RSDD-SAR data set contains 7000 images of 512*512 size, covers two polarization modes of HH and HV, has a resolution of 2-20 m, contains 10263 ship instances and 6146 small targets with a proportion of 59.88%.
[0079] Meanwhile, the RSDD-SAR dataset is a slanted box detection dataset, which can verify the generalization ability of the model. Because in the SAR image, the ships may not be arranged along the vertical or horizontal direction, in fact, the ship image will have a rotation angle because of the different directions of the ship sailing or parking.
[0080] Therefore, training through the RSDD-SAR dataset can improve the detection ability of the model for ships with different rotation angles.
[0081] Further, 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 dataset to the label format corresponding to the YOLOv8 algorithm;
[0083] The label format of the ships records the position, size, and attributes of the target in the image, etc.
[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 is responsible for extracting features from the input image, converting the image into a feature representation with rich semantic information. The neck is an intermediate layer that fuses 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 will vary depending on different tasks.
[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 frame and classify each ship in the SAR image.
[0088] Further, as shown in Figure 5 The present application improves the structure of the neck (i.e., Neck) between the backbone network (i.e., backbone) and the task head (i.e., head) based on the YOLOv8 network structure.
[0089] As shown in Figure 5 The input of the neck is the 2nd layer, the 4th layer, the 6th layer, the 8th layer, and the 9th layer of the backbone network; the 26th layer, the 27th layer, the 28th layer, the 29th layer, and the 30th layer of the neck are connected to the task head.
[0090] Compared with the original YOLOv8 network, the application adds a connection with the neck in the second layer of the backbone network. Because the feature map in the output of the second layer of the backbone network has fewer convolution times and larger feature map size, more information of small ship targets is retained. The output of the second layer of the backbone network to the neck can reduce the parameter amount while improving the accuracy of small ship targets, and the mAP is improved while the parameter amount is reduced by nearly 1 / 6.
[0091] Further, as shown in Figure 5 , a C2f-DCNv2-Dynamic module is added in the backbone network and the neck for feature extraction. Specifically, the module is arranged in the fourth layer and the eighth layer of the backbone network and the twentieth layer of the neck.
[0092] In the embodiment of the application, the C2f-DCNv2-Dynamic module integrates the DCNv2 (Deformable convnetsv2) and the CA (Coordinate Attention) attention mechanism, which can better fit the ship with various shapes, integrate the position information in the feature map into the channel attention, and improve the detection performance.
[0093] In step S205, a target frame loss function is defined. The formula of the target frame loss function is:
[0094]
[0095] Wherein, L Inner-PIoUv2 is the target frame loss function, L Inner-PIoU is the fusion of the PIoU loss function and the nner-IoU loss function; λ is a single hyperparameter for controlling the non-monotonic attention mechanism; q is a penalty item parameter of the target frame.
[0096] Specifically, as shown in the formula of the target frame loss function in step S4, the target frame loss function L Inner-PIoUv2 in the embodiment of the application is calculated according to L Inner-PIoU , and L Innwr-PIou is calculated according to L Inner-IoU , L PIoU is the fusion of the loss function and the loss function, L Inner-IoU is the fusion of the loss function and the loss function, and L PIoU is calculated by the traditional IoU algorithm.
[0097] Further, the formula derivation steps of the target frame loss function L Inner-PIoUv2 in step S205 are as follows:
[0098] S301: On the basis of the PIoU algorithm, L PIoUThe calculation formula of L is as follows:
[0099]
[0100] 0≤L PIoU ≤2
[0101] S302: According to the Inner-IoU algorithm, L Inner-IoU The calculation formula of L is as follows:
[0102] L Inner-IoU =1-IoU inner
[0103] Wherein, L Inner-IoU The calculation of each item in the calculation formula of L is 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 frame and the target frame, and union is the area of the union of the anchor frame and the target frame.
[0107] Wherein, and represent the horizontal coordinates of the left and right frames of the target frame, and represent the vertical coordinates of the upper and lower frames of the target frame, b l and b r represent the horizontal coordinates of the left and right frames of the anchor frame, b t and b b represent the vertical coordinates of the upper and lower frames of the anchor frame, and ratio is a variable representing a proportion factor, which usually takes a value range of 0.5 to 1.5.
[0108] In the embodiments of the present application, (x c ,y c ) is the anchor frame center point coordinate, and the top vertex of the left upper corner of the target frame is taken as the coordinate system origin. The frame coordinate calculation formula of the target frame and the anchor frame is as follows:
[0109]
[0110] According to the calculation formula of L Inner-IoU and the calculation formula of L PIoU , L Inner-PIoUThe calculation formula of L
[0111]
[0112] wherein, L Inner-PIoU The calculation formula of each item is as follows:
[0113]
[0114] Specifically, dw1 and dw2 are the absolute values of the distance between the two wide sides of the anchor frame and the two wide sides of the target frame, dh1 and dh2 are the absolute values of the distance between the two high sides of the anchor frame and the two high sides of the target frame, W gt is the width of the target frame, and h gt is the height of the target frame.
[0115] S304: determining the target frame loss function L Inner-PIoU according to the calculation formula of L Inner-PIoUv2 .
[0116] Specifically, after determining L Inner-PIoU , the PIoUv2 algorithm in the embodiment of the present application enhances the detection ability of the medium quality anchor point on the basis of the PIoU algorithm by introducing a single hyperparameter λ that controls the non-monotonic attention mechanism, thereby improving the target detection performance.
[0117] The specific calculation formula is as follows:
[0118]
[0119] For example, the single hyperparameter λ takes a value of 1.1, and the parameter q = e -P2 , wherein 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] After completing the model training, the training results of the ship detection model according to the embodiment of the present application are shown in Table 1, Table 2 and Table 3.
[0124] Table 1 is the ablation experiment results of the SSDD data set, Table 2 is the ablation experiment results of the RSDD-SAR data set, 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 definition of each evaluation index is as follows:
[0133] (1) The Params index represents the number of parameters, reflecting the total number of all trainable parameters in the model, including the weights and biases of the convolutional layer. This index is directly related to the storage size, computational demand, resource consumption, generalization effect, overfitting risk and deployment complexity of the model. The increase in the number of parameters may improve the performance of the model, but at the same time, it will also increase the computational cost and deployment difficulty, especially in resource-constrained environments.
[0134] (2) The P index (i.e., precision) represents the classification accuracy, and the calculation formula is as follows:
[0135]
[0136] (3) The R index (i.e., Recall) represents the proportion of correctly classified positive examples to the total number of positive examples, i.e., the ratio of the number of positive examples correctly classified by the classifier to the total number of positive examples.
[0137]
[0138] (4) The Map index (i.e., Average Precision) represents the average precision of all queries, and the calculation formula is as follows:
[0139]
[0140] In the above formula, TP represents the true positive, i.e., the number of positive examples correctly classified; TN represents the true negative, i.e., the number of negative examples correctly classified; FP represents the false positive, i.e., the number of negative examples incorrectly classified as positive; FN represents the false negative, i.e., the number of positive examples incorrectly classified as negative; 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] In the table, DCNv2-Dynamic is the improved backbone of C2f-DCNv2-Dynamic, i.e., the 2nd layer and the 4th layer of the model of the present application. ASF-P2 is the neck.
[0142] It needs to 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 is consistent with the network of the SSDD dataset.
[0143] As can be seen from Table 1 AI and Table 2 AII, the mAP50 of the C2f-DCNv2-Dynamic module on the SSDD dataset is improved by 0.2%, and on the RSDD-SAR is improved by 0.1%.
[0144] S207, evaluate the model performance according to the classification accuracy and classification recall rate of the ship detection model.
[0145] As Figure 3 shown, the F1 score of the ship detection model under different thresholds is fitted by each index in Table 1, Table 2 and Table 3.
[0146] The calculation formula of the F1 score is:
[0147]
[0148] In the embodiments of the present application, by changing the classification threshold, different precision and recall rate combinations can be obtained, so as to calculate the corresponding F1 score. The F1 curve can help us find the best classification threshold, so that the F1 score is maximized.
[0149] From Figure 3 it can be seen that in the verification model step, whether it is the SSDD dataset or the RSDD-SAR dataset, the F1 curve of the ship detection model of the embodiments of the present application has a higher highest point than the curve of the YOLOv8 network, which shows better performance.
[0150] On the PR curve, it can be seen that the ship detection model of the embodiments of the present application can completely cover the original YOLOv8n network curve, and has a higher mAP.
[0151] Embodiment Three
[0152] Based on Embodiment One, the embodiments of the present application provide a ship detection method based on the YOLOv8 algorithm, comprising:
[0153] S401, acquiring a ship remote sensing image;
[0154] S402, preprocessing the ship remote sensing image;
[0155] S403, detecting the ship target of the ship remote sensing image by the pre-trained ship detection model.
[0156] Figure 4is a detection result comparison chart of a ship detection model shown in an embodiment of the present application.
[0157] By Figure 4 It can be seen that 3x3 SAR images are distributed from top to bottom. The (a) column and the (b) column are SAR images of the near shore, and the (c) column is a SAR image of the far 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 in the present application, and the true value row is the labeled SAR image.
[0158] By Figure 4 It can be seen that in the near shore image, the original YOLOv8 network has false detection, which detects the coast as a ship, while the model shown in the embodiment of the present application can greatly inhibit this situation. In the far sea image, although there is no false detection and false detection, the IOU loss function value of the model in the embodiment of the present application is smaller than that of the original network, which means higher accuracy.
[0159] Therefore, it can be seen that the model in the embodiment of the present application can avoid false detection in complex environment and improve accuracy in simple environment.
[0160] As to the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment related to the method, and will not be described in detail here.
[0161] The above has described various embodiments of the present application, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes are obvious to those skilled in the art without departing from the scope and spirit of the described embodiments. The choice of terms used herein is intended to best explain the principles, practical application, or improvement of technology in the market of the embodiments, or to enable other ordinary skilled persons in the art to understand the embodiments disclosed herein.
Claims
1. A method for training a ship detection model based on the YOLOv8 algorithm, characterized in that, include: S1. Obtain the 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. Construct a ship detection model based on the YOLOv8 algorithm; the ship detection model integrates deformable convolution modules and coordinate attention mechanisms. S3. Set a Neck layer in the ship detection model; S4. Define the target box loss function; the formula for the target box loss function is: in, The target box loss function is... for loss function and The loss functions are combined; It is a single hyperparameter; The penalty factor is defined as follows: , ; S5. Train the ship detection model; The target box loss function is composed of loss function and The loss function consists of, specifically: The loss function and The formula for fusion of loss functions is: in, for loss function This is the distance between the anchor box and the target box; The The loss function formula is: in, It is the area of the overlapping region between the anchor frame and the target frame. It is the area of the union of the anchor box and the target box, and its calculation formula is: in, and Represents the x-coordinates of the left and right borders of the target bounding box. and This represents the y-coordinates of the top and bottom borders of the target bounding box. and This represents the x-coordinates of the left and right borders of the anchor frame. and This represents the vertical coordinates of the top and bottom borders of the anchor frame.
2. The ship detection model training method based on the YOLOv8 algorithm according to claim 1, characterized in that, The formula for calculating the distance between the anchor frame and the target frame is: in, This represents the absolute value of the distance between the two wide sides of the anchor frame and the two wide sides of the target frame. This represents the absolute value of the distance between the two heights of the anchor frame and the two heights of the target frame. The width of the target box. The height of the target bounding box.
3. The ship detection model training method based on the YOLOv8 algorithm according to claim 1, characterized in that, [0.5,1.5]。 4. The ship detection model training method based on the YOLOv8 algorithm according to claim 1, characterized in that, After acquiring the ship remote sensing image dataset, the process also includes: Convert the input image size of the ship remote sensing image dataset to a preset pixel size.
5. The ship detection model training method based on the YOLOv8 algorithm according to claim 1, characterized in that, After training the ship detection model, the process also includes: The performance of the ship detection model is evaluated based on its classification accuracy and classification recall.
6. A ship detection method based on the YOLOv8 algorithm, characterized in that, A ship detection model trained based on the ship detection model training method according to any one of claims 1 to 5 performs a ship target detection task, including the following steps: Acquire remote sensing images of ships; The remote sensing images of the ship are preprocessed; Ship targets in the remote sensing images are detected using a pre-trained ship detection model.
Citation Information
Patent Citations
Marine ship target identification method based on SAR image and YOLOv5s network
CN116994151A
High body seriola quinqueradiata detection method based on YOLOv8 network structure
CN118279935A