Pruning training, dynamic pruning method and system for small target detection model

By introducing a dynamic pruning method that incorporates a small target location weighting matrix and an importance prediction module, the problem of deploying small target detection models on resource-constrained devices is solved, achieving reduced computational overhead and improved inference efficiency without compromising accuracy.

CN123180249APending Publication Date: 2026-11-27GUANGZHOU POWER SUPPLY BUREAU GUANGDONG POWER GRID CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611266202.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-20
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively reduce the computational overhead of small target detection models without significantly impacting their detection accuracy, especially given the difficulty in deploying them on resource-constrained edge devices.

Method used

By introducing a position weighting matrix for small targets to enhance gradient response, channel importance is calculated, and an importance prediction module is designed for dynamic pruning to ensure that key feature channels are not mistakenly pruned. Pruning decisions are made by combining the overall pruning rate and single-layer importance, and a simple importance prediction module is used for real-time adjustment.

Benefits of technology

It achieves an effective reduction in model computational overhead and an improvement in inference efficiency without significantly reducing detection accuracy, while maintaining high detection accuracy on resource-constrained devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123180249A_ABST
    Figure CN123180249A_ABST
Patent Text Reader

Abstract

The application discloses a small-target-oriented detection model pruning training, dynamic pruning method and system. In the model training stage, the feature map gradient is calculated according to the detection loss of the original detection model, and a small-target-position weighted matrix is generated according to the real label, the gradient and the weighted matrix are multiplied element by element to obtain the channel importance of each output channel, and then the single-layer importance is calculated to allocate the layer pruning rate, screen the pruning target and determine the initial pruning strategy. An importance prediction module with a simple structure is added to each convolution layer, the initial pruning strategy is used as a preheating stage supervision signal for joint training to obtain a pre-training detection model. In the inference method, the image to be processed is input into the model, the importance is predicted in real time by the importance prediction module to guide the dynamic pruning layer by layer, and the detection result is output. According to the embodiment of the application, the dynamic pruning processing of the small-target-oriented detection model can be realized, and the inference calculation overhead is effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision, and more particularly to a pruning training, dynamic pruning method and system for a detection model for small targets. Background Technology

[0002] In the field of computer vision technology, detection models for small targets have encountered significant bottlenecks. Small targets have a low pixel ratio and weak feature information. To ensure recognition accuracy, the detection model must retain sufficient feature extraction capabilities. This makes the model structurally complex and computationally intensive, making it difficult to deploy on resource-constrained edge devices. The contradiction between lightweight small target detection models and detection accuracy is becoming increasingly prominent.

[0003] Model pruning is an important method for reducing model complexity. Existing methods can be divided into two categories: static pruning and dynamic pruning. Static pruning determines a globally fixed pruning structure during the training phase, and cannot dynamically adjust it based on the input content during inference. Its importance evaluation mechanism is designed for general targets, which can easily lead to the accidental deletion of feature channels that are crucial for the detection of small targets, resulting in a significant increase in the false negative rate. Although dynamic pruning can achieve input adaptation, most methods are not specifically optimized for the characteristics of small targets, and weak features are easily ignored. Moreover, the dynamic pruning module itself may introduce significant additional computational overhead, and the latency of some methods may even exceed the speedup benefits brought by pruning.

[0004] Therefore, existing technologies face the challenge of effectively pruning small target detection models to reduce computational overhead without significantly affecting detection accuracy. Summary of the Invention

[0005] This invention provides a pruning training and dynamic pruning method for detection models targeting small targets, in order to solve the technical problem that existing technologies are unable to effectively prune small target detection models.

[0006] To address the aforementioned technical problems, embodiments of the present invention provide a pruning training method for a detection model oriented towards small targets, comprising: Calculate the detection loss of the pre-defined original detection model on the training set; Based on the detection loss, the feature map gradient of the output feature map of each convolutional layer in the original detection model is calculated. At the same time, the position weighting matrix of the small target is calculated based on the training set. The feature map gradient of each convolutional layer is multiplied element-wise with the position weighting matrix to obtain the channel importance of each output channel of each convolutional layer. Based on the channel importance, calculate the single-layer importance of each convolutional layer relative to all convolutional layers; The layer pruning rate of each convolutional layer is assigned according to the single-layer importance, and the pruning target of each convolutional layer is screened according to the layer pruning rate and the channel importance to determine the initial pruning strategy of each convolutional layer. A corresponding importance prediction module is added to each convolutional layer of the original detection model. The original detection model and the importance prediction module are jointly trained according to the initial pruning strategy to obtain a pre-trained detection model. The importance prediction module for each convolutional layer is a structure that performs point-by-point interaction and single non-linear activation only in the channel dimension. The importance prediction module is used to receive the feature map of the initial output of the current convolutional layer as input and output the predicted channel importance and predicted single-layer importance of the current convolutional layer.

