Search

CN-121999238-A - Image characteristic quantization method and storage medium

CN121999238ACN 121999238 ACN121999238 ACN 121999238ACN-121999238-A

Abstract

The embodiment of the application provides a quantization method of image characteristics and a storage medium, and relates to the technical field of model quantization. The method comprises the steps of obtaining image features of an image to be processed extracted by a deep learning model, grouping the image features to obtain multiple groups of image features, calculating a shared index and a shared mantissa of each group of image features based on a preset shared index bit width and a preset shared mantissa bit width, calculating a private index and a private mantissa of each image feature according to the preset private index bit width, the preset private mantissa bit width and the shared index and the shared mantissa corresponding to the image feature group, and taking the shared index and the shared mantissa of each group of image features as a shared part, and taking the sign, the private index and the private mantissa corresponding to each image feature as a private part for nonlinear representation of the image features. The data range difference of the image features of different areas is reflected, and the data precision is ensured.

Inventors

  • WANG XUEHAN
  • ZHANG YUAN
  • XIE DI

Assignees

  • 杭州海康威视数字技术股份有限公司

Dates

Publication Date
20260508
Application Date
20241106

Claims (11)

  1. 1. A method for quantifying an image feature, the method comprising: Obtaining image features of an image to be processed extracted by a deep learning model, and grouping the image features to obtain a plurality of groups of image features; calculating a sharing index and a sharing mantissa corresponding to each group of image features based on the preset sharing index bit width and the preset sharing mantissa bit width; calculating the private index and the private mantissa of each image feature included in each group of image features according to the preset private index bit width, the preset private mantissa bit width, the shared index and the shared mantissa corresponding to the image feature group to which the image feature belongs; And aiming at each group of image features, taking a shared index and a shared mantissa corresponding to the group of image features as a shared part, and taking a symbol, a private index and a private mantissa corresponding to each image feature in the group of image features as a private part to perform nonlinear representation on the group of image features so as to obtain the quantized group of image features.
  2. 2. The method of claim 1, wherein the step of calculating, for each set of image features, the sharing exponent and sharing mantissa corresponding to the set of image features based on the preset sharing exponent bit width and the preset sharing mantissa bit width comprises: Determining the data range of the shared index corresponding to each group of image features based on the data range which can be expressed by the index with the preset shared index bit width, and determining the data range of the shared mantissa corresponding to each group of image features based on the data range which can be expressed by the mantissa with the preset shared mantissa bit width; For each group of image features, calculating an alternative sharing index capable of representing the image feature with the largest numerical value in the group of image features together with a sharing mantissa maximum value, and determining a sharing index corresponding to the group of image features based on the affiliated relation between the alternative sharing index and the data range of the sharing index, wherein the sharing mantissa maximum value is the maximum value in the data range of the sharing mantissa; For each group of image features, calculating an alternative shared mantissa which can jointly represent the image feature with the largest numerical value in the group of image features with the shared index corresponding to the group of image features, and determining the shared mantissa corresponding to the group of image features based on the affiliated relation between the alternative shared mantissa and the data range of the shared mantissa.
  3. 3. The method according to claim 2, wherein the step of calculating, for each image feature included in each group of image features, the private exponent and the private mantissa of the image feature according to the preset private exponent bit width, the preset private mantissa bit width, the shared exponent and the shared mantissa corresponding to the group of image features to which the image feature belongs, includes: Determining the data range of the private index corresponding to each image feature based on the data range which can be expressed by the index with the preset private index bit width, and determining the data range of the private mantissa corresponding to each image feature based on the data range which can be expressed by the mantissa with the preset private mantissa bit width; For each image feature included in each group of image features, calculating an alternative private index capable of jointly representing the image feature by the sharing index and the sharing mantissa corresponding to the group of image features, and determining the private index of the image feature based on the belonging relation between the alternative private index and the data range of the private index; For each image feature included in each set of image features, calculating a shared exponent that can correspond to the set of image features, a shared mantissa, and a private exponent of the image feature together represent an alternative private mantissa of the image feature, and determining the private mantissa of the image feature based on a relationship of the alternative private mantissa to a data range of the private mantissa.
  4. 4. A method according to claim 2 or 3, wherein the target parameters include a shared exponent, a shared mantissa, a private exponent and a private mantissa, the target parameters being determined in a manner comprising: determining the minimum value of the data range corresponding to the target parameter as the target parameter under the condition that the candidate parameter is smaller than the minimum value of the data range corresponding to the target parameter; when the alternative parameter is larger than the maximum value of the data range corresponding to the target parameter, determining the maximum value of the data range corresponding to the target parameter as the target parameter; And determining the alternative parameter as the target parameter under the condition that the alternative parameter is not smaller than the minimum value of the data range corresponding to the target parameter and is not larger than the maximum value of the data range corresponding to the target parameter.
  5. 5. A method according to claim 3, wherein the shared exponent and the shared mantissa are represented in binary encoding; The step of calculating, for each group of image features, an alternative sharing index capable of representing, together with a maximum value of a sharing mantissa, an image feature having a maximum value of the group of image features, and determining a sharing index corresponding to the group of image features based on a relationship between the alternative sharing index and a data range of the sharing index, includes: For each group of image features, calculating a sharing index E s corresponding to the group of image features according to the following formula; Where max (abs (x sub )) is the image feature with the largest absolute value in the set of image features x sub , b ms is the preset shared tail digital width, B es is the predetermined shared exponent bit width for the shared mantissa maximum, A maximum value of a data range for the sharing index; The step of calculating, for each group of image features, an alternative shared mantissa capable of jointly representing an image feature with a largest numerical value in the group of image features with a shared exponent corresponding to the group of image features, and determining the shared mantissa corresponding to the group of image features based on an affiliated relationship between the alternative shared mantissa and a data range of the shared mantissa, includes: For each group of image features, calculating a sharing mantissa M s corresponding to the group of image features according to the following formula;
  6. 6. The method of claim 5, wherein the private exponent and the private mantissa are represented in binary encoding; The step of calculating, for each image feature included in each group of image features, an alternative private exponent capable of representing the image feature in combination with a sharing exponent and a sharing mantissa corresponding to the group of image features, and determining a private exponent of the image feature based on a relationship of the alternative private exponent to a data range of the private exponent, includes: for each image feature included in each set of image features, the image features are calculated according to the following formula Is a private index of (2) Wherein b ep is the preset private exponent bit width, For the ith image feature in the group of image features, i is more than or equal to 0 and less than or equal to n, wherein n is the number of the image features included in each group of image features; the step of calculating, for each image feature included in each group of image features, a shared exponent that can correspond to the group of image features, a shared mantissa, and a private exponent of the image feature together represent an alternative private mantissa of the image feature, and determining a private mantissa of the image feature based on a relationship of the alternative private mantissa and a data range of the private mantissa, includes: for each image feature included in each set of image features, the image features are calculated according to the following formula Is a private index of (2) Wherein b mp is the preset private tail number width.
  7. 7. The method according to claim 6, wherein the step of non-linearly representing each image feature in the group with the shared exponent and the shared mantissa corresponding to the image feature as a shared portion and the sign, the private exponent, and the private mantissa corresponding to each image feature in the group as a private portion for each image feature in the group comprises: for each set of image features, the set of image features is represented according to the following formula: Wherein S n is a symbol corresponding to an nth image feature in the set of image features.
  8. 8. A method according to any one of claims 1-3, wherein the step of grouping the image features to obtain a plurality of sets of image features comprises: And grouping the image features according to the dimension of a processing channel of an image processor running the deep learning model to obtain a plurality of groups of image features.
  9. 9. A method according to any one of claims 1-3, wherein the method further comprises: the deep learning model performs an image processing task by using quantized image features, wherein the image processing task comprises at least one of an image classification task, an image recognition task, an image restoration task and an image segmentation task.
  10. 10. A method according to any of claims 1-3, wherein the deep learning model comprises a multi-layer network module; The step of obtaining the image characteristics of the image to be processed extracted by the deep learning model comprises the following steps: acquiring image features of an image to be processed extracted by a first layer network module of a deep learning model; After the step of obtaining the quantized set of image features, the method further comprises: Taking each quantized group of image features as input data of a next-layer network module, inputting the input data into the next-layer network module, processing the next-layer network module based on the input data, and outputting the image features; and returning to the step of grouping the image features to obtain a plurality of groups of image features until the next layer of network module is the last layer of network module, and obtaining the image features output by the last layer of network module.
  11. 11. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein a computer program which, when executed by a processor, implements the method of any of claims 1-10.

