Unmanned aerial vehicle target detection method based on historical trajectory generative attention
By constructing a historical attention map and a generative attention module, and optimizing the YOLOv8 deep learning model, the problems of low accuracy and insufficient real-time performance of visual detection technology in the detection of small object drones are solved, and efficient drone target detection is achieved.
Patent Information
- Application Number
- CN202410622181.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-20
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2044-05-20
AI Technical Summary
Existing visual inspection technologies suffer from low accuracy, are easily obscured by complex backgrounds, and are difficult to meet real-time detection requirements when detecting small target drones.
By constructing a historical attention map and a generative attention module, and combining historical trajectory information of UAV targets, the feature extraction part of the YOLOv8 deep learning model is optimized, and an improved total loss function is designed to improve the accuracy and real-time performance of target detection.
It improves the accuracy of small target UAV detection and ensures the real-time nature of the detection process, making it suitable for UAV target detection in complex backgrounds.
Smart Images

Figure CN118628936A
Abstract
Description
Technical Field
[0001] The present invention relates to a method for detecting unmanned aerial vehicle targets, in particular to a method for detecting unmanned aerial vehicle targets based on historical trajectory generation-type attention. Background Art
[0002] With the rapid development and widespread application of drone technology, the demand for anti-drone technology has also emerged, such as the detection of illegal and indiscriminate flights in the civilian field. Drone detection is the first and important step in anti-drone technology. At present, the detection technology for drones can be divided into radar detection, audio detection, radio detection, visual detection and other forms. Because some drones made of plastic have a small reflection area and there are many ground clutters in cities, airports and other areas, it is difficult to effectively detect drones using radar; audio detection technology is greatly affected by environmental noise, and it is difficult to detect drones in other noisy environments such as cities; radio detection technology has high requirements on the sensitivity of transmitting and receiving equipment, and drones in electromagnetic silent state are difficult to detect; visual detection technology relies on optical sensors that are inexpensive, easy to implement, and have the advantages of high accuracy, fast detection speed, and large monitoring range. These characteristics make it one of the most important detection technologies in anti-unmanned equipment.
[0003] Visual detection methods can find the desired objects from images, but are challenging to detect small objects, such as drones at a distance. Small objects only occupy a small number of pixels in the image, usually have low contrast, limited visual features, and are easily submerged by complex backgrounds or other objects. At the same time, drones may have different flight postures and high flight speeds during flight, forming different appearance shapes and postures in the image, which further increases the difficulty of detecting small target drones.
[0004] Deep learning methods have good multi-scale feature extraction capabilities and strong generalization capabilities, making them an important technology for target detection. By specifically building a deep learning network model, it is possible to effectively extract the features of small target objects from images and improve the accuracy of target detection. However, the complex network structure has too many network parameters, which makes the network run slowly and cannot meet the needs of real-time detection. Summary of the invention
[0005] Purpose of the invention: The technical problem to be solved by the present invention is to provide a drone target detection method based on historical trajectory generation attention in view of the shortcomings of the prior art.
[0006] In order to solve the above technical problems, the present invention discloses a drone target detection method based on historical trajectory generative attention, comprising the following steps:
[0007] Step 1: construct a historical attention map based on the historical trajectory information of the drone target. The elements in the historical attention map correspond one-to-one to the pixels of the image to be detected, and the element value in the map represents the contextual attention degree of the pixel;
[0008] Step 2: Design a generative attention module, whose input is the historical attention map constructed in step 1, that is, the historical trajectory information of the drone target; the output result is the attention prediction map of the current image to be detected, that is, the trajectory attention;
[0009] Step 3: Design a trajectory attention fusion module to use the historical trajectory information of the drone target to predict the area where the drone may appear in the image to be detected, which is defined as the attention area;
[0010] Step 4, optimizing the feature extraction part of the yolov8 deep learning model to obtain an improved feature extraction network, and designing an improved total loss function for the improved feature extraction network;
[0011] Step 5: Build a drone target detection model based on historical trajectory generative attention;
[0012] Step 6: train the drone target detection model based on historical trajectory generative attention constructed in step 5;
[0013] Step 7: Use the improved drone target detection model based on historical trajectory generative attention trained in step 6 to perform target detection, and complete drone target detection based on historical trajectory generative attention.
[0014] Furthermore, the construction of the historical attention map described in step 1 specifically includes the following steps:
[0015] Step 1-1: Assume that the image to be detected has a width of m pixels and a length of n pixels, then construct a matrix of size m×n For the matrix C 0 Assign initial values to each element in;
[0016] Step 1-2, suppose the drone set D in the drone target historical trajectory information is {1, 2, ..., d}, calculate the position area matrix L of the drone d with a size of w × h pixels from the current position pth trajectory point in the trajectory d,p , the size of the position region matrix is equal to the size of the image to be detected, and the element with coordinate (x, y) in the position region matrix takes the value a i,j Use the following method:
[0017]
[0018] Steps 1-3, accumulate the position area matrices of all drone targets with the pth trajectory point, and the result is the historical trajectory set, the historical attention map C p is the decay sum of up to p historical trajectory sets, that is:
[0019]
[0020] Where μ is the attenuation coefficient.
[0021] Furthermore, the design of the generative attention module described in step 2 specifically includes:
[0022] The generative attention module is composed of a feature context modeling layer and a trajectory attention layer; the input of this module is the historical trajectory information of the drone target;
[0023] Among them, the contextual attention layer is processed by a 1×1 convolution layer and a Softmax activation function, and its result is multiplied by itself before the 1×1 convolution to perform contextual modeling on the features of the mapping graph;
[0024] The trajectory attention layer performs 1×1 convolution, normalization, ReLU activation, and 1×1 convolution on the output of the context attention layer to capture the feature dependencies in the mapping graph.
[0025] Finally, the above results are processed by Sigmoid function to make them nonlinear outputs, which are the output results of the generative attention module: trajectory attention.
[0026] Furthermore, the design trajectory described in step 3 focuses on the fusion module, specifically including:
[0027] Step 3-1: The image to be detected is extracted through a multi-scale feature extraction network to obtain three levels of image features of different scales, of which the first level image features and the track attention output in step 2 are used as the input of this module;
[0028] Step 3-2: Linearly map the first-level image features of the image to be detected and process them with the Tanh activation function to obtain a first processing result, click the image features and the track attention, linearly map the dot product operation results to obtain a second processing result, and add and merge the above two processing results;
[0029] Step 3-3 divides the processing result after addition and merging into two branches, wherein the first branch does not perform additional processing, and the second branch uses a linear mapping layer and a Softmax activation function for processing;
[0030] Step 3-4, multiply the first branch and the processed second branch element by element to form the image feature of the additional focus area.
[0031] Furthermore, the improved total loss function described in step 4 specifically includes:
[0032] The total loss function includes: improved cross entropy loss L vfl , intersection loss L IoU and attention bias loss L att ; Among them, the improved cross entropy loss L vfl as follows:
[0033] L vfl = -r(rlog(s)+(1-r)log(1-s))
[0034] Among them, r is the intersection over union ratio of the predicted box and the true box, s is the local perception classification score, when the classification result is the same as the true result, the IoU value of the predicted box and the true box is taken, and the values of other positions are 0;
[0035] Intersection-over-combination loss L IoU for:
[0036]
[0037] Among them, b and b gt Respectively represent the center points of the predicted box and the actual box of the target, ρ represents the Euclidean distance between the two rectangular boxes, c represents the diagonal distance of the closed area of the two rectangular boxes, v represents the consistency of the relative proportions of the two rectangular boxes, and α is the weight coefficient;
[0038] The improved total loss function L is:
[0039] L=L vfl +L IoU +L att .
[0040] Furthermore, the attention bias loss described in step 4 specifically includes:
[0041] The attention deviation loss is used to represent the deviation between the trajectory attention generated by the generative attention module in step 2 and the actual position of the drone. The calculation of the attention deviation loss is the trajectory attention F generated in step 2 and the regional position matrix and L 0 Composition, where the expression of trajectory attention F is:
[0042] F=conv(ReLu(norm(conv((1+softmax(conv(C p )))C p ))))
[0043] The region position matrix and L 0 The expression is:
[0044]
[0045] Among them, d is the drone target number in the detection result, L d,0 The region position matrix representing the drone target denoted by d is generated by the detection labels corresponding to the images in the training dataset, where the detection labels include the position of the target in the corresponding image;
[0046] Focus on the bias loss L att The calculation method is:
[0047]
[0048] Where m is the number of horizontal pixels of the image to be detected, n is the number of vertical pixels of the image to be detected, F(i,j) represents the trajectory attention of the pixel point with pixel coordinates (i,j), L 0 (i,j) represents the regional position matrix of the pixel point with pixel coordinates (i,j).
[0049] Furthermore, the feature extraction part of the optimized yolov8 deep learning model described in step 4 is to make the following improvements to the original feature extraction network in the yolov8 deep learning model:
[0050] Step 4-1, using the redesigned C2p convolutional feature extraction module to replace the C2f convolutional feature extraction module in the original feature extraction network;
[0051] Step 4-2, adjust the structural branches in the original feature extraction network, parallelize the serial feature extraction operations, reduce the number of convolution blocks, optimize the repeated modules to remove feature redundancy, and reduce the number of feature extraction network parameters.
[0052] Furthermore, the redesigned C2p convolutional feature extraction module described in step 4-1 specifically includes:
[0053] Step 4-1-1, in the C2p convolution feature extraction module, the input feature is processed by the convolution module and then channel-split into n half features, where the number of channels contained in each half feature is half of the original image feature;
[0054] Step 4-1-2, pass each half feature through n Darknet feature extraction backbones in parallel, that is, each feature extraction backbone is independent of each other;
[0055] Step 4-1-3, the n half features processed by the feature extraction backbone are concatenated with the image features before splitting.
[0056] Furthermore, the improved feature extraction network described in step 5 is as follows:
[0057] The input image features are refined through the convolution module to restore the number of feature channels to the same as the input image feature channels; the input image passes through two convolution modules and is processed by a C2p convolution feature extraction module to generate the first-level derived features. The first-level features are further divided into two branches to perform feature extraction operations. The processing methods in the two branches are the same. The first-level features are first processed by the convolution module and then processed by the C2p convolution feature extraction module. The results are passed through the convolution module again and then through the C2p convolution feature extraction module; at this point, the branch feature processing is completed; after obtaining the feature results of the two branches, the two are feature spliced, and the spliced features are used as the second-level derived features; the second-level features pass through a convolution module and a C2p convolution feature extraction module, and then through a fast spatial pyramid pooling layer to generate the third-level derived features.
[0058] Furthermore, the drone target detection model based on historical trajectory generative attention described in step 6 specifically includes:
[0059] The image to be detected passes through two 3x3 convolution modules and a C2p convolution feature extraction module in sequence, and is input into the trajectory attention fusion module together with the historical trajectory of the drone that has passed the generated attention module, and then passes through the improved feature extraction network to obtain the final target detection result.
[0060] Beneficial effects:
[0061] The present invention improves the accuracy of small target UAV detection and ensures the real-time performance of the detection process by combining historical trajectory information and attention mechanism. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments, and the above and / or other advantages of the present invention will become more clear.
[0063] Figure 1 This is the overall architecture diagram of the drone target detection of the present invention.
[0064] Figure 2 This is the structure diagram of the generative attention module.
[0065] Figure 3 This is the structure diagram of the trajectory attention fusion module.
[0066] Figure 4 Diagram of the improved feature extraction network structure.
[0067] Figure 5 This is the C2p feature extraction block structure diagram. DETAILED DESCRIPTION
[0068] In order to improve the accuracy of small target UAV detection and ensure the real-time performance of the detection process, the present invention provides a small target UAV detection method based on historical trajectory generative attention. In this method, the historical trajectory information of the UAV target is calculated as a historical attention map. The elements in the historical attention map correspond one-to-one to the pixels of the detected image, and the element values in the map represent the contextual attention level of the pixel. The historical attention map is used as input to the generative attention module, and its output result is the predicted current image attention map, that is, the generative attention about the current image. The generative attention is used to guide the neural network's attention to the image to the area where the UAV may appear. The attention loss function is proposed and used as part of the total loss function of the neural network training. Its function is to back-propagate the attention area deviation in the network model, so that the network parameters are updated to better predict the area that should be paid attention to in the image. In order to improve the detection rate and ensure the real-time performance of the method while ensuring the detection quality, the present invention adjusts and optimizes the network structure based on the yolov8 deep learning model. The overall model structure diagram of the present invention is shown in the attached figure. Figure 1 shown.
[0069] The UAV target detection method based on historical trajectory generation attention of the present invention is mainly implemented by the following steps.
[0070] Step 1: Generate historical attention map
[0071] The historical trajectory information of a single drone target can be described as a sequence of (x, y, w, h) quadruplets, i.e. (center point horizontal axis coordinate, center point vertical axis coordinate, target width, target height), and the sequence length is less than the set maximum trajectory threshold; while the historical trajectory information of multiple drone targets can be described as a series of the above sequences, and the sequence length is indefinite. In order to effectively utilize the drone trajectory information in visual inspection tasks, the drone trajectory information needs to be converted to match the network processing elements, i.e. the historical attention map proposed by the present invention.
[0072] Given an image size, width m, length n, then construct a matrix C of size m×n 0 , assign initial values to each element in the matrix.
[0073] Assume that the set of drones detected in the historical trajectory is D = {1, 2, ..., d}, and calculate the position area matrix L of the pth trajectory point of drone d in the trajectory from the current position d,p , the matrix size is equal to the image size, and the elements in the position area matrix are taken as a i,j It complies with the following formula:
[0074]
[0075] The cumulative result of the position area matrix of all drones with the pth trajectory point is the historical trajectory set, the historical attention map C p is the decay sum of p trajectory sets, that is:
[0076]
[0077] Where μ is the attenuation coefficient.
[0078] Step 2: Generative attention module design, such as Figure 2 As shown:
[0079] The historical attention map generated by step 1 can be a single-channel image of the degree of attention to the target position. The generative attention module takes the historical attention map as input and outputs the trajectory attention result. The network in the module is trained simultaneously during model training to generate appropriate trajectory attention.
[0080] The historical attention map first generates map features through a convolution layer, and makes the feature size consistent with the first feature scale size of the detection image. The feature size does not change in the subsequent processing of the module. Subsequently, the map features are processed through a 1×1 convolution layer and a Softmax activation function, and the result is multiplied by itself before the 1×1 convolution. The purpose of this operation is to model the context of the map features. The above processing results are normalized after a 1×1 convolution, and the normalized results are convolved again with 1×1. The purpose of performing 1×1 convolution, normalization, ReLU activation, and 1×1 convolution in sequence is to capture the feature dependency in the map. The above results are processed using the Sigmoid function to make them nonlinear. The above processing results are the generated trajectory attention.
[0081] Step 3: The trajectory focuses on the design of the fusion module, such as Figure 3 As shown:
[0082] Track attention fusion applies track attention to the extracted features of the image to be detected. This process is designed after the first-level derived features of the image to be detected are extracted.
[0083] The input of this module is the first-level derived features of the image to be detected and the generated trajectory attention, and the output is the first-level derived features after applying attention.
[0084] In this module, the first-level derived features of the image to be detected are dot-producted with the trajectory attention, and the dot-product result is feature-mapped through a linear layer. In the obtained mapping features, the historical trajectory information of the drone is used to predict the area where the drone may appear in the current frame, and provide more attention to the predicted area. However, only paying attention to objects in the predicted area may cause the detection network to ignore the newly appeared drone in the image, so it is necessary to reconcile the original image features with the image features of the additional area attention.
[0085] A lightweight attention reconciliation method is designed in the track attention fusion module. After performing linear feature mapping on the original image features, the Tanh activation function is used for processing; while the image features of the additional area of attention are directly processed using the Tanh activation function. The results of the two are added and merged, and divided into two branches. One branch does not perform additional processing, and the other branch uses a linear mapping layer and a Softmax activation function to process the two element results element by element. The result is used as the final output of this module. The above operations match and align the features of the two sources so that the elements in the two features can correspond one to one, and merge the elements in the features accordingly.
[0086] Step 4: Improve the design of the feature extraction network
[0087] The improved feature extraction network reduces the number of parameters, making the detection model real-time in more general scenarios while maintaining reliable feature extraction capabilities. The network structure is optimized for small target detection scenarios. The input image passes through two convolution modules and is processed by a C2p module to generate the first-level derived features. The first-level features are further divided into two branches to perform feature extraction operations. The processing methods in the two branches are the same. The first-level features are first processed by the convolution module and then by the C2p module. The results are passed through the convolution module again and then through the C2p module. At this point, the branch feature processing is completed. After obtaining the feature results of the two branches, the features of the two are spliced, and the spliced features are used as the second-level derived features. The second-level features pass through a convolution module and a C2p module, and then through a fast spatial pyramid pooling layer to generate the third-level derived features. The feature extraction network is supported to complete the extraction of image features. The improved feature extraction network structure is as follows: Figure 4 Among them, the C2p module is an improved feature extraction module, and its structural design is described below.
[0088] like Figure 5As shown in the figure, in the C2p module, the input features are processed by the convolution module and then split into n half features. The number of channels contained in each feature is half of the original image feature. Each image feature is parallelly passed through n Darknet feature extraction backbones, that is, each feature extraction backbone is independent of each other. For the n features processed by the feature extraction backbone, the n adjusted half features are spliced with the image features before splitting, and the feature dimension contained in the splicing result is 1+0.5n times that of the original image feature. The feature is refined through a convolution module to restore the number of feature channels to the same as the number of input feature channels.
[0089] Step 5 focuses on the calculation of the deviation loss
[0090] The attention deviation loss represents the deviation between the trajectory prediction attention result generated by the generative attention module in the network and the actual position of the drone. The calculation of the attention deviation loss is based on the generated trajectory prediction attention F and the regional position matrix generated by the current image detection label and L 0 composition.
[0091] The expression of trajectory attention F is:
[0092] F=conv(ReLu(norm(conv((1+softmax(conv(C p )))C p ))))
[0093] The region position matrix and L 0 The expression is:
[0094]
[0095] Among them, d is the drone target number in the detection result.
[0096] The calculation formula for attention bias loss is:
[0097]
[0098] Among them, m is the number of horizontal pixels of the image, and n is the number of vertical pixels of the image.
[0099] Step 6: Total loss function design
[0100] The loss function is used to guide the training process of the model in deep learning. By changing the weight parameters in the network and minimizing the loss function result, the parameters of the model can be adjusted to better fit the training data and improve the performance of the model network.
[0101] The loss function of this method consists of three parts: improved cross entropy loss (VFL Loss), intersection over union loss (IoU) and attention bias loss.
[0102] The improved cross entropy loss is defined as:
[0103] L vfl = -r(rlog(s)+(1-r)log(1-s))
[0104] Among them, r is the intersection of the predicted box and the true box, which is the intersection of the predicted box and the true box divided by the union of the two boxes, and s is the local perception classification score. When the classification result is the same as the true result, the IoU value of the predicted box and the true box is taken, and the values of other positions are 0.
[0105] The intersection-over-union loss is defined as:
[0106]
[0107] Among them, b and b gt They represent the center points of the predicted box and the actual box of the target respectively, ρ represents the Euclidean distance between the two rectangular boxes, c represents the diagonal distance of the closed area of the two rectangular boxes, v represents the consistency of the relative proportions of the two rectangular boxes, and α is the weight coefficient.
[0108] The total loss function is expressed as:
[0109] L=L vfl +L IoU +L att
[0110] Example:
[0111] The embodiment of the present invention provides a UAV target detection method based on historical trajectory generation attention, which is used to improve the accuracy of small target UAV detection and ensure the real-time performance of the detection process.
[0112] The embodiment of the drone target detection method based on historical trajectory generation attention of the present invention is mainly implemented by the following steps.
[0113] Step 1: Generate historical attention map
[0114] The historical trajectory information of a single drone target can be described as a sequence of (x, y, w, h) quadruplets, i.e. (center point horizontal axis coordinate, center point vertical axis coordinate, target width, target height), and the sequence length is less than the set maximum trajectory threshold. Specifically, the maximum historical trajectory sequence length threshold recorded by a single drone is set to 5; while the historical trajectory information of multiple drone targets can describe the sequence of the above sequence, and its sequence length is uncertain. In order to effectively utilize the drone trajectory information in the visual inspection task, the drone trajectory information needs to be converted to match the network processing element, i.e. the historical attention map proposed by the present invention.
[0115] Given an image size, width m, length n, then construct a matrix C of size m×n 0 , assign initial values to each element in the matrix.
[0116] Assume that the set of drones detected in the historical trajectory is D = {1, 2, ..., d}, and calculate the position area matrix L of the pth trajectory point of drone d in the trajectory from the current position d,p , the matrix size is equal to the image size, and the elements in the position area matrix are taken as a i,j It complies with the following formula:
[0117]
[0118] The cumulative result of the position area matrix of all drones with the pth trajectory point is the historical trajectory set, the historical attention map C p is the decay sum of p trajectory sets, that is:
[0119]
[0120] Wherein, μ is the attenuation coefficient, and the specific attenuation coefficient is 0.6.
[0121] Step 2: Generative Attention Module Design
[0122] The historical attention map generated by step 1 can be a single-channel image of the degree of attention to the target position. The generative attention module takes the historical attention map as input and outputs the trajectory attention result. The network in the module is trained simultaneously during model training to generate appropriate trajectory attention.
[0123] The historical attention map first generates map features through a convolution layer, and makes the feature size consistent with the first feature scale size of the detection image. The feature size does not change in the subsequent processing of the module. Subsequently, the map features are processed through a 1×1 convolution layer and a Softmax activation function, and the result is multiplied by itself before the 1×1 convolution. The purpose of this operation is to model the context of the map features. The above processing results are normalized after a 1×1 convolution, and the normalized results are convolved again with 1×1. The purpose of performing 1×1 convolution, normalization, ReLU activation, and 1×1 convolution in sequence is to capture the feature dependency in the map. The above results are processed using the Sigmoid function to make them nonlinear. The above processing results are the generated trajectory attention.
[0124] The schematic diagram of the generative attention module is attached. Figure 2 shown.
[0125] Step 3 Design of trajectory attention fusion module
[0126] Track attention fusion applies track attention to the extracted features of the image to be detected. This process is designed after the first-level derived features of the image to be detected are extracted.
[0127] The input of this module is the first-level derived features of the image to be detected and the generated trajectory attention, and the output is the first-level derived features after applying attention.
[0128] In this module, the first-level derived features of the image to be detected are dot-producted with the trajectory attention, and the dot-product result is feature-mapped through a linear layer. In the obtained mapping features, the historical trajectory information of the drone is used to predict the area where the drone may appear in the current frame, and provide more attention to the predicted area. However, only paying attention to objects in the predicted area may cause the detection network to ignore the newly appeared drone in the image, so it is necessary to reconcile the original image features with the image features of the additional area attention.
[0129] A lightweight attention reconciliation method is designed in the track attention fusion module. After performing linear feature mapping on the original image features, the Tanh activation function is used for processing; while the image features of the additional area of attention are directly processed using the Tanh activation function. The results of the two are added and merged, and divided into two branches. One branch does not perform additional processing, and the other branch uses a linear mapping layer and a Softmax activation function to process the two element results element by element. The result is used as the final output of this module. The above operations match and align the features of the two sources so that the elements in the two features can correspond one to one, and merge the elements in the features accordingly.
[0130] The structure diagram of the trajectory attention fusion module is as follows Figure 3 shown.
[0131] Step 4: Improve the design of the feature extraction network
[0132] The improved feature extraction network reduces the number of parameters, making the detection model real-time in more general scenarios while maintaining reliable feature extraction capabilities. The network structure is optimized for small target detection scenarios. The input image passes through two convolution modules and is processed by a C2p module to generate the first-level derived features. The first-level features are further divided into two branches to perform feature extraction operations. The processing methods in the two branches are the same. The first-level features are first processed by the convolution module and then by the C2p module. The results are passed through the convolution module again and then through the C2p module. At this point, the branch feature processing is completed. After obtaining the feature results of the two branches, the features of the two are spliced, and the spliced features are used as the second-level derived features. The second-level features pass through a convolution module and a C2p module, and then through a fast spatial pyramid pooling layer to generate the third-level derived features. The feature extraction network is supported to complete the extraction of image features. The improved feature extraction network structure is shown in the attached figure. Figure 4 Among them, the C2p module is an improved feature extraction module, and its structural design is described below.
[0133] In the C2p module, the input features are processed by the convolution module and then split into n half features. The number of channels contained in each feature is half of the original image features. Each image feature is extracted in parallel through n Darknet feature extraction backbones, that is, each feature extraction backbone is independent of each other. For the n features processed by the feature extraction backbone, the n adjusted half features are spliced with the image features before splitting. The feature dimension contained in the splicing result is 1+0.5n times that of the original image features. The feature is refined through a convolution module to restore the number of feature channels to the same as the input feature channel number. The structure of the C2p module is shown in the attached figure. Figure 5 shown.
[0134] Step 5 focuses on the calculation of deviation loss
[0135] The attention deviation loss represents the deviation between the trajectory prediction attention result generated by the generative attention module in the network and the actual position of the drone. The calculation of the attention deviation loss is based on the generated trajectory prediction attention F and the regional position matrix generated by the current image detection label and L 0 composition.
[0136] The expression of trajectory attention F is:
[0137] F=conv(ReLu(norm(conv((1+softmax(conv(C p )))C p ))))
[0138] The region position matrix and L 0 The expression is:
[0139]
[0140] Among them, d is the drone target number in the detection result.
[0141] The calculation formula for attention bias loss is:
[0142]
[0143] Among them, m is the number of horizontal pixels of the image, and n is the number of vertical pixels of the image.
[0144] Step 6: Total loss function design
[0145] The loss function is used to guide the training process of the model in deep learning. By changing the weight parameters in the network and minimizing the loss function result, the parameters of the model can be adjusted to better fit the training data and improve the performance of the model network.
[0146] The loss function of this method consists of three parts: improved cross entropy loss (VFL Loss), intersection over union loss (IoU) and attention bias loss.
[0147] The improved cross entropy loss is defined as:
[0148] L vfl = -r(rlog(s)+(1-r)log(1-s))
[0149] Among them, r is the intersection of the predicted box and the true box, which is the intersection of the predicted box and the true box divided by the union of the two boxes, and s is the local perception classification score. When the classification result is the same as the true result, the IoU value of the predicted box and the true box is taken, and the values of other positions are 0.
[0150] The intersection-over-union loss is defined as:
[0151]
[0152] Among them, b and b gt They represent the center points of the predicted box and the actual box of the target respectively, ρ represents the Euclidean distance between the two rectangular boxes, c represents the diagonal distance of the closed area of the two rectangular boxes, c represents the consistency of the relative proportions of the two rectangular boxes, and α is the weight coefficient.
[0153] The total loss function is expressed as:
[0154] L=L vfl +L Io x+Latt
[0155] Step 7: Training of small target drone detection model
[0156] In order to train the small target drone detection model, this embodiment selects several videos containing drone targets and processes them. Specifically, each frame in the video is extracted as a picture, and a corresponding annotation file is generated according to the conversion of the video annotation file. The annotations of the 5 frames before the current picture are aggregated, and the annotations of the target boxes therein are processed as the trajectory of the current picture in the form of a four-tuple list, wherein the method for judging whether the annotation boxes in the historical annotations belong to the same trajectory point is the nearest Euclidean distance method. All acquired videos containing drone targets are processed by the above processing method, and the processing results form a drone target detection dataset containing historical trajectory annotations.
[0157] In order to complete the training of the drone detection model, the above dataset is divided into a training set and a test set. The specific dataset division ratio is 7:3. The training set is used to train the drone target detection model, and the test set is used to test the effect of the drone target detection model.
[0158] This embodiment uses Pytorch as a deep learning framework, and the specific version is 1.11.0. Accordingly, Python 3.8 is used as the Python programming language interpreter to run the embodiment code. The embodiment uses GPU for hardware acceleration, and the GPU model used is NVIDIA GeForce RTX 2080Ti.
[0159] The training of the embodiment model does not use a pre-trained model, the network model parameters are set to random values, the model training optimizer is selected as Adam, and the initial learning rate is set to 0.0001. The number of training rounds is set to 200 epochs, and batch image input is used, with 16 images per batch. The training model results are saved in pt format.
[0160] Step 8: Input the image and historical trajectory of the small target drone to be detected to obtain the detection result.
[0161] To obtain the detection results of the image to be detected, the image to be detected and the corresponding historical trajectory information of the drone are passed into the model through the inference interface. The model returns the detection results, and the detection results can be visualized on the image to be detected based on the results.
[0162] To obtain the detection result of the video to be detected, only the video needs to be input without inputting the historical trajectory information. The detection method will generate the trajectory according to the accumulated video frame image detection results.
[0163] In a specific implementation, the present application provides a computer storage medium and a corresponding data processing unit, wherein the computer storage medium can store a computer program, and when the computer program is executed by the data processing unit, the invention content of a drone target detection method based on historical trajectory generation attention provided by the present invention and some or all steps in each embodiment can be run. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0164] Those skilled in the art can clearly understand that the technical solutions in the embodiments of the present invention can be implemented by means of computer programs and their corresponding general hardware platforms. Based on such an understanding, the technical solutions in the embodiments of the present invention can be essentially or partly contributed to the prior art in the form of computer programs, i.e., software products, which can be stored in a storage medium and include several instructions for enabling a device including a data processing unit (which can be a personal computer, a server, a single-chip microcomputer, an MCU or a network device, etc.) to execute the methods described in various embodiments of the present invention or certain parts of the embodiments.
[0165] The present invention provides a method and idea for a drone target detection method based on historical trajectory generation-based attention. There are many methods and approaches to implement the technical solution. The above is only a preferred implementation of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention. All components not specified in this embodiment can be implemented using existing technologies.
Claims
1. A drone target detection method based on historical trajectory generative attention, characterized in that: The steps include: Step 1: construct a historical attention map based on the historical trajectory information of the drone target. The elements in the historical attention map correspond one-to-one to the pixels of the image to be detected, and the element value in the map represents the contextual attention degree of the pixel; Step 2: Design a generative attention module, whose input is the historical attention map constructed in step 1, that is, the historical trajectory information of the drone target; the output result is the attention prediction map of the current image to be detected, that is, the trajectory attention; Step 3: Design a trajectory attention fusion module to use the historical trajectory information of the drone target to predict the area where the drone may appear in the image to be detected, which is defined as the attention area; Step 4, optimizing the feature extraction part of the yolov8 deep learning model to obtain an improved feature extraction network, and designing an improved total loss function for the improved feature extraction network; Step 5: Build a drone target detection model based on historical trajectory generative attention; Step 6: train the drone target detection model based on historical trajectory generative attention constructed in step 5; Step 7: Use the improved drone target detection model based on historical trajectory generative attention trained in step 6 to perform target detection, and complete drone target detection based on historical trajectory generative attention.
2. The method for detecting drone targets based on historical trajectory generative attention according to claim 1, characterized in that: The construction of the historical attention map described in step 1 specifically includes the following steps: Step 1-1: Assume that the image to be detected has a width of m pixels and a length of n pixels, then construct a matrix of size m×n Assign initial values to each element in matrix C0; Step 1-2, suppose the drone set D in the drone target historical trajectory information is {1, 2, ..., d}, calculate the position area matrix L of the drone d with a size of w × h pixels from the current position pth trajectory point in the trajectory d,p , the size of the position region matrix is equal to the size of the image to be detected, and the element with coordinate (x, y) in the position region matrix takes the value a i,j Use the following method: Steps 1-3, accumulate the position area matrices of all drone targets with the pth trajectory point, and the result is the historical trajectory set, the historical attention map C p is the decay sum of up to p historical trajectory sets, that is: Where μ is the attenuation coefficient.
3. The method for detecting drone targets based on historical trajectory generative attention according to claim 2, characterized in that: Design the generative attention module described in step 2, specifically including: The generative attention module is composed of a feature context modeling layer and a trajectory attention layer; the input of this module is the historical trajectory information of the drone target; Among them, the contextual attention layer is processed by a 1×1 convolution layer and a Softmax activation function, and its result is multiplied by itself before the 1×1 convolution to perform contextual modeling on the features of the mapping graph; The trajectory attention layer performs 1×1 convolution, normalization, ReLU activation, and 1×1 convolution on the output of the context attention layer to capture the feature dependencies in the mapping graph. Finally, the above results are processed by Sigmoid function to make them nonlinear outputs, which are the output results of the generative attention module: trajectory attention.
4. The method for detecting unmanned aerial vehicle targets based on historical trajectory generative attention according to claim 3, characterized in that: The design trajectory described in step 3 focuses on the fusion module, which includes: Step 3-1: The image to be detected is extracted through a multi-scale feature extraction network to obtain three levels of image features of different scales, of which the first level image features and the track attention output in step 2 are used as the input of this module; Step 3-2: Linearly map the first-level image features of the image to be detected and process them with the Tanh activation function to obtain a first processing result, click the image features and the track attention, linearly map the dot product operation results to obtain a second processing result, and add and merge the above two processing results; Step 3-3 divides the processing result after addition and merging into two branches, wherein the first branch does not perform additional processing, and the second branch uses a linear mapping layer and a Softmax activation function for processing; Step 3-4, multiply the first branch and the processed second branch element by element to form the image feature of the additional focus area.
5. The method for detecting drone targets based on historical trajectory generative attention according to claim 4 is characterized in that: The improved total loss function described in step 4 specifically includes: The total loss function includes: improved cross entropy loss L vfl , intersection loss L IoU and the attention bias loss L att ; Among them, the improved cross entropy loss L vfl as follows: L vfl =-r(rlog(s)+(1-r)log(1-s)) Among them, r is the intersection over union ratio of the predicted box and the true box, s is the local perception classification score, when the classification result is the same as the true result, the IoU value of the predicted box and the true box is taken, and the values of other positions are 0; Intersection-over-combination loss L IoU for: Among them, b and b gt Respectively represent the center points of the predicted box and the actual box of the target, ρ represents the Euclidean distance between the two rectangular boxes, c represents the diagonal distance of the closed area of the two rectangular boxes, v represents the consistency of the relative proportions of the two rectangular boxes, and α is the weight coefficient; The improved total loss function L is: L=L vfl +L IoU +L att .
6. The method for detecting drone targets based on historical trajectory generative attention according to claim 5, characterized in that: The attention bias loss described in step 4 specifically includes: The attention deviation loss is used to represent the deviation between the trajectory attention generated by the generative attention module in step 2 and the actual position of the drone. The calculation of the attention deviation loss is composed of the trajectory attention F generated in step 2, the regional position matrix and L0, where the expression of the trajectory attention F is: F=conv(ReLu(norm(conv((1+softmax(conv(C p )))C p )))) The expressions of the region position matrix and L0 are: Among them, d is the drone target number in the detection result, L d,0 The region position matrix representing the drone target denoted by d is generated by the detection labels corresponding to the images in the training dataset, where the detection labels include the position of the target in the corresponding image; Focus on the bias loss L att The calculation method is: Among them, m is the number of horizontal pixels of the image to be detected, n is the number of vertical pixels of the image to be detected, F(i,j) represents the trajectory attention of the pixel point with pixel coordinates (i,j), and L0(i,j) represents the regional position matrix of the pixel point with pixel coordinates (i,j).
7. The method for detecting drone targets based on historical trajectory generative attention according to claim 6, characterized in that: The feature extraction part of the optimized yolov8 deep learning model described in step 4 is to make the following improvements to the original feature extraction network in the yolov8 deep learning model: Step 4-1, using the redesigned C2p convolutional feature extraction module to replace the C2f convolutional feature extraction module in the original feature extraction network; Step 4-2, adjust the structural branches in the original feature extraction network, parallelize the serial feature extraction operations, reduce the number of convolution blocks, optimize the repeated modules to remove feature redundancy, and reduce the number of feature extraction network parameters.
8. The method for detecting drone targets based on historical trajectory generative attention according to claim 7, characterized in that: The redesigned C2p convolutional feature extraction module described in step 4-1 specifically includes: Step 4-1-1, in the C2p convolution feature extraction module, the input feature is processed by the convolution module and then channel-split into n half features, where the number of channels contained in each half feature is half of the original image feature; Step 4-1-2, pass each half feature through n Darknet feature extraction backbones in parallel, that is, each feature extraction backbone is independent of each other; Step 4-1-3, the n half features processed by the feature extraction backbone are concatenated with the image features before splitting.
9. The method for detecting drone targets based on historical trajectory generative attention according to claim 8, characterized in that: The improved feature extraction network described in step 5 is as follows: The input image features are refined through the convolution module to restore the number of feature channels to the same as the input image feature channels; after the input image passes through two convolution modules, it is processed by a C2p convolution feature extraction module to generate the first-level derived features. The first-level features are further divided into two branches for feature extraction operations. The processing methods in the two branches are the same. The first-level features are first processed by the convolution module, and then processed by the C2p convolution feature extraction module. The results are passed through the convolution module again, and then through the C2p convolution feature extraction module; at this point, the branch feature processing is completed; after obtaining the feature results of the two branches, the features of the two branches are spliced, and the spliced features are used as the second-level derived features; The second-level features pass through a convolution module and a C2p convolution feature extraction module, and then through a fast spatial pyramid pooling layer to generate the third-level derived features.
10. The method for detecting drone targets based on historical trajectory generative attention according to claim 9, characterized in that: The drone target detection model based on historical trajectory generative attention described in step 6 specifically includes: The image to be detected passes through two 3x3 convolution modules and a C2p convolution feature extraction module in sequence, and is input into the trajectory attention fusion module together with the historical trajectory of the drone that has passed the generated attention module, and then passes through the improved feature extraction network to obtain the final target detection result.
Citation Information
Patent Citations
Target entity trajectory prediction method based on air-ground fusion
CN117789082A
Significance target detection method fusing mixed attention
CN117935031A
Driver Attention Detection Method
US20210357670A1
Sequential pedestrian trajectory prediction using step attention for collision avoidance
US20230038673A1
