Gated Context Model with Embedded Priors for Deep Image Compression
Haojie Liu Tong Chen Peiyao Guo Qiu Shen Zhan Ma







Gated Context Model with Embedded Priors for Deep Image Compression
    













Haojie Liu, Tong Chen, Peiyao Guo, Qiu Shen, Zhan Ma 


Vision Lab, Nanjing University

    December 30, 2023
=========================================================================================================





 A deep image compression scheme is proposed in this paper, offering the state-of-the-art compression efficiency, against the traditional JPEG, JPEG2000, BPG and those popular learning based methodologies.  This is achieved by a novel conditional probably model with embedded priors which can accurately approximate the entropy rate for rate-distortion optimization. It utilizes three separable
   stacks to eliminate the blind spots in the receptive field for better probability prediction and computation reduction.  Those embedded priors can be further used to help the image reconstruction when fused with latent features, after passing through the proposed information compensation network (ICN). Residual learning with generalized divisive normalization (GDN) based activation is used in our encoder and decoder with fast convergence rate and efficient performance.  We have evaluated our model and other methods using rate-distortion criteria, where distortion is measured by multi-scale structural similarity (MS-SSIM). We have also discussed the impacts of various distortion metrics on the reconstructed image quality. Besides, a field study on perceptual quality is also given via a dedicated subjective assessment, to compare the efficiency of our proposed methods and other conventional image compression methods.









§ INTRODUCTION

  The explosive growth of image/video data across the entire Internet poses a great challenge to network transmission and local storage, and puts forward higher demands for high-efficiency image compression. Conventionally, image compression methods, , JPEG <cit.>, JPEG2000 <cit.>, High-Efficiency Video Coding (HEVC) Intra Profile based BPG <cit.>, ,  exploit and eliminate the redundancy via spatial prediction, transform and entropy coding.
   Nevertheless, these conventional methods can hardly break the performance bottleneck due to linear transforms with fixed basis, and limited number of prediction modes.
   On the other hand, machine learning based models <cit.> have led to a great success in image compression because of learned high-effective nonlinear transform and accurate entropy rate modeling.
   These learning based methods utilize the basic autoencoders to transform the image into
   compressible representations at the bottleneck layer followed by quantization and entropy coding to generate the binary stream.

   Usually, rate-distortion optimization (RDO) is used for image/video compression <cit.> to achieve the least distortion for a given rate constraint. Here, how to accurately estimate entropy rate is the key. For instance, 
   Mentzer  <cit.> proposed a 3D conditional probability model to approximate the entropy rate and applied an importance map for adapative spatial bits allocation. Inspired by the variational autoencoders (VAEs), Ballé  <cit.> introduced hyperpriors as side information to construct a Gaussian distribution model for entropy probability estimation.
   Instead, in this work we introduce a conditional context model to produce appropriate probability density distribution (p.d.f) for better entropy rate estimation,
  where a gate mechanism is used to eliminate the blind spots in the receptive field caused by masked convolutions at deeper network layer, and a hyperprior is embedded as a latent vector z to predict the conditional p.d.f p(x|z) as a scale mixture of Gaussian distribution.
  We further transform the hyperprior z using an information compensation network (ICN) to jointly reconstruct the image by concatenating with the compressed latent representation together.
  In addition, we use deep residual learning (ResNet) <cit.> together with the generalized divisive normalization (GDN) activation to construct latent features efficiently.

  Our method has demonstrated the state-of-art compression efficiency over the entire Kodak database <cit.>, when evaluated using the multi scale structural similarity (MS-SSIM) and actual bitrate as shown in Fig. <ref> in comparison with Ballé(2018)  <cit.>, Rippel(2017)  <cit.>, Mentzer(2018)  <cit.>, BPG <cit.>, JPEG2000 <cit.> and JPEG <cit.>. We also investigate the impacts of various distortion metrics (i.e., SSIM, MSE, VGG extracted feature-based distortion, ) on the rate-distortion efficiency. An additional subjective quality assessment is also provided to further study the efficiency of proposed method.

  
  
  
  
  
  
  
  





§ RELATED WORK
 

