A method, electronic device and storage medium for small target detection by unmanned aerial vehicles (UAVs)

By combining the feature extraction capabilities of CNN and Transformer and using the backbone network and JCASA module for multi-scale feature fusion, the problem of low accuracy in small target detection in UAV aerial images is solved, and efficient small target detection is achieved.

CN119478739BActive Publication Date: 2025-10-28NANJING UNIV OF POSTS & TELECOMM

Patent Information

Application Number
CN202411580760.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-07
Publication Date
2025-10-28
Estimated Expiration
2044-11-07

AI Technical Summary

Technical Problem

Detecting small targets in drone aerial images is difficult, and existing target detection algorithms struggle to achieve optimal results in complex backgrounds, especially due to the limited pixel information and blurred textures of small targets, resulting in low detection accuracy.

Method used

Combining the feature extraction capabilities of CNN and Transformer, through the backbone network, JCASA module and detection head network, the PAFPN structure is adopted for multi-scale feature fusion, the CBAM and SA modules are used to screen important features, a small target detection head is added, and the loss function is optimized to improve detection accuracy.

Benefits of technology

It improves the accuracy and real-time performance of small target detection by UAVs, reduces the complexity of self-attention calculation, and enhances the ability to detect small targets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119478739B_ABST
    Figure CN119478739B_ABST
Patent Text Reader

Abstract

This invention relates to the field of image processing target detection, specifically to a method, electronic device, and storage medium for detecting small targets on unmanned aerial vehicles (UAVs). The method includes: acquiring an image dataset; preprocessing each image in the image dataset, wherein the image dataset consists of images captured by a UAV and corresponding small target verification data; inputting the preprocessed images into a network detection model; calculating the loss function between the output of the network detection model and the actual small target verification data; training the parameters of the network detection model until optimal; inputting the image to be detected into the optimal detection model; and outputting the UAV image small target detection result. The optimal detection model refers to the network detection model after training with its parameters adjusted to the optimal level, thereby enhancing the model's ability to locate and detect small targets.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing target detection, specifically to a method, electronic device, and storage medium for detecting small targets on unmanned aerial vehicles (UAVs). Background Technology

[0002] Small object detection refers to detecting small objects in an image, typically smaller than 1 / 10 of the image size or less. This concept is significant in computer vision because it has various applications, such as security monitoring, intelligent transportation, and drones. The challenge of small object detection lies in the fact that these objects usually carry limited information, such as texture, shape, and color, and occupy fewer pixels in the image. After multiple downsampling steps, the resolution of small objects further decreases, and their feature information gradually weakens, increasing the difficulty of detection. Therefore, general-purpose object detectors have relatively low accuracy in detecting small objects.

[0003] The significance of small object detection lies in its ability to broaden the application scope of the technology and help to better understand the detailed information in images. Small object detection has wide applications in daily life and industry, such as traffic monitoring, medical image analysis, and drone aerial photography. For example, in traffic monitoring, small object detection can be used to identify traffic lights and license plates; in medical image analysis, it can be used to identify tiny tumor cells; and in autonomous driving, it can be used to identify tiny obstacles, compensating for the limitations of lidar in detection.

[0004] The application scenarios for small target detection using drones are very extensive. For example, in urban traffic monitoring, drones can patrol the city skies, detecting vehicles and pedestrians through models to assist in traffic management; in road safety assessment, drones can capture road conditions and detect violations by pedestrians and vehicles to assess road safety; in disasters or emergencies, drones can quickly detect trapped people and vehicles, guiding rescue operations. However, due to the unstable flight altitude of drones, the vast image field, and the varying scales, high density, and occlusion between objects in drone aerial images, accurate detection is difficult. These problems pose challenges to drone aerial target detection; therefore, accurately handling various complex scenarios in drone target detection has significant theoretical and practical value.

[0005] Currently, deep learning-based object detection technologies are mainly divided into two types: the first is a two-stage method based on candidate regions, represented by Fast R-CNN and Faster R-CNN; the second is a single-stage method, represented by SSD and YOLO series algorithms. Current object detection algorithms typically focus on detection in general scenarios. Drone aerial images contain a large number of densely distributed small targets. Due to the limited pixel information and blurred textures of these small targets, coupled with complex and diverse background environments, detection becomes more difficult, hindering the achievement of optimal detection results. CNN-based object detection methods often focus only on local information when extracting features, while Transformer-based object detection methods have a stronger global attention mechanism, improving object detection accuracy, but also resulting in a larger number of model parameters. Therefore, this invention utilizes CNN to reduce the self-attention computation in Transformer, while combining the local feature extraction capabilities of CNN with the global feature extraction capabilities of Transformer to enhance the feature representation ability of object detection. Considering the real-time detection of small targets on drones, and the fact that the pure CNN YOLO algorithm is fast, simple, intuitive, and has strong generalization ability, this invention is innovatively designed based on the latest YOLOv10. Summary of the Invention

