Unmanned aerial vehicle top-view small target detection method based on density perception and spatial hierarchy
By combining adaptive image slicing and density-aware dual-branch detection head design, the problem of dense small target detection under the top-down view of UAVs is solved, realizing accurate detection of small targets in high-resolution images and high-precision recognition in complex scenes.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINESE PEOPLES LIBERATION ARMY AIR FORCE SERVICE ACAD
- Filing Date
- 2026-02-05
- Publication Date
- 2026-04-28
AI Technical Summary
The detection of dense small targets from the top-down view of UAVs suffers from problems such as the disappearance of small target features, false suppression due to dense occlusion, and lack of explicit modeling of target distribution density. Existing detection methods are unable to accurately detect small targets and distinguish closely adjacent targets in high-resolution images.
An end-to-end hierarchical detection framework is constructed using an adaptive image slicing and feature preservation module, a density-aware dual-branch detection head, and a repulsion constraint loss function. The original pixel features are preserved through adaptive image slicing, and the accurate detection of dense small targets is achieved by combining the density-aware dual-branch detection head and density-guided adaptive NMS.
It effectively solves the problems of feature loss and dense occlusion of small targets, significantly improves recall and detection accuracy, reduces false detection rate, and enhances the robustness and practicality of the algorithm in complex scenarios.
Smart Images

