Image processing model quantification method

By evaluating the difference range of neural network image processing models and symmetric quantization method, the quantization target range is adjusted, and the problem of low quantization accuracy of image processing models in the prior art is solved, and the model accuracy is maintained in the environment of hardware resource constrained and reduce the effect of space consumption.

CN119323714APending Publication Date: 2025-01-17ANHUI POLYTECHNIC UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411409156.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-10
Publication Date
2025-01-17

AI Technical Summary

Technical Problem

In the prior art, the quantization method of image processing models has low accuracy and is difficult to ensure the accuracy of the model in an environment with limited hardware resources, resulting in limited computing performance in mobile devices and embedded systems.

Method used

By determining the difference range between the neural network image processing model and before and after quantization, the model is quantized using symmetric quantization method, the weight value and activation value of each layer are collected and evaluated, the quantization target range is adjusted to maintain the accuracy within an acceptable range, and the model is reduced size.

Benefits of technology

This achieves the accuracy of the image processing model in a hardware resource-constrained environment, ensuring that it can adapt to performance requirements after quantization, while significantly reducing the model's footprint.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119323714A_ABST
    Figure CN119323714A_ABST
Patent Text Reader

Abstract

The invention provides an image processing model quantification method, and relates to the technical field of data center server cluster cooperative control, and the method comprises the steps: 1, preparing an image processing model; 2, collecting parameters of the image processing model; 3, quantifying the image processing model; according to the method, the quantized neural network image processing model is subjected to forward propagation to obtain a first performance index, then the first performance index is taken as a target to determine an acceptable range of precision reduction, and then the neural network image processing model is quantized by using a symmetric quantization method, so that the accuracy of the neural network image processing model is improved. Therefore, by taking the precision of the neural network image processing model before quantization as a target, the size of the model is quantized and reduced, and the model is kept within an acceptable range of precision reduction, so that the neural network image processing model can be suitable for being used in an environment with limited hardware resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of neural network processing model quantization, and in particular to an image processing model quantization method. Background Art

[0002] Image processing models are models that use computer vision techniques and machine learning algorithms to process and analyze image data. These models can perform a variety of tasks, including but not limited to image classification, object detection, semantic segmentation, image restoration, image generation, etc. Image processing models are usually composed of a series of layers, each of which is responsible for extracting different features of the image or performing a specific processing task.

[0003] In the field of deep learning, image processing models usually refer to neural network processing models, and neural network image processing models are models that use artificial neural networks to process and analyze image data. Such models usually adopt a convolutional neural network architecture, but because the neural network processing model itself occupies a large space, although it has the advantage of high precision, its computing performance is limited in environments with limited hardware resources such as mobile devices, embedded systems, and IoT devices, and therefore needs to be quantified.

[0004] However, in the prior art, for the quantization of image processing models, a certain number of quantization reference pictures are usually selected, and the image processing model is quantized using the quantization reference pictures. The accuracy after quantization is low, and the quantization method is obtained through multiple quantization trainings without a definite target, resulting in the deployment of quantization training after reaching a certain number of times. Although the size of the image processing model is reduced, its accuracy cannot be guaranteed. Therefore, the present invention proposes an image processing model quantization method to solve the problems existing in the prior art. Summary of the invention

[0005] In view of the above problems, the purpose of the present invention is to propose an image processing model quantization method, which has the advantage of reducing the space occupied by the image processing model and can solve the problems existing in the prior art.

[0006] To achieve the purpose of the present invention, the present invention is implemented by the following technical solution: an image processing model quantization method, comprising the following steps:

[0007] Step 1: Preparation of image processing model

[0008] Determine the neural network image processing model to be quantized, obtain a data set for quantization calibration from a publicly available data set according to the neural network image processing model, and then determine the difference range between the neural network image processing model after quantization and the neural network image processing model before quantization;

[0009] Step 2: Parameter collection of image processing model

[0010] Input the data in the data set into the neural network image processing model to be quantified for forward propagation. During this process, the weight value and activation value of each layer of the neural network image processing model are collected to obtain preliminary parameters. Then, the output results of the neural network image processing model are evaluated to obtain the first performance index.

[0011] Step 3: Quantization of image processing model

[0012] Determine the quantization target range, and then use the symmetric quantization method to quantize the neural network image processing model according to the preliminary parameters obtained in step 2, and then obtain the quantized neural network image processing model;

[0013] Step 4: Post-processing of the quantization model

[0014] The data in the data set is then input into the quantized neural network image processing model for forward propagation, and the output result is evaluated to obtain a second performance indicator. The second performance indicator is compared with the first performance indicator to obtain a difference, and the difference is compared with the difference range in step one, so as to perform corresponding processing.

[0015] A further improvement is that in step 1, the data set is divided into training set data and validation set data, and the ratio between the training set data and the validation set data is 3:1.

[0016] A further improvement is that in step 2, the preliminary parameters are the minimum and maximum values ​​of the weight values ​​and activation values ​​of each layer.

[0017] A further improvement is that in step 2, the first performance indicator is based on the accuracy of the output result.