[0006] The purpose of this invention is to provide a method, electronic device and storage medium for detecting small targets using a drone, in order to solve the problems mentioned in the background art.

[0007] To address the aforementioned technical problems, this invention provides the following technical solution: a method for detecting small targets using a UAV, the method comprising:

[0008] The image dataset is acquired, and each image in the image dataset is preprocessed. The image dataset consists of images taken by the UAV and corresponding small target verification data of the images.

[0009] The preprocessed image is input into the network detection model, the loss function between the output of the network detection model and the actual small target verification data is calculated, and the network detection model parameters are trained until the optimal value is achieved.

[0010] The image to be detected is input into the optimal detection model, and the small target detection result of the UAV image is output. The optimal detection model refers to the network detection model after training and adjusting the model parameters to the optimal.

[0011] Preferably, the network detection model includes: a backbone network, an intermediate network, and a detection head network;

[0012] The backbone network extracts features from the preprocessed image;

[0013] The intermediate network uses a PAFPN structure to collect image features at different scales and perform multi-scale feature fusion.

[0014] The detection head network converts the fused feature map into specific information required for object detection, including category, location, and confidence, as the output of the network detection model.

[0015] Preferably, the backbone network performs feature extraction and downsampling on the preprocessed image, including:

[0016] The preprocessed image is input into the CBS module, which includes a convolutional layer, a normalization layer, and an activation function layer. The convolutional layer uses convolution operations to extract local spatial information of the image and downsamples the image feature map. The normalization layer is used to normalize the feature value distribution of the image and accelerate the convergence of the network. The activation function layer introduces nonlinear transformation capability to transform and extract image features.

[0017] Image features output from the activation function layer are input into a feature network, which includes a first feature subnetwork, a second feature subnetwork, and a third feature subnetwork. The data transmission method is: first feature subnetwork → second feature subnetwork → third feature subnetwork. The first and second feature subnetworks are composed of a CBS module and a C2f module. The third feature subnetwork is composed of an SCDown module and a C2f module. The C2f module uses a Bottleneck structure to fuse image features at different scales. The SCDown module is used for spatial and channel decoupling.

[0018] The feature data output by the third feature sub-network is input into the JCASA module, which includes the CBAM module and the SA module. The CBAM module uses channel attention and spatial attention to filter out important feature data. The SA module uses self-attention to calculate multi-granularity feature information.

[0019] The feature data output by the SA module is input into the spatial pyramid module, which uses spatial pyramid pooling to efficiently capture multi-scale feature information.

[0020] Preferably, the CBAM module utilizes channel attention and spatial attention to filter out important feature data, including:

[0021] S1, Channel Attention Calculation:

