A UAV target detection method based on improved YOLOv5

By improving the yolov5 target detection algorithm, combining the ECA attention mechanism and shape-nms algorithm, the problems of large changes in target scale and poor detection of small and medium-sized targets in drone detection are solved, and high-speed and accurate drone target detection is achieved.

CN115439766BActive Publication Date: 2025-07-29CHONGQING UNIV OF POSTS & TELECOMM
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211163094.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-23
Publication Date
2025-07-29
Estimated Expiration
2042-09-23

AI Technical Summary

Technical Problem

In the drone detection technology, there are problems such as large changes in the target scale, fuzzy movement trajectory of dense targets, poor detection effects of medium and small targets, and fast detection speed requirements.

Method used

The improved yolov5 object detection algorithm is adopted, combined with the ECA attention mechanism and the shape-nms algorithm, and by building an ECA-based object detection model, adding the ECA attention module and branch network, optimizing feature extraction and fusion, and filtering redundant boxes using the shape-nms algorithm to achieve efficient detection of small and medium-sized targets.

Benefits of technology

It realizes high-speed and accurate detection during drone detection, improves the detection effect of small and medium-sized targets, and effectively reduces the emergence of redundant boxes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115439766B_ABST
    Figure CN115439766B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of computer vision, and particularly relates to a drone target detection method based on improved YOLOv5; it includes collecting a drone inspection image set and annotating to obtain a corresponding label file, where the label file includes the category of the target and the target box coordinates; converting the label file into a text file, normalizing the target box coordinates to obtain normalized box coordinates, and preprocessing the drone inspection image set to obtain a preprocessed image set; dividing the preprocessed image set and the normalized coordinate set to obtain a training set, a validation set, and a test set; obtaining anchor box samples of the training set through a clustering algorithm; constructing a target detection model based on ECA and training; performing post-processing on the trained target detection model using an improved NMS algorithm; and performing drone target detection using the obtained target detection model; the present invention improves the disadvantages of low detection accuracy of YOLOv5 and poor detection effect on small and medium-sized targets, and realizes the requirements of high speed and accuracy in the drone detection process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer vision, and particularly relates to a drone target detection method based on improved YOLOv5. Background Art

[0002] Object Detection is one of the basic tasks in the field of computer vision. There has been nearly two decades of research history in the academic community. After long-term development and technology iteration, object detection has been widely applied in fields such as face recognition, defect detection, industrial control, aerospace, etc. The current drone detection technology is mainly based on the object detection model in machine learning. There are two types of algorithms for the object detection model: one-stage algorithm and two-stage algorithm, each with its own advantages and disadvantages; the advantage of the one-stage algorithm is that the model processing speed is fast and the real-time performance is strong, but the accuracy is not high. Representative algorithms include the YOLO series, SSD, etc.; the advantage of the two-stage algorithm is high accuracy, but the training speed is slow. Representative algorithms include Faster-RCNN.

[0003] In recent years, with the rapid development of China's economy, the application demand of the drone industry has been continuously expanding, which further improves the requirements for the detection technology in the drone industry. The main problems of the current drone detection technology are that during different high-altitude flights, the target scale changes greatly, the movement trajectories of dense targets are blurred, the detection effects of medium and small targets are poor, and since the drone needs a relatively fast detection and processing speed during the detection process, the present invention will provide a drone target detection method based on the improved YOLOv5 target detection algorithm. While achieving a high-speed detection and processing speed, it improves the disadvantages of low detection accuracy of YOLOv5 and poor detection effects on medium and small targets, and realizes the requirements of high speed and accuracy during the drone detection process. Summary of the Invention

[0004] To solve the problems such as large target scale changes, blurred movement trajectories of dense targets, and poor detection effects of medium and small targets existing during the flight of drones, the present invention provides a drone target detection method based on improved YOLOv5, including the following steps:

[0005] A drone target detection method based on improved YOLOv5, characterized by including the following steps:

[0006] S1. Collect a drone inspection image set, annotate each drone inspection image in the drone inspection image set to obtain a corresponding label file, and all label files form a label file set; the label file includes the category of the target and the target box coordinates in the drone inspection image;

