Unmanned aerial vehicle detection method based on YOLO network lightweight deployment
By introducing Ghost convolution and decoupled fully connected attention mechanism into the YOLO network, combined with the structural re-parameterization strategy and multi-thread accelerated detection, the problem of insufficient detection speed of existing drones is solved, and efficient unmanned drones are realized. Machine target detection meets the needs of high-speed detection and improves the deployment efficiency of the model on the edge computing platform.
Patent Information
- Application Number
- CN202410724809.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-05
- Publication Date
- 2024-08-23
AI Technical Summary
The detection speed of existing drone detection methods is insufficient to meet the needs of high-speed drone target detection. In particular, visual detection methods can only process about 30 frames per second.
Using a lightweight deployment method based on the YOLO network, the convolution and attention mechanisms are improved through Ghost convolution and decoupled fully connected attention mechanisms, and the structural re-parameterization strategy is used for model training to complete the conversion and multi-threading of the model to rknn Accelerates detection deployment and is suitable for edge computing platforms such as Rockchip RK3588.
While maintaining the accuracy of the model, it greatly improves the detection speed, meets the real-time requirements, and achieves rapid deployment and compatibility of the model on the edge computing platform.
Smart Images

Figure CN118537704A
Abstract
Description
Technical Field
[0001] The present invention relates to a drone detection method based on lightweight deployment of a YOLO network, which belongs to the technical field of drone detection and is suitable for lightweight deployment acceleration of a YOLO model on edge computing platforms such as Rockchip RK3588 to achieve efficient target detection. Background Art
[0002] A drone is an aircraft that does not require an operator and can be operated by remote control or autonomous flight control system. Drones are widely used in many fields, including aerial photography, agricultural plant protection, environmental monitoring, power inspection, express delivery, geographic mapping, search and rescue, etc., greatly improving work efficiency and safety, and providing people with new perspectives and solutions.
[0003] The significance of drone detection is to ensure the safety of drones during flight and to monitor their flight environment and potential threats. In the civilian field, this helps prevent drones from colliding with other aircraft and ensures the safety and smoothness of air traffic. In the military field, drone detection is crucial to prevent enemy drone reconnaissance and attacks, and helps maintain national security and military secrets. In addition, with the continuous development of drone technology, drone detection can also help improve the ability to regulate illegal drone flights and illegal activities, and protect public safety and privacy.
[0004] Existing drone detection methods mainly include visual detection methods, radar detection methods, and radio spectrum analysis methods. Among them, the visual detection method detects drones through devices such as cameras or infrared cameras, and is currently the most efficient and most commonly used method. The visual detection method relies on a deep learning network model to extract features from the input image and perform reasoning to obtain detection results. Its detection speed is limited by the size of the network model and the performance of the computing platform, and the number of frames that can be processed per second is usually around 30 frames. However, drone targets have the characteristics of high-speed movement, and a processing speed of 30 frames per second cannot meet the needs of high-speed drone target detection. Summary of the invention
[0005] The technical problem solved by the present invention is: to overcome the shortcomings of the prior art, and to propose a drone detection method based on the lightweight deployment of the YOLO network. The method is suitable for lightweight deployment acceleration of the YOLO model on edge computing platforms such as Rockchip RK3588 to achieve efficient target detection. When performing lightweight deployment acceleration, the method performs a lightweight design on the backbone network of the YOLO network, and uses Ghost convolution and decoupled fully connected attention mechanisms to improve convolution and attention mechanisms respectively; uses a structural reparameterization strategy for model training; and completes the conversion of the model to rknn and multi-threaded accelerated detection deployment.
[0006] The technical solution of the present invention is as follows:
[0007] A method for detecting drones based on the lightweight deployment of the YOLO network, the steps of which include:
[0008] Step 1: Obtain the image data of the drone, label the obtained image data of the drone to obtain a data set, and then divide the obtained data set into a training set, a validation set and a test set;
[0009] Step 2: Establish a lightweight deployment model based on the YOLO network. The lightweight deployment model based on the YOLO network includes a ConvModule module, a CSPLayer module, and an SPFFBottleneck module. Ghost convolution operations are used for feature extraction in the ConvModule module, the CSPLayer module, and the SPFFBottleneck module, and then the decoupled fully connected attention mechanism is used to fuse the extracted features to obtain an attention output feature map; The ConvModule module, the CSPLayer module, and the SPFFBottleneck module all use Pytorch as the network architecture;
[0010] Step 3: Use the training set and the validation set divided in Step 1 to train the lightweight deployment model based on the YOLO network constructed in Step 2 to obtain a weight file of the model, and the suffix of this weight file is pt;
[0011] Step 4: Use the test set divided in Step 1 to test the lightweight deployment model based on the YOLO network trained in Step 3;
[0012] Step 5: First convert the weight file with the suffix pt obtained in Step 3 into a weight file with the suffix onnx, and then convert the weight file with the suffix onnx into a weight file with the suffix rknn;
[0013] Step 6: Use the rknn weight file obtained in Step 5 on edge computing platforms such as RK3588 to perform multi-threaded accelerated detection of drone targets.
[0014] In the above Step 2, the method for using Ghost convolution operation for feature extraction is as follows:
[0015] Step 2.1: Use a convolution operation to process the input feature map with dimensions of h×w×n to obtain an intrinsic feature map with dimensions of h′×w′×m, satisfying m < n′; the output feature map of the input feature map with dimensions of h×w×n in the current layer has dimensions of h′×w′×n′;
[0016] Step 2.2: To ensure the consistency of the output feature map dimensions, for each intrinsic feature map obtained in step 2.1 i (i=1,2,…m) performs linear transformation to generate the corresponding new feature map ij , and satisfies the relationship n′=m×s, j=1,2,…s, s is the number of new feature maps after linear transformation;
[0017] In step 2, the method for fusing the extracted features is:
[0018] Step 2.3, calculate the horizontal attention output feature map am q :
[0019]
[0020] Among them, P q is the height-based learnable parameter in the fully connected layer, d q For vectors d1, d2, …, d Q The elements in the vector d1,d2,…,d Q By inputting feature maps of the fully connected layer It is obtained by opening it by height; ⊙ represents element-level multiplication; Q is the height dimension of the input feature map, K is the width dimension of the input feature map, and D is the number of channels of the input feature map;
[0021] Step 2.4, according to the horizontal attention output feature map am obtained in step 2.3 q Calculate the final attention output feature map AM = {am 11 ,am 12 ,…,…,am qk ,am QK}, element am in AM qk It is expressed as:
[0022]
[0023] Among them, P k is the width-based learnable parameter in the fully connected layer;
[0024] In step 3, a structural reparameterization strategy is used during training, specifically:
[0025] During training, an inverted bottleneck basic training structure is established based on the 3×3 depth convolution and 1×1 point convolution of the MobileNet-V1 block. Skip connections and batch normalization layers are added to the basic training structure. At the same time, over-parameterization coefficients are designed and the structures of 3×3 depth convolution and 1×1 point convolution are replicated according to the designed over-parameterization coefficients.
[0026] In step 4, when testing, reparameterization is performed and the skip connection and batch normalization layer in the basic training structure are deleted, and only the inverted bottleneck established by the 3×3 depth convolution and 1×1 point convolution of the MobileNet-V1 block is retained;
[0027] In step 4, after testing, the average model accuracy (mAP50, mAP50-95), the model parameter quantity, and the floating-point operation quantity required for model reasoning are calculated to determine whether the model performance meets the requirements. If the model accuracy does not meet the requirements, the operation of step 3 is repeated and the number of training rounds is increased;
[0028] In step 6, the method for performing multi-thread acceleration detection is:
[0029] Step 6.1, create a video stream acquisition thread, which is executed on the CPU, obtains video image information from the camera or other video input unit and submits it to the task queue;
[0030] Step 6.2, create a worker thread pool, which is executed on the NPU. N worker threads are initialized in the thread pool to obtain tasks from the task queue and process them. N threads work in parallel.
[0031] Step 6.3, create a result processing thread, which is executed on the CPU, obtains the results from the worker threads in the worker thread pool, and displays them visually.
[0032] Beneficial Effects
[0033] (1) Balance between accuracy and speed: By using Ghost convolution and decoupled fully connected attention mechanism to improve convolution and attention mechanism, the present invention significantly improves the running speed of the model while maintaining the accuracy of the model. This improvement enables the target detection task to be completed more quickly on the edge computing platform, meeting the application scenario with high real-time requirements such as drone detection.
[0034] (2) Optimization of model training: The present invention adopts a structural reparameterization strategy for model training, which helps the model to converge better during the training process and improves the generalization ability of the model.
[0035] (3) Deployment acceleration and compatibility: After completing model training, the present invention realizes the rapid deployment of the model on edge computing platforms such as Rockchip RK3588 through model-to-rknn conversion and multi-threaded acceleration detection. This conversion and acceleration strategy not only improves deployment efficiency, but also makes the model fully compatible with Rockchip RK series edge computing platforms. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 Schematic diagram of Ghost convolution;
[0037] Figure 2 Schematic diagram of the decoupled fully connected attention mechanism;
[0038] Figure 3 Diagram for thread pool acceleration deployment. DETAILED DESCRIPTION
[0039] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. The following embodiments are used to illustrate the present invention, but are not used to limit the scope of the present invention.
[0040] Example
[0041] A drone detection method based on lightweight deployment of a YOLO network, the method comprising the following steps:
[0042] Step 1: obtain drone image data under the background of air and space by shooting with a camera, annotate the obtained drone image data under the background of air and space, obtain a data set, and then divide the obtained data set into a training set, a validation set, and a test set in a ratio of 7:2:1;
[0043] Step 2, establish a lightweight deployment model based on the YOLO network. The lightweight deployment model based on the YOLO network includes ConvModule module, CSPLayer module, and SPFFBottleneck module. Ghost convolution operation is used in ConvModule module, CSPLayer module, and SPFFBottleneck module for feature extraction, and then the extracted features are fused using the decoupled fully connected attention mechanism to obtain the attention output feature map; ConvModule module, CSPLayer module, and SPFFBottleneck module all use Pytorch as the network architecture;
[0044] Step 3: Use the training set and validation set divided in step 1 to train the lightweight deployment model based on the YOLO network constructed in step 2 to obtain the weight file of the model, and the suffix of the weight file is pt;
[0045] Step 4, using the test set divided in step 1 to test the YOLO network-based lightweight deployment model trained in step 3;
[0046] Step 5, convert the weight file with the suffix pt obtained in step 3 into a weight file with the suffix onnx, and then convert the weight file with the suffix onnx into a weight file with the suffix rknn;
[0047] Step 6: Use the rknn weight file obtained in Step 5 on edge computing platforms such as RK3588 to detect drone targets.
[0048] In Step 2, as Figure 1 shown, the method of using Ghost convolution operation for feature extraction is as follows:
[0049] Step 2.1: Perform convolution operation on the input feature map with dimensions h×w×n to obtain an internal feature map with dimensions h′×w′×m, where m < n′; the output feature map dimensions of the input feature map with dimensions h×w×n in the current layer are h′×w′×n′; taking the first layer of the model as an example, for the input 640×640-sized captured image containing a drone, perform convolution operation on the input feature map with dimensions 640×640×3 to obtain an internal feature map with dimensions 320×320×16.
[0050] Step 2.2: To ensure consistent output feature map dimensions, perform linear transformation on each internal feature map map i (i = 1, 2, … m) to generate corresponding new feature maps map ij , and satisfy the relationship n′ = m×s, j = 1, 2, … s, where s is the number of new feature maps after linear transformation; taking the first layer of the model as an example, expand the internal feature map with dimensions 320×320×16 (m = 16) into an output feature map with dimensions 320×320×64 through linear transformation (taking s = 4).
[0051] In Step 2, as Figure 2 shown, the method of fusing the extracted features is as follows:
[0052] Step 2.3: Calculate the horizontal attention output feature map am q :
[0053]
[0054] where P q is the height-based learnable parameter in the fully connected layer, d q is an element in the vector d1, d2, …, d Q , and the vector d1, d2, …, d Q is obtained by slicing the input feature map of the fully connected layer along the height; ⊙ represents element-wise multiplication; Q is the height dimension of the input feature map, K is the width dimension of the input feature map, and D is the number of channels of the input feature map; taking the first layer of the model as an example, for the input 640×640-sized captured image containing a drone, Q = 640, K = 640, and D = 3.
[0055] Step 2.4, according to the horizontal attention output feature map am obtained in step 2.3 q Calculate the final attention output feature map AM = {am 11 ,am 12 ,…,…,am qk ,am QK}, element am in AM qk It is expressed as:
[0056]
[0057] Among them, P k is the width-based learnable parameter in the fully connected layer;
[0058] In step 3, a structural reparameterization strategy is used during training, specifically:
[0059] During training, an inverted bottleneck basic training structure is established based on the 3×3 depth convolution and 1×1 point convolution of the MobileNet-V1 block. Skip connections and batch normalization layers are added to the basic training structure. At the same time, over-parameterization coefficients are designed and the structures of 3×3 depth convolution and 1×1 point convolution are replicated according to the designed over-parameterization coefficients.
[0060] In step 4, when testing, reparameterization is performed and the skip connection and batch normalization layer in the basic training structure are deleted, and only the inverted bottleneck established by the 3×3 depth convolution and 1×1 point convolution of the MobileNet-V1 block is retained;
[0061] In step 4, after testing, the model average accuracy (mAP50, mAP50-95), the model parameter quantity and the floating-point operation quantity required for model reasoning are calculated to determine whether the model performance meets the requirements. If the model accuracy does not meet the requirements, repeat step 3 and increase the number of training rounds.
[0062] In step 6, Figure 3 As shown, the method for multi-threaded acceleration detection is:
[0063] Step 6.1, create a video stream acquisition thread, which is executed on the CPU, pulls the video stream from the network camera using the RTSP protocol, and submits the video image information to the task queue;
[0064] Step 6.2, create a worker thread pool, which is executed on the three-core NPU of RK3588. N worker threads are initialized in the thread pool to obtain tasks from the task queue and process them. N threads work in parallel;
[0065] Step 6.3, create a result processing thread, which is executed on the CPU, obtains the results from the worker threads in the worker thread pool, marks the image frame of the drone target in the image, and displays it on the monitor via the HDMI interface.
[0066] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0067] The above is only a preferred implementation method of the present invention. It should be pointed out that for ordinary technicians in this field, various modifications and variations can be made to the embodiments without departing from the technical principles of the present invention. These modifications and variations should also be regarded as the scope of protection of the present invention.
Claims
1. A drone detection method based on lightweight deployment of YOLO network, characterized in that The steps of the method include: Step 1: obtain the image data of the drone, annotate the image data of the drone, obtain a data set, and then divide the obtained data set into a training set, a verification set, and a test set; Step 2, establish a lightweight deployment model based on the YOLO network. The lightweight deployment model based on the YOLO network includes ConvModule module, CSPLayer module, and SPFFBottleneck module. Ghost convolution operation is used in ConvModule module, CSPLayer module, and SPFFBottleneck module for feature extraction, and then the extracted features are fused using the decoupled fully connected attention mechanism to obtain the attention output feature map; ConvModule module, CSPLayer module, and SPFFBottleneck module all use Pytorch as the network architecture; Step 3: Use the training set and validation set divided in step 1 to train the lightweight deployment model based on the YOLO network constructed in step 2 to obtain the weight file of the model, and the suffix of the weight file is pt; Step 4, using the test set divided in step 1 to test the YOLO network-based lightweight deployment model trained in step 3; Step 5, convert the weight file with the suffix pt obtained in step 3 into a weight file with the suffix onnx, and then convert the weight file with the suffix onnx into a weight file with the suffix rknn; Step 6: Use the rknn weight file obtained in step 5 on edge computing platforms such as RK3588 to perform multi-threaded acceleration detection on drone targets.
2. According to claim 1, a drone detection method based on lightweight deployment of YOLO network is characterized in that: In step 2, the method of using Ghost convolution operation to extract features is: Step 2.1: Use convolution operation to process the input feature map of dimension h×w×n to obtain a feature map of dimension h ′ × ′ ×m intrinsic feature map, satisfying m <n ′ ; The dimension of the input feature map of h×w×n is h in the output feature map of the same layer. ′ × ′ ×n ′ ; Step 2.2: To ensure the consistency of the output feature map dimensions, for each intrinsic feature map obtained in step 2.1 i (i=1, 2, ...m) performs linear transformation to generate the corresponding new feature map ij , and satisfies the relationship n′=m×s, j=1, 2,…s, s is the number of new feature maps after linear transformation.
3. According to claim 1, a drone detection method based on lightweight deployment of YOLO network is characterized in that: In step 2, the method for fusing the extracted features is: Step 2.3, calculate the horizontal attention output feature map am q : Among them, P q is the height-based learnable parameter in the fully connected layer, d q For vectors d1, d2, ..., d Q The elements in the vectors d1, d2, ..., d Q By inputting feature maps of the fully connected layer It is obtained by opening it by height; ⊙ represents element-level multiplication; Q is the height dimension of the input feature map, K is the width dimension of the input feature map, and D is the number of channels of the input feature map; Step 2.4, according to the horizontal attention output feature map am obtained in step 2.3 q Calculate the final attention output feature map AM = {am 11 ,am 12 ,...,...,am qk ,am QK }, element am in AM qk It is expressed as: Among them, P k is a width-based learnable parameter in the fully connected layer.
4. The method for detecting unmanned aerial vehicles based on lightweight deployment of a YOLO network according to claim 1, characterized in that: In step 3, a structural reparameterization strategy is used during training, specifically: During training, an inverted bottleneck basic training structure is established based on the 3×3 depth convolution and 1×1 point convolution of the MobileNet-V1 block, and skip connections and batch normalization layers are added to the basic training structure. At the same time, over-parameterization coefficients are designed and the structures of 3×3 depth convolution and 1×1 point convolution are replicated according to the designed over-parameterization coefficients.
5. The method for detecting unmanned aerial vehicles based on lightweight deployment of a YOLO network according to claim 1, characterized in that: In step 4, when testing, reparameterization is performed and the skip connection and batch normalization layer in the basic training structure are deleted, and only the inverted bottleneck established by the 3×3 depth convolution and 1×1 point convolution of the MobileNet-V1 block is retained.
6. The method for detecting unmanned aerial vehicles based on lightweight deployment of a YOLO network according to claim 1, characterized in that: In step 4, after testing, the average model accuracy, model parameter quantity and floating-point operations required for model reasoning are calculated to determine whether the model performance meets the requirements. If the model accuracy does not meet the requirements, repeat step 3 and increase the number of training rounds.
7. The method for detecting unmanned aerial vehicles based on lightweight deployment of a YOLO network according to claim 1, characterized in that: In step 6, the method for performing multi-thread acceleration detection is: Step 6.1, create a video stream acquisition thread, which is executed on the CPU, obtains video image information from the camera or other video input unit and submits it to the task queue; Step 6.2, create a worker thread pool, which is executed on the NPU. N worker threads are initialized in the thread pool to obtain tasks from the task queue and process them. N threads work in parallel. Step 6.3, create a result processing thread, which is executed on the CPU, obtains the results from the worker threads in the worker thread pool, and displays them visually.
Citation Information
Patent Citations
Novel unmanned aerial vehicle target detection method based on deep learning
CN115705700A
Vehicle real-time detection method based on unmanned aerial vehicle
CN116129293A
Real-time traffic flow detection system and method based on ghost convolutional feature fusion neural network
WO2021238019A1
Cited By
ONVIF standard-based edge end detection method and system
CN119205827A
Deep learning-based dense parcel visual real-time accurate detection method
CN119338783A
A Deep Learning-Based Real-Time Accurate Visual Detection Method for Dense Packages
CN119338783B
