Image processing method, device, computer equipment and storage medium

By introducing preset thresholds and integer methods of different discretization methods in neural network image processing, the calculation accuracy problem of floating-point data in the case of uneven data distribution and high accuracy requirements is solved, and low bit width and high precision are achieved. The precision of the integer improves the image processing efficiency and calculation acceleration effect.

CN112269595BActive Publication Date: 2024-09-24TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011172285.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-28
Publication Date
2024-09-24
Estimated Expiration
2040-10-28

AI Technical Summary

Technical Problem

When existing neural network image processing algorithms have uneven data distribution and high accuracy requirements, the floating-point data integer method leads to loss of calculation accuracy and model collapse, and the normalized nearest neighbor fixed-point number in the existing technology is discrete. The calculation accuracy of the method is poor and cannot effectively solve the problems of computing acceleration and storage resource consumption in neural network image processing.

Method used

An image processing method is proposed. By introducing a preset threshold in the integerization process of floating-point data, different discretization methods are used to convert the floating-point data into integer data with a preset bit width, and the identification bit is used to control the data. Transformation method to achieve low-bit width, high-precision integerization, and use specific data transformation methods in the data storage and reading process to expand the storage and representation range of integer data.

Benefits of technology

It effectively controls the bit width of integer data, improves the efficiency of image processing and subsequent feature extraction, achieves computing acceleration and resource optimization, and is suitable for floating-point data processing with uneven data distribution or high precision requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112269595B
    Figure CN112269595B
Patent Text Reader

Abstract

The present disclosure relates to the field of image processing technology, and in particular to an image processing method, apparatus, computer equipment and storage medium. The method comprises: obtaining a target image to be processed; obtaining a neural network model, wherein the neural network model is used to discretize floating-point data of different data ranges using different discretization methods to obtain corresponding integer data of preset bit width; calling the neural network model to process the target image, and outputting image feature data. The embodiment of the present disclosure effectively controls the bit width of integer data during the integerization process of floating-point data, thereby expanding the storage representation range of integer data, that is, realizing low bit width and high precision integerization. At the same time, due to the speed advantage and resource advantage of fixed-point number operations, the calculation is accelerated, thereby improving the efficiency of image processing and the subsequent image feature extraction effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing technology, and in particular to an image processing method, apparatus, computer equipment and storage medium. Background Art

[0002] Image processing algorithms based on neural networks often require deep neural network models to extract image features in order to complete the final classification, detection, recognition and other tasks. In this process, large-scale vector or matrix floating-point multiplication and addition operations will inevitably be introduced. Considering the limitations of computing speed and computing storage resources, it is usually necessary to accelerate the floating-point operations involved in the operation of neural network image processing algorithms.

[0003] Floating point integerization is a means to effectively accelerate the calculation of neural network image processing algorithms and reduce the consumption of computing resources. By converting the floating point numbers (Float 64 / 32) involved in the neural network model to integer numbers (Int32 / 8) and converting floating point operations to integer operations, the data storage space in the neural network image processing algorithm can be greatly reduced and the calculation can be accelerated.

[0004] The related technology usually adopts the method of normalized nearest neighbor fixed-point number discretization. The calculation accuracy of this method is poor, resulting in poor subsequent image feature extraction effect. Currently, a reasonable and effective image processing method has not yet been provided. Summary of the invention

[0005] In view of this, the present disclosure proposes an image processing method, apparatus, computer equipment and storage medium. The technical solution includes:

[0006] According to one aspect of the present disclosure, there is provided an image processing method, the method comprising:

[0007] Obtaining a target image to be processed;

[0008] Obtaining a neural network model, wherein the neural network model is used to discretize floating-point data in different data ranges using different discretization methods to obtain corresponding integer data with a preset bit width;

[0009] The neural network model is called to process the target image and output image feature data.

[0010] In a possible implementation, the floating-point data includes at least one of a weight value, a neuron value, a batch normalization layer value, an activation function value, a back propagation error value, a neuron gradient value, and a weight update value.

[0011] In another possible implementation, the method further includes:

[0012] In the process of calling the neural network model to process the target image, obtaining floating point data in the neural network model;

[0013] When the absolute value of the floating-point data is greater than or equal to a preset threshold, the floating-point data is converted into the integer data of a preset bit width by using a first discretization method;

[0014] When the absolute value of the floating-point data is less than a preset threshold, a second discretization method is used to convert the floating-point data into the integer data of a preset bit width, and the second discretization method is different from the first discretization method.

[0015] In another possible implementation, the preset threshold is a target absolute value maximum, or a value determined based on the target absolute value maximum, or a custom threshold, and the target absolute value maximum is an estimated absolute value maximum of the floating-point data.