[0007] S2. Process the label file set, convert each label file into a text file, normalize the target box coordinates therein to obtain normalized box coordinates, and all the normalized box coordinates form a normalized coordinate set; meanwhile, preprocess the UAV inspection image set to obtain a preprocessed image set;

[0008] S3. Divide the preprocessed image set and the normalized coordinate set proportionally to obtain a training set, a validation set, and a test set; feed the training set into the K-means clustering algorithm to obtain anchor box samples;

[0009] S4. Construct an ECA-based object detection model according to the yolov5 network, train the object detection model through the training set and the anchor box samples, calculate the loss using the total loss function, and update the network parameters by backpropagation; the loss function formula is as follows:

[0010] Loss=a*loss cls +b*loss box +c*loss confidence

[0011] where loss cls represents the classification loss, loss box represents the localization loss, loss confidence represents the confidence loss, and a, b, and c respectively correspond to the weights of the three losses;

[0012] S5. Design a shape-nms algorithm based on the soft-nms algorithm, and use the shape-nms algorithm to post-process the trained object detection model to filter out redundant boxes;

[0013] S6. Use the object detection model obtained in S5 to perform UAV object detection.

[0014] Furthermore, the ECA-based object detection model includes a backbone module, a neck module, and a head module. Compared with the original yolov5 network structure,

[0015] the backbone module includes a first CBL layer, a second CBL layer, a first C3 layer, a third CBL layer, a second C3 layer, a fourth CBL layer, a third C3 layer, a fifth CBL layer, a fourth C3 layer, and an SPP layer connected layer by layer, and an ECA attention module is introduced in the SPP layer;

[0016] In addition to the feature pyramid network and the path aggregation network in the neck module, a branch network for generating a new feature map is added, and the size of the new feature map is 160×160;

[0017] The head module includes four outputs: Xsmall, Small, Medium, and Big.

[0018] Furthermore, the Feature Pyramid Network includes a sixth CBL layer, a first upsampling layer, a first fusion layer, a fifth C3 layer, a seventh CBL layer, a second upsampling layer, a second fusion layer, and a sixth C3 layer connected layer by layer;

[0019] The branch network includes an eighth CBL layer, a third sampling layer, a third fusion layer, and a seventh C3 layer connected layer by layer;

[0020] The Path Aggregation Network includes a ninth CBL layer, a fourth fusion layer, an eighth C3 layer, a tenth CBL layer, a fifth fusion layer, a ninth C3 layer, an eleventh CBL layer, a sixth fusion layer, and a tenth C3 layer connected layer by layer;

[0021] Among them, the ECA attention module is introduced into the fifth C3 layer, the sixth C3 layer, the seventh C3 layer, the eighth C3 layer, the ninth C3 layer, and the tenth C3 layer.

[0022] Furthermore, the ECA attention module adopts the ECA attention mechanism, and its calculation process is as follows:

[0023] S11. Perform global average pooling on the input feature map;

[0024] S12. Perform a convolution operation with a convolution kernel of 1 on the result of S11, and pass the convolution result through the Sigmoid activation function to obtain the weight ω of each channel. The calculation formula is:

[0025] ω = σ(C1D k (y))

[0026]

[0027] Among them, σ represents the Sigmoid activation function, C1D k (y) represents one-dimensional convolution, D k (y) represents the input k-dimensional size number, ψ(C) represents the convolution size variable, C represents the number of channels, and b and γ represent experimental coefficients;

[0028] S13. Multiply the weight by the corresponding elements of the input feature map in S11 to obtain the output feature map.

[0029] Furthermore, the upsampling method of each upsampling layer is the nearest neighbor interpolation method.

[0030] Furthermore, the process of filtering redundant boxes from the candidate box set of any category using the shape-nms algorithm includes:

[0031] S21. Set the confidence threshold, IOU threshold, and shape threshold. Denote the set of candidate boxes output by the object detection model as A1, and the set of corresponding confidences of the candidate boxes as S1.

[0032] S22. Select the maximum confidence F in the confidence set S1, add this maximum confidence F to the predicted box confidence set S2, and delete F from the confidence set S1.

