Target detection method and computing device
By splitting the shared convolutional layer of the detection network into two parts: regression and classification, and quantizing its outputs separately, the problem of serious quantization loss of mixed output in the detection network is solved, improving the prediction effect of the model and saving quantitative tuning time.
Patent Information
- Application Number
- CN202510129087.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-05
- Publication Date
- 2025-03-04
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The quantization loss of mixed output results in the detection network is severe, resulting in a significant decrease in the accuracy of the model and a long time for the model to be quantified.
By splitting the shared convolution layer of the model into a regression convolution layer and a classified convolution layer, and performing layer-by-layer quantization operations on the prediction box output and classification output respectively, the split-head quantization technology is used.
It effectively solves the problem of serious quantization loss of mixed output results, improves the prediction effect after model layered quantization, and saves the quantitative tuning time of the model.
Smart Images

Figure CN119559383A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a target detection method and computing device. Background Art
[0002] With the rapid development of deep learning technology and artificial intelligence computing devices, more and more object detection models are widely deployed in social applications. However, these models usually contain a large number of parameters and computational complexity, which seriously affects the performance of the model in the inference phase. Therefore, model optimization methods for this problem have emerged, among which parameter quantization technology is one of the important and effective model compression methods.
[0003] Parameter quantization technology converts model parameters from high-precision floating-point types to low-precision integer types, thereby reducing model storage space and speeding up model inference. Depending on whether additional training operations are required, parameter quantization can be divided into quantization-aware training (QAT) and post-training quantization (PTQ). Among them, QAT simulates quantization operations during training and adapts weights to the errors caused by quantization through training. Therefore, the model prediction effect produced by QAT is better, but its quantization process requires more training data and greater training overhead; PTQ is based on the trained floating-point model for quantization, and does not require additional training operations. It only needs to use a small amount of verification data to collect the maximum value information of activation (ie, test data) to achieve quantization operations on model weights and activations. Therefore, the PTQ method is more suitable for scenarios with limited data volume and running time. Affected by computational overhead, most hardware devices use a layer-by-layer quantization method when deploying applications. When the detection network is quantized layer by layer, it is found that the accuracy of the model will drop significantly after quantizing its mixed output (ie, the output result of the shared convolution).
[0004] Therefore, a technical solution is needed to solve the problem of serious quantization loss of mixed output results in the detection network and save the quantization tuning time of the model. Summary of the invention
[0005] The present invention aims to provide a method and computing device for target detection, which can solve the problem of serious quantization loss of mixed output results in the detection network, save the quantization tuning time of the model, and improve the prediction effect after hierarchical quantization of the model.
[0006] According to one aspect of the present invention, a method for target detection is provided, the method comprising: Split the shared convolutional layer of the model to obtain the first convolutional layer and the second convolutional layer; The intermediate features are calculated through the first convolutional layer to obtain a prediction box output; Calculating the intermediate features through the second convolutional layer to obtain a classification output; Performing a layer-by-layer quantization operation on the prediction box output and the classification output; The input image is used to detect the target using the layer-by-layer quantized convolutional network, and the output is the target detection result.
[0007] According to some embodiments, the shared convolutional layer of the model is split to obtain a first convolutional layer and a second convolutional layer, including: Splitting the weights of the shared convolutional layer into regression weights along the output channel dimension; According to the regression weight, the shared convolution layer is copied to obtain the first convolution layer, where the first convolution layer is a regression convolution layer, and the regression convolution layer only includes the regression weight.
[0008] According to some embodiments, the shared convolutional layer of the model is split to obtain a first convolutional layer and a second convolutional layer, including: Splitting the weights of the shared convolutional layer into classification weights along the output channel dimension; According to the classification weight, the shared convolution layer is copied to obtain the second convolution layer, where the second convolution layer is a classification convolution layer, and the classification convolution layer only includes the classification weight.
[0009] According to some embodiments, performing a layer-by-layer quantization operation on the prediction box output and the classification output includes: Collecting the first maximum value information pair of the intermediate features of the model through the first quantization strategy; Collecting the second maximum value information pair of the model weights through the second quantization strategy; Obtaining a first quantization parameter, a second quantization parameter, a third quantization parameter, and a fourth quantization parameter based on the first maximum value information pair and the second maximum value information pair; A layer-by-layer quantization operation is performed according to the first quantization parameter, the second quantization parameter, the third quantization parameter, and the fourth quantization parameter, wherein the layer-by-layer quantization operation includes a quantization operation and an inverse quantization operation.
[0010] According to some embodiments, obtaining a first quantization parameter, a second quantization parameter, a third quantization parameter, and a fourth quantization parameter based on the first maximum value information pair and the second maximum value information pair includes: Using the ratio of the difference between the maximum value and the minimum value of the first maximum value information pair and the maximum value of the quantization bit width as the first quantization parameter; The ratio of the difference between the maximum value and the minimum value of the second maximum value information pair to the maximum value of the quantization bit width is used as the second quantization parameter.
[0011] According to some embodiments, obtaining a first quantization parameter, a second quantization parameter, a third quantization parameter, and a fourth quantization parameter based on the first maximum value information pair and the second maximum value information pair further includes: performing a rounding operation on the ratio of the minimum value of the first maximum value information pair to the first quantization parameter to obtain a first value; Selecting the smallest value between the first value and the maximum value of the quantization bit width as the second value; If it is determined that the second value is greater than zero, the second value is used as the third quantization parameter; performing a rounding operation on the ratio of the minimum value of the second maximum value information pair to the second quantization parameter to obtain a third value; Selecting the smallest value between the third value and the maximum value of the quantization bit width as the fourth value; If it is determined that the fourth value is greater than zero, the fourth value is used as the fourth quantization parameter.
[0012] According to some embodiments, a layer-by-layer quantization operation is performed according to the first quantization parameter, the second quantization parameter, the third quantization parameter, and the fourth quantization parameter, wherein the layer-by-layer quantization operation includes a quantization operation and an inverse quantization operation, including: Calculating a ratio of the intermediate feature to the first quantization parameter as a fifth value; Calculating a sum of the fifth value and the third quantization parameter as a sixth value; performing a rounding operation on the sixth value; performing a truncation operation on the sixth value, the maximum value of the quantization bit width, and the minimum value of the quantization bit width to obtain a seventh value; The seventh value is a result of the intermediate feature being subjected to the quantization operation; The product of the difference between the seventh value and the third quantization parameter and the first quantization parameter is used as the result of the dequantization operation on the intermediate feature.
[0013] According to some embodiments, performing a layer-by-layer quantization operation according to the first quantization parameter, the second quantization parameter, the third quantization parameter, and the fourth quantization parameter further includes: Calculating a ratio of the weight to the second quantization parameter as an eighth value; Calculating a sum of the eighth value and the fourth quantization parameter as a ninth value; performing a rounding operation on the ninth value; performing a truncation operation on the ninth value, the maximum value of the quantization bit width, and the minimum value of the quantization bit width to obtain a tenth value; The tenth value is a result of the weight being subjected to the quantization operation; The product of the difference between the tenth value and the fourth quantization parameter and the second quantization parameter is used as the result of the weight undergoing the inverse quantization operation.
[0014] According to another aspect of the present invention, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the method as described above is implemented.
[0015] According to another aspect of the present invention, there is provided a computing device, comprising: Processor; and A memory stores a computer program, and when the computer program is executed by the processor, the method described in any one of the above items is implemented.
[0016] According to an embodiment of the present invention, the shared convolution layer of the model is split to obtain a first convolution layer and a second convolution layer, the intermediate features are calculated through the first convolution layer to obtain a prediction box output, and the classification output is calculated through the second convolution layer, and finally a layer-by-layer quantization operation is performed. The present invention adopts a separate head quantization technology, that is, the mixed output is divided into a regression head and a classification head for separate quantization operations, so that data of different levels can be quantized separately, and the obtained mixed output result is more accurate, which can solve the problem of serious quantization loss of the mixed output result in the detection network, and achieve a layer-by-layer quantization scheme close to the effect of a channel-by-channel quantization scheme. The present invention is also based on layer-by-layer quantization technology, does not require any additional training fine-tuning, and greatly saves the quantization tuning time of the model.
[0017] According to some embodiments, in the case where a shared convolutional layer performs mixed output, the computation accuracy can be improved by splitting the shared convolutional layer. For different types of convolutional layers, this flexibility helps quantize accuracy.
[0018] According to some embodiments, different hardware platforms may have different levels of support for different types of operations. By splitting the model into regression and classification parts, the hardware that is most suitable for running each part can be selected, and even distributed execution can be performed in a multi-device environment.
[0019] According to some embodiments, when PTQ is used for layer-by-layer quantization, if the network has been properly split according to the task, it helps to achieve a better balance between performance and accuracy. When detection encounters problems, the split convolutional layers make it easier to locate the problem, and as new algorithms and technologies develop, it is also easier to update or improve a single branch without affecting other parts.
[0020] It is to be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for describing the embodiments are briefly introduced below.
[0022] Figure 1 A flow chart of a method for target detection according to an example embodiment is shown.
[0023] Figure 2 A schematic diagram of a mixed output split quantization calculation for target detection according to an example embodiment is shown.
[0024] Figure 3 A schematic diagram illustrating a conventional convolutional network mixed output calculation according to an example embodiment.
[0025] Figure 4 A block diagram of a computing device is shown according to an exemplary embodiment. DETAILED DESCRIPTION
[0026] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that the present invention will be comprehensive and complete and fully convey the concepts of the example embodiments to those skilled in the art. The same reference numerals in the figures represent the same or similar parts, and thus their repeated description will be omitted.
[0027] In addition, the described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present invention. However, those skilled in the art will appreciate that the technical solution of the present invention can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring various aspects of the present invention.
[0028] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0029] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0030] It should be understood that although the terms first, second, third, etc. may be used herein to describe various components, these components should not be limited by these terms. These terms are used to distinguish one component from another component. Therefore, the first component discussed below can be referred to as the second component without departing from the teachings of the present inventive concept. As used herein, the term "and / or" includes any one of the associated listed items and all combinations of one or more.
[0031] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0032] Those skilled in the art will appreciate that the drawings are merely schematic diagrams of example embodiments, and the modules or processes in the drawings are not necessarily necessary for implementing the present invention, and therefore cannot be used to limit the protection scope of the present invention.
[0033] With the rapid development of deep learning technology and artificial intelligence computing devices, more and more object detection models are widely deployed in social applications. However, these models usually contain a large number of parameters and computational complexity, which seriously affects the performance of the model in the inference phase. Therefore, model optimization methods for this problem have emerged, among which parameter quantization technology is one of the important and effective model compression methods.
[0034] Parameter quantization technology converts model parameters from high-precision floating-point types to low-precision integer types, thereby reducing model storage space and speeding up model inference. Depending on whether additional training operations are required, parameter quantization can be divided into quantization-aware training (QAT) and post-training quantization (PTQ). Among them, QAT simulates quantization operations during the training process, and adapts the weights to the errors caused by quantization through training. Therefore, the model prediction effect generated by QAT is better, but its quantization process requires more training data and greater training overhead; PTQ is based on the trained floating-point model for quantization, and does not require additional training operations. It only needs to use a small amount of verification data to collect the maximum value information of activation (ie, test data) to achieve quantization operations on model weights and activations. Therefore, the PTQ method is more suitable for scenarios with limited data volume and running time.
[0035] The PTQ method can be divided into Per-Layer quantization and Per-Channel quantization according to the different quantization granularities. Per-Layer quantization refers to the calculation of quantization parameters in units of a network layer (such as a convolutional layer), while Per-Channel quantization refers to the calculation of quantization parameters in units of a channel in the network layer. Therefore, Per-Channel quantization has finer granularity than Per-Layer quantization and better quantization effect. However, Per-Channel quantization has higher computational overhead and higher requirements for hardware devices. Therefore, in actual deployment, most hardware still uses the Per-Layer quantization method. According to the different maximum value collection methods, the PTQ quantization collection strategy can be divided into: Absolute Maximum Value (MinMax) collection strategy, Histogram collection strategy, etc. The MinMax collection strategy directly collects the maximum values of the data to calculate the corresponding quantization parameters, and is generally used as a quantization strategy for model weights; while the Histogram collection strategy first obtains the distribution of the current output, traverses the search for the maximum value range, calculates the mean square error before and after quantization of the current output distribution each time, and takes the minimum maximum value of the mean square error as the final maximum value range, which is generally used as a quantization strategy for model activation.
[0036] Most object detection networks make predictions based on anchor boxes, such as Faster RCNN network, YOLO series network, etc. The input data of these networks passes through the backbone network and the head network to output intermediate feature data, which are then calculated through shared convolution to obtain mixed output results. Finally, the mixed output results are split along the channel dimension, and the location information and classification information of the prediction box are finally returned.
[0037] Due to the computational overhead, most hardware devices use layer-by-layer quantization when deploying applications. When quantizing the detection network layer by layer, it is found that the accuracy of the model will drop significantly after quantizing its mixed output (i.e., the output result of the shared convolution). The reason is that the distribution of the position data of the prediction box contained in the mixed output is very different from that of the classification data. Specifically, the size of the position data is generally arrive The size of the classified data is generally between 0 and 1, that is, the size of the two parts of data is very different. After layer-by-layer quantization (that is, the position data and the classified data use the same quantization parameter), part of the data will be truncated, which will significantly reduce the accuracy of the model prediction.
[0038] To this end, the present invention proposes a method for target detection based on head-by-head quantization, which can solve the problem of serious quantization loss of mixed output results in the detection network, save the quantization tuning time of the model, and improve the prediction effect of the model after hierarchical quantization.
[0039] Exemplary embodiments of the present invention are described below with reference to the accompanying drawings.
[0040] Figure 1 A flow chart of a method for target detection according to an example embodiment is shown.
[0041] See also Figure 1 , in S101, the shared convolutional layer of the model is split to obtain a first convolutional layer and a second convolutional layer.
[0042] According to some embodiments, the weights of the shared convolution layer are split into regression weights along the output channel dimension; based on the regression weights, the shared convolution layer is copied to obtain the first convolution layer, the first convolution layer is a regression convolution layer, and the regression convolution layer only contains regression weights. The weights of the shared convolution layer are split into classification weights along the output channel dimension; based on the classification weights, the shared convolution layer is copied to obtain the second convolution layer, the second convolution layer is a classification convolution layer, and the classification convolution layer only contains classification weights.
[0043] An embodiment is described below. Assume that the weight w of the shared convolution C is [84, 3, 3, 64], where 84 is the output channel size, 64 is the input channel size, and 3 is the size of the convolution kernel. Therefore, when splitting, it is only necessary to split the weight w along the first dimension (i.e., the output channel dimension) to obtain the regression weight w1 and the classification weight w2, where the size of w1 is [4, 3, 3, 64], and the size of w2 is [80, 3, 3, 64]. The regression weight w1 and the classification weight w2 can respectively form the regression convolution C1 and the classification convolution C2.
[0044] In S103, the intermediate features are calculated through the first convolutional layer to obtain a predicted box output.
[0045] According to some embodiments, the intermediate features are representations of the data output at each layer or at certain specific layers when the data passes through the layers of the network. These representations are usually the result of the activation function of the previous layer acting on the weights and biases, and serve as the input of the next layer.
[0046] After the intermediate feature x passes through the regression convolution C1, the prediction box output y1 is obtained, and the size of y1 is [1, 40, 40, 4]. Among them, 4 represents the location information of each prediction box, including: the horizontal coordinate of the center point of the prediction box, the vertical coordinate of the center point, the height, and the width.
[0047] In S105, the intermediate features are calculated through the second convolutional layer to obtain a classification output.
[0048] After the intermediate feature x passes through the classification convolution C2, the classification output y2 is obtained. The size of y2 is [1, 40, 40, 80], where 80 represents the classification information of each prediction box, that is, the probability that the prediction box belongs to each of the 80 categories.
[0049] In S107, a layer-by-layer quantization operation is performed on the prediction box output and the classification output.
[0050] According to some embodiments, a first maximum value information pair of a model intermediate feature is collected through a first quantization strategy; a second maximum value information pair of a model weight is collected through a second quantization strategy; a first quantization parameter, a second quantization parameter, a third quantization parameter and a fourth quantization parameter are obtained based on the first maximum value information pair and the second maximum value information pair; and a layer-by-layer quantization operation is performed according to the first quantization parameter, the second quantization parameter, the third quantization parameter and the fourth quantization parameter, the layer-by-layer quantization operation including a quantization operation and a dequantization operation.
[0051] The ratio of the difference between the maximum and minimum values of the first extreme value information pair and the maximum value of the quantization bit width is used as the first quantization parameter; the ratio of the difference between the maximum and minimum values of the second extreme value information pair and the maximum value of the quantization bit width is used as the second quantization parameter.
[0052] The minimum value of the first maximum value information pair and the ratio of the first quantization parameter are rounded as the first value; the smallest value between the first value and the maximum value of the quantization bit width is selected as the second value; if the second value is determined to be greater than zero, the second value is used as the third quantization parameter; the minimum value of the second maximum value information pair and the ratio of the second quantization parameter are rounded as the third value; the smallest value between the third value and the maximum value of the quantization bit width is selected as the fourth value; if the fourth value is determined to be greater than zero, the fourth value is used as the fourth quantization parameter.
[0053] Calculate the ratio of the intermediate feature to the first quantization parameter as a fifth value; calculate the sum of the fifth value and the third quantization parameter as a sixth value; round the sixth value; truncate the sixth value, the maximum value of the quantization bit width, and the minimum value of the quantization bit width to obtain a seventh value; use the seventh value as the result of the quantization operation on the intermediate feature; and use the difference between the seventh value and the third quantization parameter and the product of the first quantization parameter as the result of the dequantization operation on the intermediate feature.
[0054] Calculate the ratio of the weight to the second quantization parameter as an eighth value; calculate the sum of the eighth value and the fourth quantization parameter as a ninth value; round the ninth value; truncate the ninth value, the maximum value of the quantization bit width, and the minimum value of the quantization bit width to obtain a tenth value; use the tenth value as the result of the quantization operation on the weight; use the difference between the tenth value and the fourth quantization parameter and the product of the second quantization parameter as the result of the dequantization operation on the weight.
[0055] According to some embodiments, the optimized entire network is quantized layer by layer using PTQ. Specifically, 50 unlabeled training images are used as verification data for data verification, and the maximum value information of the model weight w is collected by the absolute MinMax method. , collect the maximum value information of the model activation value x through the Histogram method :
[0056]
[0057] Then, according to the maximum value information of the model weight w and activation x, their quantization parameters Scale (scaling coefficient) and zero_point (offset) are calculated, and quantization Q and dequantization DQ operations (collectively referred to as analog quantization operations) are performed on them respectively. The analog quantization operation belongs to post-training quantization. The calculation formula of the analog quantization operation is as follows:
[0058]
[0059]
[0060]
[0061] Where x(w) represents x or w, q max and q min It is calculated based on the quantization bit width. Since Uint8 quantization is used here, q max and q min 255 and 0 respectively. Indicates rounding operation, and Clip indicates truncation operation.
[0062] In S109, the input image is subjected to target detection using the layer-by-layer quantized convolutional network, and the target detection result is output.
[0063] According to the convolution network obtained after the layer-by-layer quantization operation in S107, target detection is performed on the input image to be detected, and the final output result is the target detection result. The data output by the final model is almost unaffected by quantization, and has a high prediction effect and target detection accuracy.
[0064] The present invention realizes the conversion of the splitting of mixed output data into the splitting of shared convolution weights through convolution splitting. The reason for this is that the data in the mixed output is data of different levels (i.e., the position data and classification data of the prediction box). This distributed data is easily distorted during the quantization process, resulting in a significant reduction in the prediction accuracy of the quantized model. By splitting the shared convolution weights, data of different levels are separated and quantized separately, thereby ensuring that the output data of the model is almost unaffected by the quantization and maintaining the original prediction effect of the model.
[0065] Figure 2 A schematic diagram of a mixed output split quantization calculation for target detection according to an example embodiment is shown.
[0066] Figure 3 A schematic diagram illustrating a conventional convolutional network mixed output calculation according to an example embodiment.
[0067] See also Figure 2 , Figure 2 The process of head-by-head quantization in a convolutional network is shown. In order to solve the impact of uneven distribution of mixed output data of a traditional detection network on the quantization effect of the detection network, this application uses a convolutional network head-by-head quantization method to improve the accuracy of quantization.
[0068] The traditional detection network mixed output calculation process is as follows Figure 3 As shown. Assuming that the size of the intermediate feature data x is [1, 40,40, 64] (i.e., 1x80x80x64), after passing through the shared convolution layer C, the size of the mixed output y is [1,40, 40, 84]; then y is split along the channel dimension (i.e., the fourth axis), the prediction box position data y1 and classification data y2 can be obtained respectively, where the size of y1 is [1, 40, 40, 4], "4" represents the position information of the current prediction box, i.e., the horizontal coordinate of the center point, the vertical coordinate of the center point, the height of the box, and the width of the box, and the size of y2 is [1, 40, 40,80], "80" represents the probability that the current prediction box belongs to 80 categories. Among them, the splitting rules of the mixed output y are different according to the output results of different models, specifically, the splitting is based on the channel position of the position data and classification data in the output results. For example, in the simplest case, assume that the size of the fourth axis of the output is 84, 80 of which are position data and the last 4 are classification data.
[0069] See also Figure 2 , this application splits the shared convolution into two parts: regression convolution and classification convolution. The weight of the shared convolution layer is split into regression weights and classification weights along the output channel dimension, and then the regression convolution layer and the classification convolution layer are copied according to the shared convolution. The regression convolution layer and the classification convolution layer should use the regression weights and classification weights as convolution weights respectively. Except for the convolution weights, the other convolution configurations of the regression convolution layer and the classification convolution layer are exactly the same as the shared convolution layer. The intermediate features are subjected to regression convolution and classification convolution respectively to obtain the prediction box output and classification output, and then the entire optimized network is quantized layer by layer by PTQ.
[0070] In order to verify the effectiveness of the patented method, test experiments were conducted on several classic object detection networks. These models all use the COCO2017 training set (select 50 images) for data verification, and the COCO2017 validation set (5000 images) for effect evaluation. The evaluation index is mAP (IoU=0.50:0.95), the quantization bit width uses UINT8, the weights all use the MinMax method to collect the maximum value information, and the activation uses the Histogram method to collect the maximum value information. The experimental results are shown in Table 1: Table 1
[0071] Among them, "FP32" represents the test result of the full floating point model, "Uint8" represents the test result of the quantized model, "layer-by-layer quantization" means that all network layers in the model are quantized by PTQ layer-by-layer quantization, "channel-by-channel quantization" means that all network layers in the model are quantized by PTQ channel-by-channel quantization, and "head-by-layer quantization" means that the shared convolution layer is split into regression layer (regression head) and classification layer (classification head) and then the whole model is quantized layer by layer, which is the quantization technology of this patent.
[0072] By comparing the test results of layer-by-layer quantization and channel-by-channel quantization in Table 1, it can be seen that the effect of channel-by-channel quantization is significantly better than that of layer-by-layer quantization. This is because the quantization granularity of channel-by-channel is finer. At the same time, it also explains the problem of large differences in data distribution between different channels in the model. However, due to the higher computational overhead of channel-by-channel quantization, layer-by-layer quantization is more often used in actual industrial deployment.
[0073] By comparing the layer-by-layer quantization and the head-by-layer quantization in Table 1, it can be found that the effect of the head-by-layer quantization is significantly better than the conventional layer-by-layer quantization. This is because the mixed output data of the shared convolution layer contains data of different levels, and it is difficult to completely restore the distribution of the data before quantization during quantization. After splitting the shared convolution, data of different levels can be quantized separately, so that each level of data can use the quantization parameters that meet the current level. This also verifies the effectiveness of this patent technology.
[0074] Figure 4 A block diagram of a computing device according to an example embodiment of the invention is shown.
[0075] like Figure 4 As shown, computing device 30 includes processor 12 and memory 14. Computing device 30 may also include bus 22, network interface 16, and I / O interface 18. Processor 12, memory 14, network interface 16, and I / O interface 18 may communicate with each other via bus 22.
[0076] The processor 12 may include one or more general-purpose CPUs (Central Processing Units, processors), microprocessors, or application-specific integrated circuits, etc., for executing relevant program instructions. According to some embodiments, the computing device 30 may also include a high-performance graphics card (GPU) 20 for accelerating the processor 12.
[0077] The memory 14 may include a machine system readable medium in the form of a volatile memory, such as a random access memory (RAM), a read-only memory (ROM) and / or a cache memory. The memory 14 is used to store one or more programs including instructions and data. The processor 12 may read the instructions stored in the memory 14 to execute the above-mentioned method according to the embodiment of the present invention.
[0078] The computing device 30 may also communicate with one or more networks via the network interface 16. The network interface 16 may be a wireless network interface.
[0079] The bus 22 may include an address bus, a data bus, a control bus, etc. The bus 22 provides a path for exchanging information between components.
[0080] It should be noted that, in the specific implementation process, the computing device 30 may also include other components necessary for normal operation. In addition, those skilled in the art may understand that the above device may only include components necessary for implementing the embodiments of this specification, and need not include all components shown in the figure.
[0081] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the above method when the program is executed by a processor. The computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a micro drive, and a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), a network storage device, a cloud storage device, or any type of medium or device suitable for storing instructions and / or data.
[0082] An embodiment of the present invention further provides a computer program product, which includes a computer program. The computer program is operable to enable a computer to execute part or all of the steps of any one of the methods described in the above method embodiments.
[0083] Those skilled in the art can clearly understand that the technical solution of the present invention can be implemented with the help of software and / or hardware. "Unit" and "module" in this specification refer to software and / or hardware that can independently complete or cooperate with other components to complete specific functions, where the hardware can be, for example, a field programmable gate array, an integrated circuit, etc.
[0084] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0085] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0086] In the several embodiments provided by the present invention, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0087] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0088] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0089] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods of various embodiments of the present invention.
[0090] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0091] The exemplary embodiments of the present invention are specifically shown and described above. It should be understood that the present invention is not limited to the detailed structures, configurations or implementations described herein; on the contrary, the present invention is intended to cover various modifications and equivalent configurations included in the spirit and scope of the appended clauses.
Claims
1. A method for target detection, characterized in that: include: Split the shared convolutional layer of the model to obtain the first convolutional layer and the second convolutional layer; The intermediate features are calculated through the first convolutional layer to obtain a prediction box output; Calculating the intermediate features through the second convolutional layer to obtain a classification output; Performing a layer-by-layer quantization operation on the prediction box output and the classification output; The input image is used to detect the target using the layer-by-layer quantized convolutional network, and the output is the target detection result.
2. The method according to claim 1, characterized in that: The shared convolutional layer of the model is split to obtain the first convolutional layer and the second convolutional layer, including: Splitting the weights of the shared convolutional layer into regression weights along the output channel dimension; According to the regression weight, the shared convolution layer is copied to obtain the first convolution layer, where the first convolution layer is a regression convolution layer, and the regression convolution layer only includes the regression weight.
3. The method according to claim 1, characterized in that The shared convolutional layer of the model is split to obtain the first convolutional layer and the second convolutional layer, including: Splitting the weights of the shared convolutional layer into classification weights along the output channel dimension; According to the classification weight, the shared convolution layer is copied to obtain the second convolution layer, where the second convolution layer is a classification convolution layer, and the classification convolution layer only includes the classification weight.
4. The method according to claim 1, characterized in that: The prediction box output and the classification output are quantized layer by layer, including: Collecting the first maximum value information pair of the intermediate features of the model through the first quantization strategy; Collecting the second maximum value information pair of the model weights through the second quantization strategy; Obtaining a first quantization parameter, a second quantization parameter, a third quantization parameter, and a fourth quantization parameter based on the first maximum value information pair and the second maximum value information pair; A layer-by-layer quantization operation is performed according to the first quantization parameter, the second quantization parameter, the third quantization parameter, and the fourth quantization parameter, wherein the layer-by-layer quantization operation includes a quantization operation and an inverse quantization operation.
5. The method according to claim 4, characterized in that Obtaining a first quantization parameter, a second quantization parameter, a third quantization parameter, and a fourth quantization parameter based on the first maximum value information pair and the second maximum value information pair, comprising: Using the ratio of the difference between the maximum value and the minimum value of the first maximum value information pair and the maximum value of the quantization bit width as the first quantization parameter; The ratio of the difference between the maximum value and the minimum value of the second maximum value information pair to the maximum value of the quantization bit width is used as the second quantization parameter.
6. The method according to claim 5, characterized in that The method further comprises: obtaining a first quantization parameter, a second quantization parameter, a third quantization parameter and a fourth quantization parameter based on the first maximum value information pair and the second maximum value information pair; performing a rounding operation on the ratio of the minimum value of the first maximum value information pair to the first quantization parameter to obtain a first value; Selecting the smallest value between the first value and the maximum value of the quantization bit width as the second value; If it is determined that the second value is greater than zero, the second value is used as the third quantization parameter; performing a rounding operation on the ratio of the minimum value of the second maximum value information pair to the second quantization parameter to obtain a third value; Selecting the smallest value between the third value and the maximum value of the quantization bit width as the fourth value; If it is determined that the fourth value is greater than zero, the fourth value is used as the fourth quantization parameter.
7. The method according to claim 5, characterized in that Performing a layer-by-layer quantization operation according to the first quantization parameter, the second quantization parameter, the third quantization parameter, and the fourth quantization parameter, wherein the layer-by-layer quantization operation includes a quantization operation and an inverse quantization operation, including: Calculating a ratio of the intermediate feature to the first quantization parameter as a fifth value; Calculating a sum of the fifth value and the third quantization parameter as a sixth value; performing a rounding operation on the sixth value; performing a truncation operation on the sixth value, the maximum value of the quantization bit width, and the minimum value of the quantization bit width to obtain a seventh value; The seventh value is a result of the intermediate feature being subjected to the quantization operation; The product of the difference between the seventh value and the third quantization parameter and the first quantization parameter is used as the result of the dequantization operation on the intermediate feature.
8. The method according to claim 5, characterized in that Performing a layer-by-layer quantization operation according to the first quantization parameter, the second quantization parameter, the third quantization parameter, and the fourth quantization parameter, further comprising: Calculating a ratio of the weight to the second quantization parameter as an eighth value; Calculating a sum of the eighth value and the fourth quantization parameter as a ninth value; performing a rounding operation on the ninth value; performing a truncation operation on the ninth value, the maximum value of the quantization bit width, and the minimum value of the quantization bit width to obtain a tenth value; The tenth value is a result of the weight being subjected to the quantization operation; The product of the difference between the tenth value and the fourth quantization parameter and the second quantization parameter is used as the result of the weight undergoing the inverse quantization operation.
9. A computer program product, characterized in that The method comprises a computer program, which implements the method according to any one of claims 1 to 8 when being executed by a processor.
10. A computing device, characterized in that: include: processor; as well as A memory storing a computer program, wherein when the computer program is executed by the processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Neural network model quantification method
CN117592515A
Method for quantifying activation value in target detection network and computing equipment
CN118133900A
Method and computing device for quantitative tuning of residual structure of self-attention model
CN118153634A