Small target identification method and system based on YOLOv5
By improving the dynamic feature pyramid and dual-path detection head of the YOLOv5 model, combining cross-level core sharing and space-frequency dual-domain attention mechanism, the problem of loss of details in small object detection in complex scenarios is solved, improving the recognition accuracy and reducing the error detection rate.
Patent Information
- Application Number
- CN202510518791.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-24
- Publication Date
- 2025-08-08
AI Technical Summary
Traditional YOLOv5 has a static feature pyramid in small object detection in complex scenarios, which lacks dynamic adaptability, making it difficult to balance high-frequency details and semantic information interactions, and data enhancement technology is difficult to simulate complex distribution of real scenes, and over-reliance on a single scoring basis leads to inflated classification confidence or positioning deviations.
The dynamic feature pyramid and dual-path detection head are adopted, combined with cross-level core sharing and space-frequency dual-domain attention mechanisms, and the YOLOv5 model is improved through superpixel segmentation and adversarial enhancement, frequency domain decomposition and aliasing enhancement technologies to enhance the small-objective recognition capabilities.
It improves the accuracy of small target recognition, reduces the error detection rate, enhances the model's ability to identify small targets, and solves the problem of loss of details caused by traditional static feature pyramids.
Smart Images

Figure CN120451493A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of target recognition technology, and in particular to a small target recognition method and system based on YOLOv5. Background Art
[0002] In recent years, object detection technology, as one of the core tasks in computer vision, has been widely used in fields such as autonomous driving, drone monitoring, and satellite remote sensing. YOLOv5, a representative single-stage object detection model, has become the mainstream choice in the industry due to its balance of high speed and high accuracy. However, it still has the following shortcomings when detecting small objects in complex scenes:
[0003] 1) Traditional YOLOv5 uses a multi-scale detection head (P3-P5) to fuse shallow and deep features. However, the static feature pyramid (FPN+PAN) lacks dynamic adaptability to small objects and cannot effectively balance the interaction between high-frequency details and semantic information.
[0004] 2) Traditional data augmentation techniques (such as random cropping, rotation, and scaling) are difficult to simulate the complex distribution of small objects in real scenes;
[0005] 3) Over-reliance on a single classification confidence or IoU (Intersection over Union) as the basis for detection scoring can easily lead to inflated classification confidence or ineffective quantification of positioning bias. Therefore, it is necessary to design a small object recognition method and system based on YOLOv5. Summary of the Invention
[0006] The purpose of the present invention is to provide a small target recognition method and system based on YOLOv5, which realizes small target recognition through a dynamic feature pyramid and a dual-path detection head, combined with cross-level kernel sharing and a space-frequency dual-domain attention mechanism, to solve the problem of detail loss caused by the traditional static feature pyramid, improve recognition accuracy and reduce the false detection rate.
[0007] To achieve the above object, the present invention provides the following solutions:
[0008] A small target recognition method based on YOLOv5 includes the following steps:
[0009] Collect multi-scale images within the target range to form an original data set;
[0010] Perform image enhancement on the original dataset through superpixel segmentation and adversarial enhancement operations to obtain an enhanced dataset;
[0011] Perform multi-scale frequency domain aliasing enhancement on the enhanced data set through frequency domain decomposition and frequency band swapping operations to obtain the data set to be detected;
[0012] The YOLOv5 model is improved to obtain a small target recognition model; the improvement steps include:
[0013] Add a dynamic routing network to the C3 module of the YOLOv5 model and replace the Focus module with a dynamic backbone module;
[0014] In the Neck part, cross-scale dynamic convolution and dual-channel attention fusion mechanism are introduced to obtain a dynamic feature pyramid;
[0015] A new cognitive memory unit is added to the Head part to obtain the cognitive decision fusion head;
[0016] The small target recognition model is used to identify small targets in the dataset to be detected, and the recognition results are obtained; the recognition results include: predicted anchor boxes and recognition confidence.
[0017] Optionally, the original dataset is subjected to image enhancement through superpixel segmentation and adversarial enhancement operations to obtain an enhanced dataset, including:
[0018] Perform superpixel segmentation on the original data set to obtain a region boundary map;
[0019] The region boundary map is used as a mask, and the low-resolution small targets in the original dataset are converted into high-resolution pseudo targets according to the mask;
[0020] Distinguish high-resolution pseudo targets from real targets through local discrimination and global consistency discrimination;
[0021] The high-resolution pseudo targets are inserted into the original dataset using the Poisson fusion algorithm to obtain the enhanced dataset.
[0022] Optionally, multi-scale frequency domain aliasing enhancement is performed on the enhanced dataset through frequency domain decomposition and frequency band swapping operations to obtain a dataset to be detected, including:
[0023] Perform fast Fourier transform on the enhanced data set to obtain the amplitude spectrum and phase spectrum;
[0024] Mixing the high-frequency components and low-frequency components in the enhanced data set to generate a mixed amplitude spectrum;
[0025] The image is reconstructed according to the mixed amplitude spectrum and phase spectrum to obtain the data set to be detected.
[0026] Optionally, the high-frequency components and the low-frequency components in the enhanced data set are mixed to generate a mixed amplitude spectrum, including:
[0027] Based on the preset critical frequency bands, the enhanced data set is divided into frequency bands using the logarithmic Gaussian pyramid to obtain the center frequency;
[0028] The bandwidth is obtained based on the center frequency and the bandwidth attenuation rate;
[0029] A filter function with bandwidth as an independent variable is constructed through a differential Gaussian filter;
[0030] Calculate the energy proportion of the frequency band through the filter function;
[0031] The enhanced data set is divided into high-frequency components and low-frequency components according to the comparison results between the energy proportion and the energy threshold;
[0032] By formula The amplitude spectra of the high-frequency component and the low-frequency component are mixed into a mixed amplitude spectrum; where A' is the mixed amplitude spectrum, α and β are both nonlinear gain coefficients, and A obj is the amplitude spectrum of the high-frequency component, A bg is the amplitude spectrum of the low-frequency component, λ k is the dynamic blending weight.
[0033] Optionally, image reconstruction is performed based on the mixed amplitude spectrum and phase spectrum to obtain a dataset to be detected, including:
[0034] The optimization equation is constructed by imposing a smoothness constraint on the phase spectrum;
[0035] The optimization equation is iteratively solved by the conjugate gradient method to obtain the optimized phase spectrum;
[0036] By formula The optimized phase spectrum and mixed amplitude spectrum are reconstructed by inverse fast Fourier transform to obtain the data set to be detected; where I re To reconstruct the data, is the two-dimensional inverse fast Fourier transform operation, P' is the optimized phase spectrum, Real(·) is the complex real part operation, j is the complex imaginary part, Window -1 is the inverse windowing compensation operation, and ⊙ is the element-by-element multiplication.
[0037] Optionally, the dynamic routing network is composed of a routing unit, a multi-branch residual unit, and a spatial-channel collaborative attention unit, and the routing unit, the multi-branch residual unit, and the spatial-channel collaborative attention unit are fully connected;
[0038] The routing unit consists of a global average pooling layer and two multi-layer perceptrons connected in sequence. The multi-branch residual unit has a three-branch independent structure, which is used to perform high-frequency enhancement, context aggregation, and identity mapping operations on the output of the routing unit respectively. The spatial-channel collaborative attention unit consists of: spatial attention, channel attention, and a collaborative fusion layer connecting spatial attention and channel attention.
[0039] The dynamic backbone module consists of a deformable convolutional layer, a channel reorganization unit, and a dynamic gating unit, which are fully connected.
[0040] Optionally, the data processing steps of the dynamic feature pyramid include:
[0041] Perform global average pooling on the output of the Backbone part to obtain the convolution kernel weight;
[0042] Through cross-level kernel sharing operations, the convolution kernel weights and adjacent level features are convolved to obtain dynamic fusion features;
[0043] Extract spatial attention and frequency domain attention of dynamic fusion features respectively;
[0044] The spatial attention and frequency domain attention are combined to obtain pyramid features.
[0045] Optionally, the data processing steps of the cognitive decision fusion head include:
[0046] Integrate pyramid features and semantic prior maps of enhanced datasets into multimodal input features;
[0047] Generate a memory matrix through the typical features of small targets pre-stored in the cognitive memory unit;
[0048] Calculate the similarity between multimodal input features and real features through the memory matrix;
[0049] The multimodal input features are enhanced according to the memory matrix and similarity to obtain enhanced features.
[0050] Optionally, a small target recognition model is used to perform small target recognition on the dataset to be detected, and a recognition result is obtained, including:
[0051] Generate predicted anchor boxes based on enhanced features;
[0052] The positioning confidence is obtained based on the Mahalanobis distance between the covariance matrices of the predicted anchor boxes;
[0053] The temperature factor is introduced into the location reliability to obtain the classification reliability;
[0054] The classification confidence is calibrated according to the temperature factor to obtain the initial score;
[0055] Adjust the initial score based on the overlap between the predicted anchor box and the semantic prior map of the enhanced dataset to obtain the optimized score;
[0056] The optimized scores are weighted and fused to obtain the recognition confidence.
[0057] A small target recognition system based on YOLOv5, including:
[0058] An image acquisition module is used to collect multi-scale images within the target range to form an original data set;
[0059] The image enhancement module is used to enhance the original dataset through superpixel segmentation and adversarial enhancement operations to obtain an enhanced dataset;
[0060] An image aliasing module is used to perform multi-scale frequency domain aliasing enhancement on the enhanced data set through frequency domain decomposition and frequency band swapping operations to obtain a data set to be detected;
[0061] The model building module is used to improve the YOLOv5 model to obtain a small object recognition model;
[0062] The target recognition module is used to identify small targets in the detection data set through the small target recognition model to obtain the recognition results.
[0063] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects: The present invention provides a small target recognition method and system based on YOLOv5, which includes: collecting multi-scale images within the target range to form an original data set; performing image enhancement on the original data set through superpixel segmentation and adversarial enhancement operations to obtain an enhanced data set; performing multi-scale frequency domain aliasing enhancement on the enhanced data set through frequency domain decomposition and frequency band swapping operations to obtain a data set to be detected; improving the YOLOv5 model to obtain a small target recognition model; and performing small target recognition on the data set to be detected using the small target recognition model to obtain a recognition result. This method realizes small target recognition through a dynamic feature pyramid and a dual-path detection head, combined with cross-level kernel sharing and a space-frequency dual-domain attention mechanism, solving the problem of detail loss caused by traditional static feature pyramids, improving recognition accuracy and reducing false detection rate. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0065] Figure 1 This is a flow chart of the small target recognition method of the present invention;
[0066] Figure 2 This is a flowchart of the image enhancement of the present invention;
[0067] Figure 3 This is a flow chart of multi-scale frequency domain aliasing enhancement of the present invention;
[0068] Figure 4 This is a data processing flow chart of the dynamic feature pyramid of the present invention;
[0069] Figure 5 This is the data processing flow chart of the cognitive decision fusion head of the present invention
[0070] Figure 6 This is a workflow diagram of the small target recognition model of the present invention. DETAILED DESCRIPTION
[0071] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0072] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0073] like Figure 1 As shown, the present invention provides a small target recognition method based on YOLOv5, comprising the following steps:
[0074] Step 100: Collect multi-scale images within the target range to form an original data set;
[0075] Step 200: Perform image enhancement on the original dataset through superpixel segmentation and adversarial enhancement operations to obtain an enhanced dataset; the specific steps are as follows: Figure 2 As shown, including:
[0076] Step 201: performing superpixel segmentation on the original data set to obtain a region boundary map;
[0077] Specifically, this embodiment uses an adaptive compact factor SLIC algorithm to perform superpixel segmentation on the original data set, and dynamically adjusts the compact factor and the number of superpixels to ensure that the segmentation granularity matches the size of the small target. The compact factor is determined based on the average area of small targets in the original data set, and the number of superpixels is determined based on the image resolution and the minimum target area. After the segmentation is completed, the boundary continuity is optimized through morphological closing operations to generate a potential small target edge area mask. The texture complexity of each superpixel area is then calculated using the Sobel gradient algorithm, and the high-texture background noise area is eliminated, ultimately obtaining a binary boundary map that accurately marks the candidate area of the small target. This process avoids the problem of over-segmentation or missed segmentation of small targets in traditional superpixel segmentation by integrating spatial distance, color similarity and texture analysis.
[0078] Step 202: Using the region boundary map as a mask, and converting low-resolution small targets in the original dataset into high-resolution pseudo targets based on the mask;
[0079] Specifically, based on the generated region boundary masks, a generative adversarial network (SP-GAN) is used to transform low-resolution small objects into high-resolution pseudo objects. The SP-GAN generator uses a U-Net++ architecture. A spatial transformer network (STN) is embedded in the generator's decoder to predict affine transformation parameters and dynamically adjust the pose and perspective of the generated objects. After feature extraction from the input low-resolution object and mask by the generator's encoder, the STN performs a geometric transformation, ensuring that the generated object maintains consistent perspective with the background.
[0080] More specifically, the generator's loss function combines a content loss with a geometric consistency loss. The content loss constrains the authenticity of texture details through VGG feature matching, while the geometric consistency loss forces the generated target to maintain topological alignment with the input low-resolution target. This process overcomes the ambiguity limitations of traditional interpolation methods and improves the edge clarity and deformation rationality of generated high-quality pseudo targets.
[0081] Step 203: Distinguish high-resolution pseudo targets from real targets through local discrimination and global consistency discrimination;
[0082] Specifically, a dual-path discriminator consisting of a local discriminator and a global discriminator performs refined adversarial training on high-resolution pseudo targets and real targets. The local discriminator focuses on image patches within the mask region, employing the PatchGAN convolutional architecture to output pixel-level true / false probability maps, with a focus on supervising texture details. The global discriminator processes the entire image, ensuring consistency in illumination and color temperature between the generated target and the background through multi-layer convolution and fully connected layer structures. The local and global discriminant losses are dynamically fused according to weights, improving the realism of the generator's local details and its compatibility with the global scene.
[0083] Step 204: insert the high-resolution pseudo target into the original data set through the Poisson fusion algorithm to obtain an enhanced data set.
[0084] Specifically, the generated high-resolution pseudo-target is seamlessly embedded into the original dataset, and a Poisson fusion algorithm is used to perform multi-scale enhancement in the gradient domain. First, a dilation region is defined for the target area. The gradient fields of the dilated region and the background image are calculated, and the two gradient fields are blended to construct the Poisson equation. The Poisson equation is discretized into a system of linear equations and then solved using a multigrid method to reconstruct the image content. Finally, based on the color transfer matrix of the target area and the background, the hue-saturation distribution of the target area and the background in HSV space is matched using the least squares method to achieve illumination compensation and obtain the enhanced dataset.
[0085] Step 300: Perform multi-scale frequency domain aliasing enhancement on the enhanced data set by frequency domain decomposition and frequency band swapping operations to obtain a data set to be detected; the specific steps are as follows: Figure 3 As shown, including:
[0086] Step 301: Perform fast Fourier transform on the enhanced data set to obtain amplitude spectrum and phase spectrum;
[0087] Step 302: Mix the high-frequency components and low-frequency components in the enhanced data set to generate a mixed amplitude spectrum;
[0088] Specifically, based on the preset critical frequency band, the enhanced data set is divided into frequency bands by the logarithmic Gaussian pyramid to obtain the center frequency f k , the calculation formula is:
[0089] f k =f max 2 -k ;
[0090] where f max It is half of the Nyquist frequency, and k is the number of frequency bands. Then, the bandwidth Δf is obtained based on the center frequency and the bandwidth attenuation rate σ. k , the calculation formula is: Δf k =f k ·σ; The wide attenuation rate of this embodiment is 0.3. Then, a differential Gaussian filter is used to construct a filter function G with bandwidth as the independent variable. k (u,v), the expression is:
[0091]
[0092] Where (u ck ,v ck ) is the center coordinate of the frequency band. Then the energy proportion E of the frequency band is calculated by the filter function k , the calculation formula is:
[0093]
[0094] Where A(u,v) is the amplitude spectrum. The frequency band with energy ratio greater than the energy threshold is classified as the high-frequency component, and the frequency band with energy ratio less than or equal to the energy threshold is classified as the low-frequency component. The energy threshold in this embodiment is 0.05. Finally, the formula:
[0095]
[0096] The amplitude spectra of the high-frequency component and the low-frequency component are mixed into a mixed amplitude spectrum; wherein A' is the mixed amplitude spectrum, α and β are nonlinear gain coefficients, which are 0.5 and 0.3 respectively in this embodiment, A obj is the amplitude spectrum of the high-frequency component, Abg is the amplitude spectrum of the low-frequency component, λ k is the dynamic mixing weight, γ is the mixing weight slope coefficient, which is used to adjust the rate of change of the high and low frequency mixing ratio with frequency. In this embodiment, it is 2.0. f0 is the mixing weight center frequency, which is used to determine the frequency band position. In this embodiment, it is 0.1f max .
[0097] Step 303: reconstruct the image according to the mixed amplitude spectrum and phase spectrum to obtain a data set to be detected.
[0098] Specifically, the optimization equation is first constructed by imposing a smooth constraint on the phase spectrum, and the expression is:
[0099]
[0100] The term before the plus sign is a smoothing term, which forces the optimized phase gradient to Close to the original gradient to preserve the edge structure. The term after the plus sign is the fidelity term, which is used to optimize the degree to which the phase P' deviates from the original phase P to avoid over-correction. μ is the smoothing intensity coefficient, which is 0.1 in this embodiment. The optimization equation is then iteratively solved using the conjugate gradient method to obtain the optimized phase spectrum. Finally, the formula:
[0101]
[0102] The optimized phase spectrum and mixed amplitude spectrum are reconstructed by inverse fast Fourier transform to obtain the data set to be detected; where I re To reconstruct the data, is the two-dimensional inverse fast Fourier transform operation, P' is the optimized phase spectrum, Real(·) is the complex real part operation, j is the complex imaginary part, Window -1 is the inverse windowing compensation operation, and ⊙ is the element-by-element multiplication.
[0103] It is important to note that by optimizing the equations to enforce phase gradient continuity, the system preserves edge structure information and resolves the geometric distortion caused by traditional phase replacement. Inverse windowing compensation accurately restores edge signals weakened by the windowing operation, avoiding brightness distortion and reducing boundary artifacts.
[0104] Step 400: Improve the YOLOv5 model to obtain a small object recognition model;
[0105] Specifically, a dynamic routing network is added to the C3 module of the YOLOv5 model, and the Focus module is replaced with a dynamic backbone module; cross-scale dynamic convolution and dual-channel attention fusion mechanism are introduced in the Neck part to obtain a dynamic feature pyramid; and a cognitive memory unit is added to the Head part to obtain a cognitive decision fusion head.
[0106] Specifically, the dynamic routing network consists of a routing unit, a multi-branch residual unit, and a spatial-channel collaborative attention unit, and the routing unit, the multi-branch residual unit, and the spatial-channel collaborative attention unit are fully connected.
[0107] More specifically, the routing unit consists of a global average pooling layer and two multi-layer perceptrons connected in sequence. The global average pooling layer compresses the input feature map and outputs a global feature vector. This vector is then fed into a cascade network consisting of two multi-layer perceptrons (MLPs). The first MLP layer compresses the vector's dimension to 1 / 4, and the second MLP layer further expands the dimension to 3. A softmax function is then used to generate normalized routing weights.
[0108] The multi-branch residual unit has a three-branch independent structure, each used to perform high-frequency enhancement, context aggregation, and identity mapping on the output of the routing unit. The high-frequency enhancement branch consists of a 1×1 convolution for dimensionality reduction, a 3×3 deformable convolution, and a 1×1 convolution for dimensionality increase. The offset prediction of the deformable convolution enables the convolution kernel to adapt to the target shape and focuses on extracting high-frequency details such as edges and textures. The context aggregation branch uses a 3×3 dilated convolution to expand the receptive field and capture long-range contextual information. This is then combined with a 5×5 depthwise separable convolution to fuse local and global features, reducing computational effort.
[0109] The spatial-channel collaborative attention unit consists of spatial attention, channel attention, and a collaborative fusion layer connecting the spatial and channel attentions. The spatial attention layer performs average pooling and max pooling along the channel dimension on the features fused by the multi-branch residual unit. The concatenation of the results is then performed through a 3×3 convolution to generate a spatial weight map. The channel attention layer performs a global average pooling operation on the features fused by the multi-branch residual unit. The channel weight vector is then generated through two MLP layers. The collaborative fusion layer performs an outer product operation on the spatial weight map and the channel weight vector to generate a joint attention map.
[0110] It should be noted that the routing unit can adaptively assign branch weights based on the input content, greatly improving the model's computational efficiency. The complementary heterogeneous features of multiple branches cover features of different granularities, enhancing the model's ability to represent small objects.
[0111] Specifically, the dynamic backbone module consists of a deformable convolutional layer, a channel reorganization unit and a dynamic gating unit, and the deformable convolutional layer, the channel reorganization unit and the dynamic gating unit are fully connected.
[0112] More specifically, the deformable convolution layer has 3 input channels and 32 output channels, with a convolution kernel size of 3×3 and a stride of 2. The channel reorganization unit divides the 32 output channels of the deformable convolution layer into four groups, each of which is periodically shifted based on the channel index, thereby enhancing cross-channel information interaction and preventing local feature solidification. The dynamic gating unit is a parallel structure consisting of two independent branches: a 3×3 depthwise separable convolution and a 1×1 standard convolution. It is used to dynamically suppress background areas through a gating mechanism.
[0113] Specifically, the data processing steps of the dynamic feature pyramid are as follows: Figure 4 As shown, including:
[0114] Step 411: Perform a global average pooling operation on the output of the Backbone part to obtain the convolution kernel weight;
[0115] More specifically, Backbonee takes the feature maps of each level and averages all pixel values of each channel along its spatial dimension to generate a channel description vector that reflects the global statistical characteristics of the features at the current level. This vector is then fed into a lightweight two-layer fully connected network: the first layer compresses the channel dimension to one-quarter of its original dimension and introduces nonlinear relationships using the ReLU activation function; the second layer expands the dimension to the preset number of convolution kernels and normalizes it using the Softmax function to generate a weight matrix. Each element in the weight matrix represents the degree of dependence of the features at the current level on different convolution kernels.
[0116] Step 412: performing a convolution operation on the convolution kernel weights and the features of the adjacent levels through a cross-level kernel sharing operation to obtain a dynamic fusion feature;
[0117] More specifically, the resolution of the feature maps of the levels adjacent to the current level (higher resolution upper layer and lower resolution lower layer) are aligned: the upper layer features are downsampled by bilinear interpolation, and the lower layer features are upsampled by nearest neighbor interpolation to ensure that the spatial size of the feature maps of all levels remains consistent. The feature maps of each level are then convolved with the shared convolution kernel respectively, and the convolution results are weighted and summed according to the convolution kernel weights to obtain dynamic fusion features. This allows the high-resolution features of the low level to enhance the details through the high-frequency enhancement kernel, and the semantic features of the high level to extract global information through the context-aware kernel.
[0118] Step 413: extracting spatial attention and frequency domain attention of dynamic fusion features respectively;
[0119] More specifically, the dynamic fusion features are average pooled and max pooled along the channel dimension, generating two spatial response maps. These two response maps are concatenated into a dual-channel feature map, which is then compressed to a single channel through a 3×3 convolutional layer and then passed through a sigmoid function to generate a spatial weight map. Simultaneously, the dynamic fusion features are fast Fourier transformed to convert them to the frequency domain. The central low-frequency region is then flattened and fed into a two-layer fully connected network to generate a channel-dimensional weight vector.
[0120] It's important to note that each pixel value in the spatial weight map represents the importance of the corresponding location. High-weight regions correspond to edges or textures of small objects. This spatial weight map allows for autonomous focus on prominent spatial locations in the image while suppressing irrelevant background interference. The channel-wise weight vector is normalized using a sigmoid function to represent the importance of different channels in the frequency domain, enhancing low-frequency contour information related to the target while suppressing interference from high-frequency noise.
[0121] Step 414: Fuse the spatial attention and the frequency domain attention to obtain pyramid features.
[0122] More specifically, each pixel value in the spatial weight map is multiplied by the frequency domain weight of its corresponding channel to generate a three-dimensional joint attention map. This map simultaneously encodes the importance of spatial position and the frequency domain energy distribution in the channel dimension. The dynamic fusion feature is then element-wise multiplied with this attention map to produce a fused dual-attention feature, achieving feature recalibration such that the channel response in key regions is enhanced while the response in less important regions is suppressed. Finally, the fused dual-attention feature is adjusted at different levels: high-level low-resolution features are upsampled by a factor of 2 using bilinear interpolation to match the resolution of mid-level features; mid-level features are further upsampled to match the resolution of low-level features. Features from all levels are concatenated into a unified pyramid feature map along the channel dimension. A 1×1 convolution is then performed to compress the number of channels and eliminate redundant information. The resulting pyramid feature preserves high-resolution details and deep semantic information.
[0123] Specifically, the data processing steps of the cognitive decision fusion head are as follows: Figure 5 As shown, including:
[0124] Step 421: Integrate the pyramid features and the semantic prior map of the enhanced dataset into multimodal input features;
[0125] More specifically, the semantic prior map is obtained by extracting small object regions from the augmented dataset through a pre-trained semantic segmentation network.
[0126] Step 422: Generate a memory matrix using typical features of small targets pre-stored in the cognitive memory unit;
[0127] More specifically, the small target features in the training set are clustered by K-means clustering, and the cluster centers are used as the initial values of the memory matrix. The memory matrix is then optimized by back propagation so that it gradually converges to the most representative small target feature pattern.
[0128] Step 423: Calculate the similarity between the multimodal input features and the real features through the memory matrix;
[0129] More specifically, the similarity calculation formula is:
[0130]
[0131] Among them, f k is the spatial position vector of the multimodal input feature, M k is the true feature of the target prototype.
[0132] Step 424: Enhance the multimodal input features according to the memory matrix and the similarity to obtain enhanced features.
[0133] More specifically, the similarity is first normalized using Softmax to generate a weight vector. The target prototype's true features are then linearly combined according to the weight vector to generate enhanced features. Finally, the enhanced features are added to the multimodal input features to form a reinforced feature.
[0134] Step 500: Use the small target recognition model to perform small target recognition on the dataset to be detected and obtain the recognition result. The recognition result includes: predicted anchor box and recognition confidence. The specific steps are as follows: Figure 6 As shown, including:
[0135] Step 501: Generate a predicted anchor box based on the enhanced features;
[0136] Step 502: Obtain the positioning confidence according to the Mahalanobis distance between the covariance matrices of the predicted anchor frames;
[0137] Specifically, the covariance matrix of this embodiment is:
[0138]
[0139] Where ρ is the correlation coefficient of the predicted anchor box center coordinates (x, y), and the value range of this embodiment is [-1, 1], σ x and σ y is the standard deviation of the center coordinates (x,y).
[0140] The calculation formula of Mahalanobis distance is:
[0141]
[0142] Among them, (μx ,μ y ) is the center coordinate of the real anchor box.
[0143] Step 503: Introducing the temperature factor into the location reliability to obtain the classification reliability;
[0144] Specifically, the expression of the temperature factor is:
[0145] T t =1+Sigmoid(W T ·v g );
[0146] Among them, Simgoid(·) is the Sigmoid function, v g is the vector obtained by global average pooling of the enhanced features, and W is a learnable weight parameter.
[0147] Step 504: Calibrate the classification confidence according to the temperature factor to obtain an initial score;
[0148] Specifically, the classification confidence and the confidence of the predicted anchor box are multiplied to obtain the initial score.
[0149] Step 505: Adjust the initial score according to the overlap between the predicted anchor box and the semantic prior map of the enhanced dataset to obtain an optimized score;
[0150] Specifically, the calculation formula for overlap is:
[0151] Among them, B p To predict the anchor box, M s is the semantic prior map, and Ar(·) is the region recognition operation.
[0152] The expression of the optimization score is:
[0153] Among them, s i is the initial score, o is the overlap, θ s is the score demarcation threshold, which is 0.3 in this embodiment.
[0154] Step 506: Perform weighted fusion on the optimized scores to obtain recognition confidence.
[0155] The present invention also provides a small target recognition system based on YOLOv5, comprising:
[0156] An image acquisition module is used to collect multi-scale images within the target range to form an original data set;
[0157] The image enhancement module is used to perform image enhancement on the original dataset through superpixel segmentation and adversarial enhancement operations to obtain an enhanced dataset;
[0158] An image aliasing module is used to perform multi-scale frequency domain aliasing enhancement on the enhanced data set through frequency domain decomposition and frequency band swapping operations to obtain a data set to be detected;
[0159] The model building module is used to improve the YOLOv5 model to obtain a small object recognition model;
[0160] The target recognition module is used to identify small targets in the detection data set through the small target recognition model to obtain the recognition results.
[0161] The beneficial effects of the present invention are as follows:
[0162] 1) By combining a dynamic feature pyramid with a spatial-frequency dual-domain attention mechanism, the high-frequency details and semantic information of small objects are enhanced, reducing missed detection and false detection rates.
[0163] 2) The multi-scale frequency domain aliasing technology greatly improves the response strength of small target edge features;
[0164] 3) The positioning error distribution is modeled through the covariance matrix and Mahalanobis distance, and a dynamic temperature factor is introduced to make the confidence distribution more consistent with the true probability and improve the recall rate of the model.
[0165] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0166] The present invention uses specific examples to illustrate the principles and implementation methods of the present invention. The above examples are only intended to help understand the method and core concept of the present invention. At the same time, those skilled in the art will find that the specific implementation methods and application scopes may vary based on the concept of the present invention. In summary, the contents of this specification should not be construed as limiting the present invention.
Claims
1. A small target recognition method based on YOLOv5, characterized in that: The steps include: Collect multi-scale images within the target range to form an original data set; Performing image enhancement on the original dataset through superpixel segmentation and adversarial enhancement operations to obtain an enhanced dataset; Performing multi-scale frequency domain aliasing enhancement on the enhanced data set by frequency domain decomposition and frequency band swapping operations to obtain a data set to be detected; Improve the YOLOv5 model to obtain a small target recognition model; The improved steps include: Add a dynamic routing network to the C3 module of the YOLOv5 model and replace the Focus module with a dynamic backbone module; In the Neck part, cross-scale dynamic convolution and dual-channel attention fusion mechanism are introduced to obtain a dynamic feature pyramid; A new cognitive memory unit is added to the Head part to obtain the cognitive decision fusion head; Small targets are identified in the dataset to be detected using the small target recognition model to obtain a recognition result; the recognition result includes: a predicted anchor box and a recognition confidence.
2. The small target recognition method based on YOLOv5 according to claim 1, characterized in that The original dataset is subjected to image enhancement through superpixel segmentation and adversarial enhancement operations to obtain an enhanced dataset, including: Performing the superpixel segmentation operation on the original data set to obtain a region boundary map; Using the region boundary map as a mask, and converting low-resolution small targets in the original data set into high-resolution pseudo targets according to the mask; Distinguishing the high-resolution pseudo target from the real target through local discrimination and global consistency discrimination; The high-resolution pseudo target is inserted into the original data set through a Poisson fusion algorithm to obtain the enhanced data set.
3. The small target recognition method based on YOLOv5 according to claim 1, characterized in that Performing multi-scale frequency domain aliasing enhancement on the enhanced data set through frequency domain decomposition and frequency band swapping operations to obtain a data set to be detected, including: Performing a fast Fourier transform on the enhanced data set to obtain an amplitude spectrum and a phase spectrum; Mixing the high-frequency components and the low-frequency components in the enhanced data set to generate a mixed amplitude spectrum; Image reconstruction is performed according to the mixed amplitude spectrum and the phase spectrum to obtain the data set to be detected.
4. The small target recognition method based on YOLOv5 according to claim 3, characterized in that Mixing the high-frequency components and the low-frequency components in the enhanced data set to generate a mixed amplitude spectrum includes: Based on a preset critical frequency band, the enhanced data set is divided into frequency bands by a logarithmic Gaussian pyramid to obtain a center frequency; Obtaining a bandwidth according to the center frequency and the bandwidth attenuation rate; Constructing a filter function with the bandwidth as an independent variable through a differential Gaussian filter; Calculating the energy proportion of the frequency band by the filter function; Dividing the enhanced data set into the high-frequency component and the low-frequency component according to a comparison result of the energy proportion and the energy threshold; By formula The amplitude spectra of the high-frequency component and the low-frequency component are mixed into the mixed amplitude spectrum; wherein A' is the mixed amplitude spectrum, α and β are both nonlinear gain coefficients, A obj is the amplitude spectrum of the high-frequency component, A bg is the amplitude spectrum of the low-frequency component, λ k is the dynamic blending weight.
5. The small target recognition method based on YOLOv5 according to claim 4, characterized in that Performing image reconstruction according to the mixed amplitude spectrum and the phase spectrum to obtain the data set to be detected includes: constructing an optimization equation by imposing a smoothness constraint on the phase spectrum; Iteratively solving the optimization equation by the conjugate gradient method to obtain an optimized phase spectrum; By formula Performing inverse fast Fourier transform on the optimized phase spectrum and the mixed amplitude spectrum to reconstruct the data set to be detected; wherein, I re To reconstruct the data, is the two-dimensional inverse fast Fourier transform operation, P' is the optimized phase spectrum, Real(·) is the complex real part operation, j is the complex imaginary part, Window -1 is the inverse windowing compensation operation, and ⊙ is the element-by-element multiplication.
6. The small target recognition method based on YOLOv5 according to claim 1, characterized in that The dynamic routing network is composed of a routing unit, a multi-branch residual unit and a spatial-channel collaborative attention unit, wherein the routing unit, the multi-branch residual unit and the spatial-channel collaborative attention unit are fully connected; The routing unit includes a global average pooling layer and two multi-layer perceptrons connected in sequence; the multi-branch residual unit has a three-branch independent structure, and the three branches are respectively used to perform high-frequency enhancement, context aggregation and identity mapping operations on the output of the routing unit; The spatial-channel collaborative attention unit includes: spatial attention, channel attention and a collaborative fusion layer connecting the spatial attention and the channel attention; The dynamic backbone module is composed of a deformable convolution layer, a channel reorganization unit and a dynamic gating unit, and the deformable convolution layer, the channel reorganization unit and the dynamic gating unit are fully connected.
7. The small target recognition method based on YOLOv5 according to claim 1, characterized in that The data processing steps of the dynamic feature pyramid include: Perform global average pooling on the output of the Backbone part to obtain the convolution kernel weight; The convolution kernel weights and the features of adjacent levels are convolved through a cross-level kernel sharing operation to obtain dynamic fusion features; Extracting the spatial attention and frequency domain attention of the dynamic fusion feature respectively; The spatial attention and the frequency domain attention are fused to obtain pyramid features.
8. The small target recognition method based on YOLOv5 according to claim 7, characterized in that The data processing steps of the cognitive decision fusion head include: Integrating the pyramid features and the semantic prior map of the enhanced dataset into multimodal input features; Generate a memory matrix using typical features of small targets pre-stored in the cognitive memory unit; Calculating the similarity between the multimodal input feature and the real feature through the memory matrix; The multimodal input feature is enhanced according to the memory matrix and the similarity to obtain an enhanced feature.
9. The small target recognition method based on YOLOv5 according to claim 8, characterized in that Performing small target recognition on the dataset to be detected using the small target recognition model to obtain a recognition result includes: Generating the predicted anchor frame according to the enhanced feature; Obtaining the positioning confidence according to the Mahalanobis distance between the covariance matrices of the predicted anchor frames; A temperature factor is introduced into the location reliability to obtain the classification reliability; Calibrate the classification credibility according to the temperature factor to obtain an initial score; Adjusting the initial score according to the overlap between the predicted anchor box and the semantic prior map of the enhanced dataset to obtain an optimized score; The optimization scores are weighted and fused to obtain the recognition confidence.
10. A small target recognition system based on YOLOv5, characterized in that: include: An image acquisition module is used to collect multi-scale images within the target range to form an original data set; An image enhancement module is used to perform image enhancement on the original data set through superpixel segmentation and adversarial enhancement operations to obtain an enhanced data set; An image aliasing module is used to perform multi-scale frequency domain aliasing enhancement on the enhanced data set through frequency domain decomposition and frequency band swapping operations to obtain a data set to be detected; The model building module is used to improve the YOLOv5 model to obtain a small object recognition model; The target recognition module is used to perform small target recognition on the data set to be detected through the small target recognition model to obtain a recognition result.
Citation Information
Cited By
Multi-scale image segmentation and damage assessment method for surface cracks of bridge structure
CN121392622A
Small target detection system based on frequency-space system, training method thereof and small target detection method
CN121458955A
Unmanned aerial vehicle small target detection method based on frequency domain enhancement and space path refinement
CN121884189A
Unmanned aerial vehicle small target detection method based on frequency domain enhancement and spatial path refinement
CN121884189B
RGB-infrared multi-mode sensing measurement method and system for automatic driving navigation
CN121937976A