[0033] S23. Find the candidate box B corresponding to F in the candidate box set A1, add this candidate box B to the predicted box set A2, and remove this candidate box B from the candidate box set A1.

[0034] S24. Calculate the Shape value of each remaining candidate box in the candidate box set A1 with the candidate box B respectively, and determine whether the Shape value is greater than the shape threshold. If so, reduce the confidence of the candidate box; otherwise, keep the confidence unchanged.

[0035] S25. Determine whether the number of candidate boxes in the candidate box set A1 is 1. If so, go to step S26; otherwise, return to step S22.

[0036] S26. Compare the confidences of the candidate boxes in the predicted box set A2 with the confidence threshold respectively. If it is less than the confidence threshold, delete the corresponding candidate box and its confidence to obtain the second predicted box set A3.

[0037] S27. Calculate the overlap degree between every two candidate boxes in the second predicted box set. If the overlap degree is higher than the IOU threshold, fuse the two candidate boxes. Finally, obtain a fused box, and the confidence of this fused box is the maximum value in the confidence set corresponding to the second predicted box set A3.

[0038] Furthermore, the calculation formula for the confidence of the candidate box is:

[0039]

[0040] where, s i represents the confidence score, M represents the candidate box with the maximum confidence, b i represents the candidate box other than the candidate box with the maximum confidence, w represents the score weight, D represents the candidate box set, width i represents the width of the candidate box b i , width M represents the width of the candidate box M with the maximum confidence, height i represents the height of the candidate box b i , height M represents the height of the candidate box M with the maximum confidence.

[0041] Advantages of the present invention:

[0042] In the process of using drones for inspection to determine whether there are defects in signal receiving stations, there are problems such as small targets and blurred contours in the images captured by drones. At the same time, there are too many redundant bounding boxes in the detection results. Therefore, in view of the above technical problems, the present invention proposes a drone inspection technology based on yolov5. This technology improves the original yolov5 model, proposes a network model with 4 detectors, and adds an ECA attention mechanism to this network model to enhance the detection effect of small targets. To solve the problem of too many redundant bounding boxes in the detection results, a Shape-based NMS algorithm is proposed, and a prediction box fusion mechanism is added after the NMS algorithm to further enhance the ability to filter redundant bounding boxes in the detection results. Description of the drawings

[0043] Figure 1 is the flowchart of the method of the present invention;

[0044] Figure 2 is the network structure diagram of the object detection model of the present invention;

[0045] Figure 3 is the structure diagram of the ECA attention mechanism of the present invention;

[0046] Figure 4 is the clustering effect diagram of the present invention;

[0047] Figure 5 is the feature map of 4 types of detectors of the present invention. Detailed implementation manners

[0048] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0049] The present invention provides a drone object detection method based on improved yolov5, as Figure 1 shown, including the following steps:

[0050] S1. Collect the image data captured by the drone during the inspection process, screen the image data to obtain a drone inspection image set, label each drone inspection image in the drone inspection image set to obtain the corresponding label file, and all the label files form a label file set; the label file includes the category of the target and the target box coordinates in the drone inspection image;

[0051] S2. Process the label file set, convert each label file into a text file, normalize the target box coordinates therein to obtain normalized box coordinates, and all the normalized box coordinates form a normalized coordinate set; meanwhile, preprocess the UAV inspection image set to obtain a preprocessed image set;

[0052] S3. Divide the preprocessed image set and the normalized coordinate set proportionally to obtain a training set, a validation set, and a test set; feed the training set into the K-means clustering algorithm to obtain anchor box samples;

[0053] S4. Construct an ECA-based object detection model according to the yolov5 network, train the object detection model with the training set and the anchor box samples, calculate the loss using the total loss function, and update the network parameters by backpropagation; the loss function formula is as follows:

[0054] Loss = a * loss cls +b * loss box +c * loss confidence

[0055] where loss cls represents the classification loss, loss box represents the localization loss, loss confidence represents the confidence loss, and a, b, and c respectively correspond to the weights of the three losses;

[0056] S5. Design a shape-nms algorithm based on the soft-nms algorithm, and use the shape-nms algorithm to post-process the trained object detection model to filter out redundant boxes;