[0022] Set the input feature to F ch-in Then according to F avg =AvgPool(F ch-in ) and F max =MaxPool(F ch-inThis yields two distinct spatial context descriptors; where F avg F max Both represent spatial context descriptors, and AvgPool represents the input feature F. ch-in Using average pooling, MaxPool represents the expression for the input feature F. ch-in Max pooling is used to aggregate spatial information from feature maps;

[0023] Two spatial context descriptors are forwarded to a shared network to generate a channel attention map, resulting in two feature data. The shared network consists of two convolutional layers and an activation function.

[0024] F avg-conv =Conv2(Act(Conv1(F avg ))), F max-conv =Conv2(Act(Conv1(F max )));

[0025] Here, Conv1 and Conv2 both represent 1*1 convolutions, with a fully connected layer in the direction of the channel, and Act represents the ReLU activation function, which introduces non-linear characteristics;

[0026] Obtain two feature data points, and then use the sigmoid activation function to obtain the weight coefficients M for the two feature data points: M = σ(F avg-conv +F max-conv ); where σ represents the sigmoid function;

[0027] Based on input features F ch-in The new feature data, scaled up, is obtained by combining the weight coefficients M: F ch-out =M×F ch-in ;

[0028] S2, Spatial Attention Calculation:

[0029] For new feature data F ch-out Performing max pooling and average pooling operations along the channel dimension respectively yields two context-scale features: F max =MaxPool(F ch-out ), F avg =AvgPool(F ch-out );

[0030] The spatial attention weight M is obtained based on two contextual scale features: M = Conv(Cat(F)). max ,F avg Cat represents the concatenation function that concatenates the features after max pooling and average pooling along the channel dimension, and Conv represents a 7*7 convolution operation.

[0031] Apply the sigmoid activation function to the generated spatial attention weights M, restricting the weights to between 0 and 1: F sp-out =σ(M)×F ch-out Confirm output feature F sp_out .

[0032] Preferably, the SA module utilizes self-attention computation to obtain multi-granularity feature information, including:

[0033] Self-attention calculation:

[0034] Obtaining two-dimensional input features X = F sp_out Where the two-dimensional input features X∈R H×W×C H and W represent the width and height of the two-dimensional image features, respectively, and C represents the number of channels; then X is divided into S×S non-overlapping regions, such that each region contains eigenvectors, and reshape X into ...

[0035] According to Q=X r W q K = X r W k V = X r W v Among them, W q W k W v ∈R C×C These are the projection weights for the query, key, and value, respectively.

[0036] First, export the projection weights of the region-level query and key, then use Q... r With the transpose of K r Matrix multiplication between regions leads to the derivation of the region-to-region affinity graph matrix. A r =Q r (K r ) T ; where the affinity graph matrix A r The entries in the text measure the degree of semantic association between two regions;

[0037] Derive the index matrix using the row-by-row topk operator And it applies fine-grained token-to-token attention: for each query token in region i, it will pay attention to... For all key-value pairs in the union of the k indexed routing regions, then according to K g =gather(K,I) r V g =gather(V,I) r Confirm key-value tensors

[0038] Obtain the routed Q and K g V g Then, Q and K g V g The algorithm is divided into four parts. Three of these parts are convolutional using depthwise convolutions of different sizes (Agg(·)) as aggregators, with kernel sizes set to 3, 5, and 7 respectively. The remaining part is left unprocessed. Finally, these four parts are concatenated to obtain the new Q and K. g V g ;

[0039] According to Q, K g V g Confirm the self-attention calculation for the two-dimensional input feature X:

[0040] O = Attention(Q,K) g V g )+LCE(V); where LCE(V) represents the local context enhancement term.

[0041] Preferably, the loss function includes the binary cross-entropy loss function, the distribution focus loss function, and the perfect intersection-union loss function. These three loss functions work together to guide the model in learning the target detection task.

[0042] Preferably, the loss function between the output of the network detection model and the actual small target validation data is calculated, and the network detection model parameters are trained until optimal, including:

[0043] The training image and small target verification image of the preprocessed UAV image are obtained and input into the network detection model. After obtaining the output result, the error between the model prediction result and the true label is calculated according to the loss function. The obtained loss is fed back to the network to update the network model weights, so that the model gradually optimizes the parameters during the training process and improves the prediction accuracy of the model.

[0044] An electronic device, comprising:

[0045] At least one processor;

[0046] And, a memory that is communicatively connected to at least one processor;

[0047] The memory stores instructions that can be executed by the at least one processor, which are then executed by the at least one processor to enable the at least one processor to perform the detection method described above.

[0048] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned detection method.

[0049] Compared with the prior art, the beneficial effects achieved by the present invention are:

[0050] This invention adds an innovative JCASA module to the backbone network. This module is mainly composed of CBAM and SA in series, which ensures accuracy while avoiding excessive overhead caused by the secondary computation complexity of self-attention. In the SA module, when Transformer self-attention calculates Q, K, and V, it combines a unique Group-Mix with Routing mechanism to reduce the number of parameters and increase the information of local feature maps of different sizes. By further adding an upsampling stage to the Neck network to obtain large-scale feature maps, and adding a corresponding small target detection head to enhance the detection capability of small-sized targets, this invention improves the detection capability of small-sized targets. Attached Figure Description

[0051] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:

[0052] Figure 1 This is a flowchart of a small target detection method for unmanned aerial vehicles (UAVs) according to the present invention;

[0053] Figure 2 This is a structural diagram of the network detection model in the UAV small target detection method of the present invention;

[0054] Figure 3 This is a backbone network structure diagram of a small target detection method for unmanned aerial vehicles (UAVs) according to the present invention;

[0055] Figure 4 This is a schematic diagram of the detection effect in an embodiment of the UAV small target detection method of the present invention;

[0056] Figure 5 This is a comparative experimental result of different detection algorithms in an embodiment of the UAV small target detection method of the present invention. Detailed Implementation

[0057] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0058] Please see Figures 1-5 The present invention provides a technical solution: a method for detecting small targets using a UAV, the method comprising:

[0059] The image dataset is acquired, and each image in the image dataset is preprocessed. The image dataset consists of images taken by the UAV and corresponding small target verification data of the images.

[0060] Preprocessing includes operations such as rotating, scaling, flipping, and randomly cropping the image to enhance the image data;

