Image Compression with Product Quantized Masked Image Modeling

Alaaeldin El-Nouby, Matthew J. Muckley, Karen Ullrich, Ivan Laptev, Jakob Verbeek, Hervé Jégou

Abstract

Recent neural compression methods have been based on the popular hyperprior framework. It relies on Scalar Quantization and offers a very strong compression performance. This contrasts from recent advances in image generation and representation learning, where Vector Quantization is more commonly employed. In this work, we attempt to bring these lines of research closer by revisiting vector quantization for image compression. We build upon the VQ-VAE framework and introduce several modifications. First, we replace the vanilla vector quantizer by a product quantizer. This intermediate solution between vector and scalar quantization allows for a much wider set of rate-distortion points: It implicitly defines high-quality quantizers that would otherwise require intractably large codebooks. Second, inspired by the success of Masked Image Modeling (MIM) in the context of self-supervised learning and generative image models, we propose a novel conditional entropy model which improves entropy coding by modelling the co-dependencies of the quantized latent codes. The resulting PQ-MIM model is surprisingly effective: its compression performance on par with recent hyperprior methods. It also outperforms HiFiC in terms of FID and KID metrics when optimized with perceptual losses (e.g. adversarial). Finally, since PQ-MIM is compatible with image generation frameworks, we show qualitatively that it can operate under a hybrid mode between compression and generation, with no further training or finetuning. As a result, we explore the extreme compression regime where an image is compressed into 200 bytes, i.e., less than a tweet.

Introduction

Neural image compression has traditionally diverged into two paths. Standard compression models prioritize efficiency using Scalar Quantization (SQ) and hyperpriors. Conversely, generative models like VQ-GAN leverage Vector Quantization (VQ) to capture complex data distributions, though VQ often struggles with the scalability required for diverse bitrates. This research introduces PQ-MIM, a framework designed to bridge this gap by combining the representational power of generative modeling with the flexibility of traditional compression.

Methodology: PQ and MIM

The PQ-MIM framework introduces two primary innovations to the VQ-VAE architecture:

  1. Product Quantization (PQ): Instead of mapping a high-dimensional latent vector to a single entry in a massive codebook, PQ decomposes the vector into $M$ sub-vectors. Each sub-vector is quantized using its own smaller codebook. This approach allows the model to represent a vast number of "virtual" codewords ($V^M$) with minimal memory overhead, enabling fine-grained control over the rate-distortion trade-off.
  2. Masked Image Modeling (MIM) Entropy Model: To compress the quantized tokens, the model employs a conditional entropy model inspired by MaskGIT. Rather than slow, pixel-by-pixel raster scanning, PQ-MIM predicts tokens in parallel stages using a Quincunx pattern (a 5-stage grid refinement).
The PQ-MIM pipeline: from image encoding and product quantization to parallel entropy coding and decoding.

The system utilizes XCiT (Cross-Covariance Image Transformers), which offer linear complexity relative to pixel count, making them highly efficient for high-resolution image processing.

Experimental Results

The model was trained on ImageNet and evaluated on standard benchmarks including Kodak, Tecnick, and CLIC 2020.

Perceptual Superiority and Extreme Compression

When optimized with adversarial and LPIPS losses, PQ-MIM demonstrates superior perceptual quality. It outperforms HiFiC, a leading GAN-based compressor, in FID and KID metrics. Notably, the model excels in the extreme compression regime, operating at bitrates as low as 0.03 bpp. At this level, a 256x256 image can be compressed into approximately 200 bytes.

Visual comparison of PQ-MIM against the original image and HiFiC at low bitrates.

Key Insights

  • PQ as a Hybrid Quantizer: PQ serves as a middle ground between SQ and VQ, avoiding "codebook collapse" while maintaining high representational power.
  • Compression as Inpainting: The generative nature of the entropy model allows the codec to "understand" data. It can effectively "fill in the blanks" if up to 50% of the data is lost during transmission.
  • Parallel Decoding: The Quincunx masking pattern enables significantly faster decoding compared to traditional autoregressive models.

Discussion and Limitations

While PQ-MIM is highly effective at low-to-extreme bitrates, traditional Scalar Quantization methods still maintain an edge at bitrates above 0.6 bpp. Additionally, the use of a 12-layer Transformer for entropy coding introduces higher computational complexity than simpler legacy codecs. Future research may focus on more efficient Transformer architectures or hybridizing PQ with scalar methods to improve performance in high-bitrate scenarios.

Summary updated

BibTeX
@article{elnouby2023image,
  author = {Alaaeldin El-Nouby and Matthew J. Muckley and Karen Ullrich and Ivan Laptev and Jakob Verbeek and Hervé Jégou},
  title = {{Image Compression with Product Quantized Masked Image Modeling}},
  journal = {Trans. Mach. Learn. Res.},
  year = {2023},
  url = {https://openreview.net/forum?id=senZQVgRNL},
}
Figure