[0007] In terms of model training, this application introduces a position weighting matrix for small targets during the importance assessment stage to enhance the gradient response to small target regions. This effectively avoids the mis-pruning of key feature channels of small targets, ensuring that the model accuracy does not significantly decrease after pruning. Subsequently, dynamic pruning is guided by the assessed importance, enabling adaptive dynamic adjustments for different input content and avoiding the problem of a fixed pruning structure that cannot adapt to complex environments. In addition, this method designs an importance prediction module. After receiving the feature map input, the importance prediction module outputs the importance prediction result and guides the pruning operation, thereby achieving the effect of dynamic pruning. Moreover, since the structure of the importance prediction module is very simple and the computational cost is minimal, it can effectively avoid the risk that the delay caused by pruning processing will offset the benefits of pruning acceleration.

[0008] Compared to existing technologies that rely solely on feature map gradients for importance assessment and lack additional adaptation for small target detection, this application actively enhances the importance of small target regions through a position weighting matrix for small targets. This prompts the model to make pruning decisions specifically for small targets, prioritizing output channels with relatively low importance for small target detection as pruning targets, thereby ensuring the detection accuracy of the model after pruning. Compared to traditional dynamic pruning algorithms, this application uses a pre-trained importance prediction model for importance assessment. This module has a very simple structure, and its computational cost is extremely low compared to the detection model itself during real-time inference, resulting in negligible inference latency. In contrast, traditional dynamic pruning algorithms often require the introduction of a computationally intensive decision module for importance assessment, which introduces additional non-negligible inference latency. This inference latency reduces the speedup benefits of pruning. This application, however, maximizes the speedup benefits of model pruning and improves the model's inference efficiency.

[0009] As a preferred embodiment, the step of calculating the position weighting matrix of the small target based on the training set data includes: Calculate the position weighting matrix of the small targets based on the training set, including: Obtain the ground truth bounding boxes and their corresponding area percentages in the images of the training set; The area ratio is nonlinearly transformed according to a preset area attenuation coefficient to generate an area weighting factor. For each pixel in the image, calculate the Euclidean distance from the pixel to the center coordinates of each real target box, and perform a nonlinear transformation on the Euclidean distance according to a preset distance attenuation coefficient to generate a distance weighting factor. The weight value of the current pixel in the position weighting matrix is ​​determined based on the area weighting factor and the distance weighting factor of each of the real target boxes. Traverse all pixels in the image, arrange the weight values ​​corresponding to each pixel according to their spatial position, and generate a position weighting matrix.

[0010] In this application, an area weighting factor and a distance weighting factor are calculated, and a position weighting matrix is ​​constructed by multiplying and accumulating the factors. The area weighting factor gives small targets a higher weight response, preventing the signals of small targets from being masked by large targets. The distance weighting factor focuses the weight on the central region of the target, preventing non-target regions from interfering with pruning decisions. By multiplying and accumulating the area factor and the distance factor, and taking into account the semantic importance and spatial proximity of small targets, the weight ratio of small targets is strengthened.

[0011] As a preferred embodiment, based on the channel importance, the single-layer importance of each convolutional layer relative to all convolutional layers is calculated, including: The sum of the channel importance of all output channels in each convolutional layer is calculated as the proportion of the sum of the channel importance of all output channels in all convolutional layers, and this proportion is used as the single-layer importance of each convolutional layer relative to all convolutional layers.

[0012] In this application, the importance of a single layer is calculated as the proportion of the sum of the importance of each layer's channels to the sum of the importance of all channels globally. This proportion directly reflects the relative contribution of each convolutional layer to the overall detection task, providing a quantitative benchmark for allocating the pruning rate layer by layer in subsequent dynamic pruning decisions.

[0013] As a preferred embodiment, the layer pruning rate of each convolutional layer is assigned according to the single-layer importance, and the pruning targets of each convolutional layer are selected according to the layer pruning rate and the channel importance, including: Based on the preset overall pruning rate and the single-layer importance, the layer pruning rate of each convolutional layer is allocated; For each convolutional layer, obtain the total number of output channels of the current layer, and calculate the number of channels to be retained for the current layer based on the layer pruning rate and the total number of output channels; The channel importance of the current layer is sorted in descending order, and the output channel with the highest channel importance is selected as the retention target until the number of retained channels reaches the number of channels to be retained. The remaining output channels are then selected as pruning targets.

[0014] In this application, the pruning rate of each convolutional layer is allocated according to the preset overall pruning rate and single-layer importance, and the overall pruning target of the model is subdivided into each convolutional layer. On this basis, by sorting the channel importance in descending order and prioritizing the retention of the most important channels, the core feature channels are ensured to be retained. This two-layer pruning architecture makes decisions based on the same set of importance evaluation systems, and achieves consistent decision-making from which layers to prune more to which channels to prune in each layer.