[0061] This invention utilizes the image-rich VisDrone2019 dataset (an image dataset captured by drones). The VisDrone2019 object detection dataset consists of images and corresponding annotation files, with 6471 images in the training set, 548 images in the validation set, and 1610 images in the test set. Image sizes in the dataset range from 2000×1500 to 480×360. Because the images were taken from a drone's perspective, they differ significantly from ground-based images such as those taken by personnel (MS-COCO, VOC2012, etc.) in terms of shooting angle, image content, background, and ambient illumination. The scenes depicted in the dataset are very diverse, including streets, squares, parks, schools, and residential communities.

[0062] The lighting conditions of the images include well-lit daytime, poorly lit nighttime, cloudy, bright light, and glare conditions; the object types labeled in the images include 10 types: pedestrians, people, bicycles, cars, vans, trucks, tricycles, awning tricycles, buses, and electric motors.

[0063] The preprocessed image is input into the network detection model, the loss function between the output of the network detection model and the actual small target verification data is calculated, and the network detection model parameters are trained until the optimal value is achieved.

[0064] The image to be detected is input into the optimal detection model, and the small target detection result of the UAV image is output. The optimal detection model refers to the network detection model after training and adjusting the model parameters to the optimal.

[0065] Preferably, the network detection model includes: a backbone network, an intermediate network, and a detection head network;

[0066] The backbone network extracts features from the preprocessed image;

[0067] The intermediate network uses a PAFPN structure to collect image features at different scales and perform multi-scale feature fusion.

[0068] The intermediate network adopts a PAFPN structure, which consists of top-down and bottom-up branches, enabling effective multi-scale feature fusion.

[0069] For example, different layers branching from top to bottom receive feature maps P5 (20*20*1024), P4 (40*40*512), P3 (80*80*256), and P2 (160*160*128) respectively from the SPPF layer in the spatial pyramid module of the backbone network and the C2f layer in the feature network through lateral connections.

[0070] The top-down branch consists of three parts. Each layer consists of upsampling, concatenation, and C2f modules. Compared with the original YOLOv10 Neck network, this invention adds an upsampling stage to obtain large-scale data and enhance the algorithm's ability to detect small targets.

[0071] In each layer, upsampling involves doubling the image size through deconvolution. Then, the Concat module fuses the enlarged image features with the features obtained from the backbone network through lateral connections. For example, P5 (20*20*1024) becomes 40*40*512 after upsampling, denoted as N1, and is input to the stitching module. The stitching module obtains the output P4 (40*40*512) of the third feature subnetwork in the backbone network through lateral connections and fuses it with N1, i.e., adding element-wise to obtain a new feature map. The new feature map then enters the C2f module for feature fusion at different scales before being input to the next stage. The final output of the Neck network is denoted as H1, which is 160*160*128 due to three upsampling operations.

[0072] The detection head network converts the fused feature map into specific information required for target detection, including category, location, and confidence, as the output of the network detection model.

[0073] The main function of the detection head network is to convert feature maps into specific information required for object detection, including category, location, and confidence. The detection head network includes several convolutional layers and activation functions. These convolutional layers are used to further process the feature maps output by the intermediate networks to extract more high-level features.

[0074] For example, there are four detection heads that receive H1 (160*160*128), H2 (80*80*256), H3 (40*40*512), and H4 (20*20*1024) as inputs to detect targets of different sizes. Among them, the detection head that receives a large-scale feature map like H1 is specifically designed for detecting small targets, which improves the overall model's ability to detect small targets.

[0075] Preferably, the backbone network performs feature extraction and downsampling on the preprocessed image, including:

[0076] The preprocessed image is input into the CBS module, which includes a convolutional layer, a normalization layer, and an activation function layer. The convolutional layer uses convolution operations to extract local spatial information of the image and downsamples the image feature map. The normalization layer is used to normalize the feature value distribution of the image and accelerate the convergence of the network. The activation function layer introduces nonlinear transformation capability to transform and extract image features.

[0077] The convolutional layer has a kernel size of 3*3, a stride of 2, and 64 channels. So when the input image size is 640*640*3, the output size after convolution is 320*320*64. The output is then passed through a BN layer to normalize the feature value distribution, which speeds up the convergence of the network.

[0078] Image features output from the activation function layer are input into a feature network, which includes a first feature subnetwork, a second feature subnetwork, and a third feature subnetwork. The data transmission method is: first feature subnetwork → second feature subnetwork → third feature subnetwork. The first and second feature subnetworks are composed of a CBS module and a C2f module. The third feature subnetwork is composed of an SCDown module and a C2f module. The C2f module uses a Bottleneck structure to fuse image features at different scales. The SCDown module is used for spatial and channel decoupling.