[0057] S6. Use the object detection model obtained in S5 to perform UAV object detection.

[0058] In one embodiment, preprocessing the UAV inspection image set includes image size adjustment and data augmentation. The adaptive image scaling mechanism is used for image size adjustment. When the length and width of the image are scaled proportionally, the remaining part is filled with gray to avoid image distortion during image size adjustment. Data augmentation adopts two methods: offline data augmentation and online data augmentation; the purpose of offline data augmentation is to increase the quantity and features of data, which is only for some categories of data with sparse quantity, rather than all data. Offline data augmentation includes methods such as flipping, translation, transposition, fusion, and splicing; the purpose of online data augmentation is to avoid overfitting during training due to low data volume, and it is for all training data for augmentation. Online data augmentation includes methods such as mix_up, mosaic, color transformation, scaling, shifting, and flipping.

[0059] Specifically, the K-means clustering algorithm is used to process image data to obtain anchor box samples. The Euclidean distance used to calculate clustering in the K-means clustering algorithm is replaced with the 1-IOU distance, and the calculation formula is:

[0060] d(box,centroid) = 1 - IOU(box,centroid)

[0061] Among them, d(box,centroid) represents the distance between the true box and the center box, and IOU(box,centroid) represents the IOU calculation between the true box and the center box. The clustering effect is as Figure 4 shown. The larger dots in the figure are the anchor box samples obtained by clustering the training set, and the remaining small dots are the samples in the training set.

[0062] Specifically, the label file set is processed. Each label file is converted into a text file, and the coordinates of the target boxes in it are normalized to obtain the normalized box coordinates because it is more beneficial to improve the model training speed after normalization processing.

[0063] The training set and the anchor box samples are used to train the object detection model. During the training process, a rectangular training mode is also provided. The purpose is to reduce redundant information without changing the image information, and at the same time adjust the size of the image to the size at which the model can obtain a better training effect.

[0064] In one embodiment, based on the yolov5 network, an optimization and improvement is carried out to construct an object detection model based on ECA. As Figure 2 shown, similar to the yolov5 network, the object detection model based on ECA also includes an input end, a backbone network (backbone module), a feature fusion network (neck module), and a detector network (head module). The backbone network is responsible for feature extraction of the input data, and the input data here is the training set data; the feature fusion network is responsible for feature fusion; the detector network makes predictions, compares the prediction results with the actual labels, and performs gradient updates.

[0065] Specifically, as Figure 2 shown, compared with the original yolov5 network structure,

[0066] the backbone module includes a first CBL layer, a second CBL layer, a first C3 layer, a third CBL layer, a second C3 layer, a fourth CBL layer, a third C3 layer, a fifth CBL layer, a fourth C3 layer, and a Spatial Pyramid Pooling (SPP) layer connected layer by layer. Among them, in order to improve the detection effect of more medium and small targets in the drone inspection images, an ECA attention module is introduced into the SPP layer;

[0067] In addition to the Feature Pyramid Network and the Path Aggregation Network, the neck module newly adds a branch network that has a better training effect on medium and small targets, obtaining a new feature map. As Figure 5 shown, the size of this new feature map is 160×160; the new feature map is clearer and has a smaller receptive field. Such a new feature map is more sensitive to medium and small targets, thus strengthening the training of medium and small targets. And a corresponding detector is constructed in the Path Aggregation Network (PANet). In this way, the training effect of the model on medium and small targets is improved.

[0068] Specifically, the Feature Pyramid Network includes the sixth CBL layer, the first upsampling layer, the first fusion layer, the fifth C3 layer, the seventh CBL layer, the second upsampling layer, the second fusion layer, and the sixth C3 layer connected layer by layer;

[0069] The branch network includes the eighth CBL layer, the third sampling layer, the third fusion layer, and the seventh C3 layer connected layer by layer.

[0070] The Path Aggregation Network includes the ninth CBL layer, the fourth fusion layer, the eighth C3 layer, the tenth CBL layer, the fifth fusion layer, the ninth C3 layer, the eleventh CBL layer, the sixth fusion layer, and the tenth C3 layer connected layer by layer.