[0015] As a preferred embodiment, the step of guiding the joint training of the original detection model and the importance prediction module according to the initial pruning strategy includes: The initial pruning strategy is used as the pruning decision basis in the warm-up stage, driving the original detection model to perform forward propagation and dynamic pruning, and outputting the prediction results after pruning. Calculate the second detection loss of the prediction result after pruning, and calculate the importance fitting loss of the importance prediction result output by the importance prediction module; Minimizing the second detection loss and the importance fitting loss are used as common optimization objectives to jointly train the original detection model and the importance prediction module.

[0016] In this application, the detection loss and fitting loss are jointly optimized within the same objective function. The detection loss guides the detection model to maintain detection accuracy after pruning, while the fitting loss guides the bypass module to accurately learn the mapping relationship between feature maps of each layer and their corresponding importance. The two converge collaboratively, avoiding accuracy shifts caused by single-objective optimization. The initial pruning strategy provides a high-reliability supervision benchmark for the bypass module during the warm-up phase and serves as a convergence anchor point for subsequent switching to pruning guided by predicted importance, ensuring a smooth transition and efficient training of pruning decisions from static labels to dynamic predictions. After training, the importance prediction module can directly output reliable importance prediction results in real time during actual inference and guide pruning, achieving dynamic pruning.

[0017] This invention also provides a dynamic pruning method for detection models targeting small targets, including: Obtain the image to be processed; The image to be processed is input into a preset detection model, and layer-by-layer forward propagation and dynamic pruning are performed to finally output the small target detection result. The preset detection model is trained using the pruning training method of the detection model for small targets.

[0018] This method applies the model trained using the pruning training method for small target detection models described above to a real-world environment. By jointly training an importance prediction module, it receives the current layer's feature map in real-time during the inference phase and outputs importance predictions, enabling pruning decisions to adaptively adjust to the input content and achieving content-aware dynamic pruning. Simultaneously, pruning decisions and feature extraction are completed synchronously in the same forward propagation, requiring no additional iterations or offline recalculation. Furthermore, the importance prediction module has a minimal structure with negligible additional computational overhead, ensuring that the acceleration benefits of dynamic pruning are not offset by the latency of the decision itself. More importantly, this inference method fully inherits the ability to protect sensitive channels for small targets through the position-weighted matrix during training, allowing the pruned model to maintain high detection accuracy in small target detection tasks.

[0019] As a preferred embodiment, the step of performing layer-by-layer forward propagation and dynamic pruning to finally output the small target detection result includes: For each convolutional layer in the preset detection model, based on the feature map output by the previous convolutional layer and the pre-trained importance prediction module corresponding to the current convolutional layer, the predicted channel importance and the predicted single-layer importance are output. Based on the predicted channel importance and the predicted single-layer importance, the initial feature map output by the current convolutional layer is dynamically pruned to obtain the feature map used as the input for the next convolutional layer. The input image of the first convolutional layer is the image to be processed, and the feature map output by the last convolutional layer is input into the detection head to output the small target detection result.

[0020] In this application, the forward propagation and dynamic pruning are performed simultaneously during the inference phase. The current layer inputs the received feature map into both the importance prediction module and the inference module, outputs the predicted importance and the initial feature map, and then immediately prunes the initial feature map based on the predicted importance. The pruned feature map is then directly sent to the next layer for further processing until all prunable layers have been processed. This process does not change the propagation path of the original model, but only introduces an additional importance prediction module to guide the pruning process, making this method easily integrated into mainstream detection models without the need for additional model structure adaptation.

[0021] As a preferred embodiment, the step of dynamically pruning the initial feature map output by the current convolutional layer based on the predicted channel importance and the predicted single-layer importance includes: The layer pruning rate of the current convolutional layer is determined based on the preset overall pruning rate and the predicted single-layer importance. Obtain the total number of output channels in the current layer, and calculate the number of channels to be retained in the current layer based on the layer pruning rate and the total number of output channels; The predicted channels in the current layer are sorted in descending order of importance. The output channel with the highest predicted channel importance is selected as the retention target until the number of retained channels reaches the number of channels to be retained. The remaining output channels are then selected as pruning targets for pruning.

[0022] In this application, the overall pruning rate and pruning decision logic in the inference phase are completely consistent with those in the training phase. Both adopt a two-layer decision architecture in which the overall pruning rate is negatively correlated with the importance of each layer, and important channels are retained by sorting them by channel importance. This isomorphic design ensures that the mapping relationship learned by the importance prediction module in the training phase is accurately aligned with the pruning target in the inference phase, avoiding prediction bias caused by inconsistencies between training and inference logic. At the same time, the pruning rules in the training phase can be directly reused in the inference phase without additional design. The small target sensitive channel protection effect enhanced by the position weighting matrix in the training phase is fully inherited in the inference phase, ensuring the stability of the model accuracy after pruning. Attached Figure Description