[0079] The feature data output by the third feature sub-network is input into the JCASA module, which includes the CBAM module and the SA module. The CBAM module uses channel attention and spatial attention to filter out important feature data. The SA module uses self-attention to calculate multi-granularity feature information.

[0080] We construct a module JCASA based on the combination of CNN and Transformer self-attention. The JCASA module is placed only after the third feature sub-network with low resolution, which ensures accuracy while avoiding excessive overhead caused by the secondary computation complexity of self-attention.

[0081] The feature data output by the SA module is input into the spatial pyramid module, which uses spatial pyramid pooling to efficiently capture multi-scale feature information.

[0082] Preferably, the CBAM module utilizes channel attention and spatial attention to filter out important feature data, including:

[0083] S1, Channel Attention Calculation:

[0084] Set the input feature to F ch-in Then according to F avg =AvgPool(F ch-in ) and Fmax =MaxPool(F ch-in This yields two distinct spatial context descriptors; where F avg F max Both represent spatial context descriptors, and AvgPool represents the input feature F. ch-in Using average pooling, MaxPool represents the expression for the input feature F. ch-in Max pooling is used to aggregate spatial information from feature maps;

[0085] Two spatial context descriptors are forwarded to a shared network to generate a channel attention map, resulting in two feature data. The shared network consists of two convolutional layers and an activation function.

[0086] F avg-conv =Conv2(Act(Conv1(F avg ))), F max-conv =Conv2(Act(Conv1(F max )));

[0087] Here, Conv1 and Conv2 both represent 1*1 convolutions, with a fully connected layer in the direction of the channel, and Act represents the ReLU activation function, which introduces non-linear characteristics;

[0088] Obtain two feature data points, and then use the sigmoid activation function to obtain the weight coefficients M for the two feature data points: M = σ(F avg-conv +F max-conv ); where σ represents the sigmoid function;

[0089] Based on input features F ch-in The new feature data, scaled up, is obtained by combining the weight coefficients M: F ch-out =M×F ch-in ;

[0090] In neural networks, the higher the dimension, the smaller the feature map size and the more channels there are. Each channel represents the feature information of the entire image. With so much channel information, it is difficult for neural networks to identify and filter out the useful channel information. This is where channel attention comes in, which tells the network which channels are important.

[0091] Furthermore, for each image, especially large images, the importance of information in different regions varies, so the attention required for different regions also varies. In this case, a spatial attention mechanism can be used to assign a weight to each pixel or region in the image. These weights determine the degree to which the model should pay attention when processing the image. Regions with higher weights will receive more attention, while regions with lower weights will be relatively ignored. Therefore, the JCASA module uses the CBAM module, which is a combination of channel attention and spatial attention, to provide more effective features for subsequent self-attention calculations.

[0092] S2, Spatial Attention Calculation:

[0093] For new feature data F ch-out Performing max pooling and average pooling operations along the channel dimension respectively yields two context-scale features: F max =MaxPool(F ch-out ), F avg =AvgPool(F ch-out );

[0094] The spatial attention weight M is obtained based on two contextual scale features: M = Conv(Cat(F)). max ,F avg Cat represents the concatenation function that concatenates the features after max pooling and average pooling along the channel dimension, and Conv represents a 7*7 convolution operation.

[0095] Apply the sigmoid activation function to the generated spatial attention weights M, restricting the weights to between 0 and 1: F sp-out =σ(M)×F ch-out Confirm output feature F sp_out .

[0096] Preferably, the SA module utilizes self-attention computation to obtain multi-granularity feature information, including:

[0097] Self-attention calculation:

[0098] Obtaining two-dimensional input features X = F sp_out Where the two-dimensional input features X∈R H×W×C H and W represent the width and height of the two-dimensional image features, respectively, and C represents the number of channels; then X is divided into S×S non-overlapping regions, such that each region contains eigenvectors, and reshape X into ...

[0099] According to Q=X r W q K = X r W kV = X r W v Among them, W q W k W v ∈R C×C These are the projection weights for the query, key, and value, respectively.

[0100] First, export the projection weights of the region-level query and key, then use Q... r With the transpose of K r Matrix multiplication between regions leads to the derivation of the region-to-region affinity graph matrix. A r =Q r (K r ) T ; where the affinity graph matrix A r The entries in the text measure the degree of semantic association between two regions;

[0101] Derive the index matrix using the row-by-row topk operator And it applies fine-grained token-to-token attention: for each query token in region i, it will pay attention to... For all key-value pairs in the union of the k indexed routing regions, then according to K g =gather(K,I) r V g =gather(V,I) r Confirm key-value tensors

[0102] Obtain the routed Q and K g V g Then, Q and K g V g The algorithm is divided into four parts. Three of these parts are convolutional using depthwise convolutions of different sizes (Agg(·)) as aggregators, with kernel sizes set to 3, 5, and 7 respectively. The remaining part is left unprocessed. Finally, these four parts are concatenated to obtain the new Q and K. g V g ;

[0103] According to Q, K g V g Confirm the self-attention calculation for the two-dimensional input feature X:

[0104] O = Attention(Q,K) g V g )+LCE(V); where LCE(V) represents the local context enhancement term;

