Quantized perception training method, device, equipment and medium for target detection model
By introducing the task harmony constraint loss function into the target detection model, the problem of detector performance degradation after quantization is solved, the detection performance and model harmony are improved, and the appearance of discordant prediction boxes is avoided.
Patent Information
- Application Number
- CN202411115733.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-08-14
AI Technical Summary
In the existing technology, after the quantified perception training of the target detection model, the problem of task disharmony is intensified, causing the detection performance of the quantized detector to decline after non-maximum suppression.
Construct a target loss function, including a classification loss function, a regression loss function and a task harmony constraint loss function. Through quantified perception training, the relationship between the classification task and the regression task becomes harmonious, avoiding the appearance of disharmonious prediction frames and improving detection performance.
Through the introduction of the task harmony constraint loss function, the target detection model is optimized, so that the detection performance of the quantized detector after non-maximum suppression is improved, and a more harmonious and higher-quality output distribution is generated.
Smart Images

Figure CN118628876B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer vision perception and model compression technology, and in particular relates to a quantitative perception training method, device, equipment and medium for a target detection model. Background Art
[0002] Object detection is a key task in the field of computer vision, and its main goal is to identify and locate objects of a specific category in an image or video. Unlike image classification tasks, object detection requires the system to not only determine whether the target object exists in the image, but also accurately calibrate the location of the target, which is usually achieved by drawing a bounding box in the image, which defines the location and size of the target object. The application of object detection is very wide, covering many fields, such as autonomous vehicle perception, security monitoring, medical image analysis, unmanned retail, etc. Object detection plays an important role in the development of the field of artificial intelligence, and the development of deep learning technology, especially convolutional neural network (CNN), provides strong support for the performance improvement of object detection algorithms. Continuously improved algorithms and larger-scale annotated data have enabled object detection systems to make significant progress in complex scenarios and diverse tasks.
[0003] Model quantization is a technique for optimizing deep learning models, aiming to reduce the model's storage requirements and computational overhead while maintaining the model's performance as much as possible. Model quantization achieves this goal by reducing the number of bits of model parameters and intermediate outputs (usually from floating-point numbers to lower-order integers or fixed-point numbers). Quantized deep learning models can be more efficiently deployed in embedded devices, mobile devices, or other resource-constrained environments. Model quantization techniques can be divided into two categories based on whether training is required during the quantization process: (1) Post-training quantization (PTQ). As the name suggests, it is quantization performed after model training. Generally, calibration data is required. These data are mainly used to obtain quantization parameters, so they do not need to be labeled. Generally, a few hundred images are sufficient. When the calibration data set is not available, data-free quantization techniques can be used to reconstruct and optimize the quantization parameters. (2) Quantization aware training (QAT): This can be divided into training from scratch or fine-tuning training. When the bit is 4 bits or less, quantization will introduce a lot of noise, resulting in a lot of information loss. Therefore, many methods require the intervention of perceptual training.
[0004] In modern object detectors, the Task Inharmony (TI) problem has always been a focus of attention. A multi-task detection framework is usually used to generate the position coordinates and corresponding labels of objects, which includes two parallel detection heads, one classification branch and one regression branch. This parallel design may lead to inconsistent distributions of classification scores and regression scores (Intersection over Union, IoU). When the predicted box output by the detector has a high classification score but poor positioning, or has a low classification score but accurate positioning, the detection performance of the detector will deteriorate after non-maximum suppression (NMS). After the detector is trained with quantization awareness, the TI problem will be further exacerbated, which is considered to be one of the main reasons for the performance degradation of the detector after quantization. Taking the Learned Step Size Quantization (LSQ) algorithm as an example, the quantized detector generates a typical example of an inconsistent bounding box, as shown in the attached figure. Figure 1 As shown in (a), there are two discordant candidate boxes (a yellow bounding box (i.e., the box corresponding to the classification score of 0.39) and a blue bounding box (i.e., the box corresponding to the classification score of 0.80)), and a true box marked in red. After the NMS process, the yellow box has a higher IoU (intersection over union) but a lower classification score, which will be suppressed by the less accurate blue box. In other words, the suboptimal results are retained while the best results are ignored. Summary of the invention
[0005] The purpose of the present invention is to provide a quantization-perceptual training method, device, equipment and storage medium for a target detection model, aiming to solve the problem that the prior art aggravates the task disharmony problem after quantization-perceptual training of the target detection model, resulting in the emergence of a large number of disharmony prediction frames, causing the detection performance of the quantized detector to deteriorate after non-maximum suppression.
[0006] In one aspect, the present invention provides a quantization-aware training method for a target detection model, the method comprising the following steps:
[0007] Constructing a target loss function of the target detection model to be quantified, wherein the target loss function includes a classification loss function, a regression loss function, and a task harmony constraint loss function;
[0008] Based on the target loss function, the target detection model is trained with quantization perception until the target loss function converges.
[0009] Preferably, the step of performing quantization perception training on the target detection model based on the target loss function comprises:
[0010] In the forward propagation process, based on a preset quantization strategy and a training data set, the weights and activation values of the target detection model are simulated and quantized;
[0011] Calculate the task relevance index using a preset task relevance index formula according to the quantized classification score and regression score of the target detection model on the training data set;
[0012] Based on the task relevance indicator, using the task harmony constraint loss function to calculate a constraint loss value;
[0013] Based on the constraint loss value, using the target loss function to calculate the quantized target loss value of the target detection model;
[0014] Through back propagation, the gradient of the target loss value to the learnable parameters in the target detection model is calculated, and the learnable parameters are updated according to the gradient.
[0015] Preferably, the task harmony constraint loss function includes a task-related loss function and a harmonious intersection-over-union loss function. Based on the task relevance index, the step of using the task harmony constraint loss function to calculate the constraint loss value includes:
[0016] Calculating a task-related loss value using the task-related loss function according to the task-related relevance indicator;
[0017] Calculating a harmonic intersection-over-union loss value using the harmonic intersection-over-union loss function according to the quantized regression score of the target detection model on the training data set;
[0018] The constraint loss value is calculated using the task harmony constraint loss function according to the task-related loss value and the harmonious intersection-over-union loss value.
[0019] Preferably, the task relevance indicator formula is: ,in, is the training data set Task relevance indicator for positive samples, represents the first output of the classification branch of the target detection model The classification scores of positive samples, is the first The regression score of positive samples is and There are two dynamic factors.
[0020] Preferably, the task harmony constraint loss function is ,in, is the number of positive samples in the training data set, Pos is the set of positive samples in the training data set, is the task-related loss function, is the harmonious intersection-over-union loss function, is a trade-off parameter.
[0021] Preferably, the task-related loss function is , the harmonious intersection-over-union loss function is ,in, is the reweighting parameter, is a hyperparameter.
[0022] Preferably, the objective loss function is ,in, , represents the number of negative samples in the training data set, Neg is the set of negative samples in the training data set, is the classification loss function, is the regression loss function.
[0023] On the other hand, the present invention provides a quantization-aware training device for a target detection model, the device comprising:
[0024] A loss function construction unit, used to construct a target loss function of the target detection model to be quantized, wherein the target loss function includes a classification loss function, a regression loss function, and a task harmony constraint loss function;
[0025] The detection model quantization unit is used to perform quantization perception training on the target detection model based on the target loss function until the target loss function converges.
[0026] On the other hand, the present invention also provides a computing device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps described in the above-mentioned quantitative perception training method for the target detection model are implemented.
[0027] On the other hand, the present invention also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, it implements the steps described in the above-mentioned quantitative perception training method of the target detection model.
[0028] The present invention constructs a target loss function of a target detection model to be quantized, wherein the target loss function includes a classification loss function, a regression loss function and a task harmony constraint loss function. Based on the target loss function, quantization perception training is performed on the target detection model until the target loss function converges, thereby making the relationship between the classification task and the regression task more and more harmonious, avoiding the appearance of inharmonious prediction frames, and improving the detection performance of the quantized target detection model after NMS. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is a schematic diagram of the effect of the detector performance after the detector is trained with the baseline method for quantization perception;
[0030] Figure 2 It is a flow chart for implementing the quantitative perception training method of the target detection model provided in the first embodiment of the present invention;
[0031] Figure 3 is a flow chart for implementing a quantitative perception training method for a target detection model provided in Embodiment 2 of the present invention;
[0032] Figure 4 It is a visualization diagram of the effects of task-related indicators under different dynamic factor settings in the quantitative perception training method of the target detection model provided in the second embodiment of the present invention;
[0033] Figure 5 This is a diagram showing the average improvement effect of positive samples in different IoU intervals in the quantization-aware training method for the target detection model provided in the second embodiment of the present invention compared with the baseline method;
[0034] Figure 6 is a schematic diagram of the effect of the detector performance quantized by the quantized perception training method of the target detection model provided in the second embodiment of the present invention;
[0035] Figure 7 It is a schematic diagram of the structure of a quantized perception training device for a target detection model provided in Embodiment 3 of the present invention;
[0036] Figure 8 It is a schematic diagram of the optimized structure of the quantitative perception training device of the target detection model provided in the third embodiment of the present invention;
[0037] Fig. 9 It is a schematic diagram of the structure of a computing device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0039] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments:
[0040] Embodiment 1:
[0041] Figure 2 The implementation process of the quantitative perception training method of the target detection model provided in the first embodiment of the present invention is shown. For the convenience of explanation, only the part related to the embodiment of the present invention is shown, which is described in detail as follows:
[0042] In step S201, a target loss function of the target detection model to be quantified is constructed, where the target loss function includes a classification loss function, a regression loss function, and a task harmony constraint loss function.
[0043] The embodiments of the present invention are applicable to computing devices, such as personal computers, servers, etc. In the embodiments of the present invention, the previous QAT methods mentioned in the background art do not take into account the task disharmony problem in target detection, and the inventors of the present invention first discovered that when the target detection model (referred to as: detector) undergoes QAT, the task disharmony problem will be further aggravated due to the reduction of bit width, which is also one of the main problems that lead to the performance degradation of the target detection model after quantization, such as Figure 1 (b) shows the statistical results of true positive (TP) samples after NMS at different bits, and the red elliptical dotted line represents the ideal sample distribution. From the statistical results, it can be seen that as the bit width decreases, the number of high-quality prediction samples (i.e., both the classification score and the IoU score are at a high level) decreases significantly, and the statistical distribution deviates from the ideal elliptical line. This indicates that as the bit width constraint decreases, the relationship between the two tasks becomes increasingly disharmonious. In order to promote a more harmonious QAT process, a target loss function including a task harmony constraint loss function is constructed for the target detection model to be quantized, so as to constrain the QAT of the target detection model through the task harmony constraint loss function, so that the target detection model in QAT is more focused on optimizing samples with lower task harmony quality, and balances the optimization of the regression branch of the target detection model at different intersection over Union (IoU) levels, thereby effectively enhancing the task harmony of the detector (especially the low-bit detector) and improving its overall performance. The target detection model to be quantized is a pre-trained floating-point model for target detection, and the constructed target loss function is called the loss function of Harmonious Quantization for Object Detection (HQOD), which is expressed as .
[0044] In step S202, based on the target loss function, the target detection model is trained with quantization perception until the target loss function converges.
[0045] In the embodiment of the present invention, based on the target loss function , perform quantization-aware training on the target detection model until the target loss function is minimized. Specifically, when performing QAT on the target detection model, during the forward propagation process, the weights and activation values of the target detection model are quantized and dequantized to simulate the effect of quantization in actual deployment, that is, the weights and activation values are first quantized to low-bit-width integer representations, and then dequantized back to floating-point numbers for subsequent calculations. During the back propagation process, the target loss function is calculated based on the quantized model performance obtained by the forward propagation. The target loss value is obtained, and the learnable parameters in the target detection model are updated in the floating-point space according to the target loss value. The process of forward propagation, back propagation and parameter update is repeated to gradually optimize the performance of the model under quantization conditions until the target loss function converges.
[0046] In a feasible embodiment, the specific implementation method of performing quantized perception training on the target detection model based on the target loss function is detailed in the description of the following method embodiment 2, which will not be repeated here.
[0047] In an embodiment of the present invention, a target loss function of a target detection model to be quantized is constructed, and the target loss function includes a classification loss function, a regression loss function, and a task harmony constraint loss function. Based on the target loss function, quantization perception training is performed on the target detection model until the target loss function converges, so that the relationship between the classification task and the regression task becomes more and more harmonious, avoiding the emergence of inharmonious prediction boxes, and improving the detection performance of the quantized target detection model after NMS.
[0048] Embodiment 2:
[0049] Figure 3 The implementation process of the quantitative perception training method of the target detection model provided by the second embodiment of the present invention is shown. For the convenience of explanation, only the part related to the embodiment of the present invention is shown, which is described in detail as follows:
[0050] The quantization perception training of the target detection model in step S202 of the first embodiment is implemented by the following steps:
[0051] In step S301, during the forward propagation process, the weights and activation values of the target detection model are simulated and quantized based on a preset quantization strategy and a training data set.
[0052] In an embodiment of the present invention, a quantization strategy includes but is not limited to determining a quantization granularity (such as tensor-by-tensor quantization, layer-by-layer quantization, channel-by-channel quantization, etc.), a quantization bit width, and a quantization type (such as symmetric quantization, asymmetric quantization). Here, a preset training data set is input into a target detection model, and a weight tensor and a feature map (i.e., activation) tensor of the target detection model are uniformly and symmetrically quantized tensor-by-tensor according to the set quantization bit width, so that the weight tensor and feature map tensor represented by floating point numbers are converted into integer representations of the quantization bit width. Afterwards, the weight tensor and feature map tensor represented by integers are dequantized back to floating point numbers, so that the effect of quantization is simulated while retaining the original scale of the input tensor. The training data set includes positive samples and negative samples. Positive samples refer to image regions or bounding boxes containing target objects (such as people, cars, animals, etc.) for training models to learn how to identify and locate target objects in images. Negative samples refer to image regions or background regions that do not contain target objects for training models to learn how to distinguish target objects from backgrounds to avoid misjudging backgrounds as target objects.
[0053] In one possible embodiment, a quantized simulation function is used. The weight tensor and feature map tensor represented by floating point numbers are converted into integer representations of quantized bit width. The dequantization process is expressed as ,in, is the weight tensor or feature map tensor represented by quantized integers, is the dequantized weight tensor or feature map tensor, is the quantization step size (also called scaling factor), As a rounding function, it adjusts floating point values to the nearest integer. Indicates that integers are restricted to the quantized range [ For signed data, , , for unsigned data, , , is the quantization bit width.
[0054] In step S302, the task relevance index is calculated using a preset task relevance index formula according to the classification score and regression score of the quantized target detection model on the training data set.
[0055] In an embodiment of the present invention, after the training data set is input into the target detection model, after forward operation, the output layer of the target detection model will output the prediction result, and the classification accuracy, precision, recall rate and F1 score and other evaluation indicators are calculated according to the predicted classification label in the prediction result and the corresponding real label marked in the training data set. The classification score of the quantized target detection model on the training data set is obtained according to these evaluation indicators, and the IoU value is calculated according to the predicted box in the prediction result and the corresponding real box marked in the training data set. The regression score of the quantized target detection model on the training data set is obtained according to all IoU values. After that, the task relevance index is calculated according to the classification score and the regression score using the preset task relevance index formula. The task relevance index is used to more accurately illustrate the harmony quality of the sample.
[0056] In a feasible embodiment, the task relevance indicator formula is: ,in, represents the output of the classification branch of the target detection model. The classification scores of positive samples, is predicted by the regression branch of the object detection model. The regression score of positive samples is and are two dynamic factors, The training data set Task relevance indicator for positive samples. It should be noted that the range of classification scores and regression scores is , so the range of the task relevance index is also ,At the same time, the task relevance index has two basic characteristics: First, the index considers the score quality of the two branches, such as when When and are all equal to 1, it means that both the classification and regression branches generate high-quality samples. , it means that at least one branch has a score of 0, indicating that the model outputs low-quality samples; secondly, this indicator also describes the consistency between the two branches. For example, when the gap between the scores of the two branches is smaller, The higher the value, the greater the difference between the output results of the two branches. The lower the value.
[0057] In another feasible embodiment, the dynamic factor and They are defined as , , through the dynamic factors to obtain the three-dimensional plane diagram of the task relevance index, as shown in the attached Figure 3 As shown, from Figure 3 It can be seen that when and When both are low, The dynamic factor does not show a lower value; on the contrary, Trending to increase.
[0058] In step S303, based on the task relevance index, the constraint loss value is calculated using the task harmony constraint loss function.
[0059] In an embodiment of the present invention, the task harmony constraint loss function includes a task-correlated (TCorr) loss function (TCorr loss for short) and a harmonious intersection over union (HIoU) loss function (HIoU loss for short). TCorr loss is used to dynamically optimize samples with low harmony quality. It increases the weights of samples with large gaps between task scores, while suppressing the weights of samples with small gaps between tasks, so that the model focuses more on optimizing samples with low harmony quality. Therefore, in the low-bit QAT process, the detector is regulated to be optimized in the direction of harmony; HIoU loss is used to dynamically coordinate the contribution of samples at each IoU level, aiming to suppress the generation of low IoU samples and promote the generation of high IoU samples.
[0060] In a feasible embodiment, the calculation of the constraint loss value is achieved through the following steps:
[0061] (1) According to the task relevance indicator, the task relevance loss value is calculated using the task relevance loss function;
[0062] In the embodiment of the present invention, we assume that when the scores of both tasks of a sample are low, there is no need to over-discuss the coordination problem of the sample. will reach a relatively high level. In this way, only two types of samples will receive special attention and be assigned a lower , one type includes samples with high scores on one of the tasks but significant score gaps between the tasks, and the other type includes samples with small score gaps between the tasks but scores of both tasks are around 0.5. Based on this, in order to focus on and optimize the samples with lower A task-related loss function is constructed based on the task-relevance indicator to prevent a large number of positive samples with low harmony quality from dominating the harmony optimization process, and the task-related loss value is calculated using the task-related loss function.
[0063] In one possible embodiment, the task-dependent loss function is ,in, is the reweighting parameter, through the formula The calculation is performed without gradient back propagation. The greater the difference in scores between tasks, the greater the weight of the loss function term.
[0064] (2) Based on the regression score of the quantized target detection model on the training dataset, the harmonic intersection-over-union loss function is used to calculate the harmonic intersection-over-union loss value;
[0065] In the embodiment of the present invention, according to the regression score of the quantized target detection model on the training data set, , use HIoU loss to calculate the harmonious intersection-over-union loss value
[0066] In a possible embodiment, as shown in the attached Figure 4 As shown in Figure 2, after using TCorr loss, we observed that the proportion of positive samples decreased at lower IoU levels, which is consistent with our expected results. However, at higher IoU levels, especially in the IoU range of 0.9 to 1.0, the proportion of positive samples decreased slightly, which is contrary to our expectations. We believe that this phenomenon is due to the fact that during the optimization process of the regression branch, samples with lower IoU levels dominate, thereby dominating the direction of gradient updates. In general, detectors tend to generate a large number of positive bounding boxes for the optimization of localization loss. However, a considerable number of these samples present lower IoU levels, thus having a significant impact on the optimization direction of the localization loss. In order to alleviate this biased optimization, HIoU loss is introduced and defined as ,in, is a hyperparameter, which is set to 0.8, and the adaptive weight It is used to balance the localization loss at each IoU level. Therefore, HIoU loss enhances the weighting of localization loss for samples with high IoU through a dynamic scaling factor, while suppressing the weight of low IoU samples. After testing, it was found that by additionally utilizing HIoU loss, the model generates more samples with higher IoU quality while reducing the output of low IoU quality samples, as shown in the following figure. Figure 4 shown.
[0067] (3) Based on the task-related loss value and the harmonious intersection-over-union loss value, the task harmony constraint loss function is used to calculate the constraint loss value.
[0068] In the embodiment of the present invention, the task harmony constraint loss function is used according to the task-related loss value and the harmony intersection loss value. Calculate the constraint loss value, where is the number of positive samples in the training data set, Pos is the set of positive samples in the training data set, As a trade-off parameter, it is set to 1.5.
[0069] In step S304, based on the constraint loss value, a target loss function is used to calculate a target loss value of the quantized target detection model.
[0070] In the embodiment of the present invention, based on the constraint loss value, the objective loss function is used Calculate the target loss value of the quantized target detection model, where , which is the total loss of a standard object detector, Represents the number of negative samples in the training data set, Neg is the set of negative samples in the training data set, is the classification loss function, is the regression loss function.
[0071] In step S305, the gradient of the target loss value with respect to the learnable parameters in the target detection model is calculated through back propagation, and the learnable parameters are updated according to the gradient.
[0072] In the embodiment of the present invention, in the QAT process, the quantization range of weights and activations is learnable during the training process, and the learnable parameters in the target detection model can be back-propagated and updated with gradients. Specifically, in the back-propagation process, a straight through estimator (STE) is usually introduced to approximate the gradient of the integer function to 1, so Relative to The local gradient can be defined as: , based on which the target loss value is calculated The gradient of the learnable parameters in the target detection model (i.e. ), and the learnable parameters are updated according to the gradient. In the QAT process, the detector optimizes all these losses in the objective loss function and is trained in an end-to-end manner.
[0073] like Figure 6 The experimental results shown in the figure show that using The framework enables the quantized detector to retain better detection results after NMS, and helps to generate a more harmonious and higher quality output distribution under bit constraints, thereby improving the detection performance of the quantized model. The proposed framework can be easily integrated into different QAT algorithms and detectors.
[0074] In an embodiment of the present invention, during the forward propagation process, the weights and activation values of the target detection model are simulated and quantized based on a preset quantization strategy and a training data set. According to the classification score and regression score of the quantized target detection model on the training data set, a preset task relevance indicator formula is used to calculate the task relevance indicator. Based on the task relevance indicator, a task harmony constraint loss function is used to calculate the constraint loss value. Based on the constraint loss value, a target loss function is used to calculate the target loss value of the quantized target detection model. During the back propagation process, the gradient of the target loss value to the learnable parameters in the target detection model is calculated, and the learnable parameters are updated according to the gradient, thereby improving the detection performance of the quantized model.
[0075] Embodiment three:
[0076] Figure 7 The structure of the quantized perceptual training device for the target detection model provided by the third embodiment of the present invention is shown. For the convenience of explanation, only the part related to the embodiment of the present invention is shown, including:
[0077] A loss function construction unit 71 is used to construct a target loss function of the target detection model to be quantized, wherein the target loss function includes a classification loss function, a regression loss function, and a task harmony constraint loss function;
[0078] The detection model quantization unit 72 is used to perform quantized perception training on the target detection model based on the target loss function until the target loss function converges.
[0079] Preferably, if Figure 8 As shown, the detection model quantization unit 72 includes:
[0080] The model parameter quantization unit 721 is used to simulate and quantize the weights and activation values of the target detection model based on a preset quantization strategy and a training data set during the forward propagation process;
[0081] A task index calculation unit 722 is used to calculate the task relevance index using a preset task relevance index formula according to the classification score and regression score of the quantized target detection model on the training data set;
[0082] A constraint loss calculation unit 723, used to calculate a constraint loss value based on a task relevance index using a task harmony constraint loss function;
[0083] A target loss calculation unit 724 is used to calculate a target loss value of the quantized target detection model using a target loss function based on the constraint loss value;
[0084] The model parameter updating unit 725 is used to calculate the gradient of the target loss value to the learnable parameters in the target detection model through back propagation, and update the learnable parameters according to the gradient.
[0085] In the embodiment of the present invention, each unit of the quantitative perception training device of the target detection model can be implemented by a corresponding hardware or software unit, and each unit can be an independent software or hardware unit, or can be integrated into a software or hardware unit, which is not intended to limit the present invention. Specifically, the implementation of each unit can refer to the description of the aforementioned method embodiment, which will not be repeated here.
[0086] Embodiment 4:
[0087] Fig. 9 The structure of a computing device provided by a fourth embodiment of the present invention is shown. For ease of description, only the parts related to the embodiment of the present invention are shown.
[0088] The computing device 9 of the embodiment of the present invention includes a processor 90, a memory 91, and a computer program 92 stored in the memory 91 and executable on the processor 90. When the processor 90 executes the computer program 92, the steps of the embodiment of the quantitative perception training method of the target detection model are implemented, such as Figure 2 Alternatively, when the processor 90 executes the computer program 92, the functions of each unit in the above-mentioned device embodiments are realized, for example Figure 7 The functions of the loss function construction unit 71 to the detection model quantization unit 72 are shown.
[0089] In an embodiment of the present invention, a target loss function of a target detection model to be quantized is constructed, and the target loss function includes a classification loss function, a regression loss function, and a task harmony constraint loss function. Based on the target loss function, quantization perception training is performed on the target detection model until the target loss function converges, so that the relationship between the classification task and the regression task becomes more and more harmonious, avoiding the emergence of inharmonious prediction boxes, and improving the detection performance of the quantized target detection model after NMS.
[0090] The computing device of the embodiment of the present invention may be a personal computer or a server. The steps implemented when the processor 90 in the computing device 9 executes the computer program 92 to implement the quantitative perception training method of the target detection model can refer to the description of the aforementioned method embodiment, which will not be repeated here.
[0091] Embodiment five:
[0092] In an embodiment of the present invention, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the steps in the embodiment of the quantization perception training method of the target detection model are implemented, for example, Figure 2 Alternatively, when the computer program is executed by a processor, the functions of each unit in the above-mentioned device embodiments are realized, for example Figure 7 The functions of the loss function construction unit 71 to the detection model quantization unit 72 are shown.
[0093] In an embodiment of the present invention, a target loss function of a target detection model to be quantized is constructed, and the target loss function includes a classification loss function, a regression loss function, and a task harmony constraint loss function. Based on the target loss function, quantization perception training is performed on the target detection model until the target loss function converges, so that the relationship between the classification task and the regression task becomes more and more harmonious, avoiding the emergence of inharmonious prediction boxes, and improving the detection performance of the quantized target detection model after NMS.
[0094] The computer-readable storage medium of the embodiment of the present invention may include any entity or device or recording medium capable of carrying computer program code, for example, ROM / RAM, magnetic disk, optical disk, flash memory and other memories.
[0095] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A quantitative perception training method for target detection models, It is characterized in that The method comprises the following steps: Construct a target loss function of the target detection model to be quantified, wherein the target loss function includes a classification loss function, a regression loss function, and a task harmony constraint loss function, wherein the target detection model is used to identify and locate objects of a specific category in an image or video, and the task harmony constraint loss function includes a task-related loss function and a harmony intersection-over-union loss function, and the task harmony constraint loss function is , the task-related loss function is , the harmonious intersection-over-union loss function is , is the number of positive samples in the training data set, Pos is the set of positive samples in the training data set, To balance the parameters, is the reweighting parameter, is a hyperparameter, is the training data set Task relevance indicator for positive samples, is the first The regression score of positive samples; Based on the target loss function, the target detection model is trained with quantization perception until the target loss function converges.
2. The method according to claim 1, It is characterized in that The step of performing quantization perception training on the target detection model based on the target loss function includes: In the forward propagation process, based on a preset quantization strategy and the training data set, the weights and activation values of the target detection model are simulated and quantized; Calculate the task relevance index using a preset task relevance index formula according to the quantized classification score and regression score of the target detection model on the training data set; Based on the task relevance indicator, using the task harmony constraint loss function to calculate a constraint loss value; Based on the constraint loss value, using the target loss function to calculate the quantized target loss value of the target detection model; Through back propagation, the gradient of the target loss value to the learnable parameters in the target detection model is calculated, and the learnable parameters are updated according to the gradient.
3. The method according to claim 2, It is characterized in that The step of calculating the constraint loss value using the task harmony constraint loss function based on the task relevance index comprises: Calculating a task-related loss value using the task-related loss function according to the task-related relevance indicator; Calculating a harmonic intersection-over-union loss value using the harmonic intersection-over-union loss function according to the quantized regression score of the target detection model on the training data set; The constraint loss value is calculated using the task harmony constraint loss function according to the task-related loss value and the harmonious intersection-over-union loss value.
4. The method according to claim 3, It is characterized in that The task relevance indicator formula is: ,in, represents the first output of the classification branch of the target detection model The classification scores of positive samples, and There are two dynamic factors.
5. The method according to claim 1, It is characterized in that The objective loss function is ,in, , represents the number of negative samples in the training data set, Neg is the set of negative samples in the training data set, is the classification loss function, is the regression loss function, is the first The classification loss value of positive samples is is the first The regression loss value of positive samples is, is the negative sample set The classification loss value of negative samples.
6. A quantitative perception training device for target detection models, It is characterized in that The device comprises: A loss function construction unit is used to construct a target loss function of a target detection model to be quantified, wherein the target loss function includes a classification loss function, a regression loss function, and a task harmony constraint loss function, wherein the target detection model is used to identify and locate objects of a specific category in an image or video, and the task harmony constraint loss function includes a task-related loss function and a harmony intersection-over-union loss function, and the task harmony constraint loss function is , the task-related loss function is , the harmonious intersection-over-union loss function is , is the number of positive samples in the training data set, Pos is the set of positive samples in the training data set, To balance the parameters, is the reweighting parameter, is a hyperparameter, is the training data set Task relevance indicator for positive samples, is the first The regression score of positive samples; The detection model quantization unit is used to perform quantization perception training on the target detection model based on the target loss function until the target loss function converges.
7. A computing device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
8. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