[0016] In another possible implementation, the method further includes:

[0017] The flag bit and the data value corresponding to the integer data are stored, wherein the flag bit is used to indicate whether the integer data is greater than or equal to the preset threshold.

[0018] In another possible implementation, the method further includes:

[0019] During the data reading process, when the flag bit is used to indicate that the integer data is greater than or equal to the preset threshold, the read data value is transformed using a first data transformation method to obtain the integer data;

[0020] When the flag bit is used to indicate that the integer data is less than the preset threshold, the read data value is transformed using a second data transformation method to obtain the integer data, and the second data transformation method is different from the first data transformation method.

[0021] According to another aspect of the present disclosure, there is provided an image processing device, the device comprising:

[0022] A first acquisition module, used for acquiring a target image to be processed;

[0023] A second acquisition module is used to acquire a neural network model, wherein the neural network model is used to discretize floating-point data in different data ranges using different discretization methods to obtain corresponding integer data with a preset bit width;

[0024] The calling module is used to call the neural network model to process the target image and output image feature data.

[0025] According to another aspect of the present disclosure, a computer device is provided, the computer device comprising: a processor; a memory for storing processor executable instructions;

[0026] Wherein, the processor is configured to:

[0027] Obtaining a target image to be processed;

[0028] Obtaining a neural network model, wherein the neural network model is used to discretize floating-point data in different data ranges using different discretization methods to obtain corresponding integer data with a preset bit width;

[0029] The neural network model is called to process the target image and output image feature data.

[0030] According to another aspect of the present disclosure, a non-volatile computer-readable storage medium is provided, on which computer program instructions are stored, characterized in that the computer program instructions implement the above method when executed by a processor.

[0031] The disclosed embodiment obtains a target image to be processed; obtains a neural network model, and the neural network model is used to discretize floating-point data in different data ranges using different discretization methods to obtain corresponding integer data with a preset bit width; calls the neural network model to process the target image, and outputs image feature data; in the process of integerizing the floating-point data, the bit width of the integer data can be effectively controlled, and the storage representation range of the integer data can be expanded, that is, low-bit-width and high-precision integerization can be achieved, and at the same time, due to the speed advantage and resource advantage of fixed-point arithmetic, the calculation is accelerated, thereby improving the efficiency of image processing and the subsequent image feature extraction effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure.

[0033] Figure 1 A schematic diagram showing the structure of a computer device provided by an exemplary embodiment of the present disclosure is shown;

[0034] Figure 2 A flowchart of an image processing method provided by an exemplary embodiment of the present disclosure is shown;

[0035] Figure 3 A flowchart of an image processing method provided by another exemplary embodiment of the present disclosure is shown;

[0036] Figure 4 A schematic diagram showing data information of integer data involved in an image processing method provided by another exemplary embodiment of the present disclosure;

[0037] Figure 5 A schematic diagram of the structure of an image processing device provided by an exemplary embodiment of the present disclosure is shown;

[0038] Figure 6 is a block diagram of a terminal according to an exemplary embodiment;

[0039] Figure 7 It is a block diagram of a server according to an exemplary embodiment. DETAILED DESCRIPTION

[0040] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.

[0041] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.

[0042] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.

[0043] With the advent of the big data era and the improvement of computing power, the development of deep learning is in full swing. In the field of image processing algorithms, compared with the previous method of manually extracting image features, the image processing algorithm based on neural networks has achieved unprecedented results. However, the improvement of the performance of neural network image processing algorithms is often accompanied by an increase in the number of parameters and an increase in computing costs. The resulting computing resources and computing speed issues have seriously limited its application on resource-constrained mobile devices. Neural network discretization can effectively reduce the storage space required for neural network parameters and speed up the computing speed of neural networks by performing integer operations on the parameters in the neural network image processing algorithm, converting the floating-point parameters in traditional neural networks into integer parameters, and converting the floating-point operations in traditional neural networks into fixed-point operations.

[0044] Existing discretization methods can better maintain the distribution characteristics of the original data when the data distribution of the neural network image processing algorithm is relatively uniform and the discretization bit width is high. However, when the data distribution range is large (for example, the absolute value distribution range of floating-point data is large) and the distribution is extremely uneven (for example, floating-point data with small absolute values ​​occupy the majority), due to the uneven data distribution, large distribution range and limited integer bit width, the discretization methods in related technologies will integerize the floating-point data with a large proportion of the data but a small absolute value to 0 during the normalization and integerization process of floating-point data, thereby causing the loss of integer data information and a huge difference in the distribution of floating-point data before and after integerization, resulting in a huge loss of accuracy in subsequent calculations and even the collapse of the model calculation results.

