SAR ship image target detection method and system based on YOLOv8
By improving the C2f module, optimizing the attention mechanism and loss function of the YOLOv8 model, the problem of poor model complexity and adaptability in SAR image detection is solved, and the detection accuracy and robustness are improved. It is suitable for real-time use of resource-constrained devices. Ship inspection.
Patent Information
- Application Number
- CN202411051911.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-01
- Publication Date
- 2024-11-08
AI Technical Summary
The existing YOLO-based ship detection method has problems such as high model complexity, poor adaptability and low detection accuracy when applied to SAR images, especially in real-time performance degradation on resource-constrained devices, and it is difficult to effectively identify variable Ship Target.
By improving the C2f module, enhancing the attention mechanism and optimizing the loss function of the YOLOv8 model, including replacing the Conv of Bottleneck as the DCNv2 module, adding the SimAM attention mechanism, and replacing the CIOU loss function as the WIOU loss function, improving the model's detection of SAR images Accuracy and robustness.
It significantly improves the accuracy and robustness of SAR image detection, enhances the recognition ability of target areas and small object detection capabilities, maintains real-time performance, and is suitable for devices with resource-constrained.
Smart Images

Figure CN118918317A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of machine learning, and in particular to a method and system for SAR ship image target detection based on YOLOv8. Background Art
[0002] SAR technology is a technology that uses the penetrating power of radar waves for remote sensing mapping. Whether it is day or night, regardless of weather conditions, SAR technology can obtain high-resolution images of the surface. This makes SAR technology an important tool for ocean and land monitoring, especially in ship detection and maritime security. At present, the detection of ship targets in SAR images usually adopts methods based on traditional image processing technology or deep learning algorithms. In the field of deep learning, the YOLO (You Only Look Once) series of algorithms are widely used in a variety of real-time detection tasks due to their fast detection speed. However, the existing YOLO-based methods encounter the following problems when applied to SAR image ship detection:
[0003] Model complexity: Although the YOLO series of algorithms have fast detection speed, their network models are usually complex, with many parameters and high demand for computing resources, which limits their application on resource-constrained mobile devices or edge devices.
[0004] Adaptability: The existing YOLO model is mainly designed for optical images, while the characteristics of SAR images are very different from those of optical images, including but not limited to image contrast, noise characteristics, and target reflection characteristics. This requires the model to be able to adapt to the characteristics of SAR images, and existing technologies often have defects in this regard.
[0005] Detection accuracy: Although some improved versions of YOLO try to improve detection accuracy by increasing network depth or width, this approach usually results in a larger model and reduced real-time performance. In addition, the size of ship targets in SAR images varies, which places higher requirements on the size adaptability of the detection algorithm. Summary of the invention
[0006] The main purpose of the embodiment of the present invention is to provide a method for SAR ship image target detection based on YOLOv8, which improves the accuracy and robustness of SAR image detection through C2f improvement, expands the global receptive field of the backbone network through attention mechanism improvement, improves the recognition ability of the target area, and improves the recognition ability of small objects through loss function improvement.
[0007] In a first aspect, a method for SAR ship image target detection based on YOLOv8 is provided, the method comprising:
[0008] Improving the initial YOLOv8 model to obtain an improved YOLOv8 model, wherein the improvements include: C2f module improvement, attention mechanism improvement, and loss function improvement;
[0009] Training the improved YOLOv8 model through training images to obtain a trained YOLOv8 model;
[0010] Perform feature extraction on the SAR image to be detected by using the trained YOLOv8 model to obtain a feature image;
[0011] The target detection result is obtained according to the feature image.
[0012] In a possible implementation, before the step of extracting features from the SAR image to be detected by using the trained YOLOv8 model to obtain a feature image, the method further includes:
[0013] The SAR image to be detected is enhanced, and the enhancement processing includes translation, scaling and mosaic enhancement.
[0014] In a possible implementation, the initial YOLOv8 model is improved to obtain an improved YOLOv8 model;
[0015] Replace the Conv of Bottleneck in the third C2f module and the fourth C2f module of the backbone network of the initial YOLOv8 model with the DCNv2 module, and form a DCNv2_C2f module according to the DCNv2 module to obtain a first improved YOLOv8 model;
[0016] Add a SimAM attention mechanism after the SPPF module of the last layer of the backbone network of the first improved YOLOv8 model to obtain a second improved YOLOv8 model;
[0017] The CIOU loss function in the second improved YOLOv8 model is replaced with the dynamic non-monotonic focusing mechanism WIOU loss function to obtain the improved YOLOv8 model.
[0018] In a possible implementation, obtaining a result of target detection according to the feature image includes:
[0019] Performing feature fusion on the feature image through the pyramid structure in the neck network of the trained YOLOv8 model to obtain a fused feature image;
[0020] Analyzing the fused feature image through the head network of the trained YOLOv8 model to obtain a confidence score for each prediction box;
[0021] The result of target detection is obtained according to the confidence score.
[0022] In a second aspect, a system for SAR ship image target detection based on YOLOv8 is provided, the system comprising:
[0023] An improved YOLOv8 model acquisition module is used to improve the initial YOLOv8 model to obtain an improved YOLOv8 model, wherein the improvements include: C2f module improvement, attention mechanism improvement, and loss function improvement;
[0024] A trained YOLOv8 model acquisition module is used to train the improved YOLOv8 model through training images to obtain a trained YOLOv8 model;
[0025] A feature image acquisition module, used to extract features of the SAR image to be detected through the trained YOLOv8 model to obtain a feature image;
[0026] The target detection module is used to obtain the target detection result according to the feature image.
[0027] In a possible implementation, the system further includes:
[0028] The enhancement processing module is used to perform enhancement processing on the SAR image to be detected, wherein the enhancement processing includes translation, scaling and mosaic enhancement.
[0029] In a possible implementation, the improved YOLOv8 model acquisition module includes:
[0030] A first improved YOLOv8 model acquisition unit is used to replace the Conv of Bottleneck in the third C2f module and the fourth C2f module of the backbone network of the initial YOLOv8 model with a DCNv2 module, and form a DCNv2_C2f module according to the DCNv2 module to obtain a first improved YOLOv8 model;
[0031] A second improved YOLOv8 model acquisition unit is used to add a SimAM attention mechanism after the SPPF module of the last layer of the backbone network of the first improved YOLOv8 model to obtain a second improved YOLOv8 model;
[0032] The improved YOLOv8 model acquisition unit is used to replace the CIOU loss function in the second improved YOLOv8 model with the dynamic non-monotonic focusing mechanism WIOU loss function to obtain the improved YOLOv8 model.
[0033] In a possible implementation, the target detection module includes:
[0034] A fused feature image acquisition unit, used for performing feature fusion on the feature image through the pyramid structure in the neck network of the trained YOLOv8 model to acquire a fused feature image;
[0035] A confidence score acquisition unit, used to analyze the fused feature image through the head network of the trained YOLOv8 model to obtain a confidence score of each prediction box;
[0036] The target detection result acquisition unit is used to acquire the target detection result according to the confidence score.
[0037] In a third aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for SAR ship image target detection based on YOLOv8 as provided in the first aspect is implemented.
[0038] In a fourth aspect, a non-transitory computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method for SAR ship image target detection based on YOLOv8 as provided in the first aspect is implemented.
[0039] In this application, the accuracy and robustness of SAR image detection are improved through C2f improvement, the global receptive field of the backbone network is expanded through attention mechanism improvement, the recognition ability of the target area is improved, and the recognition ability of small objects is improved through loss function improvement. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in describing the embodiments of the present application.
[0041] Figure 1 A flowchart of a method for SAR ship image target detection based on YOLOv8 provided by an embodiment of the present invention;
[0042] Figure 2 A flowchart of a method for SAR ship image target detection based on YOLOv8 provided by another embodiment of the present invention;
[0043] Figure 3 A flowchart of a method for SAR ship image target detection based on YOLOv8 provided by another embodiment of the present invention;
[0044] Figure 4A structural diagram of a system for SAR ship image target detection based on YOLOv8 provided by one embodiment of the present invention;
[0045] Figure 5 A structural diagram of a system for SAR ship image target detection based on YOLOv8 provided by another embodiment of the present invention;
[0046] Figure 6 A structural diagram of a system for SAR ship image target detection based on YOLOv8 provided by another embodiment of the present invention;
[0047] Figure 7 A schematic diagram of the network structure of an improved YOLOv8 model provided by one embodiment of the present invention;
[0048] Figure 8 A schematic diagram of the structure of an improved DCNv2 module provided by an embodiment of the present invention;
[0049] Fig. 9 A schematic diagram of the structure of an improved DCNv2_C2f module provided by an embodiment of the present invention;
[0050] Fig.10 A schematic diagram of the physical structure of an electronic device provided by the present invention.
[0051] Specific implementation method
[0052] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar modules or modules with the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as limiting the present invention.
[0053] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "a", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, modules and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, modules, components and / or groups thereof. It should be understood that when we refer to a module as being "connected" or "coupled" to another module, it may be directly connected or coupled to the other modules, or there may be intermediate modules. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any modules and all combinations of one or more associated listed items.
[0054] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation method of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0055] The technical solution of the present application and how to solve the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0056] like Figure 1 FIG. 1 is a flowchart of a method for detecting SAR ship images based on YOLOv8 according to an embodiment of the present invention, wherein the method comprises:
[0057] Step S101, improving the initial YOLOv8 model to obtain an improved YOLOv8 model, wherein the improvements include: C2f module improvement, attention mechanism improvement, and loss function improvement;
[0058] Step S102, training the improved YOLOv8 model through training images to obtain a trained YOLOv8 model;
[0059] Step S103, extracting features from the SAR image to be detected by using the trained YOLOv8 model to obtain a feature image;
[0060] Step S104, obtaining a target detection result according to the feature image.
[0061] In the embodiment of the present invention, the original YOLOv8 model is already an excellent object detection model, which improves the target detection performance in various scenarios by continuously optimizing the network architecture and algorithm efficiency, and is suitable for high-speed detection tasks in resource-constrained environments. However, the YOLOv8 architecture is relatively complex, has many parameters, and has a slow calculation speed. Therefore, it is necessary to improve the original YOLOv8 to obtain an improved YOLOv8 model. The improvement directions mainly include the following directions: C2f module improvement, attention mechanism improvement, and loss function improvement.
[0062] For the improved YOLOv8 model, it is also necessary to train it with labeled images to improve the subsequent target detection efficiency. By training the improved YOLOv8 model, a trained YOLOv8 model is obtained. Wherein, the training of the improved YOLOv8 model with training images to obtain the trained YOLOv8 model includes: dividing the training images into a training set, a verification set and a test set according to a preset allocation ratio, training the improved YOLOv8 model with the training set, verifying the training with the verification set, and testing the trained YOLOv8 model with the test set. Wherein, the preset allocation ratio is training set 7: verification set 2: test set 1.
[0063] The backbone network in the trained YOLOv8 model extracts features from the SAR image to be detected and obtains feature images. The feature images are processed by the neck network and the head network to obtain the final detection results.
[0064] In the embodiment of the present invention, the initial YOLOv8 model is improved to obtain an improved YOLOv8 model; the improved YOLOv8 model is trained by training images to obtain a trained YOLOv8 model; the trained YOLOv8 model is used to extract features of the SAR image to be detected to obtain a feature image; and the target detection result is obtained according to the feature image. The accuracy and robustness of SAR image detection are improved by C2f improvement, the global receptive field of the backbone network is expanded by attention mechanism improvement, the recognition ability of the target area is improved, and the recognition ability of small objects is improved by loss function improvement.
[0065] As an optional embodiment of the present invention, before the step of extracting features from the SAR image to be detected by using the trained YOLOv8 model to obtain a feature image, the method further includes:
[0066] The SAR image to be detected is enhanced, and the enhancement processing includes translation, scaling and mosaic enhancement.
[0067] Specifically, in order to obtain detection results more accurately for the SAR image to be detected, enhancement processing including translation, scaling, and mosaic enhancement may be performed on the image before target detection, thereby improving the generalization ability and robustness of the SAR image to be detected.
[0068] like Figure 2 FIG. 1 is a flowchart of a method for SAR ship image target detection based on YOLOv8 provided by another embodiment of the present invention, wherein the initial YOLOv8 model is improved to obtain an improved YOLOv8 model;
[0069] Step S201, replacing the Conv of Bottleneck in the third C2f module and the fourth C2f module of the backbone network of the initial YOLOv8 model with a DCNv2 module, and forming a DCNv2_C2f module according to the DCNv2 module to obtain a first improved YOLOv8 model;
[0070] Step S202, adding a SimAM attention mechanism after the SPPF module of the last layer of the backbone network of the first improved YOLOv8 model to obtain a second improved YOLOv8 model;
[0071] Step S203: Replace the CIOU loss function in the second improved YOLOv8 model with the dynamic non-monotonic focusing mechanism WIOU loss function to obtain an improved YOLOv8 model.
[0072] In the embodiment of the present invention, the DCNv2 module is used to replace the Conv of Bottleneck in the third C2f module and the fourth C2f module of the backbone network of the YOLOv8 model, and the DCNv2 module is combined with the C2f module to form a DCNv2_C2f module. DCNv2 has significantly enhanced the functions of its predecessor DCNv1. When facing the cross-network part, DCNv1 has limited ability to describe the interaction between features. DCNv2 innovates the cross-network structure in DCN and optimizes the fusion strategy of the cross-network and the deep network.
[0073] In order to further enhance the ability of deformable convolutional networks to control the support domain, DCNv2 introduces a modulation mechanism to perform weighted sampling point offset. Assuming w k As the weight of the Kth position, p k is the offset of the Kth position, and then by defining a 3*3 convolution, K=9 and p k ∈{(-1,-1),(-1,0),…,(1,1)}, where (-1,-1) is the upper left corner of x(p0) and (1,1) is the lower right corner of x(p0). The calculation formula of the deformed convolution is as follows:
[0074]
[0075] Among them, Δp k and Δm k The initial values of are 0 and 0.5 respectively. The learning rate of the conversion layers for added bias and modulation learning is set to 0.1 times that of the existing layers.
[0076] The deformable ROI pooling is similar to the above, and the calculation formula is as follows:
[0077]
[0078] Among them, the p of offset and modulation learning kj is the sampling position of the jth grid cell in the bin, n k is the number of sampled grid cells, Δm k are the learned weights.
[0079] Using DCNv2 for SAR ship detection can significantly improve the accuracy and robustness of detection. This is because DCNv2 introduces a learnable offset through its deformable convolution kernel, which enhances the adaptability to the changing morphology of ships in SAR images, while paying better attention to spatial details and enhancing the recognition of complex sea conditions and low-contrast targets. This not only improves the efficiency of detection, but also maintains strong generalization capabilities under different environmental conditions.
[0080] The first improved YOLOv8 model is obtained by replacing the C2f module. Adding the SimAM attention mechanism to the backbone network can expand the global receptive field of the backbone network. The SimAM attention mechanism is designed to improve the YOLOv8 model's ability to recognize the target area, thereby optimizing the accuracy of target detection and position precision.
[0081] In order to make the SimAM attention mechanism more effective, it is necessary to judge the importance of each neuron. Neurons that transmit important information often act differently from other neurons. Active neurons also inhibit neurons around them, which is called spatial inhibition. Therefore, neurons with spatial inhibition are more critical. A simple way is to see whether neurons can be easily distinguished from each other. To this end, the following formula can be used to describe the differentiation of neurons to help obtain more important neurons:
[0082]
[0083] Using binary labels and introducing regularization terms, the final energy function is defined as follows:
[0084]
[0085] According to the above formula, the following formula can be derived:
[0086]
[0087] Since the neurons in each channel share a similar distribution, redundant calculation steps can be omitted by first calculating the mean and standard deviation in the height H and width W dimensions of the input feature. Combining the above process, it can finally be expressed as the following formula:
[0088]
[0089] Since ship detection in SAR images is characterized by small and dense detection targets, the SimAM attention mechanism is added after the SPPF module in the last layer of the backbone network to enhance the receptive field range and strengthen the information on ship target detection.
[0090] The second improved YOLOv8 model is obtained after adding the SimAM attention mechanism, and the CIOU loss function in the YOLOv8 model is replaced by the WIOU loss function. Since the targets to be detected in SAR images are usually small objects, and the IOU of small objects is usually low, it is difficult for traditional loss functions to effectively train small objects, while the WIOU loss function can improve the model's detection effect for small objects. The WIOU loss function is an innovative target detection loss function that comprehensively considers more contextual information when calculating the position and shape information of the target box. Compared with the traditional IOU loss function, the WIOU loss function introduces more contextual information to calculate the degree of overlap. The calculation formula of the WIOU loss function is as follows:
[0091]
[0092] L WIOUv1 =R WIOU ×L IOU
[0093] The above formulas define from top to bottom: the overlapping area between the predicted box and the real box used to measure the target detection effect, H i and W i Defines the height and width of the cross box, H g and W g Defines the height and width of the bounding box.
[0094] The specific calculation method of WIOU is as follows: first, the IOU score between the predicted box and the true box is obtained, the center points of the predicted box and the true box are determined, and the distance between the two center points is calculated. The distance is used as an indicator to represent the maximum distance between the predicted box and the true box, thereby defining the area between the boxes; then, a weight coefficient is calculated based on this area, which reflects the relative position relationship between the predicted box and the true box, and the IOU score is weighted by the weight coefficient. Through the application of this area and weight coefficient, WIOU provides a more accurate method to evaluate the performance of target detection, effectively overcoming the limitations of the traditional IOU method.
[0095] like Figure 3 FIG. 1 is a flowchart of a method for detecting a target in a SAR ship image based on YOLOv8 according to another embodiment of the present invention. The method of obtaining a target detection result according to the feature image includes:
[0096] Step S301, performing feature fusion on the feature image through the pyramid structure in the neck network of the trained YOLOv8 model to obtain a fused feature image;
[0097] Step S302, analyzing the fused feature image through the head network of the trained YOLOv8 model to obtain a confidence score of each prediction box;
[0098] Step S303: Obtain the target detection result according to the confidence score.
[0099] Specifically, the neck network applies a feature pyramid structure for feature fusion, which can obtain information at different scales, ensuring that the YOLOv8 model can effectively detect objects at multiple scales, and enhancing the YOLOv8 model's ability to detect objects of different sizes.
[0100] After feature fusion, the head network analyzes the fused feature image through the convolution layer, predicts the bounding box position, size and object category of each position, and calculates the confidence score of each predicted box to indicate the possibility of object existence and prediction accuracy. Finally, combined with the category probability, the final target detection result is screened out through non-maximum suppression to ensure the accuracy of target detection.
[0101] like Figure 4 FIG. 1 is a structural diagram of a system for SAR ship image target detection based on YOLOv8 provided by an embodiment of the present invention, wherein the system comprises:
[0102] An improved YOLOv8 model acquisition module 401 is used to improve the initial YOLOv8 model to obtain an improved YOLOv8 model, wherein the improvements include: C2f module improvement, attention mechanism improvement, and loss function improvement;
[0103] A trained YOLOv8 model acquisition module 402 is used to train the improved YOLOv8 model through training images to obtain a trained YOLOv8 model;
[0104] A feature image acquisition module 403 is used to extract features of the SAR image to be detected by using the trained YOLOv8 model to acquire a feature image;
[0105] The target detection module 404 is used to obtain a target detection result according to the feature image.
[0106] In the embodiment of the present invention, the original YOLOv8 model is already an excellent object detection model, which improves the target detection performance in various scenarios by continuously optimizing the network architecture and algorithm efficiency, and is suitable for high-speed detection tasks in resource-constrained environments. However, the YOLOv8 architecture is relatively complex, has many parameters, and has a slow calculation speed. Therefore, it is necessary to improve the original YOLOv8 to obtain an improved YOLOv8 model. The improvement directions mainly include the following directions: C2f module improvement, attention mechanism improvement, and loss function improvement.
[0107] For the improved YOLOv8 model, it is also necessary to train it with labeled images to improve the subsequent target detection efficiency. By training the improved YOLOv8 model, a trained YOLOv8 model is obtained. Wherein, the training of the improved YOLOv8 model with training images to obtain the trained YOLOv8 model includes: dividing the training images into a training set, a verification set and a test set according to a preset allocation ratio, training the improved YOLOv8 model with the training set, verifying the training with the verification set, and testing the trained YOLOv8 model with the test set. Wherein, the preset allocation ratio is training set 7: verification set 2: test set 1.
[0108] The backbone network in the trained YOLOv8 model extracts features from the SAR image to be detected and obtains feature images. The feature images are processed by the neck network and the head network to obtain the final detection results.
[0109] In the embodiment of the present invention, the initial YOLOv8 model is improved to obtain an improved YOLOv8 model; the improved YOLOv8 model is trained by training images to obtain a trained YOLOv8 model; the trained YOLOv8 model is used to extract features of the SAR image to be detected to obtain a feature image; and the target detection result is obtained according to the feature image. The accuracy and robustness of SAR image detection are improved by C2f improvement, the global receptive field of the backbone network is expanded by attention mechanism improvement, the recognition ability of the target area is improved, and the recognition ability of small objects is improved by loss function improvement.
[0110] As an optional embodiment of the present invention, the system further includes:
[0111] The enhancement processing module is used to perform enhancement processing on the SAR image to be detected, wherein the enhancement processing includes translation, scaling and mosaic enhancement.
[0112] Specifically, in order to obtain detection results more accurately for the SAR image to be detected, enhancement processing including translation, scaling, and mosaic enhancement may be performed on the image before target detection, thereby improving the generalization ability and robustness of the SAR image to be detected.
[0113] like Figure 5 FIG. 4 is a structural diagram of a system for SAR ship image target detection based on YOLOv8 provided by another embodiment of the present invention. The improved YOLOv8 model acquisition module 401 includes:
[0114] A first improved YOLOv8 model acquisition unit 501 is used to replace the Conv of Bottleneck in the third C2f module and the fourth C2f module of the backbone network of the initial YOLOv8 model with a DCNv2 module, and form a DCNv2_C2f module according to the DCNv2 module to obtain a first improved YOLOv8 model;
[0115] A second improved YOLOv8 model acquisition unit 502 is used to add a SimAM attention mechanism after the SPPF module of the last layer of the backbone network of the first improved YOLOv8 model to obtain a second improved YOLOv8 model;
[0116] The improved YOLOv8 model acquisition unit 503 is used to replace the CIOU loss function in the second improved YOLOv8 model with the dynamic non-monotonic focusing mechanism WIOU loss function to obtain the improved YOLOv8 model.
[0117] In the embodiment of the present invention, the DCNv2 module is used to replace the Conv of Bottleneck in the third C2f module and the fourth C2f module of the backbone network of the YOLOv8 model, and the DCNv2 module is combined with the C2f module to form a DCNv2_C2f module. DCNv2 has significantly enhanced the functions of its predecessor DCNv1. When facing the cross-network part, DCNv1 has limited ability to describe the interaction between features. DCNv2 innovates the cross-network structure in DCN and optimizes the fusion strategy of the cross-network and the deep network.
[0118] In order to further enhance the ability of deformable convolutional networks to control the support domain, DCNv2 introduces a modulation mechanism to perform weighted sampling point offset. Assuming w k As the weight of the Kth position, p k is the offset of the Kth position, and then by defining a 3*3 convolution, K=9 and p k∈{(-1,-1),(-1,0),…,(1,1)}, where (-1,-1) is the upper left corner of x(p0) and (1,1) is the lower right corner of x(p0). The calculation formula of the deformed convolution is as follows:
[0119]
[0120] Among them, Δp k and Δm k The initial values of are 0 and 0.5 respectively. The learning rate of the conversion layers for added bias and modulation learning is set to 0.1 times that of the existing layers.
[0121] The deformable ROI pooling is similar to the above, and the calculation formula is as follows:
[0122]
[0123] Among them, the p of offset and modulation learning kj is the sampling position of the jth grid cell in the bin, n k is the number of sampled grid cells, Δm k are the learned weights.
[0124] Using DCNv2 for SAR ship detection can significantly improve the accuracy and robustness of detection. This is because DCNv2 introduces a learnable offset through its deformable convolution kernel, which enhances the adaptability to the changing morphology of ships in SAR images, while paying better attention to spatial details and enhancing the recognition of complex sea conditions and low-contrast targets. This not only improves the efficiency of detection, but also maintains strong generalization capabilities under different environmental conditions.
[0125] The first improved YOLOv8 model is obtained by replacing the C2f module. Adding the SimAM attention mechanism to the backbone network can expand the global receptive field of the backbone network. The SimAM attention mechanism is designed to improve the YOLOv8 model's ability to recognize the target area, thereby optimizing the accuracy of target detection and position precision.
[0126] In order to make the SimAM attention mechanism more effective, it is necessary to judge the importance of each neuron. Neurons that transmit important information often act differently from other neurons. Active neurons also inhibit neurons around them, which is called spatial inhibition. Therefore, neurons with spatial inhibition are more critical. A simple way is to see whether neurons can be easily distinguished from each other. To this end, the following formula can be used to describe the differentiation of neurons to help obtain more important neurons:
[0127]
[0128] Using binary labels and introducing regularization terms, the final energy function is defined as follows:
[0129]
[0130] According to the above formula, the following formula can be derived:
[0131]
[0132] Since the neurons in each channel share a similar distribution, redundant calculation steps can be omitted by first calculating the mean and standard deviation in the height H and width W dimensions of the input feature. Combining the above process, it can finally be expressed as the following formula:
[0133]
[0134] Since ship detection in SAR images is characterized by small and dense detection targets, the SimAM attention mechanism is added after the SPPF module in the last layer of the backbone network to enhance the receptive field range and strengthen the information on ship target detection.
[0135] The second improved YOLOv8 model is obtained after adding the SimAM attention mechanism, and the CIOU loss function in the YOLOv8 model is replaced by the WIOU loss function. Since the targets to be detected in SAR images are usually small objects, and the IOU of small objects is usually low, it is difficult for traditional loss functions to effectively train small objects, while the WIOU loss function can improve the model's detection effect for small objects. The WIOU loss function is an innovative target detection loss function that comprehensively considers more contextual information when calculating the position and shape information of the target box. Compared with the traditional IOU loss function, the WIOU loss function introduces more contextual information to calculate the degree of overlap. The calculation formula of the WIOU loss function is as follows:
[0136]
[0137] L WIOUv1 =R WIOU ×L IOU
[0138] The above formulas define from top to bottom: the overlapping area between the predicted box and the real box used to measure the target detection effect, H i and W i Defines the height and width of the cross box, H g and W g Defines the height and width of the bounding box.
[0139] The specific calculation method of WIOU is as follows: first, the IOU score between the predicted box and the true box is obtained, the center points of the predicted box and the true box are determined, and the distance between the two center points is calculated. The distance is used as an indicator to represent the maximum distance between the predicted box and the true box, thereby defining the area between the boxes; then, a weight coefficient is calculated based on this area, which reflects the relative position relationship between the predicted box and the true box, and the IOU score is weighted by the weight coefficient. Through the application of this area and weight coefficient, WIOU provides a more accurate method to evaluate the performance of target detection, effectively overcoming the limitations of the traditional IOU method.
[0140] like Figure 6 FIG. 4 is a structural diagram of a system for SAR ship image target detection based on YOLOv8 provided by another embodiment of the present invention. The target detection module 404 includes:
[0141] A fused feature image acquisition unit 601 is used to perform feature fusion on the feature image through the pyramid structure in the neck network of the trained YOLOv8 model to acquire a fused feature image;
[0142] A confidence score acquisition unit 602 is used to analyze the fused feature image through the head network of the trained YOLOv8 model to obtain a confidence score of each prediction box;
[0143] The target detection result acquisition unit 603 is used to acquire the target detection result according to the confidence score.
[0144] Specifically, the neck network applies a feature pyramid structure for feature fusion, which can obtain information at different scales, ensuring that the YOLOv8 model can effectively detect objects at multiple scales, and enhancing the YOLOv8 model's ability to detect objects of different sizes.
[0145] After feature fusion, the head network analyzes the fused feature image through the convolution layer, predicts the bounding box position, size and object category of each position, and calculates the confidence score of each predicted box to indicate the possibility of object existence and prediction accuracy. Finally, combined with the category probability, the final target detection result is screened out through non-maximum suppression to ensure the accuracy of target detection.
[0146] like Figure 7 The figure shows a schematic diagram of the network structure of an improved YOLOv8 model according to an embodiment of the present invention.
[0147] like Figure 8 FIG. 4 is a schematic diagram of the structure of an improved DCNv2 module according to an embodiment of the present invention.
[0148] like Fig. 9 The figure shows a schematic diagram of the structure of an improved DCNv2_C2f module according to an embodiment of the present invention.
[0149] Fig.10 An example of a physical structure diagram of an electronic device is shown in FIG. Fig.10 As shown, the electronic device may include: a processor (processor) 1001, a communication interface (Communications Interface) 1002, a memory (memory) 1003 and a communication bus 1004, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus. The processor may call the logic instructions in the memory to execute the method for SAR ship image target detection based on YOLOv8, the method comprising: improving the initial YOLOv8 model to obtain an improved YOLOv8 model, the improvement comprising: C2f module improvement, attention mechanism improvement and loss function improvement; training the improved YOLOv8 model through training images to obtain a trained YOLOv8 model; extracting features of the SAR image to be detected through the trained YOLOv8 model to obtain a feature image; obtaining the result of target detection according to the feature image.
[0150] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0151] On the other hand, an embodiment of the present invention further provides a computer program product, comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, and when the program instructions are executed by a computer, the computer can execute the method for SAR ship image target detection based on YOLOv8 provided in the above-mentioned method embodiments, the method comprising: improving the initial YOLOv8 model to obtain an improved YOLOv8 model, the improvement comprising: C2f module improvement, attention mechanism improvement and loss function improvement; training the improved YOLOv8 model through training images to obtain a trained YOLOv8 model; performing feature extraction on the SAR image to be detected through the trained YOLOv8 model to obtain a feature image; and obtaining the result of target detection according to the feature image.
[0152] On the other hand, an embodiment of the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the method for SAR ship image target detection based on YOLOv8 provided in the above embodiments, the method comprising: improving the initial YOLOv8 model to obtain an improved YOLOv8 model, the improvement comprising: C2f module improvement, attention mechanism improvement and loss function improvement; training the improved YOLOv8 model through training images to obtain a trained YOLOv8 model; performing feature extraction on the SAR image to be detected through the trained YOLOv8 model to obtain a feature image; and obtaining a target detection result according to the feature image.
[0153] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0154] The above is only a partial implementation of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for SAR ship image target detection based on YOLOv8, characterized in that: The method comprises: Improving the initial YOLOv8 model to obtain an improved YOLOv8 model, wherein the improvements include: C2f module improvement, attention mechanism improvement, and loss function improvement; Training the improved YOLOv8 model through training images to obtain a trained YOLOv8 model; Perform feature extraction on the SAR image to be detected by using the trained YOLOv8 model to obtain a feature image; The target detection result is obtained according to the feature image.
2. The method according to claim 1, characterized in that Before the step of extracting features from the SAR image to be detected by using the trained YOLOv8 model to obtain a feature image, the method further includes: The SAR image to be detected is enhanced, and the enhancement processing includes translation, scaling and mosaic enhancement.
3. The method according to any one of claims 1 to 2, characterized in that: The initial YOLOv8 model is improved to obtain an improved YOLOv8 model; Replace the Conv of Bottleneck in the third C2f module and the fourth C2f module of the backbone network of the initial YOLOv8 model with the DCNv2 module, and form a DCNv2_C2f module according to the DCNv2 module to obtain a first improved YOLOv8 model; Add a SimAM attention mechanism after the SPPF module of the last layer of the backbone network of the first improved YOLOv8 model to obtain a second improved YOLOv8 model; The CIOU loss function in the second improved YOLOv8 model is replaced with the dynamic non-monotonic focusing mechanism WIOU loss function to obtain the improved YOLOv8 model.
4. The method according to any one of claims 1 to 2, characterized in that: The step of obtaining a result of target detection according to the feature image comprises: Performing feature fusion on the feature image through the pyramid structure in the neck network of the trained YOLOv8 model to obtain a fused feature image; Analyzing the fused feature image through the head network of the trained YOLOv8 model to obtain a confidence score for each prediction box; The result of target detection is obtained according to the confidence score.
5. A system for SAR ship image target detection based on YOLOv8, characterized in that: The system comprises: An improved YOLOv8 model acquisition module is used to improve the initial YOLOv8 model to obtain an improved YOLOv8 model, wherein the improvements include: C2f module improvement, attention mechanism improvement, and loss function improvement; A trained YOLOv8 model acquisition module is used to train the improved YOLOv8 model through training images to obtain a trained YOLOv8 model; A feature image acquisition module, used to extract features of the SAR image to be detected through the trained YOLOv8 model to obtain a feature image; The target detection module is used to obtain the target detection result according to the feature image.
6. The system according to claim 5, characterized in that The system further comprises: The enhancement processing module is used to perform enhancement processing on the SAR image to be detected, wherein the enhancement processing includes translation, scaling and mosaic enhancement.
7. The system according to any one of claims 5 to 6, characterized in that: The improved YOLOv8 model acquisition module includes: A first improved YOLOv8 model acquisition unit is used to replace the Conv of Bottleneck in the third C2f module and the fourth C2f module of the backbone network of the initial YOLOv8 model with a DCNv2 module, and form a DCNv2_C2f module according to the DCNv2 module to obtain a first improved YOLOv8 model; A second improved YOLOv8 model acquisition unit is used to add a SimAM attention mechanism after the SPPF module of the last layer of the backbone network of the first improved YOLOv8 model to obtain a second improved YOLOv8 model; The improved YOLOv8 model acquisition unit is used to replace the CIOU loss function in the second improved YOLOv8 model with the dynamic non-monotonic focusing mechanism WIOU loss function to obtain the improved YOLOv8 model.
8. The system according to any one of claims 5 to 6, characterized in that: The target detection module comprises: A fused feature image acquisition unit, used for performing feature fusion on the feature image through the pyramid structure in the neck network of the trained YOLOv8 model to acquire a fused feature image; A confidence score acquisition unit, used to analyze the fused feature image through the head network of the trained YOLOv8 model to obtain a confidence score of each prediction box; The target detection result acquisition unit is used to acquire the target detection result according to the confidence score.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method for SAR ship image target detection based on YOLOv8 as described in any one of claims 1 to 4 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for SAR ship image target detection based on YOLOv8 as described in any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Disease and insect pest target detection method, device and equipment based on improved YOLOv8
CN117115640A
Infrared ship target detection method based on improved yolov7
CN117152691A
Fire detection method based on PD-YOLO
CN117333753A
Lightweight multi-environment tomato detection method based on improved yolov8
CN117557787A
Improved YOLOv8-based SAR image ship target detection method, medium and device
CN117689870A
Cited By
Ship high-precision identity recognition method based on target detection and character recognition
CN119648995A
Optical glass detection method and system based on image enhancement
CN119850589A
