Lossless image coding method and equipment for grouping autoregression model, medium and product
By constructing a mask-based grouped autoregressive model and a cache-post-cropping inference strategy, the problems of poor expressiveness and slow encoding speed in lossless image coding are solved, and efficient image coding is achieved.
Patent Information
- Application Number
- CN202510839901.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-10-03
AI Technical Summary
Existing lossless image coding models have problems such as poor expressiveness, slow encoding speed and large model parameters when encoding images, making it difficult to effectively capture the complex distribution of images.
A mask-based grouped autoregressive model is adopted. By constructing a network structure of mask embedding layer, masked gated convolutional Transformer and output layer, combined with a cache-post-cropping inference strategy, redundant calculations are reduced and coding efficiency is improved.
It improves the accuracy and efficiency of lossless image coding, reduces the number of model parameters, enhances the model's expressiveness and generalization performance, and improves the encoding speed.
Smart Images

Figure CN120751127A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of lossless image coding, and in particular to a lossless image coding method, device, medium and product for a grouped autoregressive model. Background Art
[0002] Traditional lossless image compression methods, such as PNG, JPEG-LS, and JPEG-XL, use hand-designed algorithms to exploit the statistical properties of images. However, these methods often struggle to capture the complex and diverse distributions in the original image, limiting their compression performance. In recent years, deep learning-based methods have achieved state-of-the-art results by learning the complex distribution of the original image. These methods use likelihood-based generative models, such as autoregressive models, flow models, and variational autoencoders (VAEs), to convert data into a compact bitstream by predicting entropy-coded probabilities. Likelihood models based on variational autoencoders (VAEs) and flow models typically have poor modeling capabilities for image distributions and suffer from large parameter sizes. These models require a very large number of parameters to effectively model the image distribution, resulting in poor expressiveness and a large number of model parameters.
[0003] The autoregressive model decomposes the data probability into conditional distributions through probability chains and uses learnable models to model these distributions. Oord et al. introduced PixelCNN, which estimates the conditional distribution using masked convolution. Salimans et al. proposed PixelCNN++, which improved the implementation of PixelCNN in many aspects. Zhang et al. studied the out-of-distribution generalization of the autoregressive model and used local PixelCNN for lossless image compression. Bai et al. developed an end-to-end framework DLPR, which uses lossy compression for prediction and a serial autoregressive model for residual image compression, and improved it with a parallel model to speed up encoding. Rhee et al. made improvements based on the autoregressive model, introducing conditional dependencies between different lighting and color components, as well as between low-frequency and high-frequency regions. Temporal autoregression usually leads to high time complexity of the autoregressive model when used as a lossless coding entropy model, so it is necessary to design better network structures, scanning strategies and acceleration methods.
[0004] The network structure of existing autoregressive models used in lossless coding is usually simple, such as a single-layer masked convolution, or a network structure in which the first layer is a large-kernel convolution and the rest are 1x1 convolutions. Their expressive power is generally weak, and there is no corresponding acceleration strategy. There is often a problem of redundant calculation during encoding. For example, when performing autoregressive prediction, it is necessary to execute it once at all positions on the feature map to obtain activation values each time, and there is a problem of repeated calculation of the activation values of the previously decoded positions.
[0005] Ho et al. proposed a local bit-back coding scheme, modifying the continuous normalized flow model for lossless compression. In contrast, discrete normalized flow processes discrete data and uses reversible transforms for integer latent space, which is encoded using a simple prior distribution. Hoogeboom et al. developed an integer flow (IDF) model that learns reversible transforms for compression. Berg et al. further proposed the IDF++ model, which improved many aspects of the IDF model, such as the network architecture. Zhang et al. introduced a reversible volume preserving flow (iVPF) model, and later proposed the iFlow model in another existing technology, which is characterized by modular scaling and a unified base conversion system. The advantage of the flow model is that it can be calculated in parallel, but the computational complexity in high-dimensional space is high, and a larger number of parameters is required.
[0006] VAE models (Variational Autoencoders) can be categorized as deterministic or stochastic based on their posterior sampling methods. A deterministic method (L3C) imposes constraints on the posterior distribution of the latent code. In the L3C method, the posterior distribution of the latent code is assumed to follow a uniform distribution centered around the predicted value. Stochastic methods, such as BB-ANS, employ random latent code sampling and use the Evidence Lower Bound (ELBO) for training. Since there are no constraints on the latent code, encoding requires a combination of back-coding. This involves first decoding the latent samples using the latent posterior distribution, encoding the image using the image distribution predicted by the prior distribution, and then encoding the latent samples using the latent prior distribution. Back-coding is the reverse of the encoding process. Compared to deterministic methods, stochastic methods achieve higher compression rates. Kingma et al. later proposed a Bit-Swap scheme based on a hierarchical VAE model, which also incorporates back-coding for image encoding. Townsend et al. introduced HiLLoC, another hierarchical latent lossless compression method that incorporates the ResNet VAE network structure. Ryder et al. proposed a split hierarchical VAE model, combining hierarchical VAE with an autoregressive model to decompose the prior distribution and address the initial bit problem required for back-coding. The VAE model has the advantage of low time complexity, but its ability to model data distributions is limited and it consumes a large number of parameters.
[0007] DLPR uses a lossy plus residual framework to losslessly encode images. The process includes encoding the original image through a lossy encoder to obtain a lossy reconstruction of the original image, and then subtracting the lossy reconstruction from the original image to obtain the residual. The residual obtained after prediction is easier to encode than the original pixel domain data, and then the residual is losslessly encoded. The bitstream of the entire image consists of two parts: one is the bitstream of the hidden layer in the lossy encoding, and the other is the lossless encoding bitstream of the residual. The problems with DLPR are: First, combined with the lossy coding framework, the existence of lossy coding leads to the same problems as the variational autoencoder type encoding method, namely, weak expression ability and large number of network parameters. On the other hand, due to the simple use of a single-layer masked convolution, the network expression ability is not strong when encoding the residual.
[0008] Therefore, in order to solve the problems of poor expression ability, slow encoding speed and large model parameters in traditional models when encoding images in lossless image coding, and to improve the accuracy and efficiency of lossless image coding, it is urgent to provide a new lossless image coding method. Summary of the Invention
[0009] The purpose of this application is to provide a lossless image coding method, device, medium and product for a grouped autoregressive model, which can improve the accuracy and efficiency of lossless image coding.
[0010] To achieve the above objectives, this application provides the following solutions:
[0011] In a first aspect, the present application provides a lossless image coding method for a grouped autoregressive model, the lossless image coding method for a grouped autoregressive model comprising:
[0012] Constructing a mask-based grouped autoregressive model; the mask-based grouped autoregressive model includes: a masked embedding layer connected in sequence, N masked gated convolutional transformers based on an autoregressive architecture, and an output layer; the masked gated convolutional transformer includes: a masked convolutional gating module and a feedforward neural network module connected in sequence; the masked convolutional gating module is used to aggregate local context information using a masked convolutional gating mechanism;
[0013] Obtain the image to be processed and set the corresponding scanning sequence;
[0014] Divide the image to be processed into multiple blocks and increase the number of pixels to be encoded in parallel according to the corresponding scanning order;
[0015] Based on a mask-based grouped autoregressive model, a cache-post-cropping inference strategy is adopted to losslessly encode multiple tiles with increasing numbers of pixels. The cache-post-cropping inference strategy minimizes the computation of decoded elements by caching activation elements in a masked convolutional gating module, and then performs a convolution operation on a cropped window around the activation location.
[0016] Optionally, the masked convolution gating module specifically includes: a first branch and a second branch;
[0017] The first branch includes: a 1×1 kernel convolution; the second branch includes: a 1×1 kernel convolution, a k×k kernel masked depth convolution, and a swish function connected in sequence;
[0018] The first branch and the second branch perform Hadamard product to simulate the gating mechanism of self-attention.
[0019] Optionally, the masked convolution gating module specifically includes:
[0020] Using formula A M =DWConv k×k (W A X, M) determine the masked convolution gated feature A M ;
[0021] Using the formula V = W V X determines the value matrix v of the linear projection of the input;
[0022] Using the formula MCG(X)=σ(A M )⊙V realizes the use of local adaptive gate value σ(A M ) to regulate the information flow in the value matrix V;
[0023] Among them, W A , W V are two linear projections, σ is a nonlinear activation function using the swish function, ⊙ represents the Hadamard product, M is a convolution mask that limits information to the decoded context range, and X is the input image.
[0024] Optionally, the mask embedding layer includes: a masked convolution with a 3x3 kernel.
[0025] Optionally, the feedforward neural network module includes: a feedforward neural network; the feedforward neural network includes: two linear layers; a GELU activation function is introduced between the two linear layers.
[0026] Optionally, the output layer includes: a convolution with a 1x1 kernel.
[0027] In a second aspect, the present application provides a lossless image coding device for a grouped autoregressive model, the lossless image coding device for a grouped autoregressive model comprising:
[0028] A model construction unit is used to construct a mask-based grouped autoregressive model; the mask-based grouped autoregressive model includes: a masked embedding layer connected in sequence, N masked gated convolutional transformers based on an autoregressive architecture, and an output layer; the masked gated convolutional transformer includes: a masked convolutional gating module and a feedforward neural network module connected in sequence; the masked convolutional gating module is used to aggregate local context information using a masked convolutional gating mechanism;
[0029] A data acquisition unit, used to acquire the image to be processed and set the corresponding scanning sequence;
[0030] A data processing unit, configured to divide the image to be processed into a plurality of blocks and increase the number of pixels to be encoded in parallel according to the corresponding scanning sequence;
[0031] A lossless image coding unit is configured to perform lossless image coding on multiple tiles of increasing pixel counts using a cached and then cropped inference strategy based on a masked grouped autoregressive model; the cached and then cropped inference strategy minimizes computation of decoded elements by caching activations in a masked convolutional gating module, and then performs a convolution operation on a cropped window around the activations.
[0032] In a third aspect, the present application provides a computer device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the aforementioned lossless image coding method for a grouped autoregressive model.
[0033] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the lossless image encoding method for the grouped autoregressive model.
[0034] In a fifth aspect, the present application provides a computer program product, comprising a computer program, which, when executed by a processor, implements the lossless image encoding method for a grouped autoregressive model.
[0035] According to the specific embodiments provided in this application, this application has the following technical effects:
[0036] The present application provides a lossless image coding method, device, medium and product for a grouped autoregressive model. By sequentially connecting a mask embedding layer, N masked gated convolutional transformers (MGCF) based on an autoregressive architecture and an output layer, a grouped autoregressive model based on a mask is constructed. Only mask prediction needs to be completed, the training problem is simple, and the number of parameters is small. The grouped autoregressive model has fewer inference steps and adopts a post-cache clipping inference strategy to further accelerate each inference and improve the encoding speed and accuracy. It can be seen that the present application can solve the problems of poor expression ability, slow encoding speed and large model parameters in traditional models when encoding images in lossless image coding. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0038] Figure 1 Schematic diagram of a flow chart of a lossless image coding method for a grouped autoregressive model in one embodiment of the present application;
[0039] Figure 2 It is a structural diagram of the mask-based group autoregressive model;
[0040] Figure 3 Schematic diagram of the structure of the masked convolution gating module;
[0041] Figure 4 Schematic diagram of the DLPR encoding process;
[0042] Figure 5 Schematic diagram of the inference acceleration strategy using post-caching pruning. DETAILED DESCRIPTION
[0043] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0044] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0045] In an exemplary embodiment, Figure 1 As shown, a lossless image coding method for a grouped autoregressive model is provided, the method comprising the following S101 to S104.
[0046] S101, construct a mask-based group autoregressive model, and Figure 2 As shown in FIG5 , the masked grouped autoregressive model includes: a masked embedding layer connected in sequence, N masked gated convolutional transformers based on an autoregressive architecture, and an output layer; the masked gated convolutional transformer includes: a masked convolutional gating module (MCG) and a feedforward neural network module connected in sequence; the masked convolutional gating module is used to aggregate local context information using the masked convolutional gating mechanism;
[0047] A gating mechanism is a gate that selectively regulates and manages information transmission in a neural network by controlling the flow of information (such as input gate, forget gate, and output gate), thereby enhancing the model's ability to capture and process key information.
[0048] Among them, the grouped autoregressive model is a statistical model that divides the data into multiple groups and applies the autoregressive method in each group to capture and predict the time series dependencies within each group.
[0049] like Figure 3 As shown, the masked convolution gating module specifically includes: a first branch and a second branch;
[0050] The first branch includes: a 1×1 kernel convolution; the second branch includes: a 1×1 kernel convolution, a k×k kernel masked depth convolution, and a swish function connected in sequence;
[0051] The first branch and the second branch perform Hadamard product to simulate the gating mechanism of self-attention.
[0052] Focusing on local features rather than global context in the masked convolutional gating module to improve efficiency and generalization;
[0053] The masked convolution gating module specifically includes:
[0054] Using formula A M =DWConv k×k (W A X, M) determine the masked convolution gated feature A M ; A M Able to capture the characteristics of local structure and details; A M Convert to gated value;
[0055] Using the formula V = W V X determines the value matrix V of the input linear projection; V can preserve the spatial information of each position;
[0056] Using the formula MCG(X)=σ(A M )⊙V performs modulation operation to realize content perception; that is, the local adaptive gate value σ(A M ) to regulate the information flow in the value matrix V; through the masked convolution gating module, the network can learn to effectively adapt to the training dataset and enhance the responsiveness of the pre-trained model to different contexts; among them, the training dataset includes high-resolution RGB natural image data, such as DIV2K and other datasets.
[0057] Among them, W A , W V are two linear projections, σ is a nonlinear activation function using the swish function, ⊙ represents the Hadamard product, M is a convolution mask that limits information to the decoded context range, and X is the input image.
[0058] MGCF introduces an autoregressive architecture based on MCG. The autoregressive architecture is built on the Transformer architecture. The Transformer is usually composed of a spatial information interaction module and a channel information interaction module. The spatial information interaction is completed through the self-attention mechanism, and the channel information interaction is completed through a feedforward network (multi-layer perceptron MLP).
[0059] In MGCF, the input image first passes through a mask embedding layer, which is implemented using a masked convolution with a 3x3 kernel. The introduction of masked convolution is intended to effectively capture local features while maintaining the causality of the autoregressive model, ensuring that the prediction of the current pixel only depends on the previous pixel information.
[0060] The embedded features are processed by N MGCF modules. MCG dynamically adjusts feature representations through a gating mechanism, enhancing the model's ability to capture important features while suppressing interference from redundant information. MCG effectively combines the local receptive field advantage of convolutional operations with the flexible adjustment capabilities of gating mechanisms, thereby improving the model's expressiveness and generalization performance.
[0061] Each MGCF module's feedforward neural network module contains two linear layers, with a Gaussian Error Linear Unit (GELU) activation function added between the two linear layers. Compared to the traditional ReLU, the GELU activation function has smoother nonlinear characteristics, better preserves the continuity of input information, and promotes effective gradient propagation, thereby improving model training efficiency and performance.
[0062] After processing by all MGCF modules, the final features are output through the output layer, which is then converted into the required parameters through a 1x1 convolution. This convolution is designed to compress high-dimensional features into the target parameter space while maintaining the spatial dimension, ensuring that the output parameters accurately reflect the detailed features of the input image.
[0063] The Discrete Logistic Mixture Model (DLM) was used in the overall modeling process of the mask-based grouped autoregressive model. This model effectively captures the complex distribution characteristics of image data and fits the probability distribution of real data by mixing multiple logistic distributions, thereby improving the accuracy and quality of the generated model.
[0064] S102, obtaining an image to be processed and setting a corresponding scan sequence; a scan sequence refers to accessing and processing data elements (such as image pixels or transform coefficients) in a specific order during the data encoding process to optimize compression efficiency or improve data structure.
[0065] S103, dividing the image to be processed into a plurality of blocks, and increasing the number of pixels to be encoded in parallel according to the corresponding scanning order;
[0066] In this application, the number of pixels for parallel coding is increased according to the corresponding scanning order, and the method provided by DLPR is used for implementation. Similar to DLPR, this application can form different grouping models by setting the corresponding scanning order, thereby achieving a compromise between performance and speed. MGCF can achieve the corresponding scanning order by changing the mask M in the convolutional network.
[0067] like Figure 4 As shown, the DLPR encoding process is:
[0068] When encoding the residual, DLPR uses an autoregressive model whose network structure is implemented by a single-layer masked convolution, similar to PixelCNN. When encoding, DLPR first divides the image into PxP-sized blocks, and then increases the number of pixels encoded in parallel by setting a specific scanning order. If temporal encoding is used, the maximum encoding parameter is PxP. After parallelization, the number of autoregressive steps is reduced to 4P-3 ( Figure 4 (a) of 3P-2( Figure 4 (b) of the convolution mask). When combined with the mask convolution, we only need to design the same compression kernel size according to the convolution kernel size, that is, the yellow part. Figure 4 The convolution kernel size in is 7.
[0069] S104, based on the mask-based grouped autoregressive model, adopts a cached and cropped inference strategy (CCI) to perform lossless image encoding on multiple tiles with an increased number of pixels; the cached and cropped inference strategy minimizes the calculation of the decoded elements by caching the activated elements in the masked convolution gating module, and then performs a convolution operation on the cropped window around the activated position.
[0070] As a specific embodiment, the post-caching pruning inference strategy is also applicable to grouped autoregressive models with different scanning orders.
[0071] like Figure 5 As shown, the image is first divided into multiple tiles, and the tiles are encoded in parallel. For each tile, the pixels are initially grouped according to a parallel scanning order as Parallel scanning consists of 3P-2 autoregressive steps (or other steps), where P is the tile size; encoding is done in groups. In step i, the first group is processed Activation and predict the current group In MGCF, A-type masked convolution and B-type masked convolution are used. For B-type masked convolution, the current group position is masked. In contrast, in A-type masked convolution, the positions of the current group and all previous groups are included in the receptive field. For B-type masked convolution (used as the embedding layer, i.e. the first layer of the network), the original pixels are directly input, and the previous group is The pixels (features) of the current group are input into the network and cached. Then, the cached data is convolved with a B-type mask at the position corresponding to the current group to aggregate the context information. To reduce the amount of computation, only the window around the current group position is cropped and zero-filled mask convolution is performed on these windows in parallel. In the embedding layer, the current group is obtained. The activation of the current group position is input to the subsequent network layer. For the subsequent A-type mask convolution in MCG, the position element of the current group is considered during the execution. Stored in the cache map, and perform cropping convolution to collect context information at these positions. The masked convolution is responsible for extracting the context information of all previous groups including the current group position. The 1×1 convolutions in the rest of the network only transfer information in the channel dimension and therefore do not need to be cached.
[0072] As a specific embodiment, the design of mask convolution is not limited to the form of "BAAA...", but can also adopt the forms of "AAA...", "B...A...", "A...B...", etc. For the case where the A-type mask convolution appears first in the network, the pixel value at the current group position should be fed at the beginning of the network. Everything else is the same.
[0073] This application uses MCG to realize the spatial information extraction of decoded pixels, and simultaneously realizes the spatial information interaction and channel information interaction of decoded pixels based on the convolutional Transformer network architecture; and adopts the cache-first-then-inference acceleration method of the cache-then-crop inference strategy to accelerate encoding and decoding.
[0074] This application has strong modeling capabilities, is based on a grouped autoregressive model, and has a simple training problem, that is, to complete the mask prediction. Based on the grouped autoregressive model, it can be completed by stacking several layers of transformation blocks. Most of the model is 1x1 kernel convolution, and depth convolution is used for the kxk kernel convolution, so the number of parameters is also small. Based on the grouped autoregressive model, the number of inference steps is fewer; the network itself is relatively small, so the GigaFloating Point Operations per Second (GFLOPs) of a single inference is lower, and each inference is further accelerated by cropping before inference, so the encoding and decoding speed is faster. Compared to performing a convolution of the kxk kernel on features with a scale of the original image each time, our method saves the repeated calculation of intermediate features of previously decoded positions, and applies cropped convolution to perform convolution only on the current group position, so the inference is accelerated.
[0075] As another specific embodiment, the gated mask convolution can be replaced by an ordinary depth-wise separable convolution; it can also be replaced by a NeighborhoodAttentionTransformer. This application performs a moving window on a spatial scale and performs self-attention in the moving window.
[0076] Based on the same inventive concept, embodiments of the present application also provide a grouped autoregressive model-oriented lossless image coding device for implementing the aforementioned grouped autoregressive model-oriented lossless image coding method. The solution provided by this device is similar to the solution described in the aforementioned method. Therefore, the specific limitations of one or more embodiments of the grouped autoregressive model-oriented lossless image coding device provided below can be found in the above-mentioned limitations of the grouped autoregressive model-oriented lossless image coding method, and will not be repeated here.
[0077] In an exemplary embodiment, a lossless image encoding device for a grouped autoregressive model is provided, including:
[0078] A model construction unit is used to construct a mask-based grouped autoregressive model; the mask-based grouped autoregressive model includes: a masked embedding layer connected in sequence, N masked gated convolutional transformers based on an autoregressive architecture, and an output layer; the masked gated convolutional transformer includes: a masked convolutional gating module and a feedforward neural network module connected in sequence; the masked convolutional gating module is used to aggregate local context information using a masked convolutional gating mechanism;
[0079] A data acquisition unit, used to acquire the image to be processed and set the corresponding scanning sequence;
[0080] A data processing unit, configured to divide the image to be processed into a plurality of blocks and increase the number of pixels to be encoded in parallel according to the corresponding scanning sequence;
[0081] A lossless image coding unit is configured to perform lossless image coding on multiple tiles of increasing pixel counts using a cached and then cropped inference strategy based on a masked grouped autoregressive model; the cached and then cropped inference strategy minimizes computation of decoded elements by caching activations in a masked convolutional gating module, and then performs a convolution operation on a cropped window around the activations.
[0082] In an exemplary embodiment, a computer device is provided, which may be a server or a terminal. The computer device includes a processor, a memory, an input / output interface (I / O), and a communication interface. The processor, memory, and I / O interface are connected via a system bus, and the communication interface is connected to the system bus via the I / O interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The I / O interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, it implements a lossless image coding method for a grouped autoregressive model.
[0083] In an exemplary embodiment, a computer-readable storage medium is provided, storing a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0084] In an exemplary embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0085] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0086] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM may be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0087] The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processors involved in the various embodiments provided herein may include, but are not limited to, general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic units, data processing logic units based on quantum computing, and the like.
[0088] In this application, all actions to obtain signals, information or data are carried out in compliance with the relevant data protection laws and policies of the country where they are located and with the authorization given by the owner of the corresponding device.
[0089] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0090] This document uses specific examples to illustrate the principles and implementation methods of this application. The description of the above examples is only intended to help understand the method and core concept of this application. At the same time, for those skilled in the art, based on the concept of this application, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this application.
Claims
1. A lossless image coding method for a grouped autoregressive model, characterized in that: The lossless image coding method for the grouped autoregressive model includes: Constructing a mask-based grouped autoregressive model; the mask-based grouped autoregressive model includes: a masked embedding layer connected in sequence, N masked gated convolutional transformers based on an autoregressive architecture, and an output layer; the masked gated convolutional transformer includes: a masked convolutional gating module and a feedforward neural network module connected in sequence; the masked convolutional gating module is used to aggregate local context information using a masked convolutional gating mechanism; Obtain the image to be processed and set the corresponding scanning sequence; Divide the image to be processed into multiple blocks and increase the number of pixels to be encoded in parallel according to the corresponding scanning order; Based on a mask-based grouped autoregressive model, a cache-post-cropping inference strategy is adopted to losslessly encode multiple tiles with increasing numbers of pixels. The cache-post-cropping inference strategy minimizes the computation of decoded elements by caching activation elements in a masked convolutional gating module, and then performs a convolution operation on a cropped window around the activation location.
2. The lossless image coding method for group autoregressive model according to claim 1, characterized in that: The masked convolution gating module specifically includes: a first branch and a second branch; The first branch includes: a 1×1 kernel convolution; the second branch includes: a 1×1 kernel convolution, a k×k kernel masked depth convolution, and a swish function connected in sequence; The first branch and the second branch perform Hadamard product to simulate the gating mechanism of self-attention.
3. The lossless image coding method for grouped autoregressive model according to claim 2, characterized in that: The masked convolution gating module specifically includes: Using formula A M =DWConv k×k (W A X, M) determine the masked convolution gated feature A M ; Using the formula V = W v X determines the value matrix V of the linear projection of the input; Using the formula MCG(X)=σ(A M )⊙V realizes the use of local adaptive gate value σ(A M ) to regulate the information flow in the value matrix V; Among them, W A , W v are two linear projections, σ is a nonlinear activation function using the swish function, ⊙ represents the Hadamard product, M is a convolution mask that limits information to the decoded context range, and X is the input image.
4. The lossless image coding method for group autoregressive model according to claim 1, characterized in that: The mask embedding layer includes: a masked convolution with a 3x3 kernel.
5. The lossless image coding method for group autoregressive model according to claim 1, characterized in that: The feedforward neural network module includes: a feedforward neural network; the feedforward neural network includes: two linear layers; a GELU activation function is introduced between the two linear layers.
6. The lossless image coding method for group autoregressive model according to claim 1, characterized in that: The output layer consists of: Convolution with 1x1 kernel.
7. A lossless image coding device for a grouped autoregressive model, characterized in that: The lossless image coding device for the grouped autoregressive model includes: A model construction unit is used to construct a mask-based grouped autoregressive model; the mask-based grouped autoregressive model includes: a masked embedding layer connected in sequence, N masked gated convolutional transformers based on an autoregressive architecture, and an output layer; the masked gated convolutional transformer includes: a masked convolutional gating module and a feedforward neural network module connected in sequence; the masked convolutional gating module is used to aggregate local context information using a masked convolutional gating mechanism; A data acquisition unit, used to acquire the image to be processed and set the corresponding scanning sequence; A data processing unit, configured to divide the image to be processed into a plurality of blocks and increase the number of pixels to be encoded in parallel according to the corresponding scanning sequence; A lossless image coding unit is configured to perform lossless image coding on multiple tiles of increasing pixel counts using a cached and then cropped inference strategy based on a masked grouped autoregressive model; the cached and then cropped inference strategy minimizes computation of decoded elements by caching activations in a masked convolutional gating module, and then performs a convolution operation on a cropped window around the activations.
8. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the lossless image coding method for a group autoregressive model according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the lossless image coding method for a grouped autoregressive model according to any one of claims 1 to 6 is implemented.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the lossless image coding method for a grouped autoregressive model according to any one of claims 1 to 6 is implemented.