[0023] Figure 1 A flowchart of one embodiment of the pruning training method for a detection model for small targets provided by the present invention; Figure 2 A flowchart of an embodiment of the dynamic pruning method for a small target detection model provided by the present invention; Figure 3 A schematic diagram of one embodiment of the pruning training device for a detection model for small targets provided by the present invention; Figure 4 This is a schematic diagram of one embodiment of the dynamic pruning device for a small target detection model provided by the present invention. Detailed Implementation

[0024] 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.

[0025] Example 1 Please refer to Figure 1 This invention provides a pruning training method for a detection model targeting small targets, comprising steps S101 to S105, each step as follows: Step S101: Calculate the detection loss of the preset original detection model on the training set.

[0026] In this embodiment, the preset original detection model refers to a pre-trained full-precision convolutional neural network detection model. The training set consists of several images and corresponding ground truth labels. The ground truth labels completely record the bounding boxes and category information of small objects in each image of the training set. The training set images are input into the original detection model, and after layer-by-layer forward propagation, the output includes the predicted bounding boxes and predicted categories. Based on this detection output, the detection loss is calculated, specifically as follows: in, Indicates detection loss; , These are the actual annotation information and the predicted annotation information, including the bounding box coordinates and category information; These represent the true category and the predicted category, respectively. Indicates CIoU loss; Represents cross-entropy loss; , These are the CIoU loss weights and the cross-entropy loss weights, respectively. This weight combination can be determined by parameter tuning using the grid search method.

[0027] Step S102: Based on the detection loss, calculate the feature map gradient of the output feature map of each convolutional layer in the original detection model. At the same time, calculate the position weighting matrix of the small target based on the training set. Multiply each feature map gradient with the position weighting matrix element by element to obtain the channel importance of each output channel of each convolutional layer.

[0028] After obtaining the detection loss output by S101, the detection loss is backpropagated layer by layer to calculate the feature map gradient of the output feature map of each convolutional layer. Specifically, the feature map gradient is calculated as follows: in, Indicates the first Output feature maps of convolutional layers gradient, The detection loss obtained from S101; They represent the first The number of output channels, height, and width of the output feature map of each convolutional layer.

[0029] Simultaneously, the position weighting matrix of the small targets is calculated based on the training set, specifically including: Obtain the ground truth bounding boxes and their corresponding area percentages in the images of the training set; The area ratio is nonlinearly transformed according to a preset area attenuation coefficient to generate an area weighting factor. For each pixel in the image, calculate the Euclidean distance from the pixel to the center coordinates of each real target box, and perform a nonlinear transformation on the Euclidean distance according to a preset distance attenuation coefficient to generate a distance weighting factor. The weight value of the current pixel in the position weighting matrix is ​​determined based on the area weighting factor and the distance weighting factor of each of the real target boxes. Traverse all pixels in the image, arrange the weight values ​​corresponding to each pixel according to their spatial position, and generate a position weighting matrix.

[0030] First, extract each ground truth bounding box from the training set for each input image and calculate its area percentage in the entire image.

[0031] Secondly, the area ratio is nonlinearly transformed according to a preset area attenuation coefficient to generate an area weighting factor, which is specifically calculated as follows: in, Indicates the first Area weighting factors for each real target bounding box; The preset area attenuation coefficient is used to adjust the sensitivity of the area ratio to the weight contribution. This value is negative and is used in the calculation, so that the area weight factor and the area ratio are negatively correlated. The larger the value, the more the larger the target area is suppressed, so that the weight allocation is more inclined to the smaller target. For the first The percentage of the area of ​​each real target bounding box.

[0032] Subsequently, for each pixel in the image, the Euclidean distance from the pixel to the center coordinates of each of the real target bounding boxes is calculated, and the Euclidean distance is nonlinearly transformed according to a preset distance attenuation coefficient to generate a distance weighting factor. The specific transformation method is as follows: in, Indicates coordinates as The pixel relative to the first Distance weighting factors for each real target bounding box; The preset distance decay coefficient is used to control the rate at which the weight decays with distance. This value is negative in the calculation, so that the distance weight factor and the Euclidean distance are negatively correlated, so that the weight is focused on the target center area and non-target areas do not interfere with the pruning decision. The larger the value, the slower the weight decays with distance. For pixels With the The Euclidean distance of each real target bounding box.

[0033] Subsequently, the weight value of each pixel is determined based on the area weight factor and the distance weight factor. The specific calculation method is as follows: in, For pixels The weight value; This represents the total number of true bounding boxes. Index the actual target bounding box; For the first The area weighting factor of each real target bounding box; For the pixel point relative to the first Distance weighting factors for each real target bounding box.

[0034] Then, by iterating through all the pixels of the image and arranging the weight values ​​corresponding to each pixel according to their spatial positions, the position-weighted matrix can be obtained. .