[0045] Compared with the traditional method of discretizing normalized nearest-neighbor fixed-point numbers, the embodiments of the present disclosure provide an image processing method, apparatus, computer equipment and storage medium, which can effectively reduce the bit width of the integerized data during the integerization process of floating-point data, expand the storage representation range of integer data, that is, realize low-bit-width, high-precision integerization, and at the same time, due to the speed advantage and resource advantage of fixed-point number operations, the calculation is accelerated, thereby improving the efficiency of image processing and the subsequent image feature extraction effect.

[0046] First, the application scenarios involved in the present disclosure are introduced.

[0047] Please refer to Figure 1 , which shows a schematic diagram of the structure of a computer device provided by an exemplary embodiment of the present disclosure.

[0048] The computer device may be a terminal or a server. The terminal includes a tablet computer, a laptop computer, a desktop computer, etc. The server may be a single server, a server cluster consisting of several servers, or a cloud computing service center.

[0049] The computer device is installed with an image processing program, which is an application program for extracting features from an input target image to obtain image feature data.

[0050] like Figure 1 As shown, the computer device includes a processor 10, a memory 20 and a communication interface 30. Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0051] The processor 10 is the control center of the computer device, and uses various interfaces and lines to connect various parts of the entire computer device. By running or executing software programs and / or modules stored in the memory 20, and calling data stored in the memory 20, the processor 10 performs various functions of the computer device and processes data, thereby controlling the computer device as a whole. The processor 10 can be implemented by a CPU or a graphics processing unit (GPU).

[0052] The memory 20 can be used to store software programs and modules. The processor 10 executes various functional applications and data processing by running the software programs and modules stored in the memory 20. The memory 20 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system 21, a first acquisition module 22, a second acquisition module 23, a call module 24, and an application 25 required for at least one function (such as neural network training, etc.); the data storage area may store data created according to the use of the computer device, etc. The memory 20 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic memory, a flash memory, a magnetic disk or an optical disk. Accordingly, the memory 20 may further include a memory controller to provide the processor 10 with access to the memory 20 .

[0053] The processor 20 executes the following functions by running the first acquisition module 22: acquiring the target image to be processed; the processor 20 executes the following functions by running the second acquisition module 23: acquiring the neural network model, the neural network model is used to discretize the floating-point data of different data ranges by using different discretization methods to obtain the corresponding integer data of the preset bit width; the processor 20 executes the following functions by running the calling module 24: calling the neural network model to process the target image and outputting the image feature data. Optionally, the neural network model discretizes the floating-point data of different data ranges by using different discretization methods to obtain the corresponding integer data of the preset bit width during training, fine-tuning or direct discretization.

[0054] Below, several exemplary embodiments are used to introduce the image processing method provided by the embodiments of the present disclosure.

[0055] Please refer to Figure 2 , which shows a flowchart of an image processing method provided by an exemplary embodiment of the present disclosure. In this embodiment, the method is used for Figure 1 The method is illustrated in the computer device shown in FIG.

[0056] Step 201: Acquire a target image to be processed.

[0057] The computer device obtains an input image, which is a target image to be processed.

[0058] Step 202, obtaining a neural network model, the neural network model is used to discretize floating-point data in different data ranges using different discretization methods to obtain corresponding integer data with a preset bit width.

[0059] The computer device obtains a stored neural network model. The neural network model discretizes floating-point data of different data ranges in the neural network model using different discretization methods during training, fine-tuning or direct discretization to obtain corresponding integer data of a preset bit width.

[0060] Optionally, the neural network model is used to discretize the floating-point data using a discretization method corresponding to the data range where the floating-point data is located to obtain corresponding integer data of a preset bit width. Different data ranges have different corresponding discretization methods.

[0061] Optionally, the neural network model is used to discretize the floating-point data in the first data range using a first discretization method to obtain corresponding integer data of a preset bit width, and to discretize the floating-point data in the second data range using a second discretization method to obtain corresponding integer data of a preset bit width, the second data range does not have an intersection with the first data range, and the first discretization method is different from the second discretization method. Schematically, the floating-point data in the first data range is floating-point data whose absolute value is greater than or equal to a preset threshold, and the floating-point data in the second data range is floating-point data whose absolute value is less than the preset threshold.

[0062] Optionally, the floating point data is a floating point number in a neural network model, also called a floating point tensor. Schematically, the floating point data includes at least one of a weight value, a neuron value, a batch normalization layer value, an activation function value, a back propagation error value, a neuron gradient value, and a weight update value.

[0063] Illustratively, floating-point data may also include floating-point numbers in other large-scale tensor (such as matrix, 3D tensor, etc.) operations.

