A training method for aerial image recognition model of small targets at sea in foggy scenes
By fogging the small target data set at sea and introducing the small target detection layer and NWD loss function into the YOLOv5 model, the problem of low accuracy and scarce data sets in small target detection at sea under foggy weather conditions was solved, and the model's performance was improved. Robustness and generalization capabilities enable more efficient detection performance in foggy scenes.
Patent Information
- Application Number
- CN202410078638.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-19
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2044-01-19
AI Technical Summary
Existing maritime small target detection models perform poorly under foggy weather conditions. Data sets are scarce, detection accuracy is low, and it is difficult to learn features under different haze conditions, resulting in insufficient model generalization capabilities.
By fogging the original maritime small target aerial photography data set, a data set under foggy weather scenes was established. The small target detection layer and NWD loss function were introduced into the YOLOv5 model, and the WIOU and Wasserstein distances were combined for model tuning and network optimization. structure to improve detection accuracy.
It improves the robustness and generalization ability of the model, enhances the detection ability of small targets at sea in foggy scenes, and improves the detection accuracy and stability of the model.
Smart Images

Figure CN117893879B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of aerial image recognition, and in particular relates to a method for training a model for aerial image recognition of small targets at sea in a foggy scene. Background Art
[0002] In recent years, with the development of target detection technology, the problem of small target detection at sea has attracted more and more attention. Small target detection and recognition technology based on marine aerial images has broad application prospects in the fields of marine emergency rescue, reconnaissance, environmental monitoring, etc. In the problem of small target detection at sea, with the continuous development of deep learning and target detection, the trained model can more accurately detect and recognize some small targets in marine images, such as ships, personnel, life buoys, etc.
[0003] Although existing research has made some progress in the accuracy of target detection and recognition in marine aerial images, there are still some potential problems that have not been solved. First, due to the small size of small targets in the image, they are often easily ignored or misjudged by the model. This is because the features of small targets are often sparsely represented in larger grids, making it difficult for the model to accurately detect them. Therefore, one of the major goals of our research is to solve how to perform more fine-grained feature extraction in smaller grids to enhance the perception of small targets, while minimizing the computational complexity and parameter volume of the model. Secondly, the existing target detection loss function mostly uses CIOU. Although this design can be simple and intuitive, it is less affected by scale and position. However, there are three problems for small target detection: 1. Gradient vanishing problem: During the training process, due to the small scale of small targets, the distance between their bounding box and the true bounding box is small, resulting in gradient vanishing. This makes it difficult for the network to learn the feature information of small targets, thereby affecting the detection performance. 2. False detection and missed detection: Due to the small size of small targets, they are easily confused with the background, resulting in false detection and missed detection. The existing CIOU loss function does not accurately estimate the target confidence when dealing with small targets, thus affecting the detection accuracy. Finally, the research on the problem of small target detection at sea relies on a large number of small target image datasets at sea. However, there are relatively few small target datasets at sea available, and most of them are taken under relatively ideal weather conditions. This causes the trained model to perform poorly in hazy weather conditions or low contrast conditions. The trained model has certain limitations, making it difficult to improve the generalization ability of the model, and it is unable to better learn the characteristics and performance of the target under different haze conditions, and falls into a local optimal situation.
[0004] Yolov5 is a target detection model based on deep learning with high accuracy. It uses a detection method called "one-stage", which can simultaneously locate and classify targets in one forward propagation. Secondly, Yolov5 supports multi-scale detection and can detect targets at different scales. This is very important for the detection of small targets at sea, because small targets may only occupy a small pixel area in the image, and multi-scale detection can improve the detection ability of small targets. Finally, Yolov5 uses a wealth of data enhancement techniques during training, which can increase the robustness of the model to small targets in different scenes and lighting conditions. Therefore, the Yolov5 model is used as the basic detection model.
[0005] However, the feature extraction network used by Yolov5 may not extract enough detailed information of small targets, making it difficult to accurately capture the features of small targets. At the same time, Yolov5 uses an anchor-based detection method to predict the position and size of the target through a predefined set of anchors. The size of these anchors is usually set according to the size of general targets. For small targets, the use of anchors may produce large offset losses, resulting in reduced detection performance.
[0006] Studying how to modify the network structure of Yolov5, introduce new loss functions, and solve the problem of scarce relevant data sets is of great significance to accelerating the application of Yolov5 small target detection in the field of emergency rescue in cloudy and foggy weather at sea. Summary of the invention
[0007] The technical problem to be solved by the present invention is to address the deficiencies of the above-mentioned prior art and provide a method for training a model for aerial image recognition of small targets at sea in foggy scenes. The YOLOV5 model that integrates NWD and small target detection layers is used to train the model of small targets at sea, which solves the problems of lack of data sets, poor defogging effect and low detection accuracy in the training process of the aerial image recognition model of small targets at sea in foggy scenes, and lays a foundation for accurate, fast and stable training of aerial image detection models of small targets at sea in foggy scenes.
[0008] In order to achieve the above technical objectives, the technical solution adopted by the present invention is:
[0009] A method for training a model for recognizing aerial images of small targets at sea in foggy weather, comprising:
[0010] Step 1: Combined with the existing fog imaging model, the original aerial photography dataset of small targets at sea is fogged by changing the thickness and brightness of the fog, simulating foggy images in various scenes, and establishing an aerial photography dataset of small targets at sea in foggy scenes;
[0011] Step 2: Set up a small target detection layer based on the YOLOv5 network structure model to build a small target aerial image recognition model for the sea under foggy conditions;
[0012] Step 3: Set the target recognition model tuning parameter NWD based on WIOU and Wasserstein distance, continuously adjust the weights of WIOU and Wasserstein distance, and use the data set established in step 1 to train the target recognition model.
[0013] To optimize the above technical solutions, the specific measures taken also include:
[0014] In the above step 1, the brightness br and thickness th values to be fogged are randomly set for each image, and fogging operations of different degrees are performed on each image in the original aerial photography dataset of small targets at sea according to the set values of br and th.
[0015] The YOLOv5 network structure model described in the above step 2 includes a Backbone network, a Neck network, and a Head network; wherein the Backbone network is used to extract image features, the Neck network is used to fuse features of different levels, and the Head network is used to predict the location and category of the target.
[0016] The above step 2 modifies the Head network to add a 160×160 small object detection layer and delete the 20×20 large object detection layer.
[0017] The tuning parameters in step 3 above are NWD = ω*WIOU + (1-ω)*Wasserstein
[0018] The WIOU loss function is
[0019] L WIOU =γR WIOU L IOU
[0020]
[0021]
[0022]
[0023] L IOU =1-IOU
[0024] Among them, δ, α are hyperparameters, γ is the gradient gain, β is the outlier degree, is the dynamic average IOU value with momentum m; tn>7000, where x, y and x gt ,ygt are the center point coordinates of the predicted box and the real box, respectively, g , H g is the width and height of the real frame. For variables The constant converted into IOU is the area of the intersection of the predicted box and the real box divided by the area of the union.
[0025] The second-order Wasserstein distance is calculated as:
[0026] First, the bounding box A=(c x ,c y ,w,h), where (c x ,c y ), w, h represent the center coordinates, bounding box width and height respectively, modeled as a two-dimensional Gaussian distribution N(μ,Σ)
[0027]
[0028] Calculate the Wasserstein distance definition and normalize it. For two two-dimensional Gaussian distributions μ1 = N (m1 + Σ1) and μ2 = N (m2 + Σ2), the second-order Wasserstein distance between them is defined as
[0029]
[0030] In the formula ||·|| F is the Frobenius norm, ||·||2 is the 2-norm, represents the distance metric, m1, m2 represent the mean vector, Σ1, Σ2 represent the covariance matrix.
[0031] So for two bounding boxes A and B, where A = (cx a ,cy a ,w a ,h a ), bounding box B = (cx b ,cy b ,w b ,h b ), the two-dimensional Gaussian distribution N of the bounding box A and N b The second-order Wasserstein distance is:
[0032]
[0033] The WIOU weight mentioned above is 0.6, and the Wasserstein distance weight is 0.4.
[0034] The present invention has the following beneficial effects:
[0035] Aiming at the foggy scene at sea, the present invention uses the drone aerial photography picture set at sea as the preliminary data set, and performs fogging processing to the data set to different degrees, so that it basically conforms to the characteristics of the foggy environment at sea under random conditions. By training the fogged data set, a model that can effectively identify different foggy scenes is obtained, which increases the diversity and complexity of the data set, improves the robustness and generalization ability of the model, and solves the problems of insufficient diversity, low precision, and easy interference by fog in small target detection data.
[0036] At the same time, based on the original Yolov5 network, the detection layer network structure is partially modified for small-scale targets;
[0037] In addition, the present invention proposes a loss function that integrates the normalized Gaussian model and IOU for the target detection performance index, which integrates the NWD (Normalized Weighted Distance) and WIOU (Weighted Intersection over Union) methods, that is, the Wasserstein distance and WIOU are integrated, and different weight coefficients are set respectively, so that they are simultaneously used as new loss functions for detecting small targets. Finally, when the weight of WIOU is 0.6, the target detection task of aerial images of small targets at sea in foggy scenes achieves the best performance. While ensuring the convergence speed of model training, the model has stronger ability to detect small targets, which can improve the accuracy of small target detection at sea. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 The figure is a principle flow chart of an embodiment of the present invention.
[0039] Figure 2 This is the improved yolov5 model network architecture of the present invention.
[0040] Figure 3 This is a schematic diagram of the model parameter tuning principle of the present invention;
[0041] Figure 4 It is a flow chart of adding mist in the present invention;
[0042] Figure 5 is the Precision-Recall Curve of the original model;
[0043] Figure 6 It is the Precision-Recall Curve of the present invention. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0045] Although the steps in the present invention are arranged with numbers, they are not used to limit the order of the steps. Unless the order of the steps is clearly stated or the execution of a certain step requires other steps as a basis, the relative order of the steps can be adjusted. It is understood that the term "and / or" used in this article involves and covers any and all possible combinations of one or more of the associated listed items.
[0046] like Figure 1 The figure is a principle flow chart of an embodiment of the present invention. A method for training a model for recognizing a small target aerial image at sea in a foggy scene of the present invention comprises:
[0047] Step 1: Combined with the existing fog imaging model, the original aerial photography dataset of small targets at sea is fogged by changing the thickness and brightness of the fog, simulating foggy images in various scenes, and establishing an aerial photography dataset of small targets at sea in foggy scenes;
[0048] The fogging process is as follows Figure 4 The fogging algorithm of the dataset adopts the image synthesis fogging algorithm, that is, extracting the depth information and detail information such as the geometric structure, texture and color of the image scene, and determining the density and concentration of the fog by calculating the propagation model of the fog, simulating the fog effect and mixing the image. This method uses the fogging algorithm for all the pictures in the dataset. The parameters br and th represent the brightness and thickness of the fog to be added, respectively, and are randomly selected for each picture. In this method, the parameters br (brightness) are taken as 0.8 as the mean, 0.15 as the standard deviation, and th (thickness) is taken as 0.08 as the mean, 0.015 as the standard deviation, and each picture in the dataset is fogged to different degrees.
[0049] Step 2: Set up a small target detection layer based on the YOLOv5 network structure model to build a small target aerial image recognition model for the sea under foggy conditions;
[0050] Based on the YOLO-v5 target detection framework, a target recognition model for aerial images of small targets at sea under foggy conditions is constructed. A 160×160 detection layer is added to the YOLOv5 network structure model, and the 20×20 detection layer for large targets is deleted. The details are as follows:
[0051] Modify the yolov5 model: The structure of Yolov5 can be expressed as:
[0052] Input image -> Backbone network -> Neck network -> Head network -> Output result
[0053] Among them, the Backbone network is responsible for extracting image features, the Neck network is used to fuse features at different levels, and the Head network is responsible for predicting the location and category of the target. To add a 160×160 large target detection layer and delete the 20×20 large target detection layer, you can achieve this goal by modifying the Head network. The specific code modifications are as follows:
[0054] Anchors:
[0055] In the code before the improvement, each sublist of anchors represents the size of an anchor box, which is stored in the form of (width, height).
[0056] The code example is as follows:
[0057] Anchors:
[0058] [10,13,16,30,33,23]#P3 / 8
[0059] [30,61,62,45,59,119]#P4 / 16
[0060] [116,90,156,198,373,326]#P5 / 32
[0061] In the improved code, anchors represents the number of anchor boxes in each output layer P. The code example is as follows:
[0062] Anchor:3#AutoAnchor evolve 3anchors per P output layer
[0063] Backbone has not been modified;
[0064] Head:
[0065] The head part has been greatly improved. The P5 detection head has been deleted. The original P5 detection head code is as follows:
[0066] [-1,1,Conv,[512,3,2],
[0067] [[-1,10],1,Concat,[1]],#cat head P5
[0068] [-1,3,c3,[1024,False]],#23(P5 / 32-large)
[0069] On this basis, a P2 detection head is added. The code of the newly added P2 detection head is as follows:
[0070] [-1,1,Conv,[128,1,1]],
[0071] [-1,1,nn.Upsample,[None,2,'nearest']],
[0072] [[-1,2],1,Concat,[1]],#cat backbone P2
[0073] [-1,1,c3,[128,False]].#21(P2 / 4-xsmall)
[0074] Specific network architecture improvements include Figure 2 shown.
[0075] Step 3: Tune the parameters in the NWD-Based Model, continuously adjust the weights, and train the model using the dataset established in step 1.
[0076] Defining the metric (model tuning parameter): First, the metric needs to be defined. In this case, the present invention uses the combination of ωWIOU and (1-ω)Wasserstein distance as the metric. Where ω represents the weight of WIOU, which is 0.6, and (1-ω) is the weight of Wasserstein distance.
[0077] Step 3.1: Calculate WIOU: L WIOU =γR WIOU L IOU
[0078]
[0079]
[0080]
[0081] L IOU =1-IOU
[0082] Among them, δ, α are hyperparameters, γ is the gradient gain, β is the outlier degree, is the dynamic average IOU value with momentum m; tn>7000, where x, y and x gt ,y gt are the center point coordinates of the predicted box and the real box, respectively, g , H g is the width and height of the real frame. For variables Convert the L in β into a constant. IOU ,R WIOU W g and H g Separated from the gradient calculation (superscript * indicates this operation). Since the quality division criteria of the prediction box are also dynamic, WIOU can make the gradient gain allocation strategy that best suits the current situation at every moment.
[0083] Step 3.2: For small targets, there will always be some background pixels in the bounding box, because real objects are not rectangular in most cases. In the bounding box, foreground pixels are generally concentrated in the middle part, and background pixels are generally concentrated in the edge part. In order to better weight each pixel in the bounding box, the bounding box is modeled as a 2D Gaussian distribution.
[0084] Specifically, for the horizontal bounding box R = (cx, cy, w, h), the inscribed ellipse can be expressed as:
[0085]
[0086] Among them, (σx, σy) is the center point of the ellipse, the radius of the X and Y axes, corresponding to the bounding box, μx = cx, μy = cy, The probability density function of the 2D Gaussian distribution is:
[0087]
[0088] Where x,u,Σ represent the coordinates (x,y), mean, and variance respectively. When (x-μ) T Σ -1 (x-μ)=1
[0089] , this ellipse is a distribution outline of a 2D Gaussian distribution. Therefore, the horizontal bounding box R = (cx, cy, w, h) can be modeled as a 2D Gaussian distribution:
[0090]
[0091] In this way, the similarity between two bounding boxes can be expressed by the distance between the two Gaussian distributions. Figure 3 shown.
[0092] Step 3.3: Solve for the optimal NWD
[0093] 1). Normalized WIOU (Intersection over Union): WIOU is used to solve the BBR balance problem between samples with better quality and samples with worse quality. Normalized IOU maps the IOU value to a range between 0 and 1 for better comparison and weighting.
[0094] 2). Normalized Wasserstein distance: Wasserstein distance is a metric used to measure the difference between two probability distributions. Normalized Wasserstein distance maps the value of Wasserstein distance to a range between 0 and 1, and uses the Wasserstein distance in optimal transfer theory to calculate the distance between two distributions. For two bounding boxes, the second-order Wasserstein distance can be defined as:
[0095]
[0096] The derivation process is: first, the bounding box A = (c x ,c y ,w,h), where (c x ,c y ), w, h represent the center coordinates, bounding box width and height respectively, modeled as a two-dimensional Gaussian distribution N(μ,Σ)
[0097]
[0098] Calculate the Wasserstein distance definition and normalize it. For two two-dimensional Gaussian distributions μ1 = N (m1 + Σ1) and μ2 = N (m2 + Σ2), the second-order Wasserstein distance between them is defined as
[0099]
[0100] In the formula ||·|| F is the Frobenius norm, ||·||2 is the 2-norm, represents the distance metric, m1, m2 represent the mean vector, Σ1, Σ2 represent the covariance matrix.
[0101] So for two bounding boxes A and B, where A = (cx a ,cy a ,w a ,h a ), bounding box B = (cx b ,cy b ,w b ,h b ), the two-dimensional Gaussian distribution N of the bounding box A and N bThe second-order Wasserstein distance is:
[0102]
[0103] Normalized Wasserstein distance = (Wasserstein distance - minimum Wasserstein distance) / (maximum Wasserstein distance - minimum Wasserstein distance)
[0104] 3) Weighted summation: Perform weighted summation of the normalized WIOU and the normalized Wasserstein distance according to the weights. The weights are adjusted according to demand to better balance the impact of the two indicators.
[0105] 4).NWD (Normalized Weighted Distance): The result of weighted summation is called NWD, which comprehensively considers the normalized WIOU and the normalized Wasserstein distance and weights them according to the weights. The calculation formula of NWD is:
[0106] NWD=ω*WIOU+(1-ω)*Wasserstein
[0107] Wasserstein is the normalized second-order Wasserstein distance.
[0108] 5) Adjust the value of weight w: Through multiple iterations, try different values of weight w and bring them into the model for training. In each iteration, evaluate the performance of the model based on the results of NWD to find the weight value that optimizes the model performance.
[0109] 6). The optimal weight value w is 0.6: After multiple iterations and evaluations, it was found that when the weight w is 0.6, the yolov5 model has the highest detection accuracy for small targets and the model performance is optimal.
[0110] Finally, the steps to put the aerial photography dataset after fogging into the improved Yolov5 model for training are as follows:
[0111] The fogged dataset is used as a training set and input into the improved Yolov5 model for training. During the training process, the model will learn how to detect and identify target objects in fogged images. Finally, a better target detection model is obtained.
[0112] The present invention uses the model training method described above to test the performance of the model and compares it with the performance of the yolov5 model. Figure 5 is the Precision-Recall Curve of the original model, Figure 6 It is the Precision-Recall Curve of this method. By comparing the performance results, it can be seen that the present invention is more effective than the original Yolov5 detection model.
[0113] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.
[0114] In addition, it should be understood that although the present specification is described according to implementation modes, not every implementation mode contains only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.
Claims
1. A method for training a model for recognizing aerial images of small targets at sea in foggy weather, characterized in that: include: Step 1: Combined with the existing fog imaging model, the original aerial photography dataset of small targets at sea is fogged by changing the thickness and brightness of the fog, simulating foggy images in various scenes, and establishing an aerial photography dataset of small targets at sea in foggy scenes; Step 2: Set up a small target detection layer based on the YOLOv5 network structure model to build a small target aerial image recognition model for the sea under foggy conditions; Step 3: Set the target recognition model tuning parameter NWD based on WIOU and Wasserstein distance, continuously adjust the weights of WIOU and Wasserstein distance, and use the data set established in step 1 to train the target recognition model; The tuning parameter in step 3 is NWD = ω*WIOU + (1-ω)*Wasserstein Among them, ω is the weight of WIOU; Wasserstein is the normalized second-order Wasserstein distance; The WIOU is IT WIOU =γR WIOU IT IOU L IOU =1-IOU Among them, δ, α are hyperparameters, γ is the gradient gain, β is the outlier degree, is the dynamic average IOU value with momentum m; where x, y and x gt ,y gt are the center point coordinates of the predicted box and the real box, respectively, g , H g is the width and height of the real frame, For variables The constant converted into IOU is the area of the intersection of the predicted box and the real box divided by the area of the union; The second-order Wasserstein distance is calculated as: First, the bounding box A=(c x ,c y ,w,h), where (c x ,c y ), w, h represent the center coordinates, bounding box width and height respectively, modeled as a two-dimensional Gaussian distribution N(μ,Σ) Calculate the Wasserstein distance definition and normalize it. The second-order Wasserstein distance between two two-dimensional Gaussian distributions μ1=N(m1+Σ1) and μ2=N(m2+Σ2) is defined as: In the formula ||·|| F is the Frobenius norm, ||·||2 is the 2-norm, represents the distance metric, m1, m2 represent the mean vector, Σ1, Σ2 represent the covariance matrix; So for two bounding boxes A and B, where A = (cx a ,cy a ,w a ,h a ), bounding box B = (cx b ,cy b ,w b ,h b ), the two-dimensional Gaussian distribution N of the bounding box a and N b The second-order Wasserstein distance is:
2. The method for training a model for recognizing small targets in aerial images at sea under foggy conditions according to claim 1, characterized in that: The step 1 randomly sets the brightness br and thickness th values to be fogged for each image, and performs fogging operations of different degrees on each image in the original aerial photography data set of small targets at sea according to the br and th setting values.
3. The method for training a model for recognizing small targets in aerial images at sea under foggy conditions according to claim 1, characterized in that: The YOLOv5 network structure model described in step 2 includes a Backbone network, a Neck network, and a Head network; wherein the Backbone network is used to extract image features, the Neck network is used to fuse features of different levels, and the Head network is used to predict the location and category of the target.
4. The method for training a model for recognizing small targets in aerial images at sea under foggy conditions according to claim 3, characterized in that: The step 2 modifies the Head network to add a 160×160 small target detection layer and delete the 20×20 large target detection layer.
5. The method for training a model for recognizing small targets in aerial images at sea under foggy conditions according to claim 1, characterized in that: The WIOU weight is 0.6 and the Wasserstein distance weight is 0.4.