[0035] Finally, the gradients of each feature map are multiplied element-wise by the position weighting matrix to obtain the channel importance of each output channel of each convolutional layer. Specifically, the... Layer The channel importance of each output channel is calculated as follows: in, Indicates the first Layer The importance of each output channel; For the first Layer The gradient of the output channel is obtained from the gradient of the first output channel. gradient of convolutional layers Obtained by extracting the corresponding two-dimensional gradient slice; By using the position weighting matrix resize to the 1st The size of the output feature map of each convolutional layer is obtained; Represents element-wise product; The value is the L2 norm. The channel importance calculated from this can characterize the contribution of each output channel within its convolutional layer; the higher the contribution, the higher the channel importance.

[0036] It is worth noting that, in the actual training process, in accordance with the conventional processing of those skilled in the art, when calculating the feature map gradient, the current small batch sample detection loss, such as the mean of all images in an input batch, can be used for backpropagation calculation to stabilize the model update direction; the position weighting matrix must be generated independently for each input image to avoid the dispersion of weight signals caused by the inconsistency of target spatial position between different samples.

[0037] S103, Calculate the single-layer importance of each convolutional layer relative to all convolutional layers based on the channel importance, including: The sum of the channel importance of all output channels in each convolutional layer is calculated as the proportion of the sum of the channel importance of all output channels in all convolutional layers, and this proportion is used as the single-layer importance of each convolutional layer relative to all convolutional layers.

[0038] Specifically, the calculation method is as follows: in, For the first The importance of a single layer in a convolutional layer; For output channel index; For the first The total number of output channels of a convolutional layer; For convolutional layer index; This represents the total number of convolutional layers. For the first Layer The importance of each output channel is calculated. The single-layer importance obtained from this calculation can characterize the relative contribution of each convolutional layer to the final detection output. The higher the contribution, the higher the single-layer importance.

[0039] S104, assign layer pruning rates to each convolutional layer according to the single-layer importance, and filter pruning targets for each convolutional layer according to the layer pruning rates and the channel importance, and determine the initial pruning strategy for each convolutional layer, including: Based on the preset overall pruning rate and the single-layer importance, the layer pruning rate of each convolutional layer is allocated; For each convolutional layer, obtain the total number of output channels of the current layer, and calculate the number of channels to be retained for the current layer based on the layer pruning rate and the total number of output channels; The channel importance of the current layer is sorted in descending order, and the output channel with the highest channel importance is selected as the retention target until the number of retained channels reaches the number of channels to be retained. The remaining output channels are then selected as pruning targets.

[0040] First, based on the preset overall pruning rate and the single-layer importance, the layer pruning rate of each convolutional layer is allocated. The specific allocation method is as follows: in, For the first Layer pruning rate of layer convolutional layers; The preset overall pruning rate; For the first The importance of a single layer in a convolutional layer.

[0041] Subsequently, for each convolutional layer, the total number of output channels of the current layer is obtained. Based on the layer pruning rate and the total number of output channels, the number of channels to be retained in the current layer is calculated. The specific calculation method is as follows: in, For the first The number of channels to be retained in each convolutional layer; For the first The total number of output channels of a convolutional layer; For the first Layer pruning rate of a convolutional layer.

[0042] Then, for each convolutional layer, the channel importance is sorted in descending order, and the output channel with the highest channel importance is selected as the retention target until the number of retained channels reaches the number of channels to be retained. The remaining output channels are then selected as pruning targets to determine the initial pruning strategy.

[0043] S105, add corresponding importance prediction modules to each convolutional layer of the original detection model, and guide the original detection model and the importance prediction modules to perform joint training according to the initial pruning strategy to obtain a pre-trained detection model.

[0044] In this embodiment, preferably, the importance prediction module includes two sub-modules, both of which adopt a 1×1 convolution + BN layer + Sigmoid activation function structure. They are used to receive the feature map of the initial output after processing by the current convolutional layer as input, and output the predicted channel importance and the predicted single-layer importance of the current convolutional layer, respectively.

[0045] The process of jointly training the original detection model and the importance prediction module based on the initial pruning strategy includes: The initial pruning strategy is used as the pruning decision basis in the warm-up stage, driving the original detection model to perform forward propagation and dynamic pruning, and outputting the prediction results after pruning. Calculate the second detection loss of the prediction result after pruning, and calculate the importance fitting loss of the importance prediction result output by the importance prediction module; Minimizing the second detection loss and the importance fitting loss are used as common optimization objectives to jointly train the original detection model and the importance prediction module.