[0064] Optionally, the neural network model is a neural network image processing model, and the neural network model includes any one of an artificial neural network, a recurrent neural network, a long short-term memory neural network, a deep reinforcement learning network, a graph neural network, and a tensor neural network in a neural network image processing algorithm. The disclosed embodiment does not limit the type of the neural network model.

[0065] Optionally, the converted integer data is integer data of a preset bit width, and the preset bit width is less than a preset bit width threshold, for example, the preset bit width is 8 bits or 16 bits. The embodiment of the present disclosure does not limit the value of the preset bit width.

[0066] Step 203, calling the neural network model to process the target image and outputting image feature data.

[0067] The computer device calls the neural network model to process the target image and outputs image feature data. That is, the computer device inputs the target image into the neural network model and outputs image feature data. The image feature data is used to indicate the image features of the target image.

[0068] Optionally, in the process of calling the neural network model to process the target image, the floating point data in the neural network model is obtained; according to the data range where the floating point data is located, the floating point data is converted into integer data of a preset bit width using a discretization method corresponding to the data range. Different data ranges have different corresponding discretization methods.

[0069] Optionally, when the absolute value of the floating-point data is greater than or equal to a preset threshold, a first discretization method is used to convert the floating-point data into integer data of a preset bit width; when the absolute value of the floating-point data is less than the preset threshold, a second discretization method is used to convert the floating-point data into integer data of a preset bit width, and the second discretization method is different from the first discretization method.

[0070] Optionally, for any one of the multiple convolutional layers of the neural network, the computer device obtains the floating-point data of the convolutional layer. When the absolute value of the floating-point data is greater than or equal to a preset threshold, the floating-point data is converted into integer data of a preset bit width using a first discretization method; when the absolute value of the floating-point data is less than the preset threshold, the floating-point data is converted into integer data of a preset bit width using a second discretization method. The output data of the convolutional layer is obtained according to the floating-point data of the convolutional layer and the input data of the target image.

[0071] Optionally, the preset threshold is a target absolute value maximum value, or a value determined based on the target absolute value maximum value, or a custom threshold value, and the target absolute value maximum value is an estimated absolute value maximum value of floating-point data.

[0072] Illustratively, the target absolute maximum value is the absolute maximum value of the floating-point data estimated based on the target fixed-point number, and the target fixed-point number is the fixed-point number closest to the absolute maximum value of the floating-point data.

[0073] For example, the preset threshold is a value that is proportional to the maximum absolute value of the target.

[0074] In summary, the disclosed embodiment obtains a target image to be processed; obtains a neural network model, and the neural network model is used to discretize floating-point data of different data ranges using different discretization methods to obtain corresponding integer data of preset bit width; calls the neural network model to process the target image, and outputs image feature data; the bit width of the integer data can be effectively controlled during the integerization of floating-point data, and the storage representation range of the integer data can be expanded, that is, low-bit-width, high-precision integerization can be achieved. At the same time, due to the speed advantage and resource advantage of fixed-point arithmetic, the calculation is accelerated, and the efficiency of image processing and the subsequent image feature extraction effect are improved. The image processing method provided by the disclosed embodiment can not only be used for the discretization of floating-point data with relatively uniform data distribution, but is also more effectively suitable for the discretization of floating-point data with uneven data distribution or high precision requirements.

[0075] In terms of application, the image processing method provided by the embodiment of the present disclosure can, on one hand, effectively solve the problem of neural network data representation accuracy and convergence in the current neural network image processing process, and can be applied to the integerization of various floating-point data such as weight values, neuron values, batch normalization layer values, activation function values, back propagation error values, neuron gradient values, weight update values, etc., thereby improving the performance of the neural network. On the other hand, compared with the current image processing method, the embodiment of the present disclosure can be combined with the current mainstream deep learning acceleration chip to convert the multiplication and addition operations of floating-point data into the multiplication and addition operations of integer data, which can greatly reduce the chip area and energy consumption, and has a great driving effect on the design of deep learning forward calculation and online training chip architecture. On the other hand, the huge computing acceleration and resource consumption advantages brought by the embodiment of the present disclosure can push the current neural network image processing algorithm model from expensive server clusters to portable embedded devices such as mobile phones and smart terminals. On the other hand, the image processing method provided by the embodiment of the present disclosure has high universality and can be widely used in artificial neural networks, recurrent neural networks, long short-term memory neural networks, deep reinforcement learning networks, graph neural networks, tensor neural networks and other models in neural network image processing algorithms.

[0076] In a possible implementation, in the process of calling the neural network model to process the target image, for the floating-point data in the neural network model, the main process includes three parts: floating-point data discretization method, storage of discretized integer data containing identification bits, and reading of discretized integer data containing identification bits, thereby realizing computational acceleration and data storage compression for neural network image processing. The image processing method includes but is not limited to the following steps, such as Figure 3 As shown:

[0077] Step 301, in the process of calling the neural network model to process the target image, the computer device discretizes the floating-point data in different data ranges in the neural network model using different discretization methods to obtain corresponding integer data with a preset bit width.

[0078] Optionally, in the process of calling the neural network model to process the target image, floating-point data in the neural network model is obtained; when the absolute value of the floating-point data is greater than or equal to a preset threshold, a first discretization method is used to convert the floating-point data into integer data of a preset bit width; when the absolute value of the floating-point data is less than the preset threshold, a second discretization method is used to convert the floating-point data into integer data of a preset bit width, and the second discretization method is different from the first discretization method.

[0079] Optionally, the computer device calculates the corresponding integer data of the preset bit width by the following formula:

[0080] in,

[0081]

[0082]

[0083] Wherein, x is the floating-point data in the neural network model; Sc(x,k) is the preset threshold, which is a value determined based on the target absolute value maximum; R(x) is the target absolute value maximum, which is the estimated absolute value maximum of the floating-point data; round(·) is the rounding function; clip(·) is the clipping function used to control the data representation range; k is the preset bit width after discretization.

[0084] In the process of converting floating-point data into integer data of a preset bit width by a computer device, the rounding function used may be a rounding function, such as a round(·) function; the rounding function may also be an upward rounding function, such as a ceil(·) function; the rounding function may also be a downward rounding function, such as a floor(·) function. The embodiments of the present disclosure are not limited to this.

[0085] A preset threshold is introduced through a threshold function, and different discretization methods are adopted for the discretization of floating-point data in the neural network image processing algorithm. While maintaining the original discretization accuracy of floating-point data greater than or less than the preset threshold, the discretization accuracy of floating-point data less than the preset threshold is increased, thereby increasing the representation range of the data.

[0086] In an illustrative example, taking k-bit discretization as an example, in the neural network image processing algorithm, for the floating-point data x in the neural network model, the discretization representation range in the related art is This discretization method will convert the data range into The data is discretized to 0, resulting in the loss of information in this part of the data. When the floating-point data x in the neural network image processing algorithm is distributed more in this part or the required precision is higher, the discretized integer data will cause huge calculation errors.

[0087] The embodiment of the present disclosure adopts different discretization methods for floating-point data of different data ranges by introducing a preset threshold. When the absolute value of the floating-point data in the neural network image processing algorithm is greater than or equal to the preset threshold, the floating-point data is discretized into {-2 k-1 +1,-2 k-1 +2,…,-1,0,1,…,2 k-1 -1}; when the absolute value of the floating-point data is less than the preset threshold, the floating-point data is discretized into The data representation range of the discretization method provided in the embodiment of the present disclosure is:

[0088]

[0089] This discretization method will convert the data range into The data is discretized to 0, compared with the discretization method in the related art that the data range is The data is discretized to 0. The method provided by the embodiment of the present disclosure has higher discretization accuracy and smaller zeroing range. For floating-point data in an interval, this method can achieve the same discretization data accuracy as the traditional (2k-1)-bit discretization under the condition of k-bit discretization. For floating-point data with uneven data distribution or high precision requirements, the discretization can better maintain data accuracy.

[0090] Step 302: Store a flag bit and a data value corresponding to the integer data, where the flag bit is used to indicate whether the integer data is greater than or equal to a preset threshold.

[0091] In order to cooperate with the above-mentioned neural network image processing algorithm parameter discretization method, the embodiment of the present disclosure provides a new data storage method. On the basis of traditional binary data storage, an identification bit is introduced in the data storage to determine whether the integer data is greater than or equal to a preset threshold to read the data after discretization.

[0092] Optionally, after converting the floating-point data into integer data of a preset bit width, the computer device stores data information of the integer data.

[0093] Optionally, data information corresponding to a plurality of integer data are stored in the computer device.

[0094] The data information of the integer data includes a flag bit and a data value corresponding to the integer data, and the flag bit is used to indicate whether the integer data is greater than or equal to a preset threshold.

[0095] Optionally, when the value of the flag is a first value, it is used to indicate that the integer data is greater than or equal to a preset threshold value, and when the value of the flag is a second value, it is used to indicate that the integer data is less than the preset threshold value. For example, the first value is 1 and the second value is 0. For another example, the first value is 0 and the second value is 1. The embodiment of the present disclosure does not limit the setting method of the flag, and the setting of the flag only needs to be consistent during the storage and reading process.

[0096] Optionally, the data information of the integer data includes a flag bit and a data value, and the data value is the value of the positive and negative flag bit and the data bit. The flag bit is the Flag bit, the positive and negative flag bits are the Sign bit, and the data bit is the Data bit. The flag bit can be stored in a specified position, before the positive and negative flag bits, or between the positive and negative flag bits and the data bits.