[0018] A further improvement is that in step three, the quantization range includes the quantization bit width and the quantization interval.

[0019] A further improvement is that in step 3, the specific steps of quantification are:

[0020] S1: Calculate the quantization scale according to the quantization range;

[0021] S2: Calculate the preliminary parameters according to the obtained quantization scale and in combination with the symmetric quantization method to obtain the quantization parameters;

[0022] S3: Apply the quantization parameters to the neural network image processing model to obtain a quantized neural network image processing model.

[0023] A further improvement is that in step 4, when the difference is within the difference range, the subsequent deployment of the quantized neural network image processing model can be carried out.

[0024] A further improvement is that in step 4, when the difference does not fall within the difference range, the quantization target range is readjusted and quantization is performed.

[0025] The beneficial effects of the present invention are as follows: an image processing model quantization method provided by the present invention obtains a first performance indicator by forward propagating the quantized neural network image processing model, and then determines an acceptable range of reduced precision with the first performance indicator as a target, and then quantizes the neural network image processing model using a symmetric quantization method, and compares the quantized models. Thus, the present invention targets the precision of the neural network image processing model before quantization, and while quantizing and reducing its model size, keeps it within an acceptable range of reduced precision, thereby enabling it to be adapted for use in an environment with limited hardware resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 It is a schematic diagram of the steps of the present invention. DETAILED DESCRIPTION

[0027] In order to deepen the understanding of the present invention, the present invention will be further described in detail below in conjunction with examples. The examples are only used to explain the present invention and do not constitute a limitation on the protection scope of the present invention.

[0028] according to Figure 1 As shown, this embodiment proposes an image processing model quantization method, comprising the following steps:

[0029] The following steps are involved:

[0030] Step 1: Preparation of image processing model

[0031] Determine the neural network image processing model to be quantized. In this embodiment, the neural network image processing model is a trained network model. For different applications, the neural network can have various network structures, such as DNN (deep neural network), CNN (convolutional neural network), RNN (recurrent neural network), LSTM (long short-term memory), etc. Regardless of the network structure, the training process is to send a set of training sets into the network and adjust the weights according to the difference between the actual output and the expected output of the network. Accordingly, after determining the neural network image processing model to be quantized, a data set for quantization calibration is obtained from the public data set according to the neural network image processing model. , and divide the data set into training set data and validation set data, the ratio between the training set data and the validation set data is 3:1, the training set data is used to obtain the parameters of the neural network image processing model, and the validation set data is used to obtain the accuracy of the quantized neural network image processing model, and the quantized model is tested and inspected using the data set to determine whether the difference between the quantized model and the original model is within an acceptable range, that is, it is necessary to determine the difference range between the neural network image processing model after quantization and the neural network image processing model before quantization. For example, in this embodiment, the target range is determined to be that the accuracy after quantization differs from the accuracy before quantization by 1% to 20%;

[0032] Step 2: Parameter collection of image processing model

[0033] The purpose of quantizing the neural network image processing model is to reduce the space occupied by the model. However, under this premise, it is still necessary to consider maintaining the accuracy of the model after quantization. Therefore, in this embodiment, the data of the data set is first used to forward propagate the neural network image processing model to be quantized, that is, the training set data is input into the neural network image processing model to obtain its results. In this process, the minimum and maximum values ​​between the weight values ​​and activation values ​​of each layer of the neural network image processing model are collected. Since the training set data contains multiple groups, multiple groups of data will appear in each layer of the structure during the forward propagation of the neural network image processing model. However, among these multiple groups of data, for a certain layer of structure, In other words, the minimum and maximum values ​​in the multiple groups of data are taken as the minimum and maximum values, thereby obtaining preliminary parameters, and the preliminary parameters take the minimum and maximum values ​​of the weight value and activation value of each layer, wherein the activation value refers to the output value of the neuron in the forward propagation process of the neural network, that is, the result after the input signal is processed by weighted summation and activation function, and the weight value refers to the connection weight connecting two adjacent neurons in the neural network. In the subsequent quantization process, these two values ​​need to be quantized and mapped, so as to be converted into low-precision representation, and at the same time, the output result of the neural network image processing model is evaluated to obtain the first performance indicator, which targets the accuracy of the output result;

[0034] Step 3: Quantization of image processing model

[0035] Determine the quantization target range. The quantization range includes the quantization bit width and the quantization interval. The quantization bit width is 8 bits, 16 bits, and 32 bits. In this embodiment, 8 bits are taken as an example. Then, according to the 8-bit quantization bit width, its quantization interval can also be obtained, which is -128 to 127. Then, according to the preliminary parameters obtained in step 2, the neural network image processing model is quantized using the symmetric quantization method, and then the quantized neural network image processing model is obtained. The specific steps of quantization are:

[0036] S1: Calculate the quantization scale S according to the quantization range. The calculation formula is as follows:

[0037]