Deep neural networks (DNN) based image compression generally depends on the well-known autoencoders and recurrent neural networks (RNN). These deep learning based methods are typically optimized using back propagation that requires all the steps differentiable. But the quatization operation usually does not meet this criteria. Thus, it is vital to implement an approximation process to replace conventional quantization (, rounding). Theis  <cit.> proposed to replace the direct derivative using the derivative of the expectation, achieving an identity gradient passing. Ballé  <cit.> added uniform noise to simulate the quantization approximately in training stage and replaced it with direct rounding operation at inference step. Mentzer  <cit.> applied a soft-to-hard quantization  using nearest neighbor assignments and computed the gradients relying on soft quantization <cit.>.


 Lossy image compression is mainly to perform the RDO, i.e.,  J = R+λ D, with R for the rate and D for the distortion such as mean square error (MSE) or MS-SSIM.
 λ is used to balance the rate and distortion trade-off for compressive models at various compression ratios.
 At the very beginning, MSE was used for RDO <cit.>, which often incurred  unpleasant visual experience particularly at a very low bitrate.
 MS-SSIM was then introduced as the distortion measurement because of its better correlation with human vision system (HVS) <cit.>. In the meantime, generative adversarial networks (GAN) and feature domain loss based distortion measurements in RDO process  <cit.> can produce extremely impressive reconstructions,
 but comes with fake texture and structure compared with reference image.

 PixelRNNs and PixelCNNs <cit.> utilize the historical data (i.e., pixel intensity, pixel p.d.f) to predict the information at current location with masked convolutions. PixelRNNs generally give better performance but PixelCNNs present higher computational efficiency. Mentzer  <cit.> extended the 2D PixelCNNs to a 3D structure for compression entropy modeling. However PixelCNNs always suffer from the blind spots which will be enlarged as the growth of receptive field observed in <cit.>.
Ballé <cit.> then proposed to construct hyperpriors and calculate the variance for Gaussian distribution as p.d.f for entropy rate modeling.

 Besides, other methods such as pyramidal decomposition <cit.> and generalized divisive normalization (GDN) based nonlinear transformation are introduced to improve the compression performance. GDN is proved to be more effective than other nonlinear activations in learning based compression <cit.>. But it usually leads to unstable training using Adam optimization with a larger learning rate.






§ PROPOSED METHOD

We define our image compression framework in Fig. <ref> using an encoder E, a decoder D, an information compensation network (ICN) I, a hyper encoder h_e, a hyper decoder h_d and a conditional context model P using the output of h_d as embedded priors.
Given an image x, the encoder E transform x into the latent representation y=E(x).
Then we add uniform noise to approximate the quantization operation Q to generate the quantized representation ŷ=Q(y).
A hyper encoder h_e with quantization is introduced to transform y into more compact representation ẑ=Q(h_e(y)) as side information.
We use an symmetric hyper decoder h_d to construct the symbols z_p=h_d(ẑ) for  conditional probability modeling and image reconstruction via ICN I. More specifically, ICN generated information is then concatenated with ŷ for the final reconstruction of x̂=D([ŷ,I(z_p])).
Here [.] represents the channel concatenation function. A gated conditional context model
P is applied to provide the mean μ and scale variance σ jointly based on z_p and ŷ using (μ,σ)=P(ŷ,z_p).
Note that z_p is treated as embedded priors for both P and D to improve the image reconstruction and the conditional probability modeling during the training.





 §.§ Residual learning with GDN Activation

GDN has been proved to be a good density model of images, and shows impressive performance compared with other nonlinear activation functions such as ReLU, leakyReLU and softplus used in compression networks <cit.>.
However with the growth of transform capacity and deeper architecture, the training becomes unstable using a larger learning rate. Even with a smaller learning rate, it often converges slowly and usually gets stuck to sub-optimal results. Klopp  <cit.> proposed a sparse GDN that uses ReLU in GDN function, to make sparse activation for better results than those reported in <cit.>. Instead, inspired by high efficiency of ResNet <cit.>, we use residual learning framework but replace the conventional ReLU activation with the GDN, yielding very effective performance for training. It is shown in Fig. <ref> that for the same number of layers used in our framework, residual connections can achieve 4× faster of convergence rate and marginal performance improvement.




 §.§ Entropy Rate Modeling


