Aerial small target detection method and system based on YOLOv12n
By using a context-guided downsampling module and a progressive feature pyramid detection head in aerial small target detection, the problems of insufficient robustness of feature extraction and insufficient multi-scale fusion in complex backgrounds are solved, and high-precision detection of aerial small targets is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- DONGHUA UNIV
- Filing Date
- 2026-03-09
- Publication Date
- 2026-06-12
Smart Images

Figure CN122200431A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of target detection technology, and in particular to a method and system for aerial small target detection based on YOLOv12n. Background Technology
[0002] With the rapid development of deep learning technology, especially convolutional neural networks (CNNs), computer vision technology has made groundbreaking progress in recent years. Object detection, as one of the core tasks in computer vision, aims to enable computers to automatically identify and locate specific objects in images or videos. It has broad application prospects in many fields such as security monitoring, autonomous driving, industrial quality inspection, smart healthcare, and content retrieval. Among numerous object detection models, algorithm frameworks represented by YOLO (You Only Look Once), Faster R-CNN, and SSD (Single Shot MultiBox Detector) have gradually become widely recognized mainstream technical solutions in the industry due to their advantages in detection speed and accuracy.
[0003] However, existing technologies still face significant bottlenecks in aerial small target detection scenarios. Aerial small targets typically have a pixel count below 32×32, making them not only tiny in size but also susceptible to complex background interference and occlusion issues. Furthermore, factors such as flight altitude, equipment movement, and atmospheric conditions can easily lead to blurred images and noise interference, resulting in generally low mean average accuracy (mAP) for existing target detection models. Additionally, these models often suffer from insufficient visual clarity and detail rendering capabilities, making it difficult to meet the practical needs of subsequent analysis and judgment.
[0004] To address the technical bottlenecks in aerial small target detection mentioned above, some improved solutions have emerged in existing technologies. Referring to the patent "A Lightweight and Multi-Scene Adaptable Target Detection Model for Remote Sensing" (CN120953859A), this solution is based on the YOLOv5s model. It replaces the SPP module in the original model with the PLDP-SPP module. Through the dynamic multi-scale pooling perception module PLDP-SPP, it achieves rapid fusion of multi-scale contextual information, which can more efficiently preserve key details of the target and extract global contextual information, thereby improving the accuracy of the detection results. In the workflow of the PLDP-SPP module, the input features are processed by the dynamic multi-scale pooling perception module, outputting three 512×20×20 feature maps. These feature maps are then fused using a weighted average method, and finally, a 1×1 convolution is performed to output the result. Although this solution can improve the average accuracy of the detection mean to some extent, the improved model still has a parameter size of 7.5 million (7.5M), which places high demands on hardware costs. Furthermore, the model training time and detection time are significantly increased, making it unsuitable for deployment and application in resource-constrained scenarios.
[0005] Another related solution is the patent "Remote Sensing Small Target Detection Method, Device and Equipment Based on Improved RT-DETR Model" (CN120913083A). This solution inputs preprocessed remote sensing images into an improved RT-DETR model for training, resulting in a network model adapted for remote sensing small target detection. The improved RT-DETR model's backbone network uses element-wise multiplication to process input features, mapping features to a high-dimensional nonlinear space. The decoder's decoding process encompasses three stages: feature extraction, feature downsampling, and feature fusion. In the feature downsampling stage, the SPDConv module is introduced, using multi-branch sub-region feature concatenation and convolutional fusion to reduce feature resolution while preserving small target details. In the feature fusion stage, the CSPOmniKernel module is introduced, balancing small target feature extraction capability with model computational complexity through feature splitting, multi-directional feature capture, and attention enhancement mechanisms. While this solution improves small target detection performance by optimizing the RT-DETR model structure, it only focuses on enhancing the model's feature extraction capability and does not propose a targeted solution for the missed detection of extremely small targets. Therefore, the detection completeness in complex scenarios still needs improvement.
[0006] While the two improvement schemes mentioned above optimize the performance of aerial small target detection from different perspectives, they still have their limitations. Considering the current application status of mainstream target detection models in this scenario, existing technologies generally face the following common problems:
[0007] (1) Feature extraction is not robust to complex backgrounds. Aerial images have complex background environments and small target sizes. The standard convolutional downsampling operation used by the model has a fixed local receptive field and processing mode, which makes it difficult to effectively distinguish the key features of high-frequency background noise from real targets. It is easily affected by factors such as shadows and occlusions, which leads to a decrease in the target signal-to-noise ratio in the subsequent feature map and affects the detection accuracy.
[0008] (2) The multi-scale feature fusion mechanism does not make full use of the features of small targets. Although the existing feature fusion path (such as the FPN structure) can achieve the aggregation of multi-scale features, the information flow path is relatively fixed. During the propagation process in the deep network, the features from the high-resolution shallow layer that carry the key details of small targets are easily diluted or lost, resulting in the semantic and positional information of small targets in the feature map used for detection being unclear. This is also one of the core factors causing the high false negative rate of small targets. Summary of the Invention
[0009] In view of the above-mentioned shortcomings of current small target detection technologies, this invention provides an aerial small target detection method based on YOLOv12n, which can significantly improve the detection accuracy of small targets in aerial images without increasing model complexity.
[0010] To achieve the above objectives, the embodiments of the present invention adopt the following technical solutions:
[0011] A method for detecting small targets in aerial photography based on YOLOv12n, the method comprising:
[0012] Acquire aerial image data and preprocess the aerial image data;
[0013] An aerial small target detection model based on YOLOv12n is constructed, comprising a backbone network and a detection head. The backbone network is based on the original YOLOv12n backbone network architecture, with its built-in downsampling layer replaced by a context-guided downsampling module. The detection head is a progressive feature pyramid detection head.
[0014] The preprocessed aerial image data is input into the aerial small target detection model to obtain the aerial small target detection result.
[0015] According to one aspect of the present invention, the preprocessing of the aerial image data specifically includes standardization, size adjustment, and format conversion.
[0016] According to one aspect of the present invention, in the aerial small target detection model: the backbone network includes a first-layer convolutional layer and a context-guided downsampling module; preprocessed aerial image data is input into the first-layer convolutional layer to obtain an initial feature map; the initial feature map is processed multiple times by the context-guided downsampling module to generate a multi-scale feature map; the multi-scale feature map is processed by a progressive feature pyramid detection head, firstly by progressive fusion to generate a multi-scale feature fusion map, and then based on the multi-scale feature fusion map, target classification, bounding box regression, and confidence prediction are performed to generate an aerial small target detection result.
[0017] According to one aspect of the present invention, the implementation steps of the context-guided downsampling module are as follows:
[0018] Perform a convolution operation on the initial feature map to obtain the basic feature map;
[0019] Features are extracted from the basic feature map using a two-branch method;
[0020] The outputs of the two branches are concatenated along the channel dimension, and then processed by batch normalization and ReLU activation. Finally, the fusion feature map is obtained by dimensionality reduction through convolution.
[0021] The fused feature map is subjected to global average pooling and fully connected layer operations in sequence to calculate attention weights;
[0022] The attention weights are multiplied element-wise with the fused feature map.
[0023] According to one aspect of the present invention, the multi-scale feature map includes four scales: P2, P3, P4, and P5, which respectively correspond to the preprocessed aerial image data. , , , size.
[0024] According to one aspect of the present invention, the multi-scale feature map is processed by a progressive feature pyramid detection head, and the multi-scale feature fusion map is generated through progressive fusion as follows:
[0025] Channel adjustments are performed on the multi-scale feature maps P2, P3, P4, and P5 to obtain feature maps P2', P3', P4', and P5', respectively.
[0026] After upsampling feature maps P2' and P3', they are concatenated and fused by convolution to obtain fused feature map F1;
[0027] The fused feature F1 is downsampled and then upsampled with the feature map P4', and then convolved and fused to obtain the fused feature map F2.
[0028] The fused feature map F3 is obtained by downsampling the fused feature map F2 and upsampling the feature map P5'.
[0029] According to one aspect of the present invention, the step of performing target classification, bounding box regression, and confidence prediction based on the multi-scale feature fusion map specifically comprises: generating prediction results corresponding to targets at different scales based on the fused feature maps F1, F2, and F3; wherein, the target classification is calculated using the softmax function to output the class probability of each predicted box, the bounding box regression outputs the bounding box coordinates, and the confidence prediction outputs the probability that each predicted box is a true target.
[0030] According to one aspect of the present invention, the aerial small target detection method further includes post-processing the aerial small target detection result after obtaining it, specifically:
[0031] Non-maximum suppression algorithm is applied to remove overlapping prediction boxes;
[0032] If the aerial image data was resized and padded during preprocessing, the output bounding box coordinates will be mapped back to the original image size.
[0033] According to one aspect of the present invention, the sizing and filling specifically includes:
[0034] The image was scaled using bilinear interpolation. And maintain the aspect ratio;
[0035] If blank areas exist after scaling, fill them with black pixels. .
[0036] A YOLOv12n-based aerial small target detection system for the above-mentioned aerial small target detection method, the system comprising:
[0037] The data acquisition module acquires aerial image data and preprocesses the aerial image data.
[0038] The model building module constructs an aerial small target detection model based on YOLOv12n, including a backbone network and a detection head. The backbone network is based on the original YOLOv12n backbone network architecture, but its built-in downsampling layer is replaced with a context-guided downsampling module. The detection head is a progressive feature pyramid detection head.
[0039] The result generation module inputs the preprocessed aerial image data into the aerial small target detection model to obtain the aerial small target detection result.
[0040] The advantages of this invention are as follows: First, the standard downsampling module in the backbone network is replaced with a context-guided downsampling module. This module extracts local details and surrounding context information simultaneously through a dual-branch structure and strengthens key features by combining a channel attention mechanism, effectively suppressing interference from complex backgrounds (such as shadows and occlusions) and improving the signal-to-noise ratio of the feature map. Second, a progressive feature pyramid detector head is used to replace the original detector head. Through a progressive, hierarchical fusion strategy, high-resolution shallow features containing rich details of small targets are fully preserved and fused, solving the problem that small target features are easily diluted in deep networks. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 This is a schematic flowchart of a small target detection method for aerial photography based on YOLOv12n, as described in this invention.
[0043] Figure 2 This is a schematic flowchart of the context-guided downsampling module of the aerial small target detection method based on YOLOv12n described in this invention;
[0044] Figure 3 These are the experimental results using the original YOLOv12n model as described in this invention;
[0045] Figure 4The experimental results are those of the aerial small target detection method based on YOLOv12n described in this invention.
[0046] Figure 5 This is a structural diagram of an aerial small target detection system based on YOLOv12n, as described in this invention. Detailed Implementation
[0047] 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.
[0048] Example 1
[0049] like Figure 1 , Figure 2 , Figure 3 , Figure 4 As shown, an aerial small target detection method based on YOLOv12n is described, the method comprising:
[0050] Step S1: Acquire aerial image data and preprocess the aerial image data;
[0051] Furthermore, the acquisition of aerial image data specifically involves:
[0052] Aerial image data can be obtained by collecting aerial images from real-world scenarios or by directly accessing the VisDrone 2019 dataset. Real-world aerial images can be captured using drones (such as the DJI Mavic 3); the VisDrone 2019 dataset is a typical aerial scene dataset, containing various target types such as pedestrians and vehicles, and the images contain a large number of pixels smaller than [a certain value]. The small target, with complex backgrounds such as tree shadows and building obstructions, can realistically simulate actual aerial inspection scenarios.
[0053] Furthermore, the acquired aerial image data undergoes preprocessing, including standardization, resizing, and format conversion, specifically:
[0054] Standardization processing: Pixel value normalization is performed, reducing the pixel value of each channel of the image from... Linear mapping to If the image is in RGB three-channel format, perform the above normalization on the R, G, and B channels respectively to eliminate the interference of pixel value range differences on model training.
[0055] Resizing: The image is scaled using bilinear interpolation. During scaling, the image aspect ratio remains unchanged. If blank areas exist after scaling, they are filled with black pixels (all RGB values are 0). Ensure that the image size of the input model is uniform.
[0056] Format conversion: Convert the preprocessed image into a tensor format with dimensions of [missing information]. (Number of channels × height × width), adapted to the input requirements of the PyTorch framework.
[0057] Step S2: Construct an aerial small target detection model based on YOLOv12n, including a backbone network and a detection head. The backbone network is based on the original YOLOv12n backbone network architecture, and its built-in downsampling layer is replaced with a context-guided downsampling module. The detection head is a progressive feature pyramid detection head.
[0058] Furthermore, in the aerial small target detection model: the backbone network includes a first-layer convolutional layer and a context-guided downsampling module. The preprocessed aerial image data is input into the first-layer convolutional layer to obtain an initial feature map. The initial feature map is processed multiple times by the context-guided downsampling module to generate multi-scale feature maps. The multi-scale feature maps are processed by a progressive feature pyramid detection head. First, a multi-scale feature fusion map is generated through progressive fusion. Then, target classification, bounding box regression, and confidence prediction are performed based on the multi-scale feature fusion map to generate the aerial small target detection result.
[0059] It should be noted that the YOLOv12n basic model consists of three parts: a backbone network, a neck feature fusion network, and a detector. The backbone network uses a C2f module to extract features, and the neck feature fusion network uses an FPN structure to fuse multi-scale features. This invention improves the downsampling layer of the backbone network and the detector. In the downsampling layer of the backbone network, the standard convolutional downsampling module is replaced with a context-guided downsampling module (ContextGuidedBlock_Down). In the detector part, the original detector is replaced with a progressive feature pyramid network detector (Detect_AFPN_P2345_Custom).
[0060] The preprocessed aerial image data is input into the aerial small target detection model, and multi-scale feature extraction is first performed through the backbone network. The feature extraction process of the YOLOv12n backbone network relies on four downsampling layers (corresponding to the pre-order dimensionality transformations for generating P2, P3, P4, and P5 feature maps, respectively). This invention replaces the standard convolutional downsampling modules of these four downsampling layers with a context-guided block downsampling module (ContextGuidedBlock_Down). Through dimensionality adaptation, dual-branch feature capture, feature fusion, and key feature enhancement processes, efficient feature extraction is achieved.
[0061] Furthermore, the implementation steps of the context-guided downsampling module are as follows:
[0062] Step S210: Perform a convolution operation on the initial feature map to obtain a basic feature map;
[0063] The initial feature map of the input (size is) (Number of channels is nIn), using Convolution kernel ( Step size ,filling The convolution operation enables the feature map size to be reduced from... Halved to At the same time, the number of channels doubles from nIn to nOut ( Specifically, this is achieved through the following convolution operation:
[0064]
[0065] Where H and W represent the height and width of the input feature map, respectively, nIn is the number of channels in the input feature map, and nOut is the number of channels in the output feature map; This setting ensures that information from the edge regions of the feature map is fully processed, avoiding the loss of edge features; and at the same time, it achieves accurate matching. The downsampling requirement ensures that the feature map size is halved as expected, providing a uniformly sized and fully informative basic feature map (size: ) for subsequent bi-branch feature extraction. (Number of channels nOut).
[0066] Step S211: Extract features from the basic feature map using a two-branch method;
[0067] The basic feature map output in step S210 (size is...) With nOut (number of channels), a dual-branch depthwise separable convolutional structure is used to capture local detail features of the target and surrounding contextual information respectively, achieving complementarity in feature dimensions:
[0068] Local feature branch (F_loc): using Depthwise separable convolution, number of groups equal to nOut (single-channel independent convolution), dilation rate ,filling Output size maintained It focuses on extracting fine-grained local features such as target edges and textures;
[0069] Contextual feature branch (F_sur): using Depthwise separable convolution, number of groups equal to nOut, dilation rate ,filling (Calculation formula:) Output size maintained Without increasing the model parameters, the receptive field is moved from... Expand to It focuses on capturing contextual information such as the spatial relationship between the target and the background, and the surrounding environment.
[0070] Step S212: The outputs of the two branches are concatenated according to the channel dimension, and after batch normalization and ReLU activation, the fusion feature map is obtained by convolution dimensionality reduction.
[0071] To integrate the complementary information of the two-branch features, while controlling the feature dimensions to avoid redundancy, the following operations are performed on the output of the two branches:
[0072] Channel concatenation: The outputs of the local feature branch (F_loc) and the context feature branch (F_sur) are concatenated along the channel dimension to obtain a result of size [size missing]. fusion feature map;
[0073] Activation Normalization: Batch Normalization is performed on the concatenated fused feature map to reduce gradient risk. Nonlinearity is introduced through the ReLU activation function to enhance feature representation.
[0074] Dimensional compression: using Convolutional reduction reduces the dimensionality of the activated feature map, decreasing the number of channels from... Compressed to nOut, the final feature map (size nOut) is obtained by fusing local details and contextual information. (Number of channels nOut).
[0075] Step S213: Perform global average pooling and fully connected layer operations on the fused feature map in sequence to calculate attention weights;
[0076] A channel attention mechanism is introduced through the Global Feature Enhancement Module (FGlo) to enhance key features and suppress invalid background features:
[0077] For the fused feature map input in step S212, perform global average pooling along the channel dimension. The spatial dimension is compressed to 1×1 to obtain a channel description vector with dimension nOut, realizing the global aggregation of spatial information; then the channel description vector is input into a fully connected layer to learn the importance weights of each channel and output an attention weight vector with dimension nOut.
[0078] Step S214: Perform element-wise multiplication of the attention weights with the fused feature map.
[0079] The attention weight vector is multiplied element-wise with the fused feature map from step S212 along the channel dimension to enhance the response of key feature channels and improve the signal-to-noise ratio of the feature map.
[0080] Furthermore, the multi-scale feature map includes four scales: P2, P3, P4, and P5, which correspond to the preprocessed aerial image data, respectively. , , , Dimensions; specifically:
[0081] The preprocessed image is then processed by a backbone network to generate four feature maps at different scales, covering full-dimensional features from shallow details to deep semantics:
[0082] P2 feature map: ( (Original image size), belongs to shallow features, focusing on the details of small objects such as edges and textures;
[0083] P3: ( (Original image size), belonging to the mid-level features, balances local details and semantic information, and is suitable for medium-sized target detection;
[0084] P4: ( (Original image size), belonging to mid-to-deep features, enhances the semantic expressiveness of the target;
[0085] P5: ( (Original image size), belonging to deep features, highlights the high-level semantic information of the target and improves classification accuracy.
[0086] Furthermore, the four feature maps at different scales output from the backbone network are input into the progressive feature pyramid network detection head for feature fusion and detection output of the target. This invention replaces the original three-scale detection head of YOLOv12n (using only P3, P4, and P5 features) with a progressive feature pyramid network detection head (Detect_AFPN_P2345_Custom). Through a process of channel unification, hierarchical progressive fusion, and multi-scale detection, it enhances the detection capability of small targets. The multi-scale feature maps are processed by the progressive feature pyramid detection head, and the specific implementation steps for generating a multi-scale feature fusion map through progressive fusion are as follows:
[0087] Step S220: Channel adjustment is performed on the multi-scale feature maps P2, P3, P4, and P5 to obtain feature maps P2', P3', P4', and P5', respectively.
[0088] Channel-adjusted convolutions were performed on the four feature maps (P2, P3, P4, P5) output by the backbone network at different scales: Convolution is used to uniformly adjust the number of channels in each feature map to 256, eliminating the impact of channel dimension differences on fusion. The outputs are as follows: , , , .
[0089] Step S221: Upsample feature maps P2' and P3', concatenate and fused them by convolution to obtain fused feature map F1 (basic feature fusion).
[0090] Will The feature map is upsampled using bilinear interpolation (scaling factor = 2), reducing the size from... Adjusted to ,and Feature maps are concatenated along the channel dimension (output) );pass Convolutional fusion of features yields a fused feature map F1 (F1). ), retain detailed information about small targets.
[0091] Step S222: After downsampling the fused feature F1, it is concatenated with the upsampled feature map P4' and then fused by convolution to obtain the fused feature map F2 (intermediate feature fusion).
[0092] The F1 feature map is adjusted by downsampling. At the same time The feature map is adjusted by upsampling to After the two were spliced together Convolutional fusion yields feature map F2 ( ), balancing details and semantics.
[0093] Step S223: After downsampling the fused feature F2, it is concatenated with the upsampled feature map P5' and then fused by convolution to obtain the fused feature map F3 (complete feature pyramid construction).
[0094] The F2 feature map is adjusted by downsampling. ;Will The feature map is adjusted by upsampling to After the two were spliced together Convolutional fusion yields feature map F3 ( Ultimately, this forms a three-scale detection branch: F1 (small target detection), F2 (medium target detection), and F3 (large target detection), covering targets of different sizes in aerial photography scenarios.
[0095] Furthermore, step S2 also includes training the constructed aerial small target detection model, specifically as follows:
[0096] Training data configuration: The VisDrone2019 dataset is used. This dataset has been pre-divided into training, test, and validation sets. The training set is used for training, and the validation set is used to monitor the training effect. Random shuffling and batch size are used during training. Load data;
[0097] Data augmentation: During the training phase, random horizontal flipping, random cropping, and color jitter are applied to the images to improve the model's generalization ability;
[0098] Training parameter settings:
[0099] Optimizer: AdamW optimizer is used, initial learning rate Weight decay coefficient ;
[0100] Learning rate scheduling: A cosine annealing scheduling strategy is adopted. In each iteration, the learning rate lr increases with the number of iterations from... decay to ;
[0101] Loss function: Total loss = Classification loss (Cross-entropy loss) + Bounding box regression loss (CIoU loss) + Confidence loss (BCEWithLogitsLoss), with weights as follows: ;
[0102] Early stopping strategy: If the validation set mAP50-95 shows no improvement for 10 consecutive rounds (the improvement range is not specified). If the condition is met, training will stop and the optimal model weights will be saved.
[0103] Step S3: Input the preprocessed aerial image data into the aerial small target detection model to obtain the aerial small target detection result. Specifically:
[0104] The preprocessed aerial image data is input into the constructed aerial small target detection model. Multi-scale features are extracted through the backbone network, and then feature fusion and detection output are performed through the progressive feature pyramid network detection head. Finally, three types of results are output: class probability, bounding box coordinates, and confidence score.
[0105] Further, the specific steps of performing target classification, bounding box regression, and confidence prediction based on the multi-scale feature fusion map are as follows: Based on the fused feature maps F1, F2, and F3, prediction results corresponding to targets at different scales are generated respectively; wherein, the target classification is calculated using the softmax function, outputting the class probability of each predicted box; the bounding box regression outputs the bounding box coordinates; and the confidence prediction outputs the probability that each predicted box is a true target.
[0106] Bounding box coordinates: format is Where x1 and y1 are the coordinates of the top left corner, and x2 and y2 are the coordinates of the bottom right corner, with the coordinate values being relative to... The pixel values of the image;
[0107] Category probability: Calculated using the softmax function, the probability that each predicted box belongs to the target (pedestrian, vehicle, etc.) is taken as the predicted category.
[0108] Confidence score: reflects the probability that the predicted bounding box is the true target, ranging from... .
[0109] Furthermore, the aerial small target detection method also includes post-processing the aerial small target detection results, specifically:
[0110] Non-maximum suppression (NMS) algorithm is applied to remove overlapping predicted boxes; the IoU threshold of NMS is set to 0.45, that is, when two predicted boxes overlap... At that time, retain the prediction boxes with higher confidence;
[0111] If the aerial image data was resized and padded during preprocessing, the output bounding box coordinates will be mapped back to the original image size.
[0112] The final output detection results include: the category name of each target in the image, the original coordinates of the bounding box, and the confidence score. It can be saved as a JSON file or the bounding box and category label can be drawn directly on the image and then the visualization image can be output.
[0113] Furthermore, this embodiment also includes experimental verification and effect comparison, the specific core descriptions of which are as follows:
[0114] 1. Definition of Evaluation Indicators
[0115] To objectively quantify the detection performance of this method, commonly used evaluation metrics in the field of target detection are used for assessment. This method shows improvement over the original model in all metrics. The core metric used is mAP50-95 to comprehensively measure the improvement effect. The definitions of each metric are as follows:
[0116] 1.1 TP (True Positive): The number of targets correctly predicted by the model to belong to a certain category;
[0117] 1.2 FP (False Positive): The number of times the model incorrectly predicts the background or other categories as the target category;
[0118] 1.3 FN (False Negative): The number of instances that the model failed to predict and that actually belong to the target class;
[0119] 1.4 Precision: This refers to the proportion of truly positive examples among the samples predicted as positive by the model, and measures the accuracy of the prediction results.
[0120] 1.5 Recall: This refers to the proportion of true positive examples that are correctly predicted by the model, reflecting the model's ability to find the target.
[0121] 1.6 F1 Score: Precision is the harmonic mean of precision and recall, which comprehensively evaluates the classification performance of the model.
[0122] 1.7 mAP (mean Average Precision):
[0123] 1.7.1 mAP50: Average accuracy when the Intersection over Union (IoU) threshold is 0.5. This means that the prediction is correct, reflecting the model's detection capability under relaxed overlap requirements;
[0124] 1.7.2 mAP75: The average accuracy when the IoU threshold is 0.75. It has higher requirements for the overlap of bounding boxes and reflects the accuracy of the model's prediction.
[0125] 1.7.3 mAP50-95: The mean of the average accuracy at each threshold within the range of IoU thresholds from 0.5 to 0.95 (step size 0.05), comprehensively reflecting the overall detection capability of the model under different overlap standards.
[0126] 2. Sources of experimental data
[0127] The experimental data comes from the VisDrone2019 dataset, which is designed specifically for aerial photography scenarios. It includes various target types such as pedestrians and vehicles. The images contain a large number of small targets with a pixel size of less than 32×32 and complex backgrounds (such as tree shadows and building occlusions), which can realistically simulate actual aerial photography detection scenarios. The dataset has been pre-divided into training, testing and validation sets, requiring no additional data processing, thus ensuring the fairness and reproducibility of the experiment.
[0128] 3. Compare experimental results
[0129] like Figure 3 and Figure 4 As shown, the original YOLOv12n model was used as the control group. During the experiment, the training parameters (learning rate, number of iterations, etc.) and hardware environment of the two models were kept completely consistent. The core performance comparison results are as follows:
[0130] 3.1 Overall Detection Accuracy: The improved YOLOv12n model achieves a 3.2% higher mAP50-95 compared to the original YOLOv12n model, fully validating the improved detection capability under different overlap requirements. Specifically, the average mAP50-95 accuracy (all) of the original YOLOv12n model is 0.1952, while that of the improved YOLOv12n model is 0.2265. The absolute difference between the two is: .
[0131] 3.2 Targeted Improvement for Small Targets: For small targets smaller than 32×32 pixels in aerial photography scenes, the improved model achieves a 31.2% improvement in detection performance compared to the original model, effectively solving the problem of missed detection of extremely small targets. These small aerial targets include: pedestrians, people, bicycles, tricycles, awning-tricycles, and motorcycles. The 31.2% improvement represents the relative improvement for these six types of small aerial targets, and the specific calculation process is as follows:
[0132] (1) Extract the mAP50-95 values of small aerial targets from the two types of models (as shown in Table 1).
[0133] Table 1. mAP50-95 values of small aerial targets for two types of models
[0134]
[0135] (2) Calculate the mean mAP50-95 of small aerial targets for both types of models.
[0136] Original model small objective mean: ;
[0137] Improved model small objective mean: .
[0138] (3) Calculate the relative increase
[0139] Relative improvement: (mean of improved model - mean of original model) ÷ mean of original model × 100%;
[0140] Substitute the values: .
[0141] 3.3 Lightweight Preservation: The number of parameters in the improved model is basically the same as that of the original YOLOv12n model. The hardware cost has not increased or the inference speed has been reduced due to the performance improvement, thus balancing accuracy and real-time performance.
[0142] The experimental results above demonstrate that, through improvements to the context-guided downsampling module and the progressive feature pyramid network detection head, this invention significantly improves the detection accuracy of small aerial targets in complex backgrounds without increasing model complexity, and its technical performance is superior to existing basic models.
[0143] Example 2
[0144] like Figure 5 As shown, an aerial small target detection system based on YOLOv12n is used in the aerial small target detection method described in Embodiment 1. The system includes:
[0145] The data acquisition module M1 acquires aerial image data and preprocesses the aerial image data.
[0146] The model building module M2 constructs an aerial small target detection model based on YOLOv12n, including a backbone network and a detection head. The backbone network is based on the original YOLOv12n backbone network architecture, but its built-in downsampling layer is replaced with a context-guided downsampling module. The detection head is a progressive feature pyramid detection head.
[0147] The result generation module M3 inputs the preprocessed aerial image data into the aerial small target detection model to obtain the aerial small target detection results.
[0148] The advantages of this invention are as follows: First, the standard downsampling module in the backbone network is replaced with a context-guided downsampling module. This module extracts local details and surrounding context information simultaneously through a dual-branch structure and strengthens key features by combining a channel attention mechanism, effectively suppressing interference from complex backgrounds (such as shadows and occlusions) and improving the signal-to-noise ratio of the feature map. Second, a progressive feature pyramid detector head is used to replace the original detector head. Through a progressive, hierarchical fusion strategy, high-resolution shallow features containing rich details of small targets are fully preserved and fused, solving the problem that small target features are easily diluted in deep networks.
[0149] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for detecting small targets in aerial photography based on YOLOv12n, characterized in that, The method includes: Acquire aerial image data and preprocess the aerial image data; An aerial small target detection model based on YOLOv12n is constructed, comprising a backbone network and a detection head. The backbone network is based on the original YOLOv12n backbone network architecture, with its built-in downsampling layer replaced by a context-guided downsampling module. The detection head is a progressive feature pyramid detection head. The preprocessed aerial image data is input into the aerial small target detection model to obtain the aerial small target detection result.
2. The aerial small target detection method according to claim 1, characterized in that, The preprocessing of the aerial image data specifically includes standardization, size adjustment, and format conversion.
3. The aerial small target detection method according to claim 1, characterized in that, In the aerial small target detection model: the backbone network includes a first-layer convolutional layer and a context-guided downsampling module. The preprocessed aerial image data is input into the first-layer convolutional layer to obtain an initial feature map. The initial feature map is processed multiple times by the context-guided downsampling module to generate multi-scale feature maps. The multi-scale feature maps are processed by a progressive feature pyramid detection head. First, a multi-scale feature fusion map is generated through progressive fusion. Then, target classification, bounding box regression, and confidence prediction are performed based on the multi-scale feature fusion map to generate the aerial small target detection result.
4. The aerial small target detection method according to claim 3, characterized in that, The implementation steps of the context-guided downsampling module are as follows: Perform a convolution operation on the initial feature map to obtain the basic feature map; Features are extracted from the basic feature map using a two-branch method; The outputs of the two branches are concatenated along the channel dimension, and then processed by batch normalization and ReLU activation. Finally, the fusion feature map is obtained by dimensionality reduction through convolution. The fused feature map is subjected to global average pooling and fully connected layer operations in sequence to calculate attention weights; The attention weights are multiplied element-wise with the fused feature map.
5. The aerial small target detection method according to claim 4, characterized in that, The multi-scale feature map includes four scales: P2, P3, P4, and P5, which correspond to the preprocessed aerial image data, respectively. , , , size.
6. The aerial small target detection method according to claim 5, characterized in that, The multi-scale feature map is processed by a progressive feature pyramid detection head. The process of generating a multi-scale feature fusion map through progressive fusion is as follows: Channel adjustments are performed on the multi-scale feature maps P2, P3, P4, and P5 to obtain feature maps P2', P3', P4', and P5', respectively. After upsampling feature maps P2' and P3', they are concatenated and fused by convolution to obtain fused feature map F1; The fused feature F1 is downsampled and then upsampled with the feature map P4', and then convolved and fused to obtain the fused feature map F2. The fused feature map F3 is obtained by downsampling the fused feature map F2 and upsampling the feature map P5'.
7. The aerial small target detection method according to claim 6, characterized in that, The specific steps of performing target classification, bounding box regression, and confidence prediction based on the multi-scale feature fusion map are as follows: Based on the fused feature maps F1, F2, and F3, prediction results corresponding to targets at different scales are generated respectively; wherein, the target classification is calculated using the softmax function to output the class probability of each predicted box, the bounding box regression outputs the bounding box coordinates, and the confidence prediction outputs the probability that each predicted box is a true target.
8. The aerial small target detection method according to any one of claims 1 to 7, characterized in that, The aerial small target detection method also includes post-processing the aerial small target detection results, specifically: Non-maximum suppression algorithm is applied to remove overlapping prediction boxes; If the aerial image data was resized and padded during preprocessing, the output bounding box coordinates will be mapped back to the original image size.
9. The aerial small target detection method according to claim 8, characterized in that, The specific dimensions adjustment and filling are as follows: The image was scaled using bilinear interpolation. And maintain the aspect ratio; If blank areas exist after scaling, fill them with black pixels. .
10. A YOLOv12n-based aerial small target detection system for use in any one of the aerial small target detection methods according to claims 1 to 9, characterized in that, The system includes: The data acquisition module acquires aerial image data and preprocesses the aerial image data. The model building module constructs an aerial small target detection model based on YOLOv12n, including a backbone network and a detection head. The backbone network is based on the original YOLOv12n backbone network architecture, but its built-in downsampling layer is replaced with a context-guided downsampling module. The detection head is a progressive feature pyramid detection head. The result generation module inputs the preprocessed aerial image data into the aerial small target detection model to obtain the aerial small target detection result.