[0071] Among them, the ECA attention module is introduced into the fifth C3 layer, the sixth C3 layer, the seventh C3 layer, the eighth C3 layer, the ninth C3 layer, and the tenth C3 layer.

[0072] Among them, the first fusion layer is used to splice the output of the first upsampling layer and the output of the third C3 layer; the second fusion layer is used to splice the output of the second upsampling layer and the output of the second C3 layer; the third fusion layer is used to splice the output of the third upsampling layer and the output of the first C3 layer; the fourth fusion layer is used to splice the output of the eighth CBL layer and the output of the ninth CBL layer, and the fifth fusion layer is used to splice the output of the tenth CBL layer and the output of the seventh CBL layer; the sixth fusion layer is used to splice the output of the eleventh CBL layer and the output of the sixth CBL layer.

[0073] The head module includes four outputs: Xsmall, Small, Medium, and Big.

[0074] Among them, the input of Xsmall is the output of the seventh C3 layer without passing through the ECA attention module; the input of Small is the output of the eighth C3 layer without passing through the ECA attention module; the input of Medium is the output of the ninth C3 layer without passing through the ECA attention module; the input of Big is the output of the tenth C3 layer without passing through the ECA attention module.

[0075] In one embodiment, the ECA attention module adopts the ECA (Efficient Channel Attention) attention mechanism, whose purpose is to strengthen the learning of effective feature channels and improve the detection effect of the model. Figure 3 It is the ECA attention mechanism, which is a channel attention mechanism. The principle is that the feature map data is learned through 1D convolution. At this time, the data in the number of channels is converted into 0-1.0 decimal values, which can be regarded as weight values, and then multiplied by the number of channels of the original feature map, so as to reduce the proportion of invalid channel numbers, thereby realizing the effective utilization of the data in the channels and making the model pay attention to where it should pay attention. The specific calculation process is as follows:

[0076] S11. Perform global average pooling on the input feature map;

[0077] S12. Perform a convolution operation with a convolution kernel of 1 on the result of S11, and obtain the weight ω of each channel through the Sigmoid activation function. The calculation formula is:

[0078] ω = σ(C1D k (y))

[0079]

[0080] where σ represents the Sigmoid activation function, C1D k (y) represents one-dimensional convolution, D k (y) represents the input k-dimensional size number, ψ(C) represents the convolution size variable, C represents the number of channels, and b, γ represent experimental coefficients.

[0081] S13. Multiply the weight by the corresponding elements of the input feature map in S11 to obtain the output feature map.

[0082] In this way, the invalid channel data in the feature map can be filtered out. By using the characteristic that convolution has good cross-channel information acquisition ability, the 1D convolution structure is combined with the average pooling structure. After the Sigmoid function processing, the attention of the model to the effective channels is improved, thereby realizing the improvement of the detection effect for images with different scale changes. The improvement of the ECA channel attention mechanism compared with the traditional channel attention mechanism is that it avoids capturing all channels.

[0083] In one embodiment, each upsampling layer of the neck module is used to expand the size of the feature map. In this embodiment, the upsampling method adopted is the nearest neighbor interpolation method, and the calculation formula is:

[0084]

[0085] where D in 、Dout are the dimensions of the input feature map and the output feature map, scale_factor is the dilation factor, H in , W in are the length and width of the input feature map, H out , W out are the length and width of the output feature map. In the branch network, the output feature map of the third upsampling layer is fused with the output of the third C3 layer in the backbone module, thereby constructing a feature map that is more affinity for medium and small targets. This feature map reduces the receptive field and strengthens the training of medium and small targets, so as to achieve the purpose of improving the detection effect.

[0086] In one embodiment, after the training of the model is completed, the obtained training weights can be used for inference. However, directly using these training weights for inference has poor effects and there will be a situation where there are multiple redundant bounding boxes for the same target. Therefore, it is necessary to process the inference results, that is, a post-processing stage is derived. The core algorithm in the post-processing stage is non-maximum suppression, abbreviated as the "NMS algorithm". The role of NMS is to select the best prediction bounding box from the redundant bounding boxes. The core idea of the NMS algorithm for filtering redundant bounding boxes is: first select the candidate bounding box with the highest confidence, then perform the IOU operation between other candidate bounding boxes and the candidate bounding box with the highest confidence. If the operation result is greater than the pre-set IOU threshold, then set the confidence of the corresponding candidate bounding box to 0, and finally perform filtering.