[0046] First, we define the training loss function in the joint training process. Preferably, the training loss function is defined as: in, For training the loss function; The detection loss of the model during training; The distillation term specifically includes a classification branch, which corresponds to the category information output by the model. It is obtained by calculating the KL divergence between the classification score vector after model pruning during training and the classification score vector of the original model. The regression branch corresponds to the target box coordinates output by the model. It is obtained by calculating the mean square error between the bounding box regression parameters (such as center point coordinates, width and height) output by the model after pruning during training and the bounding box regression parameters output by the original model. This represents the predicted single-layer importance output during the training process. The predicted channel importance output during training. This represents the total number of output channels after model pruning during training. These are the weight coefficients for the corresponding items.

[0047] The training loss function is formulated based on two main objectives of the training phase. First, it fine-tunes the inference weights of the original detection model. Model pruning inevitably reduces detection accuracy; to compensate for this reduction, the inference weights of the original model need to be fine-tuned during the joint training phase. Second, it trains the importance prediction module to learn the mapping relationship between feature maps and importance. Therefore, the training loss function consists of four parts. This is used to ensure the detection accuracy of the model after pruning; The performance of the original detection model is used to guide the pruning model to approach full accuracy; these two items are used to guide the model in fine-tuning of inference weights. , These are used to guide the importance prediction module in joint training to learn the mapping relationship between single-layer importance, channel importance, and the feature maps of the initial output of each convolutional layer; at the same time, since the numerical ranges of detection loss and fitting loss differ greatly, it is necessary to combine the weight coefficients. Adjust to the same scale to balance the magnitudes of the three loss terms.

[0048] Model training can be divided into two parts: a warm-up phase and an adaptive phase. The warm-up phase is the period before the total number of training rounds is determined. Preferably, the first 15% of the total rounds can be used for the warm-up phase. In this phase, the importance prediction module has not yet learned the mapping relationship between feature maps and importance, and the output importance prediction results have high randomness and insufficient reliability, which cannot guide the model to make effective pruning decisions. Therefore, in this phase, the importance prediction module does not directly participate in pruning decisions, but guides the original detection model to perform pruning based on the initial pruning strategy determined by the true channel importance and single-layer importance. The importance prediction module then performs backpropagation based on the training loss function to quickly learn the mapping relationship between importance and feature maps to a reliable level. The model inference part is also fine-tuned based on the training loss function to compensate for the decrease in detection accuracy caused by pruning.

[0049] After the warm-up phase, the training enters the adaptive phase. At this time, the predicted importance output by the importance prediction module replaces the actual channel importance and single-layer importance in the initial pruning strategy formulation to formulate a dynamic pruning strategy to guide the pruning decision. The detection model and the importance prediction module are optimized end-to-end through the training loss function until the training round ends or the loss converges to the preset convergence target. The fine-tuned detection model and the importance prediction module after training together form the pre-trained detection model.

[0050] It is worth noting that even after the warm-up phase, when the importance prediction results output by the importance prediction module are considered to have reached a reliable level, to avoid a sharp drop in detection accuracy that might result from a direct switch in pruning criteria, a soft-weighted transition hybrid transition strategy can be used in practical applications. This strategy controls the model's pruning criteria to switch from the initial pruning decision to adaptive dynamic pruning based on the importance prediction module, achieving a smooth transition from static real label-guided pruning to dynamic autonomous prediction pruning. Specifically, preferably, the first 15% to 25% of the total rounds are set as the transition phase. In this phase, the channel importance and single-layer importance required for pruning decision-making are obtained in the following way: in, The mixed importance is used to guide pruning decisions after mixing. This is the true importance result calculated previously; The predicted importance results output by the importance prediction module; The mixing coefficient decreases linearly from 1 to 0 during the training rounds in the transition phase.

[0051] Reference Figure 2 This invention provides a dynamic pruning method for a detection model targeting small targets, comprising steps S201 to S202, the specific details of which are as follows: S201, Obtain the image to be processed.

[0052] S202, the image to be processed is input into a preset detection model, and layer-by-layer forward propagation and dynamic pruning are performed to finally output the small target detection result.

[0053] Specifically, the image to be processed is input into a preset detection model, which is trained using the pruning training method of the previous detection model for small targets. Internally, it can be divided into two parts: an inference part and an importance prediction module.

[0054] The step of performing layer-by-layer forward propagation and dynamic pruning to finally output small target detection results includes: For each convolutional layer in the preset detection model, based on the feature map output by the previous convolutional layer and the pre-trained importance prediction module corresponding to the current convolutional layer, the predicted channel importance and the predicted single-layer importance are output. Based on the predicted channel importance and the predicted single-layer importance, the initial feature map output by the current convolutional layer is dynamically pruned to obtain the feature map used as the input for the next convolutional layer. The input image of the first convolutional layer is the image to be processed, and the feature map output by the last convolutional layer is input into the detection head to output the small target detection result.

