Image compression method and apparatus, electronic device, computer program product, and storage medium
Through the combination of image transformation network, super prior network and context network of the image processing model, using super prior probability and transfer window attention mechanism, the problem of low image compression efficiency in the existing technology is solved, and more efficient image processing is achieved Compression and smaller storage size.
Patent Information
- Application Number
- PCT/CN2023/138206
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-09
- Filing Date
- 2023-12-12
- Publication Date
- 2024-09-12
AI Technical Summary
In the existing technology, when compressing images, the convolutional network has limited ability to transform images, resulting in a low compression rate, and the serial decoding efficiency of the context model is low, making it difficult to effectively improve image compression efficiency and quality.
Use image processing models, including image transformation network, super-prior network and context network, to encode and decode the image to be compressed, perform partial decoding through super-prior probability estimates, and use the transfer window attention mechanism and autoregressive prediction to generate compressed Post-image, reducing information redundancy and improving compression efficiency.
It improves the efficiency and quality of image compression, makes the compressed image smaller, reduces storage costs, and saves time in the compression process.
Smart Images

Figure CN2023138206_12092024_PF_FP_ABST
Abstract
Description
Image compression method, device, electronic device, computer program product, and storage medium
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application is based on the Chinese patent application with application number 2023101368433 and application date of February 9, 2023, and claims the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby introduced into this application as a reference. Technical Field
[0003] The present application relates to computer technology, and in particular to an image compression method, device, electronic device, computer program product, and computer storage medium. Background Art
[0004] In the related art, deep neural networks have achieved excellent performance in many computer vision tasks. However, when compressing images through neural network models, these technologies use basic convolutional networks to transform the images. When the compression rate is low, latent variables need to be recovered from the byte stream to reconstruct a high-quality image. However, the capabilities of the image nonlinear transformation network limit the network's ability to reconstruct high-quality images. Furthermore, the context model in these technologies uses PixelCNN serial decoding, resulting in low image compression efficiency.
[0005] Summary of the Invention
[0006] In view of this, the embodiments of the present application provide an image compression method, device, electronic device, computer program product and computer storage medium, which can improve the efficiency of image compression by utilizing the image processing model. At the same time, the compressed image has a smaller volume, thereby reducing the storage cost of the image.
[0007] The technical solution of the embodiment of the present application is implemented as follows:
[0008] An embodiment of the present application provides an image compression method, the method comprising:
[0009] Encoding the image to be compressed to obtain a first latent variable corresponding to the image to be compressed;
[0010] Determining a super-prior probability estimate corresponding to the first latent variable;
[0011] Partially decoding the first latent variable according to the super-prior probability estimate to obtain a partial decoding result of the first latent variable;
[0012] Based on the partial decoding result of the first latent variable and the first latent variable corresponding to the image to be compressed, a compressed image corresponding to the image to be compressed is generated, where the data amount of the compressed image is smaller than the data amount of the image to be compressed.
[0013] The present application also provides an image compression device, comprising:
[0014] an encoding module configured to encode the image to be compressed to obtain a first latent variable corresponding to the image to be compressed;
[0015] an information processing module configured to determine a super-prior probability estimate corresponding to the first latent variable;
[0016] The information processing module is further configured to partially decode the first latent variable according to the super-prior probability estimate to obtain a partial decoding result of the first latent variable;
[0017] The information processing module is further configured to generate a compressed image corresponding to the image to be compressed based on a partial decoding result of the first latent variable and the first latent variable corresponding to the image to be compressed, wherein the data volume of the compressed image is smaller than the data volume of the image to be compressed.
[0018] The present application also provides an electronic device, wherein the training device includes:
[0019] a memory configured to store executable instructions;
[0020] The processor is configured to implement the aforementioned image compression method when running the executable instructions stored in the memory.
[0021] An embodiment of the present application also provides a computer program product, which implements the aforementioned image compression method when the computer program or instructions are executed by a processor.
[0022] An embodiment of the present application further provides a computer-readable storage medium storing executable instructions, which implement the aforementioned image compression method when executed by a processor.
[0023] The embodiments of the present application have the following beneficial effects:
[0024] The embodiment of the present application encodes the image to be compressed to obtain a first latent variable, and determines a super-prior probability estimate based on the first latent variable; if the encoded first latent variable obeys a certain inherent prior probability, the obtained super-prior probability estimate can be used as a reference for subsequent partial decoding, making the decoding result obtained by decoding more accurate, while improving the performance of image compression, making the compressed image smaller after decoding, and reducing the storage cost of the image. Based on the super-prior probability estimate, the first latent variable is partially decoded to obtain a partial decoding result; partially decoding the first latent variable, that is, decoding a portion of the pixels, so that when other pixels are subsequently decoded, prediction (decoding) can be made based on the partial decoding result, thus saving the time spent on compressing the image and improving the compression efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] FIG1 is a schematic diagram of an environment in which an image compression method is used according to an embodiment of the present application;
[0026] FIG2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0027] FIG3A is a flowchart diagram 1 of an image compression method provided in an embodiment of the present application;
[0028] FIG3B is a second flow chart of the image compression method provided in an embodiment of the present application;
[0029] FIG4 is a schematic diagram of data flow of an image processing model provided in an embodiment of the present application;
[0030] FIG5 is a schematic diagram of the model structure of the image processing model provided in an embodiment of the present application;
[0031] FIG6 is a schematic diagram of the working process of the space-depth conversion layer and the depth-space conversion layer provided in an embodiment of the present application;
[0032] FIG7 is a schematic diagram of the composition structure of the transfer window attention mechanism module provided in an embodiment of the present application;
[0033] FIG8 is a schematic diagram of the calculation principle of the transfer window attention mechanism module provided in an embodiment of the present application;
[0034] FIG9 is a schematic diagram of an autoregressive context network provided by an embodiment of the present application;
[0035] FIG10 is a flow chart of an image processing model training method provided in an embodiment of the present application;
[0036] FIG11 is a schematic diagram of an effect test of the image processing model provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solutions and advantages of this application clearer, this application will be described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limiting this application. All other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0038] In the following description, reference is made to “some embodiments”, which describes a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0039] Before describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.
[0040] 1) Wasserstein distance: A distance metric function used to measure the difference between two distributions.
[0041] 2) Artificial Neural Network: Neural Network (NN) for short, in the field of machine learning and cognitive science, is a mathematical model or computational model that imitates the structure and function of biological neural networks and is used to estimate or approximate functions.
[0042] 3) Model parameters: These are quantities that use universal variables to establish the relationship between functions and variables. In artificial neural networks, model parameters are usually real number matrices.
[0043] 4) Model training: Multi-classification learning is performed on image datasets. This model can be built using deep learning frameworks such as TensorFlow and Torch, using multiple layers of neural network layers such as CNN to form a multi-image classification model. The model input is a three-channel or original channel matrix of images read using tools such as OpenCV. The model output is multi-class probabilities, and the final image compression result is output using algorithms such as softmax. During training, the model approaches the correct trend using objective functions such as cross entropy.
[0044] 5) Variational Autoencoder (VAE). A variational autoencoder is a commonly used network architecture in image compression. It transforms a high-dimensional input image to generate a low-dimensional latent variable (latent code). The latent variable obeys certain inherent prior probabilities, and the input image obeys conditional probabilities conditioned on the latent variable. The low-dimensional variable can describe the information contained in the input image and can reconstruct the high-dimensional input image through sampling. When compressing an image, the variational autoencoder compresses the low-dimensional latent variable, reducing information redundancy.
[0045] 6) Hyper prior. Based on the latent variables obtained by the encoder from the input image, the hyper prior uses a lightweight network to create a scalar entropy model for each point in the latent variables. The entropy model of the eigenvalues is used to obtain the occurrence of feature points for bitrate estimation and entropy coding. The hyper prior stores the probabilistic modeling of the latent variables in a smaller byte size. During decoding, the byte stream stored by the hyper prior module is first decoded. The latent variables are then restored using the probabilities decoded from the byte stream to reconstruct the image.
[0046] 7) Context Model. Context models typically use an autoregressive approach, leveraging decoded pixel information to predict undecoded pixel information and reduce information redundancy. Commonly used autoregressive models utilize sliding window linear serial prediction, and their complexity increases exponentially with the dimensionality of the input data. While autoregressive context models can significantly improve model performance, they also significantly increase the computational complexity of the compression model.
[0047] 8) Entropy Coding: This is a lossless coding method that does not lose any information during the encoding process according to the entropy principle. It is also a key module in lossy coding and is located at the end of the encoder. Information entropy is the average amount of information in the source (a measure of uncertainty). Common entropy coding methods include Shannon coding, Huffman coding, Exp-Golomb coding, and arithmetic coding. Since entropy coding uses the symbols to be encoded after the encoder performs a series of operations such as quantization, transformation, motion, and prediction, and an appropriate entropy coding model is selected based on the distribution of the encoded symbols, entropy coding is a relatively independent unit that can be applied not only to video encoding and decoding, but also to other encoders such as image coding and point cloud coding.
[0048] Before introducing the image compression method provided by the embodiments of the present application, the defects of the image compression methods in the related art are first explained. In the related art, the image coding method requires manual setting of image features. For example, JPEG, BPG and VVC-intra use orthogonal linear transformations, such as discrete cosine transform (DCT) and discrete wavelet transform (DWT) to decorrelate the image pixels before quantization and encoding. Among them, JPEG compression compresses Y, Cb, and Cr separately based on the premise that the human eye is sensitive to color but more sensitive to brightness. For example, for a natural image, JPEG performs DCT decomposition on each 8*8 patch and obtains 64 DCT parameters. According to the energy aggregation principle, the more important parameters are basically concentrated in the low-frequency area, so the image can be restored to an acceptable quality range without all parameters. After quantizing the DCT parameters, variable-length coding and Huffman coding can be used to compress redundancy. However, when the compression rate is low, it is necessary to recover the latent variables from the byte stream to reconstruct a high-quality image, and the capacity of the image nonlinear transformation network limits the network's ability to reconstruct a high-quality image. At the same time, the context model in the related art uses PixelCNN serial decoding, which has low decoding efficiency.
[0049] Based on this, an embodiment of the present application provides an image compression method, which compresses images using an image processing model including an image transformation network, a hyper-prior network and a context network, thereby improving compression efficiency and the quality of the compressed image.
[0050] FIG1 is a schematic diagram of a usage scenario of the image compression method provided in an embodiment of the present application. Referring to FIG1 , a client having an image processing function or a client having a video processing function is provided on the terminal (including terminal 10-1 and terminal 10-2). The user can input the corresponding image to be processed through the provided image processing client, and the image processing client can also receive the corresponding compressed image and display the received compressed image to the user; the video processing client can compress each frame of the video through the image processing model provided in an embodiment of the present application to reduce the server storage space occupied by the video. The terminal is connected to the server 200 via a network 300. The network 300 can be a wide area network or a local area network, or a combination of the two, and a wireless link is used to realize data transmission.
[0051] As an example, the server 200 is configured to deploy an image processing model and train the image processing model to determine the network parameters of the image transformation network, the hyper-prior network and the context network in the image processing model; and after the image processing model training is completed, the compressed image corresponding to the image to be processed generated by the image processing model is displayed through the terminal (terminal 10-1 and / or terminal 10-2).
[0052] Of course, before compressing the image to be processed through the image processing model, the image processing model needs to be trained to determine the network parameters of the image transformation network, the super prior network and the context network.
[0053] The following is a detailed description of the structure of an electronic device that implements the image compression method provided in the embodiments of the present application. The electronic device can be implemented in various forms, such as a dedicated terminal with an image compression function, or a server equipped with an image compression function, such as the server 200 in Figure 1. Figure 2 is a schematic diagram of the composition structure of the electronic device provided in the embodiments of the present application. It should be understood that Figure 2 only shows an exemplary structure of the electronic device and not the entire structure. As needed, part or all of the structure shown in Figure 2 can be implemented.
[0054] The electronic device provided in an embodiment of the present application includes: at least one processor 201, a memory 202, a user interface 203, and at least one network interface 204. The various components in the electronic device 20 are coupled together via a bus system 205. It will be appreciated that the bus system 205 is configured to enable connections and communications between these components. In addition to a data bus, the bus system 205 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in FIG. 2 , all of the various buses are labeled as the bus system 205.
[0055] The user interface 203 may include a display, a keyboard, a mouse, a trackball, a click wheel, keys, buttons, a touch pad or a touch screen.
[0056] It is understood that the memory 202 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. The memory 202 in the embodiment of the present application can store data to support the operation of the terminal (such as 10-1). Examples of these data include: any computer program for operating on the terminal (such as 10-1), such as an operating system and an application. Among them, the operating system includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application can include various applications.
[0057] In some embodiments, the image compression device provided in the embodiments of the present application can be implemented in a combination of software and hardware. As an example, the image compression device provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the image compression method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.
[0058] As an example of an image compression device provided in an embodiment of the present application being implemented by a combination of software and hardware, the image compression device provided in an embodiment of the present application can be directly embodied as a combination of software modules executed by a processor 201. The software module can be located in a storage medium, and the storage medium is located in the memory 202. The processor 201 reads the executable instructions included in the software module in the memory 202, and combines with the necessary hardware (for example, including the processor 201 and other components connected to the bus 205) to complete the image compression method provided in the embodiment of the present application.
[0059] As an example, the processor 201 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0060] As an example of hardware implementation of the image compression device provided in the embodiment of the present application, the device provided in the embodiment of the present application can be directly executed by a processor 201 in the form of a hardware decoding processor, for example, one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components to implement the image compression method provided in the embodiment of the present application.
[0061] The memory 202 in the embodiment of the present application is configured to store various types of data to support the operation of the electronic device 20. Examples of such data include any executable instructions for operating on the electronic device 20, such as executable instructions. A program implementing the image compression method in the embodiment of the present application may be included in the executable instructions.
[0062] In other embodiments, the image compression device provided in the embodiments of the present application can be implemented in software. Figure 2 shows an image compression device stored in the memory 202, which can be software in the form of programs and plug-ins, and includes a series of modules. As an example of a program stored in the memory 202, the image compression device includes the following software modules: an encoding module 2081 and an information processing module 2082.
[0063] When the software modules in the image compression device are read into the random access memory (RAM) by the processor 201 and executed, the image compression method provided by the embodiment of the present application is implemented. The functions of each software module in the image compression device in the embodiment of the present application are described below, among which:
[0064] The encoding module 2081 is configured to encode the image to be compressed to obtain a first latent variable corresponding to the image to be compressed;
[0065] An information processing module 2082 is configured to determine a hyper-priori probability estimate corresponding to the first latent variable;
[0066] The information processing module 2082 is configured to partially decode the first latent variable according to the super prior probability estimate to obtain a partial decoding result of the first latent variable;
[0067] The information processing module 2082 is further configured to generate a compressed image corresponding to the image to be compressed based on the partial decoding result of the first latent variable and the first latent variable corresponding to the image to be compressed, wherein the data volume of the compressed image is smaller than the data volume of the image to be compressed.
[0068] In some embodiments, the information processing module 2082 is further configured to perform autoregression on the second latent variable according to the partial decoding result to obtain the mean and variance of the second latent variable;
[0069] The information processing module 2082 is further configured to decode the second latent variable using the mean and variance to obtain a compressed image.
[0070] In some embodiments, the information processing module 2082 is configured to encode the first latent variable to obtain a third latent variable;
[0071] The information processing module 2082 is configured to perform entropy coding on the third latent variable to obtain an entropy coding of the third latent variable;
[0072] An information processing module 2082 is configured to decode the entropy coding of the third latent variable to obtain a fourth latent variable;
[0073] The information processing module 2082 is configured to decode the fourth latent variable to obtain a super-prior probability estimate.
[0074] In some embodiments, the information processing module 2082 is configured to group the second latent variable to obtain at least two groups of sub-latent variables;
[0075] An information processing module 2082 is configured to perform spatial autoregression on each group of latent sub-variables through a checkerboard grid;
[0076] The information processing module 2082 is configured to predict the undecoded channel group based on the partial decoding results after each group of sub-latent variables completes spatial autoregression until the second latent variable completely completes autoregression, thereby obtaining the mean and variance of the second latent variable.
[0077] In some embodiments, the information processing module 2082 is further configured to decode the second latent variable using the mean and variance to obtain a decoding result of the second latent variable;
[0078] The information processing module 2082 is configured to alternately segment and transfer the attention mechanism on the decoding result of the second latent variable until the decoding result of the second latent variable is completely segmented to obtain a compressed image.
[0079] In some embodiments, the information processing module 2082 is further configured to encode the image to be compressed through an image transformation network of the image processing model to obtain a first latent variable;
[0080] Determine a super-prior probability estimate according to the first latent variable through the super-prior network;
[0081] The first latent variable is partially decoded according to the super prior probability estimate through the context network to obtain a partial decoding result;
[0082] Through the context network, the second latent variable is autoregressed according to the partial decoding results to obtain the mean and variance of the second latent variable;
[0083] The second latent variable is decoded using the mean and variance through the image transformation network to obtain the compressed image.
[0084] In some embodiments, the information processing module 2082 is further configured to obtain a first training sample set corresponding to the image processing model, the first training sample set including at least one set of noise-free training samples;
[0085] The information processing module 2082 is further configured to configure random noise for the first training sample set to obtain a second training sample set;
[0086] The information processing module 2082 is further configured to obtain initial parameters of the image processing model;
[0087] The information processing module 2082 is also configured to train the image processing model based on the initial parameters of the image processing model and the loss function of the image processing model through a first training sample set and a second training sample set to determine the image transformation network parameters, super prior network parameters and context network parameters of the image processing model.
[0088] In some embodiments, the information processing module 2082 is configured to determine a dynamic noise amount threshold that matches the use environment of the image processing model when the use environment of the image processing model is video image compression;
[0089] According to the dynamic noise quantity threshold, a dynamic quantity of random noise is configured for the first training sample to obtain a second training sample set that matches the dynamic noise threshold.
[0090] In some embodiments, the information processing module 2082 is configured to determine a fixed noise amount threshold that matches the use environment of the image processing model when the use environment of the image processing model is medical image compression;
[0091] According to the fixed noise amount threshold, a fixed amount of random noise is configured for the first training sample to obtain a second training sample set that matches the fixed noise threshold.
[0092] In some embodiments, the information processing module 2082 is configured to obtain the pixel difference between the compressed image and the image to be compressed; obtain the number of bytes when storing the second latent variable and the fourth latent variable in the image processing model; and determine the fusion loss function of the image processing model based on the pixel difference and the number of bytes.
[0093] The present application also provides a computer program product or computer program, which includes computer-executable instructions stored in a computer-readable storage medium. A processor of a computer device or electronic device reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions, causing the computer device to perform the various embodiments and combinations of the above-described image compression methods.
[0094] After the image processing model training is completed, it can be deployed in a server or a cloud server network. The image compression device provided in this application can also be deployed in the electronic device shown in Figure 2 to execute the image compression method provided in the embodiment of this application.
[0095] The image compression method provided in the embodiment of the present application is described with reference to the electronic device 20 shown in FIG2 . Referring to FIG3A , FIG3A is a flow chart of the image compression method provided in the embodiment of the present application, which includes the following steps:
[0096] Step 3001: Encode the image to be compressed to obtain a first latent variable corresponding to the image to be compressed.
[0097] Here, the image to be compressed can be a natural image. In practical applications, the image to be compressed can be encoded through an image transformation network for image encoding, such as a variational autoencoder, to obtain a first latent variable corresponding to the image to be compressed. The first latent variable refers to a random variable that exists in the model but cannot be directly observed, and is used to represent the potential characteristics of the input data. In actual implementation, the first latent variable can be the output of the hidden layer of the image transformation network (that is, the intermediate layer between the input layer and the output layer of the image transformation network).
[0098] Here, the image transformation network can be a neural network model for encoding the image to be compressed, including an input layer, at least one hidden layer and an output layer. The image to be compressed is encoded through the image transformation network to obtain a first latent variable corresponding to the image to be compressed.
[0099] Taking electronic game applications as an example, due to the large number of game images, high-definition images in electronic games are usually compressed in batches by a factor of 4 to compress them. For example, the original game image resolution is 1024*1024, and after a factor of 4 compression, a low-resolution game image with a resolution of 256*256 is formed. However, the image compression method of the present application can batch convert image resources into compressed images suitable for running on the terminal's graphics processing unit (GPU), thereby reducing terminal-side memory overhead and network overhead during image transmission. For example, if the original game image with a resolution of 1024*1024 is compressed by a factor of 8, the size of the compressed image obtained after decoding will be smaller, reducing image storage costs.
[0100] Step 3002: Determine the super-prior probability estimate corresponding to the first latent variable.
[0101] In some embodiments, based on the first latent variable obtained by encoding, the super-prior probability estimate can be determined in the following manner: encoding the first latent variable to obtain an encoding result, quantizing the encoding result to obtain a quantization result, and then decoding the quantization result to obtain a super-prior probability estimate.
[0102] The encoding of the first latent variable can be achieved using a super-a priori encoder, and the decoding of the quantized result can be achieved using a super-a priori decoder. The super-a priori encoder and super-a priori decoder can be included in the Transformer model. In this way, if the encoded first latent variable obeys a certain inherent prior probability, the obtained super-a priori probability estimate can be used as a reference for subsequent partial decoding, thereby improving the accuracy of the decoding result.
[0103] Here, the super-prior probability estimation can be the process of estimating the parameters of the prior distribution, wherein the parameters of the prior distribution depend on the form of the prior distribution. For example, when the prior distribution is a normal distribution, the corresponding parameters of the prior distribution can be the mean and variance. That is, when the prior distribution of the first latent variable is a normal distribution, the corresponding parameters of the prior distribution can be the mean and variance. The super-prior probability estimate is the value obtained by estimating the parameters of the prior distribution.
[0104] Step 3003: Partially decode the first latent variable according to the super-prior probability estimate to obtain a partial decoding result of the first latent variable.
[0105] Here, in practical applications, the super-prior probability estimate is used as reference information for decoding to partially decode the first latent variable, that is, to decode a portion of the pixels, so that when other pixels are subsequently decoded, prediction (decoding) can be performed based on the partial decoding results.
[0106] For example, the first latent variable is grouped along the channel dimension to obtain multiple channel latent variable groups corresponding to each channel dimension. Then, an autoregressive method (such as a checkerboard autoregressive method) can be used to decode a portion of the multiple channel latent variable groups (such as one channel latent variable group) to obtain a partial decoding result of the first latent variable. This partial decoding result is then used as prediction reference information to decode the next undecoded channel latent variable group. The decoded channel latent variable group can be randomly selected.
[0107] Here, a channel refers to the components of color information that make up a color image, or the components used to represent the characteristics of an image. For the RGB color model, a color image consists of three color channels: red (R), green (G), and blue (B); for the HSV color model, a color image consists of three channels: hue, saturation, and brightness.
[0108] In some embodiments, when the channel dimension corresponds to a color dimension, including a red (R) dimension, a green (G) dimension, and a blue (B) dimension, the first latent variable is grouped based on these three color dimensions to obtain a channel latent variable group corresponding to the red (R) dimension, a channel latent variable group corresponding to the green (G) dimension, and a channel latent variable group corresponding to the blue (B) dimension, each latent variable group including multiple pixels.
[0109] In this way, after the first latent variable is grouped in the channel dimension, checkerboard autoregression is used instead of serial autoregression within each latent variable group, realizing the orthogonal alternating autoregression processing in the spatial and channel dimensions, and using the first decoded channel group to predict the undecoded channel group.
[0110] Step 3004: Generate a compressed image corresponding to the image to be compressed based on the partial decoding result of the first latent variable and the first latent variable corresponding to the image to be compressed.
[0111] The data volume of the compressed image is smaller than the data volume of the image to be compressed.
[0112] In some embodiments, based on the partial decoding results of the first latent variable and the first latent variable corresponding to the image to be compressed, a compressed image corresponding to the image to be compressed can be generated in the following manner: based on the partial decoding results of the first latent variable and the first latent variable corresponding to the image to be compressed, a new image is generated by performing autoregressive modeling on each pixel of the image. This process may include masked convolution and pixel-by-pixel conditional probability modeling. For example, for each convolution layer, future pixels are masked with a suitable mask to ensure that only known pixel values can be used to predict the probability distribution of the pixel value of the current pixel during training. Conditional modeling is performed on each pixel using a series of convolution layers. Each convolution layer is responsible for modeling a subset of the input image. By modeling the conditional probability distribution of each pixel (given the pixel values to its left and above), known pixels can be used to predict the possible values of the current pixel.
[0113] Here, conditional probability distribution refers to the probability distribution of the possible values of variable Y given variable X, that is, the distribution of Y under the condition of given X. Modeling the conditional probability distribution of each pixel, that is, for each pixel, such as the target pixel, the distribution of the possible pixel values of the target pixel given the pixel values of its associated pixels (such as the pixel values to the left and above the pixel).
[0114] In some embodiments, based on the partial decoding result of the first latent variable and the first latent variable corresponding to the image to be compressed, a compressed image corresponding to the image to be compressed can be generated in the following manner: quantizing the first latent variable to obtain a second latent variable; performing autoregression on the second latent variable according to the partial decoding result to obtain the mean and variance of the second latent variable; and decoding the second latent variable using the mean and variance to obtain the compressed image.
[0115] In some embodiments, the process of quantizing the first latent variable can be regarded as a process of reducing the dimensionality of the first latent variable. For example, the first latent variable is mapped to a preset low-dimensional space to obtain a second latent variable. The low-dimensional space here refers to a low-dimensional space relative to the dimension of the first latent variable. In practical applications, the first latent variable can be quantized by nonlinear dimensionality reduction or quantization matrix. The operation of quantizing the first latent variable can also be implemented by a vector quantizer. The vector quantizer is a system that maps a continuous or discrete vector sequence into a digital sequence suitable for communication or storage on a digital channel. By quantizing the first latent variable, data compression is achieved while maintaining the necessary data fidelity.
[0116] In some embodiments, the process of performing autoregression on the second latent variable according to the partial decoding result to obtain the mean and variance of the second latent variable can be achieved as follows: constructing sequence data according to the partial decoding result and the second latent variable, fitting the sequence data through at least one of an autoregressive model or a conditional heteroscedasticity model to obtain at least one of the mean dynamic model and the variance dynamic model of the second latent variable, and performing parameter estimation on the mean dynamic model and the variance dynamic model of the second latent variable respectively through maximum likelihood estimation or other parameter estimation methods to obtain the mean and variance of the second latent variable.
[0117] Here we explain the autoregressive model. It's a type of stationary time series model that can be used to predict and analyze data with autocorrelation. By constructing an autoregressive model, we can investigate whether data at different time points have dependencies and the strength of those dependencies. By fitting and analyzing sequence data using the autoregressive model, we can predict the average trend of random variable values at future moments and derive a dynamic model of the mean of the second latent variable.
[0118] This section explains the conditional heteroskedasticity model. The conditional heteroskedasticity model is a model used to describe heteroskedasticity (i.e., non-constant variance) in time series / series data. In practical applications, the variance of data may change significantly over time or due to other factors. The conditional heteroskedasticity model can better capture this heteroskedasticity. Fitting the conditional heteroskedasticity model to sequence data yields a dynamic variance model.
[0119] The mean dynamic model and variance dynamic model of the second latent variable are described. The mean dynamic model describes the average trend changes of time series data, indicating the dynamic characteristics of the sequence data. The variance dynamic model describes the variance changes of time series data, indicating the dynamic changes of the variance of time series data.
[0120] In some embodiments, the second latent variable can be decoded using the mean and variance to obtain a compressed image in the following manner: a multivariate Gaussian distribution is constructed based on the mean and variance of the latent variable. When constructing the Gaussian distribution, it is necessary to ensure that the dimension of the distribution is the same as the dimension of the latent variable; a certain number of samples are extracted from the constructed Gaussian distribution. These samples represent the possible values of the latent variable under the given mean and variance conditions of the latent variable; the extracted sample values are used as the input of the latent variable and decoded by a decoder. The decoder is usually a neural network structure corresponding to the encoder, which can map the latent variable back to the original image space, and the input is mapped to the generated image by the decoder.
[0121] In some embodiments, the second latent variable can be decoded using the mean and variance to obtain a compressed image in the following manner: the second latent variable is decoded using the mean and variance to obtain a decoded result of the second latent variable; the decoded result of the second latent variable is alternately segmented and attention-shifted until the decoded result of the second latent variable is completely segmented, thereby obtaining a compressed image. The second latent variable is obtained by quantizing the first latent variable. Compared to the first latent variable, the second latent variable contains more abstract, compressed information used for decoding or reconstructing the image. This allows the image to be compressed based on the second latent variable to improve image compression efficiency.
[0122] Segmenting the decoding result of the second latent variable, that is, dividing the decoding result of the second latent variable into different regions or blocks, so that parallel processing can be performed to improve efficiency. Using the attention mechanism to focus on specific parts of the segmented region can concentrate resources on processing relevant parts of the image and improve the accuracy of image reconstruction. In some embodiments, segmenting and attention mechanism transfer are performed alternately on the decoding result of the second latent variable until the decoding result of the second latent variable is completely segmented to obtain a compressed image, including:
[0123] Divide the decoding result of the second latent variable into a target number of different regions and apply the attention mechanism to each region;
[0124] Iteratively perform the above process until the number of blocks into which the decoding result of the second latent variable is divided reaches a number threshold (i.e., the decoding result of the second latent variable is completely divided), thereby obtaining multiple image regions;
[0125] The obtained multiple image regions are combined to obtain a compressed image.
[0126] Through the processing steps shown in Figure 3A, autoregression is performed alternately in the spatial and channel dimensions, significantly improving compression efficiency. For an input image, the compression process first transforms the input image to generate a low-dimensional latent variable (latent code). Then, a probability estimation model is performed on the latent variable. Finally, entropy coding is used to compress the latent variable into a bitstream based on the calculated probabilities. During decompression, the latent variable is first decoded from the bitstream to recover the latent variable, and then the image is reconstructed based on the latent variable, achieving efficient image compression.
[0127] When actually used, the processing steps shown in Figure 3A can be implemented using an image processing model. Different from the image processing models in related technologies, the image processing model used in the image compression method provided in this application includes: an image transformation network, a super prior network and a context network. The working processes of the image processing model including: the image transformation network, the super prior network and the context network are explained below.
[0128] Referring to FIG. 3B , FIG. 3B is a schematic flow chart of an image compression method provided in an embodiment of the present application. It is understood that the steps shown in FIG. 3B can be performed by various electronic devices running an image compression device, such as a server or server cluster with image compression functionality, for compressing each image frame in a received image or video using an image processing model to reduce the storage space occupied by image storage. The steps shown in FIG. 3B are described below.
[0129] Step 301: The electronic device encodes the image to be compressed through the image transformation network of the image processing model to obtain a first latent variable.
[0130] Refer to Figure 4, which is a data flow diagram of the image processing model in an embodiment of the present application. The image processing model in the present application includes: an image transformation network, a hyper-prior network, and a context network; the functions are as follows:
[0131] 1) The role of the image transformation network is to use high-resolution natural images to generate low-dimensional latent variables (latent codes). Assuming that the first latent variable obeys some inherent prior probability and the input image to be compressed obeys the conditional probability conditional on the latent variable, the image transformation network should make the probability estimates constructed by the encoder and decoder close enough so that the image reconstructed by the latent variable is close to the original image.
[0132] 2) The super-prior network uses an encoder and decoder structure to model the entropy value of each point in the latent variable. The occurrence of entropy feature points during the eigenvalue entropy modeling process is used to estimate the bit rate of the compressed image and perform entropy coding. The super-prior network can store the probabilistic modeling of the latent variable using a smaller number of bytes, providing auxiliary reference for subsequent decoding by the context network.
[0133] 3) The context network uses an autoregressive approach to predict undecoded pixel information using decoded pixel information. The prediction result is finally input into the decoder network of the image transformation network for decoding to obtain the compressed image. The context network can reduce information redundancy and improve the efficiency of image compression.
[0134] The following describes the model structure and working principle of the image transformation network, super prior network and context network included in the image processing model.
[0135] Refer to Figure 5, which is a schematic diagram of the model structure of the image processing model in an embodiment of the present application, wherein the image transformation network includes: an image encoder network and an image decoder network; the image encoder network includes: a transfer window attention mechanism module (Swin Transformer Block) and a block fusion module (Patch Merge Block), wherein the block fusion module includes: a spatial depth conversion layer (Space-to-Depth), a normalization layer (LayerNorm) and a mapping layer (Linear); the image decoder network includes: a transfer window attention mechanism module (Swin Transformer Block) and a block segmentation module (Patch Split Block), wherein the block segmentation module includes: a mapping layer (Linear), a normalization layer (LayerNorm) and a depth space conversion layer (Depth-to-Space) in sequence.
[0136] Referring to Figure 6, Figure 6 is a schematic diagram of the working process of the space-depth conversion layer and the depth-space conversion layer in an embodiment of the present application. Since the image processing model needs to compress the image to be compressed, the volume of the compressed image is smaller than the image to be compressed, but the resolution is close to the image to be compressed. Therefore, the space-depth conversion layer (Space-to-Depth) in the encoder network is configured to perform downsampling, and the depth-space conversion layer (Depth-to-Space) in the decoder network is configured to perform upsampling. As shown in Figure 6, for a 4*4 image to be compressed, Space-to-Depth divides each 2*2 adjacent pixel into a block (patch), splices the pixels in the same position (same shadow) in each block, and connects them along the channel direction to obtain 4 2*2 blocks. Depth-to-Space is the inverse operation of Space-to-Depth, which converts 4 2*2 blocks into a 4*4 image by upsampling.
[0137] Referring to Figure 7, Figure 7 is a schematic diagram of the composition structure of the transfer window attention mechanism module in an embodiment of the present application, wherein the transfer window attention mechanism module (Swin-Transformer block) mainly includes layer normalization, multi-layer perceptron, a normal window multi-attention and a transfer window multi-head attention mechanism. It is worth noting that the use of the window attention mechanism can effectively reduce the computational complexity of the operation process compared to the traditional attention mechanism, greatly improve the efficiency of the calculation, and enable the attention mechanism to be applied in the processing of large images. However, if only the normal window attention mechanism is used, the receptive field of the framework is severely limited. Therefore, by adding the transfer window attention mechanism, the receptive field of the attention mechanism is greatly improved without increasing the computational complexity. The transfer window attention mechanism module constructs a hierarchical feature map by merging deeper image blocks, and since attention is only calculated within each local window, it has a linear computational complexity for the input image size. As shown in Figure 7, in this application, the transfer window attention mechanism module performs local self-attention within each non-overlapping window of the feature map and retains the feature size. Figure 7 shows the internal structure of two consecutive Swin Transformer Blocks, including Layer Norm, multi-head self-attention and fully connected layers, which are connected internally using short cuts. The window size used by the encoder network and decoder network of the image transformation network is 8, the number of channels is 128, 192, 256, and 320 respectively, and the number of transfer window attention mechanism module networks superimposed is 2, 2, 6, and 2 respectively.
[0138] 8, FIG8 is a schematic diagram of the calculation principle of the transfer window attention mechanism module in an embodiment of the present application, wherein the input image (Images) HxWx3 is divided into a set of non-overlapping patches, where each patch size is 4x4, then the feature dimension of each patch is 4x4x3=48, and the number of patch blocks is H / 4 x W / 4; as shown in FIG8, stage1: first, a linear embedding is used to convert the feature dimension of the divided patch into C, and then it is sent to the transfer window attention mechanism module; stage2-stage4 operations are the same, first, a patch merging is used to merge the input according to 2x2 adjacent patches, so that the number of sub-patch blocks becomes H / 8 x W / 8, and the feature dimension becomes 4C. As shown in FIG8, the processing results of each transfer window attention mechanism module are as follows: stage1: [H / 4 x W / 4, C], stage2: [H / 8 x W / 8, 2C] stage3: [H / 16 x W / 16, 4C] stage4: [H / 32 x W / 32, 8C], the number of transfer window attention mechanism modules will gradually decrease as the network depth increases and the perception range of each block will expand. This design is to facilitate the hierarchical construction of transfer window attention mechanism modules and be able to adapt to multi-scale visual tasks.
[0139] Step 302: Determine a super-prior probability estimate according to the first latent variable through a super-prior network.
[0140] As shown in Figure 4, the encoder network of the super-prior network includes: a transfer window attention mechanism module and a block fusion module; the decoder network of the super-prior network includes: a transfer window attention mechanism module and a block segmentation module, the window size is 4, the number of channels is 192, 192 respectively, and the number of superimposed transfer window attention mechanism modules is 5, 1 respectively.
[0141] In some embodiments, the super-prior network determines the super-prior probability estimate based on the first latent variable, which can be achieved by:
[0142] The first latent variable y is encoded by the super-prior encoder of the super-prior network to obtain the third latent variable z; the super-prior probability estimate corresponding to the first latent variable is determined by the quantization module (Q), arithmetic encoding module (AE) and arithmetic decoding module (AD) of the super-prior network, and the third latent variable z is quantized by the quantization module (Q) of the super-prior network to obtain the fourth latent variable The fourth latent variable is compressed using the arithmetic coding module Perform entropy coding to obtain a byte stream (i.e., the fourth latent variable Entropy coding). When decompressing, the fourth latent variable is decoded from the byte stream using an arithmetic decoder. As shown in FIG4 , the fourth latent variable is obtained by quantizing the third latent variable z. When compressing, the fourth latent variable is compressed to obtain a byte stream. When decompressing, the fourth latent variable is restored from the byte stream. The fourth latent variable is decoded by the decoder network of the super prior network shown in FIG4 Decode and obtain the super prior probability estimate N(μ,σ).
[0143] In some embodiments, since the occurrence probability or cumulative probability distribution (CDF) of the decoding point is required in the stages of arithmetic encoding and arithmetic decoding of the compressed latent variables using Gaussian distribution parameters, the occurrence probability or cumulative probability distribution needs to be transmitted to the decoding end for correct entropy decoding. Therefore, the encoder of the super prior network needs to compress the probability or cumulative probability distribution into z first, and transmit it to the decoding end of the encoder of the super prior network by quantizing entropy encoding z, and learn the modeling parameters of the potential representation y through decoding at the decoding end. After obtaining the modeling distribution of the potential representation of y through the encoder of the super prior network, the compressed code stream file is obtained by modeling it and entropy encoding the quantized second latent variable, and the arithmetic decoding obtains it from the byte stream. The entropy decoding result is then input into the decoding module to obtain the final compressed image.
[0144] Step 303: quantify the first latent variable to obtain a second latent variable, and input the second latent variable into the context network.
[0145] Step 304: Perform autoregression on the second latent variable through the context network to obtain the mean and variance of the second latent variable.
[0146] Among them, after the electronic device calculates the mean and variance of the second latent variable through the context network, the arithmetic encoder models it according to the probability distribution of the second latent variable to obtain a byte stream.
[0147] Among them, the electronic device performs autoregression on the second latent variable according to the partial decoding results through the context network, performs probability modeling on the second latent variable, calculates the mean and variance of the second latent variable, and then the arithmetic encoder models according to the probability distribution of the second latent variable to obtain a byte stream.
[0148] Wherein, referring to FIG9 , FIG9 is a schematic diagram of the autoregression of the context network in an embodiment of the present application. In some embodiments, the context network performs autoregression on the second latent variable based on the partial decoding result to obtain the mean and variance of the second latent variable, which can be achieved in the following manner:
[0149] The second latent variable is grouped to obtain at least two groups of sub-latent variables; spatial autoregression is performed on each group of sub-latent variables through a checkerboard grid; when each group of sub-latent variables completes spatial autoregression, the undecoded channel group is predicted using the partial decoding results until the second latent variable completely completes autoregression, thereby obtaining the probability distribution of the second latent variable.
[0150] Here, spatial autoregression generally assumes that the features of a spatial location are correlated with the features of its surrounding locations. This correlation can be represented by a weight matrix (often called a spatial weight matrix), which describes the spatial relationship between points in space. The spatial weight matrix can also be used to describe the association between latent variables and predicted results.
[0151] For example, autoregression in the spatial dimension can be implemented by associating the current decoded symbol with the decoded symbols, modeling the variables probabilistically based on all observable neighboring symbols. Use autoregressive convolution g in the spatial direction sp Predict the context expression Φ at position i sp,i , where the calculation of the context expression in the context network refers to Formula 1:
[0152] Channel dimension autoregression can be achieved by dividing the channels of the second latent variable into K groups for autoregression to reduce redundancy between channels, and using the first decoded channel group to perform autoregressive convolution in the channel direction g ch Predicting contextual representations for undecoded channel groups The process refers to formula 2:
[0153] In channel autoregression, setting the number of channel groups is crucial for balancing compression performance and runtime speed. A larger grouping number, k, results in finer computational granularity and better rate-distortion performance, but also slower parameter estimation. k = 5 is the optimal grouping number for this application's image processing model.
[0154] As shown in Figure 9, combining a checkerboard spatial contextual autoregressive model and a channel contextual autoregressive model achieves accelerated computation by orthogonally alternating autoregression in the spatial and channel dimensions. In practical applications, latent variables are grouped in the channel dimension. Within each latent variable group, checkerboard autoregression is used instead of serial autoregression. After spatial autoregression is completed within the second latent variable in that group, channel autoregression is used to predict the undecoded channel group using the previously decoded channel group. In the initial autoregressive phase, the contextual network performs autoregressive prediction based on hyper-prior probability modeling. It first predicts the first checkerboard grid in the first channel group and then uses the currently predicted checkerboard grid results to predict the remaining checkerboard grids. After two checkerboard grid autoregressions, the prediction for the first channel group is complete. When predicting the second channel group, the predicted results of the first group serve as reference for subsequent probability modeling. The entire computational process performs orthogonal autoregression in the spatial and channel dimensions, effectively improving the image compression rate.
[0155] Step 305: Decode the second latent variable using the mean and the variance through the image transformation network to obtain a compressed image.
[0156] As shown in the aforementioned Figure 4, the second latent variable is decoded by the transfer window attention mechanism module of the decoder network of the image transformation network to obtain a decoding result of the second latent variable; the second latent variable is used to alternately pass through the transfer window attention mechanism module and the block segmentation module to obtain a compressed image, wherein the volume of the compressed image is smaller than the image to be compressed.
[0157] FIG10 is a flow chart of the image processing model training method provided in an embodiment of the present application. It is understood that the steps shown in FIG10 can be performed by various electronic devices running an image processing model training device, such as a dedicated terminal with image processing functions, a server with image processing model training functions, or a server cluster. The steps shown in FIG10 are described below.
[0158] Step 1001: The image processing model training apparatus obtains a first training sample set, where the first training sample set includes at least one set of noise-free training samples.
[0159] Step 1002: The image processing model training device configures random noise for the first training sample set to obtain a second training sample set.
[0160] In some embodiments, configuring random noise for the first training sample set to obtain the second training sample set can be achieved by:
[0161] When the usage environment of the image processing model is the generation of mini-program game images, a dynamic noise quantity threshold that matches the usage environment of the image processing model is determined; according to the dynamic noise quantity threshold, a dynamic quantity of random noise is configured for the first training sample to form a second training sample set that matches the dynamic noise threshold. In particular, since the usage environments of mini-program game images are diverse, for example, they can be role-playing mini-program game images, they can be images of users collected by terminals as mini-program game images, or they can be images captured from video image frames as mini-program game images. Since the training samples come from different data sources, the data sources include data of various types of application scenarios as the data source of the corresponding training books. For the different usage scenarios of these image processing models, the second training sample set that matches the dynamic noise threshold can be used to conduct targeted training on the image processing model.
[0162] In some embodiments, configuring random noise for the first training sample set to obtain the second training sample set can be achieved by:
[0163] When the use environment of the image processing model is medical image generation, a fixed noise quantity threshold that matches the use environment of the image processing model is determined; according to the fixed noise quantity threshold, a fixed amount of random noise is configured for the first training sample to form a second training sample set that matches the fixed noise threshold. Since the training samples are derived from a fixed data source, the data source includes data of fixed scenes as the data source of the corresponding training book (for example, any electronic device that generates medical images). For example, the image processing model provided in this application can be encapsulated as a software module in a mobile detection electronic device, or it can be encapsulated in different fixed medical examination equipment (including but not limited to: handheld diagnostic instruments, ward central monitoring systems, bedside monitoring systems), and of course it can also be solidified in the hardware equipment of the intelligent robot. For different use scenarios of these image processing models, the second training sample set that matches the fixed noise threshold can be used to conduct targeted training on the image processing model to improve the training speed of the image processing model.
[0164] Step 1003: The image processing model training device calculates the loss function of the image processing model.
[0165] In some embodiments of the present application, first, the pixel difference between the compressed image and the image to be compressed is obtained; then, the number of bytes used to store the second latent variable and the fourth latent variable in the image processing model is obtained; finally, the fusion loss function of the image processing model is calculated based on the pixel difference and the number of bytes. The loss function of the image processing model is referred to in Formula 3: L = R + λD Formula 3
[0166] Among them, R represents rate, which is the bytes required to store the second latent variable and the fourth latent variable. D represents distortion, which is usually expressed as Calculate the difference between the compressed image and the original image, where d is typically the mean squared error (MSE). λ is a parameter that controls the rate and distortion. Generally, a larger λ corresponds to a larger pixel depth (BPP Bits Per Pixel) of the corresponding model, and thus higher image reconstruction quality.
[0167] Step 1004: Based on the initial parameters of the image processing model and the loss function of the image processing model, the image processing model is trained using the first training sample set and the second training sample set.
[0168] Here, the image processing model is trained to determine the image transformation network parameters, super-prior network parameters and context network parameters of the image processing model.
[0169] In the test phase after training is completed, FIG11 is a schematic diagram of the effect test of the image processing model provided by the embodiment of the present application, wherein a performance test was conducted on the standard data set Kodak, with bpp as the horizontal axis and PSNR (Peak Signal to Noise Ratio) as the vertical axis to plot the rate-distortion performance of the model at different compression rates. The values of λ at the four test points in the image processing model of the present application are 0.002, 0.005, 0.02, and 0.04, respectively. It can be seen that the image processing model of the present application improves the efficiency of image compression, and the compressed image is smaller in size. When the same PSNR=32 is used, the bpp=0.4 of the present application is greater than the bpp=0.25 of the related art.
[0170] This application has the following beneficial technical effects:
[0171] 1) In the embodiment of the present application, the image to be compressed is encoded by the image transformation network of the image processing model to obtain a first latent variable, and the super prior network determines the super prior probability estimate based on the first latent variable; thus, the image is processed by the image transformation network and the super prior network constructed by the transfer window attention mechanism, which can improve the performance of image compression, make the compressed image obtained after decoding smaller, and reduce the storage cost of the image.
[0172] 2) The context network partially decodes the first latent variable according to the super-prior probability estimate to obtain a partial decoding result; the context network performs autoregression on the second latent variable according to the partial decoding result to obtain the mean and variance of the second latent variable; the second latent variable is decoded using the mean and the variance to obtain a compressed image, wherein the volume of the compressed image is smaller than the image to be compressed. Thus, the context network uses the first decoded channel grouping information as the prior knowledge of the subsequent channel grouping to be decoded to reduce the subsequent compression redundancy and save the time of compressing the image. At the same time, the context network can perform autoregression alternately from the spatial dimension and the channel dimension, thereby improving the compression efficiency.
[0173] 3) When training the image processing model, the training sample set can be flexibly adjusted according to different usage requirements, so that the image processing model can be applied to different image compression environments.
[0174] The above are merely embodiments of the present application and are not intended to limit the scope of protection of the present application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present application should be included in the scope of protection of the present application.
Claims
1. An image compression method, the method being performed by an electronic device, the method comprising: Encoding the image to be compressed to obtain a first latent variable corresponding to the image to be compressed; Determine a super priori probability estimate corresponding to the first latent variable; Partially decoding the first latent variable according to the super a priori probability estimate to obtain a partial decoding result of the first latent variable; Based on the partial decoding result of the first latent variable and the first latent variable corresponding to the image to be compressed, a compressed image corresponding to the image to be compressed is generated, and the data amount of the compressed image is smaller than the data amount of the image to be compressed.
2. The method according to claim 1, wherein: The generating a compressed image corresponding to the image to be compressed based on the partial decoding result of the first latent variable and the first latent variable corresponding to the image to be compressed includes: quantifying the first latent variable to obtain a second latent variable; Performing autoregression on the second latent variable according to the partial decoding result to obtain a mean and a variance of the second latent variable; The second latent variable is decoded using the mean and the variance to obtain the compressed image.
3. The method according to claim 2, wherein: The step of performing autoregression on the second latent variable according to the partial decoding result to obtain the mean and variance of the second latent variable includes: Grouping the second latent variable to obtain at least two groups of sub-latent variables; Perform spatial autoregression on each group of latent sub-variables through the chessboard; After each group of sub-latent variables completes spatial autoregression, the undecoded channel group is predicted by the partial decoding result until the second latent variable completely completes autoregression, and the mean and variance of the second latent variable are obtained.
4. The method according to claim 2, wherein: The step of decoding the second latent variable by using the mean and the variance to obtain the compressed image includes: Decoding the second latent variable using the mean and the variance to obtain a decoding result of the second latent variable; The decoding result of the second latent variable is alternately segmented and the attention mechanism is transferred until the decoding result of the second latent variable is completely segmented to obtain the compressed image.
5. The method according to claim 2, wherein: The method is implemented based on an image processing model, which includes: an image transformation network, a hyper-prior network and a context network. The encoding of the image to be compressed to obtain a first latent variable corresponding to the image to be compressed includes: The image to be compressed is encoded through the image transformation network of the image processing model to obtain the first latent variable; The step of determining the hyper-priori probability estimate corresponding to the first latent variable comprises: Determining the super a priori probability estimate value according to the first latent variable through the super a priori network; The partially decoding the first latent variable according to the super a priori probability estimate to obtain a partial decoding result of the first latent variable includes: Partially decoding the first latent variable according to the super prior probability estimate through the context network to obtain the partial decoding result; The step of performing autoregression on the second latent variable according to the partial decoding result to obtain the mean and variance of the second latent variable includes: By using the context network, autoregressing the second latent variable according to the partial decoding result, to obtain a mean and a variance of the second latent variable; The step of decoding the second latent variable by using the mean and the variance to obtain the compressed image includes: The second latent variable is decoded by the image transformation network using the mean and the variance to obtain the compressed image.
6. The method according to claim 5, wherein: The image transformation network includes: an image encoder network and an image decoder network; The image encoder network includes: a transfer window attention mechanism module and a block fusion module, wherein the block fusion module includes: a spatial depth conversion layer, a normalization layer and a mapping layer in sequence; The image decoder network includes: a transfer window attention mechanism module and a block segmentation module, wherein the block segmentation module includes: a mapping layer, a normalization layer and a depth space conversion layer in sequence.
7. The method according to claim 5, wherein: The method further comprises: Acquire a first training sample set corresponding to the image processing model, wherein the first training sample set includes at least one set of noise-free training samples; configuring random noise for the first training sample set to obtain a second training sample set; Obtaining initial parameters of the image processing model; Based on the initial parameters of the image processing model and the loss function of the image processing model, the image processing model is trained through the first training sample set and the second training sample set to determine the image transformation network parameters, super prior network parameters and context network parameters of the image processing model.
8. The method according to claim 7, wherein: The configuring random noise for the first training sample set to obtain a second training sample set includes: When the use environment of the image processing model is video image compression, determining a dynamic noise quantity threshold that matches the use environment of the image processing model; According to the dynamic noise quantity threshold, a dynamic quantity of random noise is configured for the first training sample to obtain a second training sample set that matches the dynamic noise threshold.
9. The method according to claim 7, wherein: The configuring random noise for the first training sample set to obtain a second training sample set includes: When the use environment of the image processing model is medical image compression, determining a fixed noise quantity threshold that matches the use environment of the image processing model; According to the fixed noise quantity threshold, a fixed quantity of random noise is configured for the first training sample to obtain a second training sample set that matches the fixed noise threshold.
10. The method according to claim 7, wherein: The method further comprises: Obtaining a pixel difference between the compressed image and the image to be compressed; Obtaining the number of bytes when storing the second latent variable and the fourth latent variable in the image processing model; A fusion loss function of the image processing model is determined according to the pixel difference and the number of bytes.
11. The method according to any one of claims 1 to 10, wherein: The step of determining the hyper-priori probability estimate corresponding to the first latent variable comprises: Encoding the first latent variable to obtain a third latent variable; Performing entropy coding on the third latent variable to obtain an entropy coding of the third latent variable; Decoding the entropy coding of the third latent variable to obtain a fourth latent variable; The fourth latent variable is decoded to obtain the super a priori probability estimate.
12. An image compression device, the device comprising: An encoding module, configured to encode the image to be compressed to obtain a first latent variable corresponding to the image to be compressed; An information processing module, configured to determine a hyper-priori probability estimate corresponding to the first latent variable; The information processing module is further configured to partially decode the first latent variable according to the super a priori probability estimate to obtain a partial decoding result of the first latent variable; The information processing module is further configured to generate a compressed image corresponding to the image to be compressed based on a partial decoding result of the first latent variable and the first latent variable corresponding to the image to be compressed, wherein the data amount of the compressed image is smaller than the data amount of the image to be compressed.
13. An electronic device, comprising: a memory configured to store executable instructions; A processor, configured to implement the image compression method according to any one of claims 1 to 11 when running the executable instructions stored in the memory.
14. A computer program product, comprising a computer program or an instruction, wherein when the computer program or the instruction is executed by a processor, the image compression method according to any one of claims 1 to 11 is implemented.
15. A computer-readable storage medium storing executable instructions, wherein the executable instructions, when executed by a processor, implement the image compression method according to any one of claims 1 to 11.