[0105] When calculating self-attention, it can be found that queries in different semantic regions actually focus on completely different key-value pairs; therefore, forcing all queries to process the same set of tokens may not be optimal. This invention utilizes a routing mechanism to ensure that each query only focuses on the semantically most relevant key-value pairs. In addition, most Transformer model attention graphs only describe the correlation between each individual token pair at a single granularity, and multiplying the attention graph with the value only linearly recombines the individual tokens. Such models obviously do not consider the correlation between different token groups at different granularities. In this model, the token is divided into four parts, and some individual tokens are replaced with group proxies generated by the group aggregator. Subsequently, the attention graph is calculated using the query and key, and it is used to recombine the group proxies and individual tokens in the value. This allows for the acquisition of multi-granularity feature information, that is, mixing different attentions together to better understand the tokens from a comprehensive perspective. To generate group proxies of different sizes, depthwise convolutions with different kernel sizes are used as aggregators. At the same time, depthwise convolutions can reduce the spatial scale of K and V. This calculation method is the Group-Mix with Routing mechanism used in this invention.

[0106] Preferably, the loss function includes the binary cross-entropy loss function, the distribution focus loss function, and the perfect intersection-union loss function. These three loss functions work together to guide the model in learning the target detection task.

[0107] Preferably, the binary cross-entropy loss function is used to evaluate the difference between predicted values ​​and actual labels in a classification model: given a set of actual labels y, the corresponding predicted value is p(y), and the BCE Loss is denoted as L. BCE The calculation is as follows:

[0108]

[0109] Where N is the number of samples, y i p(y) is the actual label of the i-th sample, taking the value 0 or 1. i ) is the predicted value of the i-th sample, and its value ranges between (0, 1);