We use different density models for ŷ and ẑ.
We model the priors ẑ using a non-parametric, fully factorized density model following <cit.>. We convolve it with a standard uniform density to get p_ẑ|ψ,

    p_ẑ|ψ(ẑ|ψ) = ∏_i ( p_z_i|ψ^(i)(ψ^(i))*𝒰(-1/2,1/2)) (ẑ_i),

where ψ^(i) represents the parameters of each univariate distribution p_ẑ|ψ^(i).

For ŷ, each element ŷ_i can be modeled as a Gaussian distribution,

    p_ŷ|ẑ(ŷ|ẑ) = ∏_i (𝒩(μ,σ) *𝒰(-1/2,1/2)) (ŷ_i),

where its μ and σ are predicted by P(ŷ,z_p). We can simply use the cumulative distribution function (CDF) to calculate the probability of each symbol for Gaussian distribution. Note that P represents the gated conditional context model that takes the z_p as a hidden vector to jointly derive μ and σ with ŷ.



  §.§.§ Gated 3D Context Model

To predict μ and σ of Gaussian distribution, we propose a PixelCNN <cit.> alike method for entropy rate modeling. Traditional PixelCNNs usually predict the pixels in a raster scan manner and estimate  next channel by combining former reconstructed and current channel information. Note that x_i is the current pixel and the conditional distribution is represented as:

    p(x) = ∏_i p(x_i|x_1,...,x_i-1),

  Mentzer  <cit.> introduced a 3D probability model and proved to be more powerful than other traditional methods. However, if we make the context model larger for better prediction by adding more layers, it usually loses the information at the top-right corner. To solve such blind spot problems, we design a novel gated probability model inspired by <cit.> to split the 3D convolution kernal   into 3 separable stacks, i.e., channel stack, vertical stack and horizontal stack as shown in Fig. <ref>.



   Therefore, we can access the entire neighbors of previous pixels in a 3D cubic. It is supposed that a (n×n×n) convolution kernel with a mask can be simply split into (n×n×⌈n⌉/2), (n×⌈n⌉/2×1) and (⌈n⌉/2×1×1)
convolutions via appropriately padding and cropping. It is also proven to be a very effective way to increase the parallelization and improve the prediction performance of context model. Each output of stack can be expressed as:

    v = tanh(W_k_1*a)⊙σ(W_k_2*a),

where a denotes the input of separable stacks, v denotes the output and W_k is the weight of convolution. It performs the similar way as gate mechanism which is widely used in LSTM <cit.> to model the complex interactions. In fact, residual connections between each stack are also applied to formulate our final gated model as shown in Fig. <ref>.





  §.§.§ Conditional Generation

    Conditional generation models commonly utilize the embedding as extra information to generate the output which is related to it. Conditional generative adversarial networks (CGAN) <cit.> introduced a method to generate the images belonging to the relevant category with a caption. For sequential data, Mathieu  <cit.> utilized the previous reconstructed frame as priors to combine with the generated frames for training the discriminator. We predict the current pixel using the former pixels and the hyperpriors produced by h_d as additional conditions and rewrite Eq. (<ref>) and (<ref>) as:




    p(x) = ∏_i p(x_i|x_1,...,x_i-1,h),

 
    v = tanh(W_k_1*a+V_k_1*h)⊙σ(W_k_2*a+V_k_2*h),

where h denotes the output of the hyper decoder z_p, V_k is the 1×1×1 convolution kernel.

Eq. (<ref>) describes a basic layer in our gated conditional context model.
We split the final output into μ and σ as the same size of ŷ.
By calculating probability of each symbol ŷ_i, we can further get the entropy of ŷ:

    R_ŷ = - ∑_ilog_2(p_ŷ_i|ẑ_i(ŷ_i|ẑ_i)),
 while the entropy of ẑ is calculated as the same:
 
    R_ẑ = -∑_ilog_2(p_ẑ_i|ψ^(i)(ẑ_i|ψ^(i)))




 §.§ Information Compensation Network


