A method and device for detecting ships in nearshore water areas based on deep learning
By segmenting and classifying SAR images, combined with the use of rotating detection frames, the problem of redundant information and misdetection in ship target detection in the near-shore area is solved, and a more efficient and accurate detection effect is achieved.
Patent Information
- Application Number
- CN202111391812.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-19
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2041-11-19
AI Technical Summary
There is a large amount of redundant information and misdetection and missed detection problems in ship target detection in near-shore areas, resulting in low detection efficiency and low accuracy. It is especially difficult to accurately separate ship targets under interference from large-scale land areas.
A method based on deep learning is used to segment the SAR image to be detected into sub-images, use a regional classification network for classification, filter out non-land area images, and then use the detection network for target detection, using a rotating detection frame instead of a rectangular detection frame. Combine angle information to improve detection accuracy.
It effectively improves the detection efficiency and accuracy, reduces the interference of land areas on detection, improves the separation ability of ship targets and background, and significantly improves the accuracy of detection results.
Smart Images

Figure CN114387492B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of ship target detection, and in particular, relates to a method and device for detecting ships in a nearshore water area based on deep learning. Background Art
[0002] As an important military strike target and a major maritime transport carrier, ship target detection has great research value and significance. In the military field, timely and accurate detection of enemy ships can provide support for our decision-making and is greatly related to the success or failure of the battle; in the civilian field, real-time monitoring of ships in the sea area can better manage the sea area and has a wide range of applications in marine transportation, fishery production, and maritime rescue.
[0003] In recent years, ship target detection using SAR images has become a major focus and hot issue in the field of target detection. Whether ships can be detected quickly and accurately has important military significance and economic value. Synthetic Aperture Radar (SAR) is a high-resolution imaging radar that can achieve all-day and all-weather ground observation without being restricted by conditions such as light and climate, and has strong penetration ability.
[0004] However, SAR image scenes are usually relatively large, and the nearshore area includes not only the sea area but also large areas of land scenes. When using the current detection method to detect ship targets, a large amount of redundant information (such as information in the land scene) will be generated, resulting in relatively low detection efficiency; moreover, there are a large number of imaging features similar to ship targets such as ports and islands in the nearshore area scenes. In many cases, ships and ships, ships and ports are densely arranged together, which can easily cause missed detections and false detections, resulting in relatively low detection accuracy. Summary of the invention
[0005] The purpose of the present invention is to provide a method and device for detecting ships in nearshore water areas based on deep learning, so as to improve detection efficiency and detection accuracy.
[0006] The present invention adopts the following technical solution: A method for detecting ships in a nearshore water area based on deep learning, comprising the following steps:
[0007] Divide the SAR image to be detected into several sub-images;
[0008] Classify each sub-image using a region classification network;
[0009] Filter out the sub-images whose classification results are the first category as target detection images; wherein the first category is a non-land area class;
[0010] The detection network is used to perform target detection on the target detection image to obtain the ship target detection result;
[0011] The target detection result of the SAR image to be detected is obtained by combining the ship target detection result of each target detection image.
[0012] Furthermore, using the detection network to perform target detection on the target detection image includes:
[0013] Extract feature maps from target detection images;
[0014] Determine the prediction result of the target detection image according to the feature map;
[0015] The prediction result is decoded to obtain the target detection result of the target detection image.
[0016] Furthermore, extracting a feature map from the target detection image includes:
[0017] The Darknet-53 network with the last fully connected layer deleted is used to extract the feature map of the target detection image, and the feature layers at the middle layer, the lower-middle layer and the bottom layer are obtained.
[0018] Furthermore, determining the prediction result of the target detection image according to the feature map includes:
[0019] The bottom feature layer is processed by DBL 5 times and the first prediction result is obtained;
[0020] The processed bottom feature layer is concatenated with the upsampled middle and lower feature layers to obtain a first fused feature layer;
[0021] Perform DBL processing on the first fusion feature layer 5 times to obtain the second prediction result;
[0022] The processed first fused feature layer is concatenated with the upsampled intermediate feature layer to obtain a second fused feature layer;
[0023] Perform DBL processing on the second fused feature layer 5 times to obtain the third prediction result;
[0024] The first prediction result, the second prediction result and the third prediction result are combined to obtain a prediction result.
[0025] Furthermore, the loss function of the detection network is:
[0026] loss=λ1L loc (x,y,w,h)+λ2L conf (C)+λ3L cla (P)+λ4L ang (θ),
[0027] Among them, loss is the loss function of the detection network, L loc (x, y, w, h) is the position loss function, L conf (C) is the confidence loss function, L cla (P) is the cross loss function, L ang (θ) is the angle loss function, λ1, λ2, λ3 and λ4 are all hyperparameters, is a binary coefficient, w i and h i are all coefficients normalized to (0,1], K is the size of the feature map, i is the ordinal number of the grid in the feature map, j is the ordinal number of the prior box of the grid in the feature map, θ i is the true value of the angle adjustment parameter, Predicted values for the angle adjustment parameters.
[0028] Furthermore, the detection frame in the detection network is a rotated detection frame, and the parameters of the rotated detection frame include its rotation parameters relative to the target detection image to be detected.
[0029] Furthermore, the region classification network includes an input part, an intermediate convolution part, and an output part;
[0030] The input part includes a 7*7 convolution layer and a maximum pooling layer; the convolution layer step size is 2, and the maximum pooling layer step size is 2;
[0031] The middle convolution part divides the input data of the input part into two parts, one part passes through two convolution layers and the other part is directly short-circuited. The results of the two parts are added and output to the output part through the relu function; the output part includes an average pooling layer and a fully connected layer; the number of output nodes in the output part is 2.
[0032] Furthermore, the non-land area class includes a water area class and a combined class; the combined class is a class that combines water area and land.
[0033] Another technical solution of the present invention: a nearshore water area ship detection device based on deep learning, comprising:
[0034] A segmentation module is used to segment the SAR image to be detected into a number of sub-images;
[0035] A classification module for classifying each sub-image using a region classification network;
[0036] A screening module, used to screen out sub-images whose classification results are the first category as target detection images; wherein the first category is a non-land area class;
[0037] The target detection module is used to perform target detection on the target detection image using the detection network to obtain the ship target detection result;
[0038] The combining module is used to combine the ship target detection result of each target detection image to obtain the ship target detection result of the SAR image to be detected.
[0039] Another technical solution of the present invention: a nearshore water area ship detection device based on deep learning, characterized in that it includes 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 computer program, it implements a nearshore water area ship detection method based on deep learning as claimed in any one of claims 1 to 8.
[0040] The beneficial effects of the present invention are as follows: in view of the problem that large-scale land areas in nearshore scenes interfere with ship target detection, the present invention proposes a new ship detection method, which first divides the large-scene nearshore area image into several sub-images, and then classifies the sub-images through a regional classification network to eliminate the influence of the land area, and finally performs detection through a detection network, thereby improving detection efficiency; in view of the problems that target detection in nearshore scenes is prone to missed detection, false detection, and low detection accuracy, the traditional target detection framework YOLOV3 is improved, and a rotatable detection frame is used to replace the original anchor frame, which can effectively separate the ship target from the background and improve the detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 This is a flow chart of a method for detecting ships in nearshore water areas based on deep learning according to an embodiment of the present invention;
[0042] Figure 2 is a residual structure diagram of a deep residual network in an embodiment of the present invention;
[0043] Figure 3 A basic structural diagram of a regional classification network in an embodiment of the present invention;
[0044] Figure 4 A schematic diagram showing a comparison between a rotation detection frame in a detection network according to an embodiment of the present invention and a rectangular detection frame in the prior art;
[0045] Figure 5 A basic structural diagram of a detection network in an embodiment of the present invention;
[0046] Figure 6 A schematic diagram of the adjustment relationship of adjustment parameters in a detection network in an embodiment of the present invention;
[0047] Figure 7 Schematic diagram of detection frames with different rotation angles in an embodiment of the present invention;
[0048] Figure 8 Schematic diagram of detection frames of different sizes in an embodiment of the present invention;
[0049] Fig. 9 Schematic diagram of the change of the loss function of the regional classification network in the experiment of the embodiment of the present invention;
[0050] Fig.10 It is a comparison diagram of the PR curves of the detection method before and after the improvement in the experiment of the embodiment of the present invention;
[0051] Fig.11 This is a comparison diagram of the detection results of the detection network before and after improvement in the experiment of the embodiment of the present invention;
[0052] Fig.12 This is a schematic structural diagram of a device for detecting ships in nearshore water areas based on deep learning according to an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0054] Traditional SAR image ship target detection methods are mostly based on the Constant False Alarm Rate (CFAR) algorithm or its improved algorithm. However, the premise of this type of algorithm is that the target has a strong contrast with the background. This model is easily affected by sea conditions, climate and other conditions, and its performance is more dependent on the clutter model. It is very time-consuming to perform dense sliding windows in large-scene SAR images, and the detection false alarm rate is high.
[0055] SAR images often contain large land areas. It is unnecessary to process such land areas when detecting ship targets. Therefore, there is often information redundancy during detection, and the detection efficiency is relatively low. With the rapid development of deep learning theory and related technologies, the use of deep learning for target detection has become the mainstream direction in the field of target detection. The deep learning method has a strong processing capability for complex scenes and has higher detection accuracy than traditional target detection methods. Therefore, the detection method of this application is designed based on the deep learning method.
[0056] In view of the problems existing in the background technology, the present invention proposes a new detection method for detecting ship targets in SAR images of nearshore areas. Based on the deep learning method, on the one hand, a front-end regional classification network is used to classify the scene, which reduces the interference of the land area on the detection and improves the detection efficiency. On the other hand, angle information is added to the framework of the basic detection network, and a rotating detection frame is used instead of a rectangular detection frame, which realizes the effective separation of the target and the background and improves the detection accuracy.
[0057] More specifically, the present invention provides a new detection method for ship target detection in the nearshore area. First, the image is segmented, and then classified using a regional classification network (the classification network uses a convolutional neural network). Finally, the detection network performs target detection on the nearshore waters. The improved detection network of the present invention introduces angle information and replaces the rectangular detection frame with a more accurate rotation detection frame to improve detection accuracy. This method is an improvement on the existing detection framework YOLOV3. The improvements are mainly reflected in two aspects. On the one hand, the prior frame needs to be modified and angle information needs to be added. On the other hand, the loss function needs to be modified to increase the angle loss.
[0058] The present invention provides a method for detecting ships in nearshore waters based on deep learning, such as Figure 1 As shown, the following steps are included: step S110, dividing the SAR image to be detected into several sub-images; step S120, using the regional classification network to classify each sub-image; step S130, screening out the sub-images whose classification results are the first category as the target detection images; wherein the first category is the non-land area class; step S140, using the detection network to perform target detection on the target detection image to obtain the ship target detection result; step S150, combining the ship target detection result of each target detection image to obtain the target detection result of the SAR image to be detected.
[0059] In view of the problem that large-scale land areas in nearshore scenes interfere with ship target detection, the present invention proposes a new ship detection method. First, the large-scene nearshore area image is divided into several sub-images, and then the sub-images are classified through a regional classification network to eliminate the influence of the land area. Finally, the detection network is used for detection, thereby improving the detection efficiency. In view of the problems that target detection in nearshore scenes is prone to missed detection, false detection, and low detection accuracy, the traditional target detection framework YOLOV3 is improved, and a rotatable detection frame is used to replace the original anchor frame, which can effectively separate the ship target from the background and improve the detection accuracy.
[0060] The present invention first introduces the overall process of the method, and then describes the two main parts of the method respectively: a region classification network based on ResNet18 and an improved target detection network based on a rotation detection frame.
[0061] The method of the present invention mainly includes two parts: a regional classification network and an improved detection network. The overall process of the method is as follows Figure 1As shown in the figure, a large SAR image containing land areas is first divided into many sub-images, and then the sub-images are classified through the regional classification network. The sub-images classified as land areas will be directly discarded, and the sub-images classified as non-land areas will be detected through the detection network. The purpose is to remove the land area by classification to reduce the impact of the land area on the detection results and reduce information redundancy. The detection network is improved by rotating the detection frame, replacing the rectangular detection frame with a more accurate rotating detection frame to improve the detection accuracy, and finally output the detection results.
[0062] The present invention can use the sliding window method to segment the large scene SAR image, that is, use a window of a certain size to slide on the image with a certain step size, the size of the window and the size of the step size can be arbitrarily set according to different specific circumstances, for example, when the distribution of land areas is relatively dispersed, a smaller sliding window and step size can be used, and when the distribution of land areas is relatively concentrated, a larger sliding window and step size can be used.
[0063] After the sub-images are classified using the regional classification network, the classification results will be sent to the detection network for further detection. The quality of the classification results will directly affect the final detection effect, so the higher the accuracy of the regional classification network, the better. At the same time, the regional classification network should be lightweight and process images quickly enough to avoid the classification part taking up too much time and thus affecting the overall speed of the algorithm. Therefore, the regional classification network design should not be too complicated, and the faster the processing speed, the better.
[0064] After trying a variety of classic convolutional neural networks (such as LeNet, AlexNet, VggNet, ResNet), the present invention finally selected ResNet18 as the basic structure of the regional classification network.
[0065] The biggest feature of ResNet is that it introduces a residual structure to overcome the degradation of the network. With the help of the residual structure, ResNet allows the network to be as deep as possible, so that the performance of the network will no longer decrease with the increase of depth.
[0066] ResNet is composed of a series of residual blocks. The residual structure is the basic structure of ResNet. The basic structure of the residual block is as follows Figure 2 As shown, the residual structure can be divided into two parts, the direct mapping part (identity mapping) and the residual part (residual mapping). The direct mapping part corresponds to Figure 2 The right side of the curve, the residual part corresponds to the upper Figure 2 The left side contains the convolution part. This connection method is called shortcut connection. A residual structure can be expressed as:
[0067] y=F(x,w)+x (1)
[0068] Among them, y is the output of the residual block, F(x,w) corresponds to the residual part, and w is the weight of the network, which is equivalent to Figure 2 In the weight layer, x corresponds to the direct mapping part.
[0069] In this invention, considering the classification accuracy and speed, the regional classification network adopts the basic structure of ResNet18 with a relatively simple structure. Its specific structure is as follows: Figure 3 As shown in the figure, the network can be divided into three main parts: input part, intermediate convolution part, and output part. ResNet18 contains a total of 18 convolution layers. The difference between it and other Res series networks lies mainly in the intermediate convolution part, and the other parts are similar. The flow of data in the regional classification network is roughly as follows:
[0070] (1) After entering the network, it first passes through the input part, which includes a 7*7 convolution layer (7*7conv) and a maximum pooling layer (max pool); (2) It then enters the intermediate convolution part for feature extraction, which includes various residual structures in the middle;
[0071] (3) Finally, the data is output through the output part to obtain the result, which includes the average pooling layer (avgpool) and the fully connected layer (FC).
[0072] Specifically, in this embodiment, the SAR image is divided into several sub-images of 416*416 size. Since the input size of the ResNet18 network is fixed and a 416*416 image cannot be directly input, the sub-image is converted into a 224*224 image. It is sent to the input part of the regional classification network. The network input part contains a large convolution kernel of size 7*7 and a step size of 2, and a maximum pooling layer of size 3*3 and a step size of 2. Through this step, a 224*224 input image will be converted into a feature map of size 56*56, which can greatly reduce the required storage size.
[0073] The middle convolution part extracts information by stacking the residual structure. The residual structure is as follows Figure 2 As shown in the figure, the input data is divided into two parts, one part passes through two convolutions, and the other part is directly short-circuited. The two are added and directly output after passing through the relu function. If the dimensions are inconsistent, the dimensions need to be converted through 1*1 convolution, such as Figure 3 Shown by dotted line.
[0074] The output part of the network is very simple. Through global average pooling, the size of the feature map is converted. Specifically, the 512*7*7 input data is converted to 512*1*1, and finally connected to the fully connected layer output. The number of output nodes is set to 2.
[0075] In this way, the process of classifying the sub-image scenes is completed, and each sub-image is divided into two types: land area class and non-land area class. The non-land area class does not only include water area sub-images, but also includes land and water area combined sub-images. Next, ship targets need to be identified for each non-land area sub-image.
[0076] In the present invention, a detection network is used to detect non-land sub-images, and the detection network is designed based on a rotation detection frame. The method of the present invention effectively detects rotating targets and improves the problem of missed detection and false detection of targets in densely arranged conditions to a certain extent. Figure 4 As shown, in the prior art, the horizontal candidate box (i.e. Figure 4 The size and aspect ratio of the rectangular detection box in a cannot reflect the true shape of the target, and the target and background pixels are not effectively separated. It is even more difficult to separate dense objects (such as a large number of ships in the nearshore area). Figure 4 The rotating detection box in (b) improves these problems. On the one hand, the length and width of the target in the SAR image are relatively large, and the rotating rectangular box more accurately expresses the target information. On the other hand, there is no overlapping area between adjacent targets, and the extracted target features are more accurate, which can better segment the ship target from the dock, the ship target from the reef, etc.
[0077] YOLOV3 is a one-stage target detection algorithm. While ensuring detection accuracy, the detection speed is also very fast, and the real-time detection effect is good. It is widely used in the industry. The detection network proposed in the present invention is an improvement based on YOLOV3. On this basis, angle information is introduced and the original rectangular detection frame is replaced by a rotating detection frame, which can improve the detection effect. The detection network is introduced from the following aspects.
[0078] The basic structure of the detection network is as follows: Figure 5 As shown, the detection network includes:
[0079] (1) Feature extraction part, that is, extracting feature maps from target detection images.
[0080] For an input image, it first needs to be converted to 416*416*3 size, and then sent to the network for feature extraction. In the present invention, when performing sub-image segmentation, each sub-image has been segmented into this size, which meets the requirements. The feature extraction part of the detection network adopts the basic structure of the Darknet-53 network, such as Figure 5 As shown in the dashed box, in this embodiment, the last fully connected layer of Darknet-53 is removed, and the first 52 layers are used for feature extraction to obtain the feature layers in the middle layer, the lower-middle layer, and the bottom layer.
[0081] like Figure 5 As shown in the lower left corner, the DBL module is the basic unit of Darknet-53 and the detection network. This unit first performs a convolution on the input data, and then performs Batch Normalization and Leaky ReLU operations. The res unit module borrows the basic structure of the residual module. The input data is directly added to the original data by channel after feature extraction through the residual part, but the residual part does not directly use the convolution layer, but is replaced by the DBL module. The resn module is the basic module that constitutes the Darknet53 network. This module first fills the input data with 0, and then passes it through the DBL module and n res unit modules in sequence.
[0082] Therefore, the input image of size 416*416*3 passes through the DBL module, res1 module, res2 module, and res8 module in turn to obtain the first feature layer, then passes through the res8 module to obtain the second feature layer, and finally passes through the res4 module to obtain the third feature layer. After feature extraction, a total of three feature layers of different sizes are obtained.
[0083] (2) Obtain prediction results from the feature map and determine the prediction results of the target detection image based on the feature map.
[0084] The process of obtaining prediction results from feature maps can be divided into two parts: feature combination and using YOLOhead to obtain prediction results.
[0085] a) Feature combination part:
[0086] In the feature extraction part, the detection network extracts a total of three feature layers of different sizes. These three feature layers are located in different positions of the feature extraction network Darknet53, namely the middle layer, the lower middle layer, and the bottom layer. The sizes of the three feature layers are (52,52,256), (26,26,512), and (13,13,1024). After obtaining the three feature layers, these three feature layers are used for further combination of feature layers. The upsampling and fusion method similar to FPN (feature pyramid networks) is adopted to perform detection at different scales. The specific construction method is as follows:
[0087] The 13*13*1024 bottom feature layer is first processed by DBL 5 times. After the processing, Yolo Head is used to obtain the first prediction result. On the other hand, DBL processing and upsampling are performed and then spliced with the 26*26*512 feature layer. The size of the fused feature layer is (26, 26, 768); the fused feature layer is processed by DBL 5 times again. After the processing, YoloHead is used to obtain the second prediction result. On the other hand, DBL processing and upsampling are performed and then spliced with the 52*52*256 feature layer. The size of the fused feature layer is (52, 52, 384); the fused feature layer is processed by DBL 5 times again. After the processing, Yolo Head is directly used to obtain the third prediction result.
[0088] b) Use YOLO head to obtain prediction results:
[0089] After feature combination, three enhanced feature layers can be obtained. The sizes of these three enhanced feature layers are (13, 13, 512), (26, 26, 256) and (52, 52, 128) respectively. Then these three feature layers of different sizes are passed into the YOLO head to obtain the prediction results.
[0090] Yolo Head is essentially a 3*3 convolution and a 1*1 convolution. The 3*3 convolution is used for feature integration, and the 1*1 convolution is used for channel conversion. After YOLO head, the three output feature maps with sizes of (13,13,21), (26,26,21), and (52,52,21) are obtained.
[0091] Input N 416*416*3 images (i.e., sub-images) into the detection network. After multiple layers of calculations, three data of sizes (N, 13, 13, 21), (N, 26, 26, 21), and (N, 52, 52, 21) are finally output. That is, the first prediction result, the second prediction result, and the third prediction result are combined to obtain the prediction result.
[0092] For example, a set of data sizes obtained from a sub-image is (1,13,13,21), (1,26,26,21) and (1,52,52,21). When inputting, N sub-images are input into the network together, so the data sizes obtained are (N,13,13,21), (N,26,26,21) and (N,52,52,21). Next, these data need to be decoded.
[0093] (3) Decoding of prediction results, that is, decoding the prediction results.
[0094] In fact, the physical meaning of the feature layer finally output by the detection network is to divide the entire image into grids corresponding to their length and width. For example, the feature layer of (N, 26, 26, 21) means to divide the entire image into 26*26 grids, and then use the prior boxes established for each grid to make predictions. The prediction results of the grids will output information such as whether these prior boxes contain objects and the type of the object.
[0095] The detection network pre-sets three prior frames for each grid, and the prediction result should include seven parameters, including the center (x, y) coordinate adjustment parameters (i.e. horizontal and vertical coordinates) of the detection frame, width and height adjustment parameters, angle adjustment parameters, confidence, and classification results. These parameters are all parameters of the detection frame, among which the first five parameters are relative parameters, which are the parameters of the prior frame relative to the detection frame.
[0096] For example, the first one is to add the center coordinates of the prior frame to the center coordinate adjustment parameters (x, y) to obtain the coordinate parameters of the detection frame. The others are similar to this method. The specific formulas are the following formulas (3), (4), (5), (6), and (7). The parameters of the prior frame are all known. After the network predicts the adjustment parameters, the corresponding calculations are performed to obtain the parameters of the detection frame. Finally, the confidence is the probability that the predicted frame is the target. The classification result is to determine which category the target belongs to. In this embodiment, there is only one category, namely the ship category. Because there are three prior frames, the final number of channels is 3*7=21.
[0097] The output feature map sizes are (N, 13, 13, 21), (N, 26, 26, 21) and (N, 52, 52, 21), and the number of channels in the last dimension is 21. Taking the first one as an example, N is the number of images, 13 and 13 are the width and height of the feature map, which is equivalent to dividing the image into 13*13 grids, each grid is a point on the feature map, and 21 is the number of channels, which is equivalent to 21 parameters for this point, and 7 parameters for one prior box. These 21 numbers are the parameters of 3 prior boxes arranged together. The existing YOLOV3 does not have angle adjustment parameters, that is, 6 parameters, a total of 3*6 is 18 parameters, and after improvement it is 3*7 with a total of 21 parameters, so the number of channels is designed to be 21.
[0098] From step (2), we can get the prediction results of three feature layers, the sizes are: (N, 13, 13, 21), (N, 26, 26, 21) and (N, 52, 52, 21), and their shapes are converted to (N, 13, 13, 3, 7), (N, 26, 26, 3, 7) and (N, 52, 52, 3, 7). Because we get the adjustment parameters, we need to do the following to get the final result: Figure 6 The operation shown can be specifically expressed by the following relationship (the above parameters are all relative parameters, which are converted into absolute parameters here, namely the position of the center coordinates of the detection box on the sub-image, the width, height and angle of the detection box, etc.):
[0099] b x =σ(t x )+C x (2)
[0100] b y =σ(t y )+C y (3)
[0101]
[0102]
[0103] b θ =t θ +P θ (6)
[0104] Among them, b x is the center x coordinate of the prediction box (i.e. the horizontal coordinate of the sub-image), b y is the center y coordinate of the prediction box, and b w is the width of the prediction box, b h is the height of the prediction box, b θ is the rotation angle of the prediction box, C x is the distance in the x direction between the grid where the prior box (the prediction box in this embodiment is the detection box, and each grid has three prior boxes, which are responsible for detecting the target in the grid. The network directly outputs the adjustment parameters of the prior box relative to the detection box. The parameters of the detection box can only be obtained after conversion) and the origin of the coordinate system. y is the distance in the y direction between the grid where the prior box is located and the origin of the coordinate system, P w is the width of the prior box, P h is the height of the prior box, P θ is the rotation angle of the prior frame, t x ,t y ,t w ,t h and tθ They are the adjustment parameters of the detection network output respectively, and finally the final detection result is obtained through non-maximum suppression and confidence screening.
[0105] In this embodiment, YOLOV3 designs three sets of prior frames of different sizes for the three feature layers of different sizes finally obtained, and the detection network makes some adjustments to the size of the prior frames based on the characteristics of the data set.
[0106] There are three feature layers, and the corresponding receptive field of each feature layer is different. The 13*13 feature map (32 times downsampling) has the largest receptive field and is suitable for detecting larger targets. The sizes of the prior boxes are designed to be (58,45), (78,89) and (186,163). The 26*26 feature map (16 times downsampling) is suitable for detecting targets of average size, and the sizes of the prior boxes are (20,41), (42,25) and (30,56). The 52*52 feature map (8 times downsampling) has the smallest receptive field and is suitable for detecting small targets. The sizes of the prior boxes are designed to be (10,13), (16,30) and (33,23). Therefore, when the input size is 416*416, there are actually a total of (52*52+26*26+13*13)*3=10647 prediction boxes.
[0107] like Figure 7 As shown, the angle between the long side of the detection frame and the y-axis is defined as the rotation angle θ of the detection frame, and the range of θ is [0, π) (the angle is in radians).
[0108] like Figure 8 As shown in the figure, the detection network adds angle information to the prior box. The prior box with added angle information is expressed as (short side, long side, angle). The 9 prior boxes are as follows: (45, 58, π / 2), (78, 89, 0), (163, 186, π / 2); (20, 41, 0), (25, 42, π / 2), (30, 56, 0); (10, 13, 0), (16, 30, 0), (23, 33, π / 2).
[0109] In the detection network of the present invention, the loss function is designed based on the loss function of YOLOV3, which can be divided into three parts: position loss, confidence loss and classification loss. The loss function of the detection network in the present invention adds angle loss on this basis. It is expressed as follows:
[0110] loss=λ1L loc (x,y,w,h)+λ2L conf (C)+λ3L cla (P)+λ4L ang (θ) (7)
[0111] Among them, loss is the loss function of the detection network, L loc (x, y, w, h) is the position loss function, L conf (C) is the confidence loss function, L cla (P) is the cross loss function, L ang (θ) is the angle loss function, λ1, λ2, λ3 and λ4 are all hyperparameters, which are all pre-set, and their sum is 1, which is used to weight the losses of each part. x, y, w, h and θ are the adjustment parameters directly output by the network, C and P are the confidence and classification results respectively, C represents the probability of being the target, and its value is between 0 and 1. The larger the probability of being the target, the larger the value. P is the classification result, there is only one category here, and it is always 1.
[0112] Regarding position loss, it refers to the loss caused by the difference between the center coordinates, width and height of the predicted box and the real box. It contains three parts. The first two items represent the difference loss of the center coordinates, and the third item represents the difference loss of the width and height. The formula is as follows:
[0113]
[0114] Among them, (2-w i *h i ) is a factor introduced to improve the detection effect of small targets, w i and h i All coefficients are normalized to (0,1]. The larger the target, the higher the w i and h i The closer it is to 1, the smaller the value of the coefficient is, the smaller the target is, and the greater the weight it occupies. is a binary coefficient. According to the IoU (i.e., the ratio of the intersection area of two detection frames to the union area) between the prior frame and the target, the prior frame can be divided into positive samples (containing the target) and negative samples (excluding the target). If the prior frame is a positive sample, then Take 1, otherwise take 0, so the position loss is only for positive samples. The cross entropy loss function is used for the difference in center coordinates, and the square loss function is used for the difference in width and height. In the above formula, x, y, w′, h′ are the true values (labels). are the network prediction results respectively.
[0115] Regarding the confidence loss, it is the loss caused by the difference between the confidence of the predicted box and the true value. If the predicted box is a positive sample, the confidence is 1, otherwise it is 0. Therefore, it contains two parts of loss. The first term is the confidence loss of the predicted box containing the target, and the second term is the confidence loss of the predicted box without the target. Both use the cross entropy loss function. The specific formula is as follows:
[0116]
[0117] The first part on the right side of the equation is the loss of the box with the target, and the second part is the loss of the box without the target, because the network may predict the box with the target as without the target, or may predict the box without the target as with the target, so the loss has two parts. The C value is 1, which means there is a target, the coefficient of the first term is 1, and the coefficient of the second term is 0; the C value is 0, which means there is no target, the coefficient of the first term is 0, and the coefficient of the second term is 1.
[0118] The classification loss is caused by the difference between the predicted box and the target. In this embodiment, the target category is only one ship, and the calculation is relatively simple. The classification loss is only for positive samples, and the cross entropy loss function is used. The specific formula is as follows:
[0119]
[0120] Among them, c is the category, because there is only one category, so P(c) represents the probability that the target is a ship.
[0121] In this embodiment, the detection box in the detection network is a rotated detection box, and the parameters of the rotated detection box include its rotation parameters relative to the target detection image to be detected. The angle loss is caused by the angle difference between the predicted box and the target. The angle loss is only for positive samples and uses a square loss function. The form is similar to the width and height loss. Coefficients are also introduced for small targets. The specific formula is as follows:
[0122]
[0123] in, is a binary coefficient (i.e., represents the jth prior box of the i-th grid), w i and h i are all coefficients normalized to (0,1], K is the size of the feature map, i is the ordinal number of the grid in the feature map, and j is the ordinal number of the prior box of the grid in the feature map. For example, for a 13*13 feature map, the K value is 13, and for a 26*26 feature map, the K value is 26; the M value is 2, and the values of j correspond to 3 prior boxes. θ i is the true value of the angle adjustment parameter, is the predicted value of the angle adjustment parameter. In this way, the target detection result of each sub-image can be obtained through the above detection network.
[0124] In the present invention, experiments are also conducted and the experimental results are analyzed. In the following content, the data sets used by the regional classification network and the detection network are first introduced, and then the experimental results and experimental analysis of the regional classification network and the detection network are described respectively. Finally, the method is analyzed as a whole by combining the regional classification network and the improved detection network, and the effect of the detection method is explained by comparison. The method used to compare with the method of the present invention is to directly input the image into the detection network (YOLOV3) before the improvement for comparison.
[0125] The datasets used for regional classification network training and testing are AIR-SAR-Ship1.0. The images in this dataset are all from the Gaofen-3 satellite. There are 31 large scene images in total, with image resolutions of 1m and 3m, 30 images with a size of 3000*3000 pixels, and 1 image with a size of 4140*4140 pixels. The polarization mode used is single polarization, the imaging modes include strip and beam, and the image type is Tiff. The dataset information is shown in the following table:
[0126] Table 1 Dataset information
[0127]
[0128] The annotation format of the AIR-SARShip-1.0 dataset is the PASCAL VOC dataset annotation format, and the label file is saved in XML format.
[0129] This dataset not only contains a lot of ship information, but also contains relevant information such as nearshore waters, ports, and land.
[0130] The datasets used in the detection network training and testing are some images in the self-annotated AIR-SAR-Ship1.0 dataset and the SSDD+ dataset. The content of the AIR-SAR-Ship1.0 dataset has been explained above.
[0131] The SSDD+ dataset adds the annotation of rotation detection boxes based on the SSDD dataset, and other conditions are exactly the same as the SSDD dataset.
[0132] The SSDD dataset is the first publicly available dataset for ship target detection in SAR images. The SSDD dataset is constructed in the same format as the PASCAL VOC dataset, and is divided into training, test, and validation sets in a ratio of 7:2:1. The SSDD dataset tries to include a variety of imaging conditions, such as different sizes, resolutions, sensor types, and sea conditions, to ensure that the trained detection model has better robustness.
[0133] The SSDD dataset contains a total of 1,160 images, with a total of 2,456 ships, with an average of 2.12 ships in each image. The number of samples can be increased and the dataset can be expanded according to task requirements.
[0134] The images in the AIR-SAR-Ship1.0 dataset are divided into training and test sets at a ratio of about 2:1. 21 images are used as training sets, and the remaining 10 images are used as test sets. The images in the AIR-SAR-Ship1.0 dataset are all large scene images, including both land and ocean areas. The number of images is also small, with only 31 scenes. To this end, it is first necessary to divide the 3000*3000 pixel image into multiple 416*416 pixel sub-images, manually annotate the sub-images, and select a part of the sub-images for training and testing. The division into 416*416 pixels can facilitate subsequent classification and detection. In the annotation process, images containing only ocean areas are non-land area images, and images containing only land areas and images containing both land and ocean areas are all land area images. The annotated sub-images are divided into two categories, one is land area and the other is non-land area. The non-land area includes the sea-land boundary area and the ocean area.
[0135] Since the number of samples in the dataset is too small, data enhancement is required. The enhancement methods used in this experiment are mainly flipping and rotation, including 90° clockwise rotation, 180° clockwise rotation, 270° clockwise rotation, horizontal flipping, and vertical flipping. A total of five enhancement methods are used.
[0136] After data enhancement, the number of images in the dataset has expanded to 6 times the original number. The training set contains 1050 images, including 384 land area images and 666 non-land area images. The test set contains 564 images, including 234 land area images and 330 non-land area images.
[0137] The prepared training set is used to train the regional classification network. The loss function used is the cross entropy loss function, and the optimization algorithm used is the Adam optimization algorithm. The model is trained for a total of 100 rounds, and each round uses all the training set images for training. The changes in the loss function on the validation set during the training process are shown in the figure below. Fig. 9 The results on the test set are shown in Table 2 below:
[0138] Table 2 Test set results
[0139] Accuracy Number of misjudgments in land areas Number of false positives in non-land areas Run time 96.45% 10 / 234 10 / 330 9.24s
[0140] The model has a high accuracy rate on the test set, which can eventually reach 96.45%. Using a GTX 1050Ti graphics card, it takes a total of 9.24 seconds from loading the model to completing the processing of the test set images. The processing speed is not too slow while ensuring accuracy, and the overall effect of the model is good.
[0141] Next, we will test the network experimental results and analyze them. The environment is Windows 10 system and Pytorch deep learning framework. The computer configuration is i5-8300H, 2.30GHz, 8Gb memory, NVIDIA GEFORCE GTX1050Ti, 4Gb video memory. The training and testing of the algorithm are completed using GPU acceleration.
[0142] The datasets used in the experiment are some self-annotated images in the SSDD+ dataset and the AIR-SAR-Ship1.0 dataset. The specific details of the datasets are as follows:
[0143] Table 3 Dataset
[0144] category Number of pictures Number of ships Training set 1000 1678 Test Set 200 808
[0145] The confidence of the detection algorithm before and after the improvement is greater than 0.1, and the IoU with the target is greater than 0.4, which is considered a correct detection. The PR curve drawn under this condition is as follows Fig.10 The solid line shows the PR curve of the detection algorithm before improvement, and the dotted line shows the PR curve of the detection algorithm after improvement. The calculation method of the VOC2010 data set is used for calculation. The mAP of the detection algorithm before improvement is 52.79%, and the mAP of the algorithm after improvement is 56.16%, and the accuracy is improved by about 4%. According to the above content, the improved detection method does have a certain improvement in accuracy, indicating that adding angle information can improve the accuracy to a certain extent.
[0146] like Fig.11 As shown in the figure, it is an example of the detection effect of the detection algorithm before and after the improvement. It can be seen that the algorithm before the improvement did not detect the ship close to the dock in the lower left corner of the picture, but the improved algorithm detected the ship more accurately, indicating that the improved detection algorithm has a certain effect.
[0147] The following Table 4 shows the detection status of the detection algorithm before and after the improvement when the confidence level is greater than 0.5 and the IoU with the target is greater than 0.4, which is considered to be a correct detection.
[0148] Table 4 Detection status of detection algorithm before and after improvement
[0149] category Checking for the correct number of ships Total number of ships detected Total number of ships in the test set Algorithm before improvement 467 718 808 Improved algorithm 501 840 808
[0150] It can be seen from the above table that the improved algorithm detects more correct ships than the algorithm before the improvement.
[0151] In addition, the experiment uses the detection network before improvement to detect directly after segmenting the image as a comparative experiment. The method of the present invention first allows the image to be classified through the regional classification network, and then the results are obtained through the improved detection network after classification. The same experimental environment, the software environment is Windows 10 system and Pytorch deep learning framework, the computer configuration is i5-8300H, 2.30GHz, 8Gb memory, NVIDIA GEFORCE GTX1050Ti, 4Gb video memory, and the tests of both methods are completed using GPU acceleration.
[0152] From the 10 images in the AIR-SAR-Ship1.0 test set, 5 images with a large number of ships were selected for testing. After being segmented into sub-images, the rotation detection frames were manually annotated according to the corresponding rectangular detection frame annotation files. A total of 245 sub-images were obtained, including 42 land area images, 203 non-land area images, and 61 images with ships, containing a total of 93 ships. The specific situation is shown in the following table:
[0153] Table 5 Dataset situation
[0154] Number of pictures Number of land area images Number of non-land area images Number of ships 245 42 203 93
[0155] The data set was used for experiments. For both methods, the confidence level was greater than 0.5, and the IoU with the target was greater than 0.4, which was considered a correct detection. The experimental results are as follows:
[0156] Table 6 Experimental results
[0157]
[0158] According to the above table, it can be found that the accuracy of the method proposed by the present invention is higher than that of the comparison method, and the false detection rate is lower than that of the comparison method. Using F1-score for evaluation, the Precision of the method proposed by the present invention is 0.284, Recall is 0.316, and F1-score is 0.355, and the Precision of the comparison algorithm is 0.290, Recall is 0.181, and F1-score is 0.223. The method proposed by the present invention is better than the comparison method.
[0159] However, the running time is different from the expected result. The algorithm proposed by the present invention is slower. It is speculated that there are too few land area pictures and the classification part takes too much time. Subsequently, 5 pictures with more land areas were added for experiment. The final results are as follows:
[0160] Table 7 Experimental results
[0161]
[0162] As shown in the table above, the experimental results after adding 5 scenes of pictures show that the method of the present invention not only has a higher F1-score, but also has a faster computing speed.
[0163] In summary, the present invention introduces a pre-region classification network to detect ship targets in the nearshore area. In view of the information redundancy problem existing in detection, the improved target detection method of the present invention speeds up the detection speed. Compared with the general detection method, the method proposed in the present invention includes a pre-region classification network for classifying images. The network adopts the basic structure of the ResNet18 network and is trained using the AIR-SAR-Ship1.0 data set enhanced by manual segmentation and annotation. For a large-scene SAR image, it is first segmented into many sub-images. After passing through the regional classification network, the sub-images are divided into two categories: land areas and non-land areas (including sea-land boundary areas and ocean areas). Only sub-images judged as non-land areas will be further detected by the detection network. Experiments show that this method can effectively speed up the detection speed, and the larger the land scene, the more obvious the improvement.
[0164] In addition, the present invention introduces a rotating detection frame into the YOLOV3 network to improve the detection accuracy. In view of the problem that ship targets have similar imaging features to ports, islands and reefs, and are densely arranged and difficult to distinguish, the present invention improves the existing detection framework YOLOV3 and replaces the original detection frame with a rotating detection frame, thereby overcoming the problem that the rectangular frame background and the target cannot be effectively separated, and improving the detection accuracy. The improved method adds the angle information of the ship, and makes corresponding improvements to the prior frame part and the loss function part of YOLOV3. Tests were conducted on the self-annotated dataset and the SSDD+ dataset, and the experimental results show that this method can effectively improve the detection accuracy.
[0165] The present invention also discloses a ship detection device in a nearshore water area based on deep learning, such as Fig.12 The system shown includes: a segmentation module 210, used for segmenting the SAR image to be detected into a plurality of sub-images; a classification module 220, used for classifying each sub-image using a regional classification network; a screening module 230, used for screening out sub-images whose classification results are the first category as target detection images; wherein the first category is the non-land area class; a target detection module 240, used for performing target detection on the target detection image using a detection network to obtain a ship target detection result; and a combining module 250, used for combining the ship target detection results of each target detection image to obtain a ship target detection result of the SAR image to be detected.
[0166] It should be noted that the information interaction, execution process and other contents between the modules of the above-mentioned device are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0167] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. The functional modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0168] The present invention also discloses a nearshore water area ship detection device based on deep learning, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the above-mentioned nearshore water area ship detection method based on deep learning is implemented.
[0169] The device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that the device may include more or fewer components, or a combination of certain components, or different components, such as an input / output device, a network access device, etc.
[0170] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0171] In some embodiments, the memory may be an internal storage unit of the device, such as a hard disk or memory of the device. In other embodiments, the memory may also be an external storage device of the device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the device. Further, the memory may also include both an internal storage unit of the device and an external storage device. The memory is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program, etc. The memory may also be used to temporarily store data that has been output or is to be output.
[0172] In the above embodiments, the description of each embodiment has its own emphasis. For the parts that are not described or recorded in detail in a certain embodiment, please refer to the relevant description of other embodiments. Those of ordinary skill in the art can appreciate that the modules and algorithm steps of each example described in conjunction with the embodiments disclosed in the present invention can be implemented with electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
Claims
1. A method for detecting ships in nearshore waters based on deep learning, characterized in that: The following steps are involved: Divide the SAR image to be detected into several sub-images; classifying each of the sub-images using a region classification network; Filter out sub-images whose classification results are the first category as target detection images; wherein the first category is a non-land area class; Using a detection network to perform target detection on the target detection image to obtain a ship target detection result; Combining the ship target detection result of each of the target detection images, obtaining the ship target detection result of the SAR image to be detected; The loss function of the detection network is: loss=λ1L loc (x,y,w,h)+λ2L conf (C)+λ3L cla (P)+λ4L ang (i), Among them, loss is the loss function of the detection network, L loc (x, y, w, h) is the position loss function, L conf (C) is the confidence loss function, L cla (P) is the cross loss function, L ang (θ) is the angle loss function, is a binary coefficient, w i and h i are all coefficients normalized to (0,1], K is the size of the feature map, i is the ordinal number of the grid in the feature map, j is the ordinal number of the prior box of the grid in the feature map, θ i is the true value of the angle adjustment parameter, is the predicted value of the angle adjustment parameter, The detection frame in the detection network is a rotation detection frame, and the parameters of the rotation detection frame include its rotation parameters relative to the target detection image to be detected.
2. A method for detecting ships in a nearshore water area based on deep learning as claimed in claim 1, characterized in that: Using a detection network to perform target detection on the target detection image includes: Extracting a feature map from the target detection image; Determining a prediction result of the target detection image according to the feature map; The prediction result is decoded to obtain a ship target detection result of the target detection image.
3. A method for detecting ships in nearshore waters based on deep learning as claimed in claim 2, characterized in that: Extracting a feature map from the target detection image includes: The Darknet-53 network with the last fully connected layer deleted is used to extract the feature map of the target detection image, and the feature layers at the middle layer, the lower-middle layer and the bottom layer are obtained.
4. A method for detecting ships in nearshore waters based on deep learning as claimed in claim 3, characterized in that: Determining a prediction result of the target detection image according to the feature map includes: Performing DBL processing on the underlying feature layer 5 times and obtaining a first prediction result; The processed bottom feature layer is concatenated with the upsampled middle and lower feature layers to obtain a first fused feature layer; Performing DBL processing on the first fused feature layer five times to obtain a second prediction result; The processed first fused feature layer is concatenated with the upsampled intermediate feature layer to obtain a second fused feature layer; Performing DBL processing on the second fused feature layer five times to obtain a third prediction result; The first prediction result, the second prediction result and the third prediction result are combined to obtain the prediction result.
5. The method for detecting ships in nearshore waters based on deep learning as claimed in claim 1, characterized in that: The region classification network includes an input part, an intermediate convolution part and an output part; The input part includes a 7*7 convolution layer and a maximum pooling layer; the convolution layer step size is 2, and the maximum pooling layer step size is 2; The intermediate convolution part divides the data input by the input part into two parts, one part passes through two convolution layers and the other part is directly short-circuited, the results of the two parts are added and output to the output part through the relu function; the output part includes an average pooling layer and a fully connected layer; the number of output nodes of the output part is 2.
6. A method for detecting ships in nearshore waters based on deep learning as claimed in claim 1 or 5, characterized in that: The non-land area class includes a water area class and a combination class; the combination class is a category that combines water area and land.
7. A ship detection device in nearshore water area based on deep learning, characterized in that: include: A segmentation module is used to segment the SAR image to be detected into a number of sub-images; A classification module, used for classifying each of the sub-images using a region classification network; A screening module, used to screen out sub-images whose classification results are a first category as target detection images; wherein the first category is a non-land area class; A target detection module is used to perform target detection on the target detection image using a detection network to obtain a ship target detection result; A combining module, used for combining the ship target detection results of each of the target detection images to obtain the ship target detection result of the SAR image to be detected; The loss function of the detection network is: loss=λ1L loc (x,y,w,h)+λ2L conf (C)+λ3L cla (P)+λ4L ang (i), Among them, loss is the loss function of the detection network, L loc (x, y, w, h) is the position loss function, L conf (C) is the confidence loss function, L cla (P) is the cross loss function, L ang (θ) is the angle loss function, is a binary coefficient, w i and h i are all coefficients normalized to (0,1], K is the size of the feature map, i is the ordinal number of the grid in the feature map, j is the ordinal number of the prior box of the grid in the feature map, θ i is the true value of the angle adjustment parameter, is the predicted value of the angle adjustment parameter, The detection frame in the detection network is a rotation detection frame, and the parameters of the rotation detection frame include its rotation parameters relative to the target detection image to be detected.
8. A ship detection device for nearshore waters based on deep learning, characterized in that: It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, it implements a nearshore water area ship detection method based on deep learning as described in any one of claims 1 to 6.