[0087] However, the way NMS filters redundant bounding boxes is a bit rough. Because NMS directly filters the candidate bounding boxes whose operation results are greater than the IOU threshold, this leads to many missed detection situations in the detection process. Therefore, the soft-NMS algorithm is derived. The improvement of soft-NMS compared to the original NMS algorithm is that it uses a slightly lower confidence to replace the original confidence, rather than directly setting it to 0. The confidence calculation formula is as follows:

[0088]

[0089] where, s i represents the confidence of the i-th candidate bounding box, iou(M, b i ) represents the IOU operation, M represents the candidate bounding box with the highest confidence, and b i represents the candidate bounding box other than the candidate bounding box with the highest confidence. The confidence of the candidate bounding box that highly overlaps with the candidate bounding box M with the highest confidence is reduced. The higher the overlap degree, the more the confidence is reduced. Each time a cycle is completed, the candidate bounding box with the current highest confidence is retained until there is only one candidate bounding box left. Finally, the candidate bounding boxes with lower confidence among the retained candidate bounding boxes are filtered out through the confidence threshold. After the above processing, the problem of missed detection is alleviated to a certain extent.

[0090] In soft-nms, the method of filtering redundant bounding boxes is based on the IOU algorithm. This method has certain drawbacks. If two redundant bounding boxes are far apart or have a large size difference, the redundant bounding boxes cannot be filtered out. Based on this, the present invention develops a method of filtering redundant bounding boxes based on comparing the aspect ratios of the lengths and widths of the redundant bounding boxes. The calculation formula is as follows:

[0091]

[0092] where s i represents the confidence score, M represents the candidate bounding box with the highest confidence, b i represents the candidate bounding boxes other than the candidate bounding box with the highest confidence, w represents the score weight, D represents the set of candidate bounding boxes, width i represents the width of the candidate bounding box b i , width M represents the width of the candidate bounding box M with the highest confidence, height i represents the height of the candidate bounding box b i , height M represents the height of the candidate bounding box M with the highest confidence. The improvement of this algorithm is to replace iou(M,bi) in the soft-nms algorithm with a filtering method based on the Shape strategy of the aspect ratio. By making such modifications, the filtering method of redundant bounding boxes can be improved.

[0093] In order to further achieve the purpose of filtering redundant bounding boxes, the present invention proposes a mechanism for fusing redundant bounding boxes based on the shape-nms algorithm, that is, fusing the redundant bounding boxes not filtered out by the shape-nms algorithm. Specifically, it includes: obtaining the set of bounding boxes after the shape-nms algorithm, calculating the overlap degree between every two bounding boxes in the set of bounding boxes using the IOU algorithm, and if the overlap degree is greater than the IOU threshold, fusing these two bounding boxes. Specifically, the fusion formula is:

[0094]

[0095] S = max(s i )

[0096] where x1 represents the abscissa of the upper left corner of the predicted bounding box, y1 represents the ordinate of the upper left corner of the predicted bounding box, x2 represents the abscissa of the lower right corner of the predicted bounding box, y2 represents the ordinate of the lower right corner of the predicted bounding box, A represents a candidate predicted bounding box, then Ax1 represents the abscissa of the upper left corner of the candidate predicted bounding box A, A area represents the area of A, B represents another candidate predicted bounding box, B area represents the area of B, C represents the fused predicted bounding box; S represents the maximum value of the confidence scores of all predicted bounding boxes, and finally is the confidence score of the fused bounding box.

[0097] Specifically, the candidate boxes of multiple categories are filtered by the shape-nms algorithm. The specific process of filtering redundant boxes from the candidate box set of one category by using the shape-nms algorithm includes:

[0098] S21. Set the confidence threshold, IOU threshold, and shape threshold. The candidate box set output by the object detection model is denoted as A1, and the confidence set corresponding to the candidate box set is denoted as S1.