[0038] Among them, F max is the maximum value of a floating point number (weight values ​​and activation values ​​are collectively referred to as floating point numbers), F min Is the minimum value of a floating point number, I max is the maximum value of the quantized integer range (quantization interval), I min is the minimum value of the quantized integer range (quantization interval);

[0039] S2: According to the obtained quantization scale S, combined with the symmetric quantization method, the preliminary parameters are calculated, that is, according to the quantization scale, the weights and activations are mapped to the integer range to obtain the quantization parameters. The quantization formula is:

[0040]

[0041] Wherein, q is a quantized integer, X is an original floating point number, the clamp function is used to ensure that the quantized value is within the integer range, and Z is a zero point used for offset mapping. Since the symmetric quantization method is adopted in this embodiment, in the symmetric quantization, since the quantization interval is symmetric, the zero point is set to 0;

[0042] S3: Apply the quantization parameters to the neural network image processing model to obtain a quantized neural network image processing model, that is, use the determined quantization parameters to convert the high-precision weight values ​​in the model into low-precision representations, and then store the quantized integer weights in the model to replace the original floating-point weights, which will significantly reduce the storage requirements of the model;

[0043] Step 4: Post-processing of the quantization model

[0044] The data in the data set is then input into the quantized neural network image processing model for forward propagation, and the output result is evaluated, that is, the performance is verified using the data of the validation set to obtain a second performance indicator, and the second performance indicator is compared with the first performance indicator to obtain a difference, and the difference is compared with the difference range in step one to perform corresponding processing. When the difference is within the difference range, it means that the quantized neural network image processing model meets the requirements determined in step one, and the subsequent quantized neural network image processing model can be deployed. When the difference does not fall within the difference range, the quantization target range is readjusted, such as adjusting the quantization bit width, and re-quantization is performed.

[0045] By forward propagating the quantized neural network image processing model, a first performance indicator is obtained, and then the acceptable range of reduced precision is determined with the first performance indicator as the target, and then the neural network image processing model is quantized using a symmetric quantization method, and a comparison is performed after quantization. Thus, the present invention takes the precision of the neural network image processing model before quantization as the target, and while quantizing and reducing its model size, keeps it within the acceptable range of reduced precision, so that it can be adapted for use in an environment with limited hardware resources.

[0046] The above shows and describes the basic principles, main features and advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited by the above embodiments. The above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the framework and scope of application of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention to be protected. The scope of protection of the present invention is defined by the attached claims and their equivalents.

Claims

1. A method for quantizing an image processing model, characterized in that: The following steps are involved: Step 1: Preparation of image processing model Determine the neural network image processing model to be quantized, obtain a data set for quantization calibration from a publicly available data set according to the neural network image processing model, and then determine the difference range between the neural network image processing model after quantization and the neural network image processing model before quantization; Step 2: Parameter collection of image processing model Input the data in the data set into the neural network image processing model to be quantified for forward propagation. During this process, the weight value and activation value of each layer of the neural network image processing model are collected to obtain preliminary parameters. Then, the output results of the neural network image processing model are evaluated to obtain the first performance index. Step 3: Quantization of image processing model Determine the quantization target range, and then use the symmetric quantization method to quantize the neural network image processing model according to the preliminary parameters obtained in step 2, and then obtain the quantized neural network image processing model; Step 4: Post-processing of the quantization model The data in the data set is then input into the quantized neural network image processing model for forward propagation, and the output result is evaluated to obtain a second performance indicator. The second performance indicator is compared with the first performance indicator to obtain a difference, and the difference is compared with the difference range in step one, so as to perform corresponding processing.

2. The image processing model quantization method according to claim 1, characterized in that: In the step 1, the data set is divided into training set data and validation set data, and the ratio between the training set data and the validation set data is 3:

1.

3. The image processing model quantization method according to claim 1, characterized in that: In the step 2, the preliminary parameters are the minimum and maximum values ​​of the weight values ​​and activation values ​​of each layer.

4. The image processing model quantization method according to claim 1, characterized in that: In the step 2, the first performance indicator is based on the accuracy of the output result.

5. The image processing model quantization method according to claim 1, characterized in that: In the step three, the quantization range includes the quantization bit width and the quantization interval.

6. The image processing model quantization method according to claim 1, characterized in that: In step 3, the specific steps of quantification are: S1: Calculate the quantization scale according to the quantization range; S2: Calculate the preliminary parameters according to the obtained quantization scale and in combination with the symmetric quantization method to obtain the quantization parameters; S3: Apply the quantization parameters to the neural network image processing model to obtain a quantized neural network image processing model.

7. The image processing model quantization method according to claim 1, characterized in that: In the step 4, when the difference is within the difference range, the subsequent deployment of the quantized neural network image processing model can be carried out.

8. The image processing model quantization method according to claim 1, characterized in that: In the step 4, when the difference does not fall within the difference range, the quantization target range is readjusted and quantization is performed.

Citation Information

Cited By

  • Multi-energy power distribution network low-carbon cooperative scheduling optimization method based on edge calculation

    CN120728744A

  • Progressive model inversion system and method for non-data compression scene

    CN122635460A