Ballé  <cit.> proposed a hyper model as a probability model for entropy coding. During the training, the hyperpriors ẑ consume a portion of bits that is referred as the side information cost.
We could consider the whole framework as a scalable compression system, where the essential problem is how to allocate the bits between latent features ŷ and hyperpriors ẑ.
 While more bits are spent to ẑ,  an ICN is necessary to fully exploit the information and correlation contained in ẑ for final image reconstruction.
 Although we use concatenation operation to fuse the information, an add operation can also be adapted at the bottom layer to treat ẑ as residual information as presented in <cit.>. Overall, we provide a 3-layer modified residual network to achieve information reconstruction and pass-through. We remove Batch Normalization layers (BN) and replace the ReLU with PReLU in this study.




§ EXPERIMENTAL STUDIES

This section details the compression efficiency for our proposed framework. We set N and M to 192 and 128 to train the entire system in an end-to-end fashion.






Dataset: We use COCO <cit.> and CLIC <cit.> training dataset to train our framework. We randomly resize the images and take 256 × 256 crops for preprocessing.  Furthermore, we test the results on the standard Kodak dataset <cit.> for fair comparison.

RDO in Encoder Control We choose MS-SSIM as our distortion metric d and the loss function is described as:

    L = λ(1-d)+R_y+R_z

where we set different λ to achieve rate-distortion trade-off to generate several models for variable compression ratio.
In our experiment, we set λ to 2, 8, 32, 128 and 384. We replaced the MSE with MS-SSIM <cit.> because it exhibits better correlation with the subjective quality perceived by our HVS.
We then also study the impact of various distortion metrics on the compression efficiency, particularly for low bitrate range.

Training: All of the modules in our framework are trained together.
We set different learning rate ρ for E, D, h_e, h_d and P. For E, D, h_e, h_d, we use a ρ of 10^-4 and clip the value after 30 epoch to 10^-5. For P, we use a ρ of 5 × 10^-5.
Batch size is set to 64 and finally trained on 4-GPUs in parallel. To evaluate the results for different distortion metrics, we retrain our compression framework accordingly, and control the bitrate close to each other as much as possible.

Performance: The performance comparison measured on Kodak is shown in Fig. <ref>. Our method offers the state-of-the-art efficiency by outperforming the traditional codecs such as BPG, JPEG2000 and JPEG as well as those learning based methodologies reported in <cit.>. We also plot the R-D curves for three typical images in Fig. <ref>, to further evident the superior performance of our proposed method over the traditional image codecs. In the mean time,  Fig. <ref> visualizes the sample snapshots of reconstructed “kodim15” that were compressed at similar bit rate using our proposed method, BPG, JPEG and JPEG2000. We can clearly observe that our method have provided a better reconstruction with clean details and sharp edges. Besides, in the subsequent Section <ref>, we have given in-depth studies on the perceptual quality of compressed images via a dedicated subjective quality assessments.










Additional Studies for Distortion Metric To explore the impact of various distortion  metrics on the compression efficiency (particularly at low bitrate), we choose MSE, SSIM, MS-SSIM and MSE in feature domain based on VGG19 <cit.> (MSEf) to conduct extra experiments. For fair comparison, we control the bitrate for each metric as close as possible and optimize the compression framework individually. We find that MSE always shows the over-smoothed results and SSIM provides a strong contrast but a slight brightness shift. For feature domain loss MSEf, it usually causes some noise around texture. Note that we extract the 5th, 10th and 17th layer of VGG19 net as the representations for the shallow-, mid-, high-level features, respectively. The result is shown in Fig. <ref>. 




§ SUBJECTIVE QUALITY ASSESSMENT

Existing objective quality metrics, , PSNR, SSIM, sometimes are not always consistent with our subjective perception. A straightforward way is to perform the subjective assessment. Towards this goal, we have invited 43 volunteers to participate the assessments. These subjects are from diverse majors including 19 males and 24 females, aging from 18 to 30. All of them have normal vision(or after  correction) and color perception, and almost all of them (≈98%)  are naive without expertises in video/image compression field.





 §.§ Test Sequence Pool