[0097] In an illustrative example, Figure 4 As shown, the data information of the integer data includes the flag bit, the positive and negative flag bit and the data bit in sequence, that is, the flag bit is before the positive and negative flag bit. The value of the flag bit is 0, which is used to indicate that the integer data is greater than or equal to the preset threshold; the value of the positive and negative flag bit is 1, which is used to indicate that the integer data is a positive number; the data bit includes a binary value of k-1 bits.

[0098] The embodiment of the present disclosure does not limit the storage location of the identification bit, and it only needs to be consistent during the storage and reading process.

[0099] Optionally, the data information of the integer data also includes a preset threshold corresponding to the integer data.

[0100] Step 303: During the data reading process, the computer device transforms the read data value according to the identification bit to obtain the corresponding integer data.

[0101] Optionally, during the data reading process, the computer device transforms the read data value using a data change method corresponding to the identification bit corresponding to the data value to obtain corresponding integer data. That is, the computer device transforms data values ​​with different identification bits using different data transformation methods to obtain respective corresponding integer data.

[0102] Optionally, during the data reading process, when the flag is used to indicate that the integer data is greater than or equal to a preset threshold, the read data value is transformed using a first data transformation method to obtain the integer data. When the flag is used to indicate that the integer data is less than the preset threshold, the read data value is transformed using a second data transformation method to obtain the integer data, and the second data transformation method is different from the first data transformation method.

[0103] In a possible implementation, the first data change mode is used to indicate that the read data value is multiplied by a preset threshold value to obtain integer data. The second data change mode is used to indicate that the read data value is divided by a first value to obtain a divisor, and the divisor is multiplied by the preset threshold value to obtain integer data, where the first value is 2 to the power of k-1, and k is a preset bit width.

[0104] Schematically, the computer device reads the discretized integer data x through the following formula q :

[0105]

[0106] Among them, Sc is the preset threshold, x read is the data value, that is, the data value of the positive and negative flag bits and the data bits are read according to the traditional binary system, and k is the preset bit width of the discretization.

[0107] In summary, the image processing method provided by the embodiment of the present disclosure achieves computational acceleration and resource reduction in the image processing process by improving the floating-point data integerization method and data storage representation method in the neural network image processing process. The image processing method provided by the embodiment of the present disclosure involves two processes: integerization of floating-point data in the neural network image processing algorithm and storage representation of integer data. Floating-point data integerization converts floating-point data into integer data with a determined bit width by introducing a specific data integerization function; the storage representation of integer data reduces the data bit width and increases the data representation range by introducing an identification bit. For the integerization of floating-point data with uneven data distribution or high precision requirements, the embodiment of the present disclosure can greatly improve the calculation speed and calculation accuracy of large-scale floating-point data operations in the neural network image processing algorithm at a very low storage and calculation cost, and improve the distribution similarity between integer data and original floating-point data. The embodiment of the present disclosure can be widely used in the parameter integerization of artificial intelligence algorithms such as artificial neural networks, long short-term memory neural networks, reinforcement learning, graph neural networks, tensor neural networks, etc. in the neural network image processing algorithm, reduce algorithm storage and computing resource consumption, reduce chip area and energy consumption, and improve chip calculation speed. Based on the reduction in computing resources and the improvement in computing speed brought about by the embodiments of the present disclosure, related applications involving the above-mentioned neural network image processing algorithm, such as image classification, recognition, tracking and other applications, can be transferred from server GPU computing clusters with high computing costs and huge energy consumption to embedded intelligent terminals, thereby expanding the scope of application of related applications involving neural network image processing algorithms.

[0108] The following is an apparatus embodiment of the present disclosure. For parts not described in detail in the apparatus embodiment, reference may be made to the technical details disclosed in the above method embodiment.

[0109] Please refer to Figure 5 , which shows a schematic diagram of the structure of an image processing device provided by an exemplary embodiment of the present disclosure. The image processing device can be implemented as all or part of a computer device through software, hardware, or a combination of the two. The device includes: a first acquisition module 510, a second acquisition module 520, and a calling module 530.

[0110] A first acquisition module 510 is used to acquire a target image to be processed;

[0111] A second acquisition module 520 is used to acquire a neural network model, where the neural network model is used to discretize floating-point data in different data ranges using different discretization methods to obtain corresponding integer data with a preset bit width;

[0112] The calling module 530 is used to call the neural network model to process the target image and output the image feature data.

[0113] In one possible implementation, the floating-point data includes at least one of a weight value, a neuron value, a batch normalization layer value, an activation function value, a back propagation error value, a neuron gradient value, and a weight update value.