[0110] Specifically, for each sample, first according to formula y i log(p(y i ))+(1-y i )log(1-p(y i )) Calculate the loss, then take the negative of the above result, i.e., -[y i log(p(y i ))+(1-y i)log(1-p(y i Finally, by averaging the losses of all samples, we can calculate the output loss of the model for a set of size N.

[0111] Calculate L BCE When y = 1, the true label indicates that the event has occurred, and L... BCE = -log(p(y)), when the predicted value p(y) is close to 1, L BCE When the predicted value p(y) is close to 0, L BCE Approaching infinity;

[0112] When y = 0, the true label indicates that the event has not occurred; in this case, L BCE = -log(1-p(y)), when the predicted value p(y) is close to 1, L BCE Approaching infinity; when the predicted value p(y) approaches 0, L BCE Approaching 0;

[0113] Therefore, when training the model, the model parameters can be optimized by minimizing the BCE Loss, so that the predicted probability is as close as possible to the true label.

[0114] Preferably, the regression loss, or distribution focus loss, focuses on the distribution differences of bounding box regression, rather than directly predicting the bounding box, but rather predicting the probability distribution of the bounding box; it aims to solve challenging objects with blurred or partially occluded boundaries; in traditional object detection, especially in complex scenes, the definition of the true bounding box of the target object cannot be given precisely; considering that the true distribution is usually not too far from the labeled position, DFL chooses to optimize the probability of the two positions to the left and right of the label, so that the network distribution focuses on the vicinity of the label value;

[0115] The loss function is denoted as L DFL The definition is as follows: In layman's terms, during training, the bounding box of the target should not be a fixed value, but rather a distribution. For example, for the object of waves, its boundary is unclear. This loss function can reduce the overfitting phenomenon that occurs during network training.

[0116]

[0117] Where y is the actual value of the label, y i y i+1 S represents two predicted values ​​near label y. i S i+1 y i y i+1The corresponding probability; for example, if the center point of an object is 73px from its upper boundary, in a feature map with a maximum downsampling factor of 32, its mapping value y in DFL is calculated as 73 / 32 = 2.3. Rounding down gives the label value y. i =2, neighboring label value y i+1 =3.

[0118] Preferably, the perfect intersection-union ratio loss function is used to measure the difference between the predicted bounding box and the actual bounding box; it is a comprehensive metric that considers three attributes between the bounding boxes: overlap ratio, distance between center points, and aspect ratio.

[0119] The loss function is denoted as L CIOU The calculation process is as follows:

[0120]

[0121] L CIOU =1-CIoU;

[0122] In the formula, the three terms of CIOU correspond exactly to IOU: center point distance, aspect ratio calculation, α and υ being the aspect ratio, parameter c being the diagonal of the bounding box, ρ being the Euclidean distance, and b, w, h being the distance between the two values. gt w gt h gt These represent the center, width, and height of the predicted bounding box and the ground truth bounding box, respectively.

[0123] Preferably, the loss function between the output of the network detection model and the actual small target validation data is calculated, and the network detection model parameters are trained until optimal, including:

[0124] The training image and small target verification image of the preprocessed UAV image are obtained and input into the network detection model. After obtaining the output result, the error between the model prediction result and the true label is calculated according to the loss function. The obtained loss is fed back to the network to update the network model weights, so that the model gradually optimizes the parameters during the training process and improves the prediction accuracy of the model.

[0125] For example, images from the visdrone2019 dataset are preprocessed by scaling, random cropping, etc., and then fed into the network detection model. The loss function value of the images is calculated based on the loss function, and the resulting loss is fed back to the network detection model to update the weights of the network detection model.

[0126] Preferably, the network is trained using the PyTorch 2.0.1 framework. The initial learning rate parameter determines the step size of the model weight adjustment, which helps to achieve rapid convergence in the early stages of training, and is set to 0.01. Stochastic gradient descent (SGD) with momentum is used as the optimizer. Momentum is a technique to accelerate the gradient descent process and increase the stability of parameter updates. The optimizer's momentum is set to 0.937, and the weight decay coefficient is 0.0005. Weight decay is a regularization technique used to reduce model complexity and prevent overfitting. The entire network is trained for 200 epochs to fully learn from the data.

[0127] To further verify the potential advantages of the algorithm of this invention, a variety of target detection algorithms were selected for comparative experiments, mainly including commonly used frameworks and the latest improvements in the field of small target detection; such as Figure 5 As shown, by comparing and analyzing the mAP values ​​of each category after training on the VisDrone2019 dataset, it can be seen that the algorithm model of this invention has the best overall performance compared with other algorithm models. On the one hand, it has the best detection accuracy in target categories such as pedestrians and cars; on the other hand, it has improved the average detection accuracy by 1.9% compared with the latest YOLOv11 model. Compared with the RT-DETR detection algorithm, which relies more on the Transformer architecture, the algorithm model of this invention still maintains its advantage in detection accuracy. The algorithm model of this invention adopts a unique Group-Mix with Routing mechanism to calculate self-attention, and adds feature extraction and detection heads for small targets in the intermediate network and the detection head network, so that the entire model can more fully mine the texture information of small targets and enhance the model's ability to locate and detect small targets.

[0128] An electronic device, comprising:

[0129] At least one processor;

[0130] And, a memory that is communicatively connected to at least one processor;

[0131] The memory stores instructions that can be executed by the at least one processor, which are then executed by the at least one processor to enable the at least one processor to perform the detection method described above.

[0132] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned detection method.

[0133] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for detecting small targets using an unmanned aerial vehicle (UAV), characterized in that: The method includes: An image dataset is acquired, and each image in the image dataset is preprocessed. The image dataset consists of images taken by a drone and corresponding small target verification data of the images. The preprocessed image is input into the network detection model, the loss function between the output of the network detection model and the actual small target verification data is calculated, and the parameters of the network detection model are trained until the optimal value is achieved. The image to be detected is input into the optimal detection model, and the small target detection result of the UAV image is output. The optimal detection model refers to the network detection model after training and adjusting the model parameters to the optimal. The network detection model includes: a backbone network, an intermediate network, and a detection head network; The backbone network extracts features from the preprocessed image; The intermediate network uses a PAFPN structure to collect image features at different scales and perform multi-scale feature fusion. The detection head network converts the fused feature map into specific information required for target detection, including category, location, and confidence, as the output of the network detection model. The backbone network performs feature extraction and downsampling on the preprocessed image, including: The preprocessed image is input into the CBS module, which includes a convolutional layer, a normalization layer, and an activation function layer. The convolutional layer uses convolution operations to extract local spatial information of the image and downsamples the image feature map. The normalization layer is used to normalize the feature value distribution of the image, accelerating the convergence of the network. The activation function layer introduces nonlinear transformation capabilities to transform and extract image features. The image features output from the activation function layer are input into a feature network, which includes a first feature subnetwork, a second feature subnetwork, and a third feature subnetwork. The data transmission method is: first feature subnetwork → second feature subnetwork → third feature subnetwork. The first and second feature subnetworks are composed of a CBS module and a C2f module. The third feature subnetwork is composed of an SCDown module and a C2f module. The C2f module uses a Bottleneck structure to fuse image features at different scales. The SCDown module is used for spatial and channel decoupling. The feature data output by the third feature sub-network is input to the JCASA module, which includes a CBAM module and an SA module; the CBAM module uses channel attention and spatial attention to filter out important feature data; the SA module uses self-attention calculation to obtain multi-granularity feature information; The feature data output by the SA module is input to the spatial pyramid module, which uses spatial pyramid pooling to efficiently capture multi-scale feature information. The SA module utilizes self-attention computation to obtain multi-granularity feature information, including: Self-attention calculation: Obtaining 2D Input Features Two-dimensional input features H and W represent the width and height of the two-dimensional image features, respectively, and C represents the number of channels; then X is divided into S×S non-overlapping regions, such that each region contains 1 eigenvector, and Remodeling ; according to ,in, These are the projection weights for the query, key, and value, respectively. First, export the projection weights of the region-level query and key, then... With transpose Matrix multiplication between regions leads to the derivation of the region-to-region affinity graph matrix. : ; where the affinity graph matrix The entries in the text measure the degree of semantic association between two regions; Derive the index matrix using the row-by-row topk operator And apply fine-grained token-to-token attention: for each query token in region i, it will pay attention to... Given all key-value pairs in the union of the k indexed routing regions, then according to Confirm key-value tensors ; Get the routed Afterwards, The algorithm is divided into four parts. Three of these parts are convolutional using depthwise convolutions of different sizes (Agg(·) as aggregators), with kernel sizes set to 3, 5, and 7 respectively. The remaining part is left unprocessed. Finally, these four parts are concatenated to obtain a new algorithm. ; according to Confirm 2D input features Self-attention calculation: Where LCE(V) represents the Local Context Enhancement term.

2. The UAV small target detection method as described in claim 1, characterized in that, The CBAM module uses channel attention and spatial attention to filter out important feature data, including: S1, Channel Attention Calculation: Set the input features as According to and This results in two different spatial context descriptors; among them, , Both represent spatial context descriptors. Indicates input features Use average pooling operation. Indicates input features Max pooling is used to aggregate spatial information from feature maps; The two spatial context descriptors are forwarded to a shared network to generate a channel attention map, resulting in two feature data. The shared network consists of two convolutional layers and an activation function. , ; in, and Both represent 1*1 convolutions, with a fully connected layer in the direction of the channel. Act represents the ReLU activation function, which introduces non-linear characteristics. Obtain the two feature data, and then use the sigmoid activation function to obtain the weight coefficients M1 of the two feature data: Where σ represents the sigmoid function; Based on input features The new feature data is obtained after scaling by combining the weight coefficients M1: ; S2, Spatial Attention Calculation: For the new feature data Performing max pooling and average pooling operations along the channel dimension respectively yields two context-scale features: , ; The spatial attention weight M is obtained based on the two contextual scale features: ; where Cat represents the concatenation function that concatenates the features after max pooling and average pooling along the channel dimension, and Conv represents a 7*7 convolution operation; Apply the sigmoid activation function to the generated spatial attention weights M, restricting the weights to between 0 and 1: Confirm output characteristics .

3. The UAV small target detection method as described in claim 1, characterized in that, The loss functions include the binary cross-entropy loss function, the distribution focus loss function, and the complete intersection-union loss function. These three loss functions work together to guide the model in learning the target detection task.

4. The UAV small target detection method as described in claim 1, characterized in that, The calculation of the loss function between the output of the network detection model and the actual small target verification data, and the training of the network detection model parameters until optimal, includes: The training image and small target verification image of the preprocessed UAV image are obtained and input into the network detection model. After obtaining the output result, the error between the model prediction result and the true label is calculated according to the loss function. The obtained loss is fed back to the network to update the network model weights, so that the model gradually optimizes the parameters during the training process and improves the prediction accuracy of the model.

5. An electronic device, characterized in that, include: At least one processor; And, a memory communicatively connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the detection method as described in any one of claims 1-4.

6. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the detection method according to any one of claims 1-4.

Citation Information

Patent Citations

  • Lightweight target detection method and system based on YOLOv8 improvement

    CN116740538A

  • Unmanned aerial vehicle target detection method based on space-frequency feature fusion detection head

    CN118691929A

Cited By

  • Infrared image unmanned aerial vehicle target detection method and device based on complementary design, and medium

    CN122289650A