[0055] It should be noted that after the image to be processed is input into the pre-trained detection model, the first convolutional layer receives the image as input and performs inference to obtain the initial feature map. This feature map is not directly used as the input to the second layer, but is first input to the importance prediction module of the first layer, which outputs the predicted channel importance and predicted single-layer importance of the first layer. Based on the predicted channel importance and predicted single-layer importance, pruning is performed to obtain the pruned feature map, which is then input to the second convolutional layer. Subsequent convolutional layers sequentially receive the pruned feature map output from the previous convolutional layer as input and perform inference, then perform importance prediction and pruning. The pruned feature map is then input to the forward propagation and dynamic pruning of the next convolutional layer, until the last convolutional layer. Its pruned feature map is then input to the model's detection head, which processes it and outputs the final small target detection result.

[0056] The process involves dynamically pruning the initial feature map output by the current convolutional layer based on the predicted channel importance and the predicted single-layer importance, including: The layer pruning rate of the current convolutional layer is determined based on the preset overall pruning rate and the predicted single-layer importance. Obtain the total number of output channels in the current layer, and calculate the number of channels to be retained in the current layer based on the layer pruning rate and the total number of output channels; The predicted channels in the current layer are sorted in descending order of importance. The output channel with the highest predicted channel importance is selected as the retention target until the number of retained channels reaches the number of channels to be retained. The remaining output channels are then selected as pruning targets for pruning.

[0057] The preset overall pruning rate remains consistent with that during the training phase. Once the model is trained, this parameter is fixed and cannot be adjusted. The method of making pruning decisions based on the predicted single-layer importance and the predicted channel importance remains consistent with that during the training phase, and will not be described in detail here.

[0058] This application introduces a small target location weighting matrix during the importance evaluation phase in the model training stage, focusing pruning decisions on small target regions and ensuring that key feature channels are not mistakenly pruned. Simultaneously, a minimally structured importance prediction module is set up to achieve adaptive dynamic pruning during the real-time inference stage with negligible additional computational overhead. This results in a small target detection model optimized for small target detection, capable of adaptive dynamic pruning to improve inference efficiency. This application provides strong support for the efficient deployment of small target detection models on resource-constrained edge devices. By adjusting the preset overall pruning rate, it can flexibly adapt to computing environments with different computing power levels, achieving an optimal balance between detection accuracy and inference efficiency.

[0059] Reference Figure 3 , Figure 3 This is a schematic diagram of an embodiment of the pruning training device for a detection model for small targets provided by the present invention. The device includes a detection loss calculation module 301, a channel importance evaluation module 302, a single-layer importance calculation module 303, an initial pruning strategy formulation module 304, and a joint training module 305.

[0060] Among them, the detection loss calculation module 301 is used to calculate the detection loss of the original detection model on the training set; The channel importance evaluation module 302 is used to calculate the feature map gradient of the output feature map of each convolutional layer in the original detection model based on the detection loss. At the same time, it calculates the position weighting matrix of the small target based on the training set, and multiplies each feature map gradient with the position weighting matrix element by element to obtain the channel importance of each output channel of each convolutional layer. The single-layer importance calculation module 303 is used to calculate the single-layer importance of each convolutional layer relative to all convolutional layers based on the channel importance. The initial pruning strategy formulation module 304 is used to allocate the layer pruning rate of each convolutional layer according to the single layer importance, and to filter the pruning targets of each convolutional layer according to the layer pruning rate and channel importance, and to determine the initial pruning strategy of each convolutional layer. The joint training module 305 is used to add corresponding importance prediction modules to each convolutional layer of the original detection model. Based on the initial pruning strategy, the original detection model and the importance prediction module are jointly trained to obtain a pre-trained detection model.

[0061] Reference Figure 4 , Figure 4 This is a schematic diagram of an embodiment of the dynamic pruning device for a small target detection model provided by the present invention. The device includes an image acquisition module 401 and a small target detection module 402.

[0062] The image acquisition module 401 is used to acquire the image to be processed. The small target detection module 402 is used to input the image to be processed into a preset detection model, perform layer-by-layer forward propagation and dynamic pruning processing, and finally output the small target detection result.

[0063] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.

[0064] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.

Claims

1. A pruning training method for a detection model targeting small targets, characterized in that, include: Calculate the detection loss of the pre-defined original detection model on the training set; Based on the detection loss, the feature map gradient of the output feature map of each convolutional layer in the original detection model is calculated. At the same time, the position weighting matrix of the small target is calculated based on the training set. The feature map gradient of each convolutional layer is multiplied element-wise with the position weighting matrix to obtain the channel importance of each output channel of each convolutional layer. Based on the channel importance, calculate the single-layer importance of each convolutional layer relative to all convolutional layers; The layer pruning rate of each convolutional layer is assigned according to the single-layer importance, and the pruning target of each convolutional layer is screened according to the layer pruning rate and the channel importance to determine the initial pruning strategy of each convolutional layer. A corresponding importance prediction module is added to each convolutional layer of the original detection model. The original detection model and the importance prediction module are jointly trained according to the initial pruning strategy to obtain a pre-trained detection model. The importance prediction module for each convolutional layer is a structure that performs point-by-point interaction and single non-linear activation only in the channel dimension. The importance prediction module is used to receive the feature map of the initial output of the current convolutional layer as input and output the predicted channel importance and predicted single-layer importance of the current convolutional layer.