Eight images, all sampled at 768×512 and shown in Fig. <ref>),
are selected from the Kodak dataset for assessments.
These images covers a wide range of content complexity measured by the spatial information index (SI).
Each image was encoded with four codecs, i.e., Ours, BPG(4:4:4), JPEG, JPEG2000, using multiple bitrate settings for sufficient quality scales. Even though we enforce the same bitrates for all contents, it still present the variations for actual encoded bits because of the distinct content characteristics.















 §.§ Test Protocol

All test sequences are displayed at the center of a 23.8 inch DELL U2414H monitor with a resolution of 1920×1080. Viewers usually rate the image from a 65-cm distance away,  which keeps a 18.2^∘ visual angle that ensures the viewer with the most accurate sensation of the image quality. The displayed contents are surrounded with a mid grey level background as recommended by BT.500-13 <cit.>.

We adopt the Double Stimulus Impairment Scale (DSIS <cit.>) Variant 1 to evaluate the impairments across different compression methods.
In this test, each stimulus consists of a pair of images with identical content, while one is the original image as the reference, another is the one with compression noise.
Image pairs are displayed sequentially for about 6 seconds with a 3-seconds pause followed for subjects to give the ratings.


We divide the reference images and their corresponding variants into two sub-groups  to avoid unexpected rating
noise caused by dizziness and tiredness due to a longer duration of assessment. Image pairs with various bitrates but same content are randomly permuted. Different contents occur alternatively in case that the same reference image with its variants are presented for two successive occasions with the same or different levels of impairment. Each image repeats twice in general. We prepare the training sequence to let viewers familiarize with the test protocol before the formal test.



 §.§ Test Analysis

For each image pair, raw scores from all participants are collected.
 A standard outliers screening is conducted to remove subjects whose ratings deviate from others largely, under the guidelines recommended in <cit.>.
 After data screening, each test sequence has 20 valid ratings. We average all users' ratings for each processed image sample as its mean opinion score (MOS).
 Then we plot the MOS together with confidence interval (CI) versus bitrates in Fig. <ref>.


 It is observed that the subjective results are reliable as the 95% confidence interval is relatively small.
Apparently, our method demonstrates better perceptual quality at low bitrate for almost all test images, i.e., ≤ 0.5 bpp. For those extremely low bitrates (≤ 0.2 bpp), our method still presents high-quality
and conformable reconstructions, but others often produce very bad image quality with color distortion, blockiness and oversmoothed area, as exemplified in Fig. <ref>.

For high bitrate scenarios, we have found that BPG and JPEG2000 present better visual quality. One main reason is that MS-SSIM metric used in our method is not favored at high bitrate for end-to-end learning, but rather the PSNR. Figure <ref> plots the PSNR versus bitrate for Motobike image. We can see that the PSNR of our learning based method is even worse than JPEG at high bitrate case. Hence, it calls for an effective distortion metric that can preserve the fidelity for entire bit rate range when applied in learning based methodology.










 
 
 







§ CONCLUSION

In this paper, we proposed a novel gated context model with embedded priors for end-to-end optimized image compression
and achieve the state-of-the-art performance measured by MS-SSIM and bitrate.
A three separable stacks are used to avoid blind spots in conditional probability prediction for entropy rate modeling. In addition, those embedded priors are exploited and fused with latent features to improve the final image reconstruction, via introduced information compensation network. Residual learning with GDN has proved to maintain both convergence speed and performance.

Additional studies have been extended to investigate various distortion metrics in learning framework, such as MSE, SSIM, MS-SSIM, MSEf, , together with the independent subjective quality assessment, to evaluate the efficiency of our proposed methods and other traditional image compression schemes. MS-SSIM used in current work could preserve high-quality reconstructions at low bitrate (i.e., ≤0.5 bpp) scenarios.  A better distortion metric is highly desired for learning based compression, to retain the same performance as MS-SSIM for low bitrate range, and as PSNR or MSE  used in BPG, JPEG2000 for high bitrates.

For future study, we can make our context model deeper to improve image compression performance. Parallelization and acceleration is important to deploy the model for actual usage in practice, particularly for mobile platforms. In addition, it is also meaningful to extend our framework for end-to-end video compression framework with more priors acquired from spatial and temporal information.

ieee



