Quantitative perception training method and device of target detection model, equipment and medium
By constructing a target loss function, including a classification loss function, a regression loss function and a task harmony constraint loss function, the target detection model is trained for quantified perception, which solves the task disharmony problem of the quantized detector and improves the detection performance.
Patent Information
- Application Number
- CN202411115733.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2044-08-14
AI Technical Summary
After the existing technology performs quantized perception training on 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, and the appearance of discordant prediction boxes is avoided.
The detection performance of the quantized target detection model after non-maximum suppression is improved, ensuring a more harmonious relationship between classification tasks and regression tasks, reducing discordant prediction frames, and improving detection performance.
Smart Images

Figure CN118628876A
Abstract
Description
Technical Field
[0001] The present invention belongs to the fields 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 computer vision, aiming to identify and locate objects of a specific class within an image or video. Unlike image classification, object detection requires the system to not only determine the presence of an object in an image but also accurately locate the object. This is typically achieved by drawing a bounding box within the image, which defines the object's position and size. Object detection has a wide range of applications, encompassing fields such as autonomous vehicle perception, security surveillance, medical image analysis, and unmanned retail. Object detection plays a crucial role in the development of artificial intelligence, and deep learning techniques, particularly convolutional neural networks (CNNs), have significantly boosted the performance of object detection algorithms. Continuously improved algorithms and larger amounts of annotated data have enabled significant progress in object detection systems across 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 in 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 on 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, is quantization performed after model training. Calibration data is generally required. These data are mainly used to statistically obtain quantization parameters, so they do not need to be labeled. Generally, a hundred or so images are sufficient. When the calibration dataset is unavailable, 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 size is 4 bits or less, quantization will introduce a lot of noise, resulting in a large amount 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: a classification branch and a regression branch. This parallel design may lead to inconsistent distributions of classification scores and regression scores (Intersection over Union, IoU). When the prediction 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 undergoes quantization-aware training, 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 quantitative perception training method, device, equipment and storage medium for a target detection model, aiming to solve the problem that the existing technology will aggravate the task disharmony after quantitative perception training of the target detection model, resulting in the emergence of a large number of discordant 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 an object detection model, the method comprising the following steps: Constructing 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; Based on the target loss function, the target detection model is trained with quantization perception until the target loss function converges.
[0007] Preferably, the step of performing quantized perceptual training on the target detection model based on the target loss function includes: 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 dataset; Calculating a task relevance index using a preset task relevance index formula based on the quantified classification score and regression score of the target detection model on the training data set; Based on the task relevance indicator, calculating a constraint loss value using the task harmony constraint loss function; 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 with respect to the learnable parameters in the target detection model is calculated, and the learnable parameters are updated according to the gradient.
[0008] Preferably, the task harmony constraint loss function includes a task-related loss function and a harmonious intersection-over-union loss function. The step of calculating the constraint loss value using the task harmony constraint loss function based on the task relevance index includes: Calculating a task-related loss value using the task-related loss function according to the task-related index; 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 harmony intersection-over-union loss value.
[0009] Preferably, the task relevance indicator formula is: ,in, is the first The task relevance index of 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, and There are two dynamic factors.
[0010] 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.
[0011] Preferably, the task-related loss function is , the harmonious intersection-over-union loss function is ,in, is the reweighting parameter, is a hyperparameter.
[0012] 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.
[0013] In another aspect, the present invention provides a quantitative perceptual training device for a target detection model, the device comprising: A loss function construction unit 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; A detection model quantization unit is used to perform quantized perceptual training on the target detection model based on the target loss function until the target loss function converges.
[0014] 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 runnable on the processor, wherein when the processor executes the computer program, the steps described in the quantitative perception training method of the above-mentioned target detection model are implemented.
[0015] 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, implements the steps described in the quantitative perception training method of the above-mentioned target detection model.
[0016] The present invention constructs a target loss function of the target detection model to be quantized, which includes a classification loss function, a regression loss function and a task harmony constraint loss function. Based on the target loss function, the target detection model is trained with quantization perception until the target loss function converges, thereby making the relationship between the classification task and the regression task more and more harmonious, avoiding the emergence of disharmonious prediction frames, and improving the detection performance of the quantized target detection model after NMS. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 This is a diagram showing the performance of the detector after the baseline method is used to perform quantitative perception training on the detector; Figure 2 This is a flowchart of the implementation of the quantitative perception training method for the target detection model provided in Example 1 of the present invention; Figure 3 This is a flowchart of the implementation of the quantitative perception training method for the target detection model provided in the second embodiment of the present invention; Figure 4 This is a visualization diagram of the effects of task-related indicators under different dynamic factor settings in the quantitative perception training method for the target detection model provided by the second embodiment of the present invention; Figure 5 This is a graph showing the average improvement of positive samples in different IoU intervals in the quantized perceptual training method for the target detection model provided in the second embodiment of the present invention compared with the baseline method; Figure 6 2. This is a schematic diagram showing the effect of detector performance quantized by the quantized perceptual training method for the target detection model provided in the second embodiment of the present invention; Figure 7 Schematic diagram of the structure of the quantitative perception training device for the target detection model provided in the third embodiment of the present invention; Figure 8 Schematic diagram of the optimized structure of the quantitative perception training device for the target detection model provided in the third embodiment of the present invention; Figure 9 It is a structural diagram of the computing device provided in Example 4 of the present invention. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to 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.
[0019] The following describes the specific implementation of the present invention in detail with reference to specific embodiments: Example 1: Figure 2 The implementation process of the quantitative perception training method for the target detection model provided in the first embodiment of the present invention is shown. For ease of explanation, only the part related to the embodiment of the present invention is shown, which is detailed as follows: In step S201 , a target loss function of the target detection model to be quantized is constructed, where the target loss function includes a classification loss function, a regression loss function, and a task harmony constraint loss function.
[0020] 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 have discovered for the first time that when the target detection model (abbreviated as: detector) undergoes QAT, the task disharmony problem will be further exacerbated by 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 can focus more on optimizing samples with lower task harmony quality in QAT, and balance 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. Among them, the target detection model to be quantized is a pre-trained floating-point model for target detection. The constructed target loss function is called the loss function of Harmonious Quantization for Object Detection (HQOD), which is expressed as .
[0021] In step S202, based on the target loss function, the target detection model is trained with quantization perception until the target loss function converges.
[0022] 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 backpropagation process, the target loss function is calculated based on the quantized model performance obtained by 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, backpropagation and parameter update is repeated to gradually optimize the performance of the model under quantization conditions until the target loss function converges.
[0023] In a feasible embodiment, the specific implementation method of performing quantized perceptual training on the target detection model based on the target loss function is described in the following method embodiment 2 and will not be repeated here.
[0024] 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, the target detection model is subjected to quantization perception training until the target loss function converges, thereby making the relationship between the classification task and the regression task more and more harmonious, avoiding the emergence of disharmonious prediction boxes, and improving the detection performance of the quantized target detection model after NMS.
[0025] Example 2: Figure 3 The implementation process of the quantitative perception training method for the target detection model provided by the second embodiment of the present invention is shown. For ease of explanation, only the part related to the embodiment of the present invention is shown, which is detailed as follows: The quantitative perception training of the target detection model in step S202 of the first embodiment is implemented by the following steps: 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 dataset.
[0026] In an embodiment of the present invention, a quantization strategy includes, but is not limited to, determining a quantization granularity (e.g., tensor-by-tensor quantization, layer-by-layer quantization, channel-by-channel quantization, etc.), a quantization bit width, and a quantization type (e.g., symmetric quantization or asymmetric quantization). A preset training dataset is input into a target detection model. Based on the set quantization bit width, uniform symmetric quantization is performed on the weight tensors and feature map (i.e., activation) tensors of the target detection model, tensor by tensor. This converts the weight tensors and feature map tensors represented by floating-point numbers into integer representations of the quantization bit width. Subsequently, the integer-represented weight tensors and feature map tensors are dequantized back to floating-point numbers to simulate the quantization effect while preserving the original scale of the input tensors. The training dataset includes positive samples and negative samples. Positive samples refer to image regions or bounding boxes containing target objects (e.g., people, vehicles, animals, etc.) for training the model 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 the model to learn how to distinguish between target objects and background, thereby avoiding misclassifying background as target objects.
[0027] In one possible embodiment, a quantized analog function is used. The weight tensor and feature map tensor represented by floating point numbers are converted into integer representations of quantized bit widths. 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 to adjust 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.
[0028] In step S302, a task relevance index is calculated using a preset task relevance index formula according to the classification score and regression score of the quantized object detection model on the training data set.
[0029] 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. According to the predicted classification label in the prediction result and the corresponding real label marked in the training data set, the classification accuracy, precision, recall rate and F1 score and other evaluation indicators are calculated. According to these evaluation indicators, the classification score of the quantized target detection model on the training data set is obtained, 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. According to all IoU values, the regression score of the quantized target detection model on the training data set is obtained. Afterwards, according to the classification score and the regression score, the preset task relevance indicator formula is used to calculate the task relevance indicator. The task relevance indicator is used to more accurately describe the harmony quality of the sample.
[0030] In a feasible embodiment, 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, is the first The regression score of positive samples, and are two dynamic factors, The training data set Task relevance index of 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, this index considers the score quality of the two branches, e.g. When, explain and are 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 The higher the value, the greater the difference between the output results of the two branches. The lower the value.
[0031] In another possible 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, It does not show lower values under the influence of dynamic factors; on the contrary, Tends to increase.
[0032] In step S303, based on the task relevance index, the task harmony constraint loss function is used to calculate the constraint loss value.
[0033] 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.
[0034] In a feasible embodiment, the calculation of the constraint loss value is achieved through the following steps: (1) According to the task relevance index, the task-related loss value is calculated using the task-related loss function; 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 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 index 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.
[0035] In one feasible 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.
[0036] (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; In the embodiment of the present invention, the regression score of the quantized target detection model on the training data set is , use HIoU loss to calculate the harmonious intersection-over-union loss value In a feasible 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 was 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 was 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. Generally speaking, 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, which has a significant impact on the optimization direction of 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 positioning loss at each IoU level. Therefore, HIoU loss enhances the weighting of the positioning loss of 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.
[0037] (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.
[0038] 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.
[0039] 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.
[0040] In the embodiment of the present invention, based on the constraint loss value, the target loss function is used Calculate the target loss value of the quantized target detection model, where , which is the total loss of a standard target 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.
[0041] 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.
[0042] In the embodiment of the present invention, during 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, during the back-propagation process, a straight-through estimator (STE) is usually introduced to approximate the gradient of the rounding 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. During the QAT process, the detector optimizes all these losses in the objective loss function and is trained in an end-to-end manner.
[0043] 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. In addition, the The proposed framework can be easily integrated into different QAT algorithms and detectors.
[0044] 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 index. Based on the task relevance index, the task harmony constraint loss function is used to calculate the constraint loss value. Based on the constraint loss value, the 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.
[0045] Example 3: Figure 7 The structure of the quantitative perception training device for the target detection model provided by the third embodiment of the present invention is shown. For ease of explanation, only the parts related to the embodiment of the present invention are shown, including: A loss function construction unit 71 is used to construct a target loss function of the target detection model to be quantized, where the target loss function includes a classification loss function, a regression loss function, and a task harmony constraint loss function; 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.
[0046] Preferably, if Figure 8 As shown, the detection model quantization unit 72 includes: The model parameter quantization unit 721 is used to simulate quantization of the weights and activation values of the target detection model based on a preset quantization strategy and training data set during the forward propagation process; A task index calculation unit 722 is configured to calculate a task relevance index using a preset task relevance index formula based on the classification score and regression score of the quantized object detection model on the training data set; A constraint loss calculation unit 723 is used to calculate a constraint loss value based on the task relevance index using a task harmony constraint loss function; A target loss calculation unit 724 is configured to calculate a target loss value of the quantized target detection model using a target loss function based on the constraint loss value; The model parameter updating unit 725 is used to calculate the gradient of the target loss value with respect to the learnable parameters in the target detection model through back propagation, and update the learnable parameters according to the gradient.
[0047] In the embodiments of the present invention, each unit of the quantized perceptual training device for an object detection model can be implemented by corresponding hardware or software units. Each unit can be an independent software or hardware unit, or can be integrated into a single software or hardware unit, without limiting the present invention. Specifically, the implementation of each unit can refer to the description of the aforementioned method embodiment and will not be repeated here.
[0048] Example 4: Figure 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.
[0049] 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 for the target detection model described above 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.
[0050] 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, the target detection model is subjected to quantization perception training until the target loss function converges, thereby making the relationship between the classification task and the regression task more and more harmonious, avoiding the emergence of disharmonious prediction boxes, and improving the detection performance of the quantized target detection model after NMS.
[0051] The computing device of the embodiment of the present invention can 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 be referred to the description of the aforementioned method embodiment, and will not be repeated here.
[0052] Embodiment 5: 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 quantitative 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.
[0053] 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, the target detection model is subjected to quantization perception training until the target loss function converges, thereby making the relationship between the classification task and the regression task more and more harmonious, avoiding the emergence of disharmonious prediction boxes, and improving the detection performance of the quantized target detection model after NMS.
[0054] The computer-readable storage medium of the embodiment of the present invention may include any entity, device, or recording medium capable of carrying computer program code, for example, ROM / RAM, magnetic disk, optical disk, flash memory, or other memory.
[0055] 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 scope of protection of the present invention.
Claims
1. A quantitative perception training method for a target detection model, characterized in that: The method comprises the following steps: 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; 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, 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 a 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, characterized in that 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: 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, characterized in that 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.
5. The method according to claim 4, characterized in that 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.
6. The method according to claim 5, characterized in that The task-related loss function is , the harmonious intersection-over-union loss function is ,in, is the reweighting parameter, is a hyperparameter.
7. The method according to claim 6, 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.
8. A quantitative perception training device for a target detection model, characterized in that: The device comprises: 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; 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.
9. A computing device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, 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 7 are implemented.
Citation Information
Patent Citations
Visual multitask processing method based on deep learning
CN115909245A
Multi-unit dental implant
KR102661328B1
Modeling quantization loss using a preprocessing network that simulates hardware behavior
US11586892B1
Training method for binary target detection neural network structure and model
WO2023165024A1
KR20220109301A
Cited By
Large model reasoning acceleration method and device and medium
CN119204222A