[0099] S22. Select the maximum confidence F in the confidence set S1, add the maximum confidence F to the predicted box confidence set S2, and delete F from the confidence set S1.

[0100] S23. Find the candidate box B corresponding to F in the candidate box set A1, add the candidate box B to the predicted box set A2, and remove the candidate box B from the candidate box set A1.

[0101] S24. Calculate the Shape value of the remaining candidate boxes in the candidate box set A1 respectively with the candidate box B, and determine whether the Shape value is greater than the Shape threshold. If so, reduce the confidence of the candidate box, otherwise the confidence remains unchanged.

[0102] S25. Determine whether the number of candidate boxes in the candidate box set A1 is 1. If so, go to step S26, otherwise return to step S22.

[0103] S26. Compare the confidence of the candidate boxes in the predicted box set A2 with the confidence threshold respectively. If it is less than the confidence threshold, delete the corresponding candidate box and its confidence to obtain the second predicted box set A3.

[0104] S27. Calculate the overlap degree between every two candidate boxes in the second predicted box set A3. If the overlap degree is higher than the IOU threshold, fuse the two candidate boxes. The fused candidate box is again calculated and judged for the overlap degree with the remaining candidate boxes until there is no case where the overlap degree is greater than the IOU threshold, that is, the redundant boxes have been filtered out. At this time, one fused box may be obtained, or multiple fused boxes may be obtained. If multiple fused boxes are obtained, select one to get a final fused box. The confidence of the final fused box is the maximum value in the confidence set corresponding to the second predicted box set A3.

[0105] In the present invention, unless otherwise clearly specified and defined, terms such as "installation", "setting", "connection", "fixation", "rotation", etc. shall be understood in a broad sense. For example, it may be a fixed connection, a detachable connection, or integrated; it may be a mechanical connection or an electrical connection; it may be directly connected or indirectly connected through an intermediate medium, and it may be the communication inside two elements or the interaction relationship between two elements. Unless otherwise clearly defined, for those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0106] Although the embodiments of the present invention have been shown and described, for those of ordinary skill in the art, it can be understood that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A drone target detection method based on improved YOLOv5, characterized in that, It includes the following steps: S1. Collect the UAV inspection image set, annotate each UAV inspection image in the UAV inspection image set to obtain the corresponding label file, and all label files form a label file set; the label file includes the category of the target in the UAV inspection image and the target box coordinates; S2. Process the label file set, convert each label file into a text file, and normalize the target box coordinates therein to obtain normalized box coordinates, and all the normalized box coordinates form a normalized coordinate set; at the same time, preprocess the UAV inspection image set to obtain a preprocessed image set; S3. Divide the preprocessed image set and the normalized coordinate set proportionally to obtain a training set, a validation set and a test set; feed the training set into the K-means clustering algorithm to obtain anchor box samples; S4. Construct an ECA-based object detection model according to the yolov5 network, train the object detection model with the training set and the anchor box samples, calculate the loss using the total loss function, and update the network parameters by backpropagation; the loss function formula is as follows: Loss=a*loss cls +b*loss box +c*loss confidence Among them, loss cls represents the classification loss, loss box represents the localization loss, loss confidence represents the confidence loss, and a, b, and c respectively correspond to the weights of the three losses; S5. Design a shape-nms algorithm based on the soft-nms algorithm, and use the shape-nms algorithm to post-process the trained object detection model to filter redundant boxes; The process of filtering redundant boxes from the candidate box set of any category using the shape-nms algorithm includes: S21. Set the confidence threshold, IOU threshold and shape threshold. The candidate box set output by the object detection model is denoted as A1, and the confidence set corresponding to the candidate box set is denoted as S1. S22. Select the maximum confidence F in the confidence set S1, add the maximum confidence F to the predicted box confidence set S2, and delete F in the confidence set S1; S23. Find the candidate box B corresponding to F in the candidate box set A1, add the candidate box B to the predicted box set A2, and remove the candidate box B from the candidate box set A1; S24. Calculate the Shape value of the remaining candidate boxes in the candidate box set A1 respectively with the candidate box B, and judge whether the Shape value is greater than the Shape threshold. If so, reduce the confidence of the candidate box, otherwise the confidence remains unchanged; S25. Judge whether the number of candidate boxes in the candidate box set A1 is 1. If so, go to step S26, otherwise return to step S22; S26. Compare the confidence of the candidate boxes in the predicted box set A2 with the confidence threshold respectively. If it is less than the confidence threshold, delete the corresponding candidate box and its confidence to obtain the second predicted box set A3; S27. Calculate the overlap degree between every two candidate boxes in the second predicted box set A3. If the overlap degree is higher than the IOU threshold, fuse the two candidate boxes, and finally obtain a fused box. The confidence of the fused box is the maximum value in the confidence set corresponding to the second predicted box set A3; The calculation formula for the confidence of the candidate box is: The filtering method of the above Shape strategy filters redundant bounding boxes based on comparing the aspect ratios of redundant bounding boxes; where s i represents the confidence score, M represents the candidate bounding box with the highest confidence, b i represents the candidate bounding boxes other than the candidate bounding box with the highest confidence, w represents the score weight, D represents the set of candidate bounding boxes, width i represents the width of the candidate bounding box b i , width M represents the width of the candidate bounding box M with the highest confidence, height i represents the height of the candidate bounding box b i , height M represents the height of the candidate bounding box M with the highest confidence; S6. Use the object detection model obtained in S5 to perform UAV object detection.