2. The pruning training method for a detection model for small targets as described in claim 1, characterized in that, The step of calculating the position weighting matrix of the small target based on the training set includes: Obtain the ground truth bounding boxes and their corresponding area percentages in the images of the training set; The area ratio is nonlinearly transformed according to a preset area attenuation coefficient to generate an area weighting factor. For each pixel in the image, calculate the Euclidean distance from the pixel to the center coordinates of each real target box, and perform a nonlinear transformation on the Euclidean distance according to a preset distance attenuation coefficient to generate a distance weighting factor. The weight value of the current pixel in the position weighting matrix is ​​determined based on the area weighting factor and the distance weighting factor of each of the real target boxes. Traverse all pixels in the image, arrange the weight values ​​corresponding to each pixel according to their spatial position, and generate a position weighting matrix.

3. The pruning training method for a detection model for small targets as described in claim 1, characterized in that, The step of calculating the single-layer importance of each convolutional layer relative to all convolutional layers based on the channel importance includes: The sum of the channel importance of all output channels in each convolutional layer is calculated as the proportion of the sum of the channel importance of all output channels in all convolutional layers, and this proportion is used as the single-layer importance of each convolutional layer relative to all convolutional layers.

4. The pruning training method for a detection model for small targets as described in claim 1, characterized in that, The step of allocating layer pruning rates for each convolutional layer based on the single-layer importance, and filtering pruning targets for each convolutional layer based on the layer pruning rates and the channel importance, includes: Based on the preset overall pruning rate and the single-layer importance, the layer pruning rate of each convolutional layer is allocated; For each convolutional layer, obtain the total number of output channels of the current layer, and calculate the number of channels to be retained for the current layer based on the layer pruning rate and the total number of output channels; The channel importance of the current layer is sorted in descending order, and the output channel with the highest channel importance is selected as the retention target until the number of retained channels reaches the number of channels to be retained. The remaining output channels are then selected as pruning targets.

5. The pruning training method for a detection model for small targets as described in claim 1, characterized in that, The step of jointly training the original detection model and the importance prediction module according to the initial pruning strategy includes: The initial pruning strategy is used as the pruning decision basis in the warm-up stage, driving the original detection model to perform forward propagation and dynamic pruning, and outputting the prediction results after pruning. Calculate the second detection loss of the prediction result after pruning, and calculate the importance fitting loss of the importance prediction result output by the importance prediction module; Minimizing the second detection loss and the importance fitting loss are used as common optimization objectives to jointly train the original detection model and the importance prediction module.

6. A dynamic pruning method for a detection model targeting small targets, characterized in that, include: Obtain the image to be processed; The image to be processed is input into a preset detection model, and layer-by-layer forward propagation and dynamic pruning are performed to finally output the small target detection result. The preset detection model is trained using the pruning training method for small target detection models according to any one of claims 1 to 5.

7. The dynamic pruning method for a small target detection model as described in claim 6, characterized in that, The process involves layer-by-layer forward propagation and dynamic pruning, ultimately outputting small target detection results, including: For each convolutional layer in the preset detection model, based on the feature map output by the previous convolutional layer and the pre-trained importance prediction module corresponding to the current convolutional layer, the predicted channel importance and the predicted single-layer importance are output. Based on the predicted channel importance and the predicted single-layer importance, the initial feature map output by the current convolutional layer is dynamically pruned to obtain the feature map used as the input for the next convolutional layer. The input image of the first convolutional layer is the image to be processed, and the feature map output by the last convolutional layer is input into the detection head to output the small target detection result.

8. The dynamic pruning method for a detection model for small targets as described in claim 7, characterized in that, The step of dynamically pruning the initial feature map output by the current convolutional layer based on the predicted channel importance and the predicted single-layer importance includes: The layer pruning rate of the current convolutional layer is determined based on the preset overall pruning rate and the predicted single-layer importance. Obtain the total number of output channels in the current layer, and calculate the number of channels to be retained in the current layer based on the layer pruning rate and the total number of output channels; The predicted channels in the current layer are sorted in descending order of importance. The output channel with the highest predicted channel importance is selected as the retention target until the number of retained channels reaches the number of channels to be retained. The remaining output channels are then selected as pruning targets for pruning.

9. A pruning training system for a detection model targeting small targets, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the computer program is executed by the processor, it implements the steps of the pruning training method for the detection model for small targets as described in any one of claims 1-5.

10. A dynamic pruning system for a detection model targeting small targets, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the computer program is executed by the processor, it implements the steps of the dynamic pruning method for the detection model for small targets as described in any one of claims 6-8.