Figure CN121640326B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and deep learning technology, and in particular to a method for detecting small targets from above by UAVs based on density perception and spatial hierarchy. Background Technology
[0002] With the rapid development of drone technology and the significant reduction in cost, drone-based aerial surveillance has become an important technical means in fields such as smart city construction, public safety and security, traffic flow management, and emergency response. This, in turn, places more stringent demands on target detection algorithms: accurately detecting tiny targets in high-resolution images and distinguishing multiple closely adjacent targets in high-density occlusion scenarios. However, in dense small target detection scenarios from a drone's top-down perspective (such as the VisDrone and UAVDT datasets), existing detection methods suffer from the following technical bottlenecks.
[0003] First, small target features are lost. Drone images typically have a resolution of 1920×1080 pixels or even higher, while existing detectors usually scale the input to 640×640 pixels to accommodate GPU memory. This causes pedestrians or vehicles that originally occupied only 20×20 pixels to be compressed to less than 5×5 pixels, making it impossible for convolutional layers to extract effective features.
[0004] Secondly, dense occlusion leads to false suppression. In scenarios such as traffic intersections and squares, targets are highly densely packed and severely occluded. Existing detectors' non-maximum suppression algorithms use a fixed IoU threshold (e.g., 0.5). This strategy easily misclassifies two closely adjacent real targets as duplicate detections and deletes one of them, resulting in a significant drop in recall.
[0005] Third, there is a lack of explicit modeling of the target distribution density. Existing detectors only output bounding boxes and cannot dynamically adjust the detection strategy according to the degree of regional crowding. This makes it impossible for the algorithm to adopt differentiated processing strategies for dense and sparse regions, making it difficult to meet the requirements of detection accuracy and robustness in practical applications.
[0006] Therefore, there is an urgent need to design a technical solution that can adapt to the characteristics of UAV overhead scenes and effectively solve the problems of small target feature extraction, dense occlusion differentiation and density adaptive detection. Summary of the Invention
[0007] To address the aforementioned technical issues, this invention provides a method for detecting small targets from above using UAVs based on density perception and spatial hierarchy. By constructing an end-to-end hierarchical detection framework using adaptive image slicing, a density-perceived dual-branch detection head, a repulsive force constraint loss function, and density-guided adaptive NMS, this method achieves accurate and real-time detection of dense small targets in this scenario, meeting the needs of UAV high-altitude overhead monitoring in intelligent transportation, public safety, and other fields.
[0008] The technical solution adopted by this invention to solve its technical problem is: a method for detecting small targets from above by a UAV based on density perception and spatial hierarchy, comprising the following steps:
[0009] S1: The high-resolution input image acquired by the UAV is preprocessed by the adaptive image slicing and feature preservation module to obtain sub-images of uniform size and establish a global coordinate mapping relationship;
[0010] S2: Input the preprocessed sub-image into the feature extraction system to obtain a multi-scale feature map. The feature extraction system includes a feature extraction backbone network, a spatial attention enhancement module, and a multi-scale feature fusion network.
[0011] S3: Multi-scale feature map input density-aware dual-branch detection head, parallel output target detection information and pixel-level density heatmap, the target detection information including bounding box coordinates, class probability and target confidence;
[0012] S4: During the training phase, the total loss function constrained by repulsion force is used to optimize the detection model. During the inference phase, density-guided adaptive nonmaximum suppression is used to post-process the target detection information and output the final detection result.
[0013] Furthermore, the specific implementation process of the adaptive image slicing and feature preservation module in step S1 is as follows:
[0014] Step-a1, Adaptive Slicing Parameter Calculation: Set the slice window size to... S×S The overlap rate of adjacent subgraphs is set to i The width of the overlapping pixels is O=S×θ ;
[0015] Calculate the number of horizontal slices based on the original image dimensions. N ω and the number of slices in the vertical direction N h The formula is: ; ;
[0016] In the formula, W The horizontal pixel dimensions of the original image; H The vertical pixel dimensions of the original image; N ω , N h Round all up to the nearest whole number; total number of slices N=N ω ×N h ;
[0017] Step-a2, Edge Reverse Alignment Strategy: During the sliding window cropping process, for the last sub-image of each row or column... P edge If the remaining pixels are insufficient S Then, a reverse alignment method is adopted, that is, tracing back from the boundary of the original image. S Crop each sub-image by one pixel to ensure all sub-images have a constant size. S×S ;
[0018] Step-a3, for each subgraph Establish a coordinate transformation function, where i ∈[ 1,N ω ], j∈[ 1,N h ]; Set the coordinates of the local detection bounding box ( x local ,y local Map back to the original coordinate system x global ,y global );
[0019] The mapping formula is ; ;
[0020] When dealing with subgraphs that are reverse-aligned at the edges, their offsets are directly set to... W−S or H−S .
[0021] Furthermore, the specific implementation process of the feature extraction system in step S2 is as follows:
[0022] Step-b1: The feature extraction backbone network adopts the CSPDarknet network. S×S Feature extraction is performed on the sub-images of different sizes, and three feature layers C3, C4 and C5 with different scales are output, corresponding to resolutions of 80×80 pixels, 40×40 pixels and 20×20 pixels respectively;
[0023] Step-b2, the implementation process of the spatial attention enhancement module is as follows: Max pooling and average pooling are performed on the feature layer in the channel dimension respectively. The pooling results are concatenated and then generated into a weight map by passing it through a 7×7 convolutional layer and the Sigmoid activation function. The weight map is multiplied pixel by pixel with the original feature layer to obtain the enhanced feature layer.
[0024] Step-b3: The multi-scale feature fusion network adopts a structure combining a feature pyramid network and a path aggregation network. The feature pyramid network transmits deep semantic information from top to bottom, while the path aggregation network enhances shallow localization information from bottom to top, ultimately outputting three feature maps that fuse multi-scale information.F i This serves as the input for the subsequent dual-branch detection head.
[0025] Furthermore, the density-aware dual-branch detection head described in step S3 employs a parallel dual-branch decoupled architecture to receive multi-scale feature maps output from the multi-scale feature fusion network. F i The density-sensing dual-branch detection head specifically includes the following two task branches:
[0026] The first is the object detection branch: the object detection branch adopts a decoupled head design, and extracts category features and localization features through two sets of parallel 3×3 convolutional layers respectively;
[0027] The output tensor dimension of the classification sub-branch is... H '× W '× C ,in C The number of categories is used to predict the target category probability at each location. P cls The regression subbranch output tensor has a dimension of . H '×W'×5, used to predict bounding box offset ( x,y, w,h ) and target confidence level conf;
[0028] The second is the density estimation branch: the density estimation branch shares shallow features with the target detection branch, and the deep features are decoupled through an independent three-layer convolutional module;
[0029] The three-layer convolutional module includes two 3×3 convolutional layers and one 1×1 convolutional layer. Each convolutional layer is followed by a BN layer and a ReLU activation function, outputting a pixel-level single-channel density heatmap. D ∈ R H'×W'×1 ;
[0030] True value of single-channel density heatmap ;
[0031] in d For Dirac d function, G σ The variance is s A two-dimensional Gaussian filter; s Adaptively adjusts based on the average size of the target bounding box; M For the target total number, p k Let be the center coordinates of the k-th target.
[0032] Furthermore, the total loss function of the repulsive force constraint mentioned in step S4 is: Ltotal =L cls +L box +L density +λL Rep ;
[0033] in, L cls For classifying losses, L box For bounding box regression loss, L density For density map loss, L Rep Loss due to repulsive force l The repulsive force loss weight hyperparameter; L cls
[0034] For training to monitor sub-branches, a binary cross-entropy loss is used, calculated as follows: ;
[0035] In the formula, y For real category labels, p The predicted class probability; L box To monitor the localization accuracy of the regression sub-branch, the CIoU loss function is used, which simultaneously considers the overlap area, center point distance, and aspect ratio. The formula is as follows: ;
[0036] In the formula, IoU is the crossover-union ratio. The distance between the center points of the predicted bounding box and the ground truth bounding box is the Euclidean distance. c The length of the diagonal of the minimum bounding rectangle. au This is a penalty term for aspect ratio; L density The training of the density estimation branch is supervised, and the predicted density map is calculated using the mean squared error. D With the truth density plot D GT The pixel-level difference between them is expressed by the formula: ;
[0037] In the formula, To predict the density map at the pixel p The value at that location, For the true density map in pixels p The value at; L Rep This is used to introduce a rejection mechanism to prevent the predicted bounding box from shifting excessively towards adjacent interfering targets; the formula is: ;
[0038] In the formula, For the first i One prediction box, For the first j There are 1 non-target truth boxes, and 1[・] is an indicator function that applies a penalty only when the predicted box overlaps with the non-target truth box.
[0039] Furthermore, the specific implementation process of density-guided adaptive nonmaximum suppression in step S4 is as follows:
[0040] Step-c1: Extract regional crowding index: Read the density heatmap output by the density estimation branch. D For each candidate box output by the detection branch B i Extract the coordinates of its center point ( x c , y c To enhance robustness, the average density within the candidate box coverage area is used as an indicator of crowding. d i The formula is: ;
[0041] in, w i and h i These are the width and height of the candidate box, respectively;
[0042] Step-c2, Constructing a density-threshold adaptive mapping function: Establishing a mapping function based on crowding index d i To the dynamic IoU threshold T i The mapping function; the adaptive formula is: ;
[0043] In the formula, T base The set baseline suppression threshold, α For density-adjusted gain coefficient, d max The maximum density observation in the current image; the mapped value. T i Constraints on [ T min ,T max Within the specified range, this effectively curbs the accidental deletion of densely packed targets;
[0044] Step-c3, Candidate Box Filtering: Sort all candidate boxes in descending order of confidence (conf), and select the box with the highest confidence. B maxAs a benchmark, calculate B max With remaining candidate boxes B j IoU, if IoU( B max ,B j )> T max_idx Then remove B j Otherwise, retain; repeat the above process until all candidate boxes have been processed to obtain the final detection result; where T max_idx For the reason B max The dynamic threshold obtained from the calculation of regional density.
[0045] Furthermore, the basic suppression threshold T base =0.45, dynamic threshold range [ T min ,T max = [0.45, 0.75].
[0046] The beneficial effects of this invention are:
[0047] This invention employs an adaptive slicing technique based on overlap rate to fully preserve the original pixel features during the inference stage, effectively solving the problem of missed detection of small targets at a distance. This significantly improves the recall performance on datasets such as VisDrone and effectively addresses the issue of feature loss of small targets in high-resolution images.
[0048] This invention achieves real-time perception and dynamic threshold adjustment of regional congestion through a combination design of a density-sensing dual-branch detection head and a density-guided adaptive NMS. In densely occluded scenarios such as traffic intersections and squares, it effectively avoids the false deletion of real targets caused by traditional fixed IoU thresholds, and significantly improves the detection accuracy in dense scenarios.
[0049] This invention introduces a repulsive force constraint loss function, which applies targeted penalties to force the predicted bounding box to shrink toward the real target and move away from adjacent interfering targets, making the output bounding box more compact and effectively reducing the common problems of predicted bounding box "sticking" and positioning deviation in dense scenes.
[0050] This invention, by embedding a spatial attention mechanism in the feature extraction stage, can automatically suppress complex background noise such as trees and shadows, focus on foreground target features, effectively reduce the false detection rate under the premise of real-time performance, and enhance the robustness and practicality of the algorithm in real-world complex application scenarios. Attached Figure Description
[0051] Figure 1 This is a flowchart of the method of the present invention.
[0052] Figure 2 This is a schematic diagram of the adaptive image slicing logic in this invention.
[0053] Figure 3 This is a schematic diagram of the density-sensing dual-branch detection head structure in this invention.
[0054] Figure 4 This is a comparison diagram of the density-guided adaptive NMS logic in this invention.
[0055] Figure 5 This is a performance comparison chart of the algorithms in this invention. Detailed Implementation
[0056] The present invention will be further described in detail below with reference to the accompanying drawings.
[0057] This invention discloses a method for detecting small targets from above by UAVs based on density perception and spatial hierarchy. In one specific embodiment, the feature extraction network can be implemented using an existing convolutional neural network structure, but is not limited to a specific network form.
[0058] Reference Figure 1 to Figure 5 A method for detecting small targets from above by a UAV based on density perception and spatial hierarchy includes the following steps:
[0059] S1. The high-resolution input image acquired by the UAV is preprocessed through the adaptive image slicing and feature preservation module to obtain sub-images of uniform size and establish a global coordinate mapping relationship.
[0060] High-resolution input images acquired by drones typically have a resolution of no less than 1920×1080 pixels, denoted as I ∈ R H ×W×3 Direct scaling can lead to the loss of features for small targets smaller than 20×20 pixels. Therefore, preprocessing is performed using adaptive image slicing and a feature preservation module. The specific method is as follows:
[0061] Step-a1, Adaptive Slicing Parameter Calculation: Set the slice window size to... S×S In this embodiment S =640 pixels; overlap rate of adjacent subimages is set to 640 pixels; i , i Within the range of 10%-30%, this embodiment preferably has a lower concentration. i =25%; therefore, the overlapping pixel width is calculated to be... O=S×θ= 160 pixels; reference Figure 2This is a schematic diagram of the adaptive image slicing logic. In the diagram, the original image refers to the raw high-resolution image captured by the drone. I ∈ R H×W×3 Sub-images refer to uniformly sized S×S pixel blocks of the image to be detected, obtained by cropping using adaptive slicing parameters and an edge-reverse alignment strategy. Overlapping bands refer to the overlapping areas between adjacent sub-images, designed to prevent the target from being truncated at the edges; their width is [missing information]. O=S×θ .
[0062] Calculate the number of horizontal slices based on the original image dimensions. N ω and the number of slices in the vertical direction N h ;
[0063] ; ;
[0064] In the formula, W The horizontal pixel dimensions of the original image; H The vertical pixel dimensions of the original image; N ω , N h Round all up to the nearest whole number; total number of slices N=N ω ×N h .
[0065] Step-a2, Edge Reverse Alignment Strategy: During the sliding window cropping process, for the last sub-image P in each row or column... edge If its remaining pixels are insufficient S Then, a reverse alignment method is adopted, that is, tracing back from the boundary of the original image. S Crop each sub-image by one pixel to ensure all sub-images have a constant size. S×S, Effectively avoids the loss of texture information of edge targets.
[0066] Step-a3, for each subgraph Establish a coordinate transformation function, where i ∈[ 1,N ω ], j ∈[ 1,N h ]; Set the coordinates of the local detection bounding box ( x local ,y local Map back to the original coordinate system x global ,y global );
[0067] The mapping formula is ; ;
[0068] When dealing with subgraphs that are reverse-aligned at the edges, their offsets are directly set to... W−S or H−S This ensures the accuracy of coordinates in subsequent global detection results.
[0069] S2. Input the preprocessed sub-image of uniform size into the feature extraction system consisting of a feature extraction backbone network, a spatial attention enhancement module, and a multi-scale feature fusion network to obtain a multi-scale feature map adapted for small object detection; the specific steps are as follows:
[0070] Step-b1: The feature extraction backbone network adopts the CSPDarknet network. S×S Feature extraction is performed on sub-images of different sizes, and three feature layers C3, C4 and C5 with different scales are output, corresponding to resolutions of 80×80 pixels, 40×40 pixels and 20×20 pixels respectively, to adapt to the feature requirements of targets of different sizes.
[0071] Step-b2: The spatial attention enhancement module is used to suppress complex background noise such as trees and shadows. Max pooling and average pooling are performed on each feature layer in the channel dimension. The two pooling results are concatenated and then passed through a 7×7 convolutional layer and a Sigmoid activation function to generate a pixel-level weight map. The weight map is multiplied pixel by pixel with the original feature layer to obtain the enhanced feature layer, thereby enhancing the foreground target features and suppressing background noise, and improving the recognition of small target features.
[0072] Step-b3: The multi-scale feature fusion network (Neck) adopts a structure combining FPN (Feature Pyramid Network) and PAN (Path Aggregation Network). FPN passes the semantic information of the deep C5 feature from top to bottom to the C4 and C3 feature layers, compensating for the lack of semantic information in shallow features. PAN enhances the localization information of the shallow C3 feature from bottom to top to the C4 and C5 feature layers, solving the problem of insufficient localization accuracy of deep features. Finally, it outputs three feature maps that fuse multi-scale information. F i ( i =1,2,3), which serve as the input for the subsequent dual-branch detection head.
[0073] S3, Multi-scale Feature Map F i The input density-aware dual-branch detection head adopts a parallel dual-branch decoupled architecture, which simultaneously performs target detection and density estimation, realizing the collaboration between detection and perception.
[0074] The density-aware dual-branch detection head specifically includes the following two task branches:
[0075] The first is the object detection branch: The object detection branch adopts a decoupled head design, which extracts category features and localization features through two sets of parallel 3×3 convolutional layers to avoid feature interference;
[0076] The output tensor dimension of the classification sub-branch is... H '× W '× C ,in C The number of categories, such as pedestrians and vehicles in intelligent transportation scenarios, is used to predict the probability of the target category at each location. P cls The regression subbranch output tensor has a dimension of . H '× W ×5, used to predict bounding box offset ( x,y,w,h ) and target confidence level conf 。
[0077] The second is the density estimation branch: the density estimation branch shares shallow features with the object detection branch to reduce computational cost, while the deep layers are decoupled through independent three-layer convolutional modules;
[0078] This three-layer convolutional module includes two 3×3 convolutional layers and one 1×1 convolutional layer. Each convolutional layer is followed by a Batch Normalization (BN) layer and a ReLU activation function, outputting a pixel-level single-channel density heatmap. D ∈ R H'×W'×1 ;
[0079] True value of single-channel density heatmap Through the formula: calculate;
[0080] in d For Dirac d function, G σ The variance is s A two-dimensional Gaussian filter; s The value is adaptively adjusted based on the average size of the target bounding box, typically set to 0.3 times the target's width and height. M For the target total number, p k Let be the center coordinates of the k-th target. This formula transforms discrete target labels into a continuous probability density distribution, enabling the network to accurately learn the spatial crowding information between targets.
[0081] S4. During the training phase, the total loss function constrained by repulsion force is used to optimize the detection model. During the inference phase, density-guided adaptive nonmaximum suppression is used to post-process the target detection information and output the final detection result.
[0082] The total loss function using repulsive force constraints during the training phase is: L total =L cls +L box +L density +λL Rep ;
[0083] in, L cls For classifying losses, L box For bounding box regression loss, L density For density map loss, L Rep Loss due to repulsive force l This is a hyperparameter for the repulsive force loss weight, with a value range of 0.1 to 0.5, used to balance the repulsive force loss weight. L cls The training used for monitoring sub-branches employs binary cross-entropy (BCE) loss, as shown in the formula: ;
[0084] In the formula, y The labels are for the real categories (1 for target, 0 for background). p This represents the predicted class probability. L box To monitor the localization accuracy of the regression sub-branch, the CIoU loss function is used, which simultaneously considers the overlap area, center point distance, and aspect ratio. The formula is as follows: ;
[0085] In the formula, IoU is the crossover-union ratio. The distance between the center points of the predicted bounding box and the ground truth bounding box is the Euclidean distance. c The length of the diagonal of the minimum bounding rectangle. au This is a penalty term for aspect ratio;
[0086] L density The training of the density estimation branch is supervised, and the predicted density map is calculated using mean squared error (MSE). D With the truth density plot D GT The pixel-level difference between them is expressed by the formula: ;
[0087] In the formula, To predict the density map at the pixel p The value at that location, For the true density map in pixels p The value at;
[0088] L Rep This is used to introduce a rejection mechanism to prevent the predicted bounding box from shifting excessively towards adjacent interfering targets; the formula is: ;
[0089] In the formula, For the first i One prediction box, For the first j The loss term provides a list of other target bounding boxes adjacent to the current predicted target's spatial location, with 1[・] serving as an indicator function that applies a penalty only if the predicted box overlaps with a non-target ground truth box. This loss term effectively addresses the common problems of predicted box adhesion and false suppression in traditional algorithms under dense overhead views by forcing the predicted box away from adjacent non-matching interfering targets and forcing it to shrink and closely adhere to the center of the real target.
[0090] During the inference phase, density-guided adaptive nonmaximum suppression (NMS) is used to post-process the target detection information, avoiding the false suppression problem of traditional fixed-threshold NMS in dense scenes, as detailed below:
[0091] Step-c1: Extract regional crowding index: Read the density heatmap output by the density estimation branch. D For each candidate box output by the detection branch B i Extract the coordinates of its center point ( x c ,y c To enhance robustness, the average density within the candidate box coverage area is used as an indicator of crowding. d i The formula is: ;
[0092] in, w i and h i These are the width and height of the candidate box, respectively;
[0093] Step-c2, Constructing a density-threshold adaptive mapping function: Establishing a mapping function based on crowding index d i To the dynamic IoU threshold T i The mapping function; the adaptive formula is: ;
[0094] In the formula, T base =0.45 is the set basic suppression threshold; αThis is the density-adjustable gain coefficient, with a value ranging from 0.1 to 0.5. d max The maximum density observation in the current image; the mapped value. T i Constraints on [ T min ,T max Within the interval [0.45, 0.75], this design maintains strong suppression in sparse regions and weak suppression in dense regions, effectively curbing the false deletion of dense targets.
[0095] Step-c3, Candidate Box Filtering: First, map the coordinates of all candidate boxes output from the slice detection back to the original image's global coordinate system while retaining local density values. Then, sort all candidate boxes by confidence level (conf) from high to low and extract the box with the highest confidence level. B max As a benchmark, calculate B max With remaining candidate boxes B j IoU, if IoU( B max ,B j )> T max_idx Then remove B j Otherwise, retain; repeat the above process until all candidate boxes have been processed to obtain the final detection result; where T max_idx For the reason B max The dynamic threshold obtained from the calculation of regional density.
[0096] To verify the effectiveness and reliability of the method of this invention, experiments were conducted on the VisDrone dataset. The experimental environment was an Ubuntu operating system, with an NVIDIA GeForce RTX 3090 (24G) GPU, and the model was built based on the PyTorch framework. The training parameters were set to batch-size=16, iteration epochs=150, and initial learning rate=0.01 to ensure that the model fully converged. This invention adopts a common evaluation metric in the field of object detection: mAP50 is the average precision when the intersection-over-union (IoU) threshold is set to 0.5, and mAP50-95 refers to the average precision at 10 thresholds with IoU thresholds from 0.5 to 0.95 and a step size of 0.05. Precision reflects the accuracy of the detection results, recall reflects the completeness of the detection results, and bounding box regression loss reflects the degree of localization deviation between the predicted box and the ground truth box. The verification results show that the algorithm of this invention achieves 0.401 mAP@0.5, which is 40.7% higher than the benchmark algorithm's 0.285. The recall rate is improved from 0.368 to 0.385, and the inference speed is maintained at 52.1 FPS, meeting the requirements for real-time detection.
[0097] The results of the ablation experiment are shown in the table below:
[0098] Ablation experiments further validated the effectiveness of each module: A comparison between group 1 and group 2 shows a significant improvement in mAP@0.5, demonstrating that preserving original pixel features instead of direct scaling effectively addresses the pain point of "missed detection of small targets at long distances" under UAV top-down views. Comparing group 3 and group 4, a repulsive force loss was introduced. L Rep Subsequently, the mAP metric jumped again. Experiments showed that this module forces the predicted bounding box away from non-target ground truth boxes, effectively reducing the "boundary box sticking" phenomenon in congested traffic or densely populated scenes, resulting in tighter localization. In group 5, by adjusting the suppression threshold in real-time using the density map D, the mAP reached a peak of 0.401, verifying that the proposed "density-aware" mechanism enables the algorithm to adaptively increase the IoU threshold in dense areas, thereby preserving overlapping targets mistakenly deleted by traditional algorithms and achieving optimal coverage for detecting dense small targets.
[0099] Based on the above-described preferred embodiments of the present invention, and through the foregoing description, those skilled in the art can make various changes and modifications without departing from the inventive concept. The technical scope of this invention is not limited to the contents of the specification, but must be determined according to the scope of the claims.
Claims
1. A method for detecting small targets from above by a UAV based on density sensing and spatial hierarchy, characterized in that: Includes the following steps: S1: The high-resolution input image acquired by the UAV is preprocessed by the adaptive image slicing and feature preservation module to obtain sub-images of uniform size and establish a global coordinate mapping relationship; S2: Input the preprocessed sub-image into the feature extraction system to obtain a multi-scale feature map. The feature extraction system includes a feature extraction backbone network, a spatial attention enhancement module, and a multi-scale feature fusion network. S3: Multi-scale feature map input density-aware dual-branch detection head, parallel output target detection information and pixel-level density heatmap, the target detection information including bounding box coordinates, class probability and target confidence; The density-aware dual-branch detection head employs a parallel dual-branch decoupled architecture to receive multi-scale feature maps F output from a multi-scale feature fusion network. i The density-sensing dual-branch detection head specifically includes the following two task branches: The first is the object detection branch: the object detection branch adopts a decoupled head design, and extracts category features and localization features through two sets of parallel 3×3 convolutional layers respectively; The classification subbranch output tensor has dimensions H'×W'×C, where C is the number of classes, and is used to predict the target class probability P at each location. cls The regression subbranch output tensor has a dimension of H'×W'×5, which is used to predict the bounding box offset (x,y,w,h) and the target confidence conf. The second is the density estimation branch: the density estimation branch shares shallow features with the target detection branch, and the deep features are decoupled through an independent three-layer convolutional module; The three-layer convolutional module includes two 3×3 convolutional layers and one 1×1 convolutional layer. Each convolutional layer is followed by a BN layer and a ReLU activation function, outputting a pixel-level single-channel density heatmap D∈R. H'×W'×1 ; True value of single-channel density heatmap ; Where δ is the Dirac delta function, G σ A two-dimensional Gaussian filter with variance σ; σ is adaptively adjusted according to the average size of the target box; M is the total number of targets, p k The center coordinates of the k-th target; S4: During the training phase, the total loss function constrained by the repulsive force is used to optimize the detection model. During the inference phase, density-guided adaptive nonmaximum suppression is used to post-process the target detection information and output the final detection result. The implementation process of density-guided adaptive nonmaximum suppression includes the following steps: Step-c1: Extract regional congestion indicators; Step-c2: Construct the density-threshold adaptive mapping function; Step-c3: Candidate box filtering.
2. The method for detecting small targets from above by a UAV based on density perception and spatial hierarchy according to claim 1, characterized in that: The specific implementation process of the adaptive image slicing and feature preservation module in step S1 is as follows: Step-a1, Adaptive Slicing Parameter Calculation: Set the slice window size to S×S, and the overlap rate of adjacent sub-images to θ, then the width of overlapping pixels is O=S×θ; Calculate the number of horizontal slices N based on the original image dimensions. ω and the number of slices in the vertical direction N h The formula is: ; ; In the formula, W is the horizontal pixel size of the original image; H is the vertical pixel size of the original image; N ω N h Round all values up, the total number of slices N = N ω ×N h ; Step-a2, Edge Reverse Alignment Strategy: During the sliding window cropping process, for the last sub-image P in each row or column... edge If the remaining pixels are less than S, then reverse alignment is adopted, that is, cropping is performed by going back S pixels from the boundary of the original image to ensure that the size of all sub-images is constant at S×S. Step-a3, for each subgraph Establish a coordinate transformation function, where i∈[1, N] ω ], j∈[1, N h ]; Set the local detection bounding box coordinates (x local ,y local Mapping back to the original coordinate system (x) global ,y global ); ; ; When dealing with subgraphs that are edge-aligned in reverse, their offsets are set directly to WS or HS.
3. The method for detecting small targets from above by a UAV based on density perception and spatial hierarchy according to claim 2, characterized in that: The specific implementation process of the feature extraction system in step S2 is as follows: Step-b1: Feature extraction. The backbone network adopts the CSPDarknet network to extract features from the S×S size sub-image and output three feature layers C3, C4 and C5 of different scales, corresponding to resolutions of 80×80 pixels, 40×40 pixels and 20×20 pixels, respectively. Step-b2, the implementation process of the spatial attention enhancement module is as follows: Max pooling and average pooling are performed on the feature layer in the channel dimension respectively. The pooling results are concatenated and then generated into a weight map through a 7×7 convolutional layer and a Sigmoid activation function. The weight map is multiplied with the original feature layer pixel by pixel to obtain the enhanced feature layer. Step-b3: The multi-scale feature fusion network adopts a structure combining a feature pyramid network and a path aggregation network. The feature pyramid network transmits deep semantic information from top to bottom, while the path aggregation network enhances shallow localization information from bottom to top, ultimately outputting three feature maps F that fuse multi-scale information. i This serves as the input for the subsequent dual-branch detection head.
4. The method for detecting small targets from above by a UAV based on density perception and spatial hierarchy according to claim 3, characterized in that: The total loss function of the repulsive force constraint mentioned in step S4 is: L total =L cls +L box +L density +λL Rep ; Among them, L cls For classification loss, L box For bounding box regression loss, L density For density map loss, L Rep The repulsive force loss is represented by λ, which is the weight hyperparameter of the repulsive force loss. L cls For training to monitor sub-branches, a binary cross-entropy loss is used, calculated as follows: ; In the formula, y is the true class label, and p is the predicted class probability; L box To monitor the localization accuracy of the regression sub-branch, the CIoU loss function is used, which simultaneously considers the overlap area, center point distance, and aspect ratio. The formula is as follows: ; In the formula, IoU is the crossover-union ratio. is the Euclidean distance between the center point of the prediction box and the center point of the truth box, c is the length of the diagonal of the minimum bounding rectangle, and αυ is the aspect ratio penalty term; L density To supervise the training of the density estimation branch, the mean squared error is used to calculate the predicted density map D and the true density map Dt. GT The pixel-level difference between them is expressed by the formula: ; In the formula, To predict the value of the density map at pixel p, This represents the value of the truth density map at pixel p; L Rep This is used to introduce a rejection mechanism to prevent the predicted bounding box from shifting excessively towards adjacent interfering targets; the formula is: ; In the formula, For the i-th prediction box, Let be the j-th non-target truth box, and 1[・] be the indicator function, which applies a penalty only when the predicted box overlaps with the non-target truth box.
5. The method for detecting small targets from above by a UAV based on density sensing and spatial hierarchy according to claim 4, characterized in that: The specific method for Step-c1, extracting the regional crowding index, is as follows: read the density heatmap D output by the density estimation branch, and for each candidate box B output by the detection branch... i Extract its center point coordinates (x c ,y c To enhance robustness, the average density within the candidate box coverage area is used as the crowding index d. i , Crowding index d i The formula is: ; Among them, w i and h i These are the width and height of the candidate box, respectively; The specific method for Step-c2, constructing the density-threshold adaptive mapping function, is as follows: Establish a mapping function based on the crowding index d... i To the dynamic IoU threshold T i The mapping function; The adaptive formula is: ; In the formula, T base The set baseline suppression threshold, α is the density adjustment gain coefficient, and d max The maximum density observation in the current image; the mapped T i Constraints on [T] min ,T max Within the specified range, this effectively curbs the accidental deletion of densely packed targets; The specific method for Step-c3, candidate box selection, is as follows: sort all candidate boxes from high to low confidence level (conf), and select the box B with the highest confidence level. max As a benchmark, calculate B max With remaining candidate box B j IoU, if IoU(B max B j )>T max_idx Then remove B. j Otherwise, retain; repeat the above process until all candidate boxes have been processed to obtain the final detection result; where T max_idx For B max The dynamic threshold obtained from the calculation of regional density.
6. The method for detecting small targets from above by a UAV based on density perception and spatial hierarchy according to claim 5, characterized in that: The basic inhibition threshold T base =0.45, dynamic threshold range [T min ,T max = [0.45, 0.75].
Citation Information
Patent Citations
Dense small target detection method for unmanned aerial vehicle aerial photography scene
CN121438142A
Population quantity determination method and apparatus, device, storage medium, and program product
WO2022179474A1