2. The method for detecting an unmanned aerial vehicle target based on improved YOLOv5 according to claim 1, wherein The ECA-based object detection model includes a backbone module, a neck module, and a head module. Compared with the original YOLOv5 network structure, the backbone module includes a first CBL layer, a second CBL layer, a first C3 layer, a third CBL layer, a second C3 layer, a fourth CBL layer, a third C3 layer, a fifth CBL layer, a fourth C3 layer, and an SPP layer connected layer by layer. An ECA attention module is introduced in the SPP layer; in addition to the Feature Pyramid Network and the Path Aggregation Network, the neck module adds a branch network that generates a new feature map with a size of 160×160; the head module includes four outputs: Xsmall, Small, Medium, and Big.

3. The method for detecting an unmanned aerial vehicle target based on improved YOLOv5 according to claim 2, wherein, The Feature Pyramid Network includes a sixth CBL layer, a first upsampling layer, a first fusion layer, a fifth C3 layer, a seventh CBL layer, a second upsampling layer, a second fusion layer, and a sixth C3 layer connected layer by layer; the branch network includes an eighth CBL layer, a third sampling layer, a third fusion layer, and a seventh C3 layer connected layer by layer; the Path Aggregation Network includes a ninth CBL layer, a fourth fusion layer, an eighth C3 layer, a tenth CBL layer, a fifth fusion layer, a ninth C3 layer, an eleventh CBL layer, a sixth fusion layer, and a tenth C3 layer connected layer by layer; wherein an ECA attention module is introduced in each of the fifth C3 layer, the sixth C3 layer, the seventh C3 layer, the eighth C3 layer, the ninth C3 layer, and the tenth C3 layer.

4. A drone target detection method based on improved YOLOv5 according to claim 2 or 3, characterized in that The ECA attention module adopts the ECA attention mechanism, and its calculation process is as follows: S11. Perform global average pooling on the input feature map; S12. Perform a convolution operation with a convolution kernel of 1 on the result of S11, and pass the convolution result through the Sigmoid activation function to obtain the weight ω of each channel. The calculation formula is: ω = σ(C1D k (y)) Among them, σ represents the Sigmoid activation function, C1D k (y) represents one-dimensional convolution, ψ(C) represents the convolution size variable, C represents the number of channels, and b and γ represent experimental coefficients; S13. Multiply the weight by the corresponding elements of the input feature map in S11 to obtain the output feature map.

5. The method for drone target detection based on improved YOLOv5 according to claim 3, wherein The upsampling method of each upsampling layer is the nearest neighbor interpolation method.

Citation Information

Patent Citations

  • Improved clustering algorithm based on Shape-GIoU

    CN114494756A

  • YOLOv5 marine fish target detection method based on attention mechanism and DropBlock

    CN114677708A