[0114] In another possible implementation, the device further includes: a processing module; the processing module is configured to:

[0115] In the process of calling the neural network model to process the target image, the floating point data in the neural network model is obtained;

[0116] When the absolute value of the floating-point data is greater than or equal to a preset threshold, the floating-point data is converted into integer data of a preset bit width using a first discretization method;

[0117] When the absolute value of the floating-point data is less than a preset threshold, a second discretization method is used to convert the floating-point data into integer data of a preset bit width, and the second discretization method is different from the first discretization method.

[0118] In another possible implementation, the preset threshold is a target absolute value maximum, or a value determined based on the target absolute value maximum, or a custom threshold, and the target absolute value maximum is an estimated absolute value maximum of floating-point data.

[0119] In another possible implementation, the device further includes: a storage module; the storage module is used to store a flag bit and a data value corresponding to the integer data, the flag bit being used to indicate whether the integer data is greater than or equal to a preset threshold.

[0120] In another possible implementation, the device further includes: a reading module; the reading module is used to:

[0121] During the data reading process, when the flag bit is used to indicate that the integer data is greater than or equal to a preset threshold, the read data value is transformed using a first data transformation method to obtain integer data;

[0122] When the flag bit is used to indicate that the integer data is less than a preset threshold, the read data value is transformed using a second data transformation method to obtain the integer data, and the second data transformation method is different from the first data transformation method.

[0123] It should be noted that the device provided in the above embodiment only uses the division of the above-mentioned functional modules as an example to implement its functions. In practical applications, the above-mentioned functions can be assigned to different functional modules according to actual needs, that is, the content structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0124] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0125] The embodiment of the present disclosure further provides a computer device, which includes: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to: implement the steps executed by the computer device in the above-mentioned various method embodiments.

[0126] Optionally, the computer device is a terminal or a server.

[0127] The embodiments of the present disclosure further provide a non-volatile computer-readable storage medium on which computer program instructions are stored. When the computer program instructions are executed by a processor, the methods in the above-mentioned various method embodiments are implemented.

[0128] Figure 6 6 is a block diagram of a terminal 600 according to an exemplary embodiment. For example, the terminal 600 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0129] Reference Figure 6 The terminal 600 may include one or more of the following components: a processing component 602 , a memory 604 , a power component 606 , a multimedia component 608 , an audio component 610 , an input / output (I / O) interface 612 , a sensor component 614 , and a communication component 616 .

[0130] The processing component 602 generally controls the overall operation of the terminal 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.

[0131] The memory 604 is configured to store various types of data to support operations at the terminal 600. Examples of such data include instructions for any application or method operating on the terminal 600, contact data, phone book data, messages, pictures, videos, etc. The memory 604 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0132] The power supply component 606 provides power to various components of the terminal 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the terminal 600.

[0133] The multimedia component 608 includes a screen that provides an output interface between the terminal 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the terminal 600 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0134] The audio component 610 is configured to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC), and when the terminal 600 is in an operation mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 604 or sent via the communication component 616. In some embodiments, the audio component 610 also includes a speaker for outputting audio signals.

[0135] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0136] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the terminal 600. For example, the sensor assembly 614 can detect the open / closed state of the terminal 600, the relative positioning of the components, such as the display and keypad of the terminal 600, and the sensor assembly 614 can also detect the position change of the terminal 600 or a component of the terminal 600, the presence or absence of contact between the user and the terminal 600, the orientation or acceleration / deceleration of the terminal 600, and the temperature change of the terminal 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 614 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0137] The communication component 616 is configured to facilitate wired or wireless communication between the terminal 600 and other devices. The terminal 600 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0138] In an exemplary embodiment, terminal 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.

[0139] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 604 including computer program instructions, which can be executed by a processor 620 of a terminal 600 to perform the above method.

[0140] Figure 7 FIG. 7 is a block diagram of a server 700 according to an exemplary embodiment. Figure 7The server 700 includes a processing component 722, which further includes one or more processors, and a memory resource represented by a memory 732 for storing instructions, such as applications, that can be executed by the processing component 722. The application stored in the memory 732 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 722 is configured to execute instructions to perform the above method.

[0141] The server 700 may also include a power supply component 726 configured to perform power management of the server 700, a wired or wireless network interface 750 configured to connect the server 700 to a network, and an input / output (I / O) interface 758. The server 700 may operate based on an operating system stored in the memory 732, such as Windows Server™, MacOS X™, Unix™, Linux™, FreeBSD™, or the like.

[0142] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 732 including computer program instructions that can be executed by the processing component 722 of the server 700 to perform the above method.

[0143] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.

[0144] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.

[0145] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0146] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.

[0147] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.