Description

Image characteristic quantization method and storage medium Technical Field The present application relates to the field of model quantization technologies, and in particular, to a quantization method for image features and a storage medium. Background The deployment and operation of the deep learning model typically requires a significant amount of storage and computing resources, and in order to reduce the resource footprint of the deep learning model, the model parameters and the number of bits of output data in between the model may be reduced to quantify the deep learning model. Currently, a deep learning model quantization method for directly weighting the full-precision weight of each network module in a deep learning model into a low-bit weight by using Tang or log nonlinear mapping is proposed in the related art. However, quantization is performed on the deep learning model by using Tang or log nonlinear mapping, so that the difference of the data ranges of different areas of the image cannot be considered, and the model processing precision is reduced. Disclosure of Invention The embodiment of the application aims to provide a quantization method and a storage medium for image features, which are used for quantizing each group of image features extracted by a deep learning model, reflecting the data range difference of the image features of different areas of an image and ensuring the data precision of each image feature. The specific technical scheme is as follows: in a first aspect, an embodiment of the present application provides a method for quantifying an image feature, where the method includes: Obtaining image features of an image to be processed extracted by a deep learning model, and grouping the image features to obtain a plurality of groups of image features; calculating a sharing index and a sharing mantissa corresponding to each group of image features based on the preset sharing index bit width and the preset sharing mantissa bit width; calculating the private index and the private mantissa of each image feature included in each group of image features according to the preset private index bit width, the preset private mantissa bit width, the shared index and the shared mantissa corresponding to the image feature group to which the image feature belongs; And aiming at each group of image features, taking a shared index and a shared mantissa corresponding to the group of image features as a shared part, and taking a symbol, a private index and a private mantissa corresponding to each image feature in the group of image features as a private part to perform nonlinear representation on the group of image features so as to obtain the quantized group of image features. Optionally, the step of calculating, for each set of image features, the sharing exponent and the sharing mantissa corresponding to the set of image features based on the preset sharing exponent bit width and the preset sharing mantissa bit width includes: Determining the data range of the shared index corresponding to each group of image features based on the data range which can be expressed by the index with the preset shared index bit width, and determining the data range of the shared mantissa corresponding to each group of image features based on the data range which can be expressed by the mantissa with the preset shared mantissa bit width; For each group of image features, calculating an alternative sharing index capable of representing the image feature with the largest numerical value in the group of image features together with a sharing mantissa maximum value, and determining a sharing index corresponding to the group of image features based on the affiliated relation between the alternative sharing index and the data range of the sharing index, wherein the sharing mantissa maximum value is the maximum value in the data range of the sharing mantissa; For each group of image features, calculating an alternative shared mantissa which can jointly represent the image feature with the largest numerical value in the group of image features with the shared index corresponding to the group of image features, and determining the shared mantissa corresponding to the group of image features based on the affiliated relation between the alternative shared mantissa and the data range of the shared mantissa. Optionally, the step of calculating, for each image feature included in each group of image features, the private exponent and the private mantissa of the image feature according to the preset private exponent bit width, the preset private mantissa bit width, the shared exponent and the shared mantissa corresponding to the image feature group to which the image feature belongs, includes: Determining the data range of the private index corresponding to each image feature based on the data range which can be expressed by the index with the preset private index bit width, and determining the data range of the private mantiss