[0148] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0149] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0150] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.

[0151] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims

1. An image processing method, characterized in that: The method comprises: Obtaining a target image to be processed; Obtaining a neural network model, and discretizing floating-point data in different data ranges in the neural network model using different discretization methods to obtain corresponding integer data with a preset bit width; Calling the neural network model to process the target image and outputting image feature data; The method further comprises: In the process of calling the neural network model to process the target image, obtaining floating point data in the neural network model; When the absolute value of the floating-point data is greater than or equal to a preset threshold, the floating-point data is converted into the integer data of a preset bit width by using a first discretization method; When the absolute value of the floating-point data is less than a preset threshold, the floating-point data is converted into the integer data of a preset bit width using a second discretization method, where the second discretization method is different from the first discretization method; Storing a flag bit and a data value corresponding to the integer data, the flag bit being used to indicate whether the integer data is greater than or equal to the preset threshold; The corresponding integer data Q(x, k) of preset bit width is calculated by the following formula: in, Among them, x is the floating-point data in the neural network model, Sc(x,k) is the preset threshold, R(x) is the target absolute maximum value, the target absolute maximum value is the estimated absolute maximum value of the floating-point data, round is the rounding function, clip is the truncation function, and k is the preset bit width after discretization.

2. The method according to claim 1, characterized in that The floating-point data includes at least one of weight values, neuron values, batch normalization layer values, activation function values, back propagation error values, neuron gradient values, and weight update values.

3. The method according to claim 1, characterized in that The preset threshold is a target absolute value maximum value, or a value determined based on the target absolute value maximum value, or a custom threshold value, and the target absolute value maximum value is an estimated absolute value maximum value of the floating-point data.

4. The method according to claim 1, characterized in that: The method further comprises: During the data reading process, when the flag bit is used to indicate that the integer data is greater than or equal to the preset threshold, the read data value is transformed using a first data transformation method to obtain the integer data; When the flag bit is used to indicate that the integer data is less than the preset threshold, the read data value is transformed using a second data transformation method to obtain the integer data, and the second data transformation method is different from the first data transformation method.

5. An image processing device, characterized in that: The device comprises: A first acquisition module, used for acquiring a target image to be processed; A second acquisition module is used to acquire a neural network model, and discretize floating-point data of different data ranges in the neural network model using different discretization methods to obtain corresponding integer data of preset bit width; A calling module, used for calling the neural network model to process the target image and output image feature data; The device further comprises: a processing module, configured to: In the process of calling the neural network model to process the target image, obtaining floating point data in the neural network model; When the absolute value of the floating-point data is greater than or equal to a preset threshold, the floating-point data is converted into the integer data of a preset bit width by using a first discretization method; When the absolute value of the floating-point data is less than a preset threshold, the floating-point data is converted into the integer data of a preset bit width using a second discretization method, where the second discretization method is different from the first discretization method; The device further comprises: a storage module, configured to store a flag bit and a data value corresponding to the integer data, wherein the flag bit is used to indicate whether the integer data is greater than or equal to the preset threshold; The corresponding integer data Q(x, k) of preset bit width is calculated by the following formula: in, Among them, x is the floating-point data in the neural network model, Sc(x,k) is the preset threshold, R(x) is the target absolute maximum value, the target absolute maximum value is the estimated absolute maximum value of the floating-point data, round is the rounding function, clip is the truncation function, and k is the preset bit width after discretization.

6. A computer device, characterized in that: The computer device comprises: a processor; a memory for storing instructions executable by the processor; Wherein, the processor is configured to: Obtaining a target image to be processed; Obtaining a neural network model, and discretizing floating-point data in different data ranges in the neural network model using different discretization methods to obtain corresponding integer data with a preset bit width; Calling the neural network model to process the target image and outputting image feature data; In the process of calling the neural network model to process the target image, obtaining floating point data in the neural network model; When the absolute value of the floating-point data is greater than or equal to a preset threshold, the floating-point data is converted into the integer data of a preset bit width by using a first discretization method; When the absolute value of the floating-point data is less than a preset threshold, the floating-point data is converted into the integer data of a preset bit width using a second discretization method, where the second discretization method is different from the first discretization method; Storing a flag bit and a data value corresponding to the integer data, the flag bit being used to indicate whether the integer data is greater than or equal to the preset threshold; The corresponding integer data Q(x, k) of preset bit width is calculated by the following formula: in, Among them, x is the floating-point data in the neural network model, Sc(x,k) is the preset threshold, R(x) is the target absolute maximum value, the target absolute maximum value is the estimated absolute maximum value of the floating-point data, round is the rounding function, clip is the truncation function, and k is the preset bit width after discretization.

7. A non-volatile computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 4 is implemented.