Abstract
Current state-of-the-art image generation models typically employ a two-stage process involving fixed-length vector quantization followed by autoregressive modeling. However, this approach ignores local information density, leading to either insufficient detail in complex regions or redundancy in simple ones. This paper introduces Dynamic Vector Quantization (DQ), a framework that utilizes variable-length coding to adapt to local image complexity. By employing a DQ-VAE for adaptive compression and a DQ-Transformer for coarse-to-fine generation, the proposed method achieves superior reconstruction quality and faster generation speeds compared to traditional fixed-length counterparts.
Introduction
The standard paradigm for high-resolution image synthesis involves compressing images into a discrete grid of codes (e.g., VQGAN) and subsequently modeling these codes using a transformer. A significant limitation of this approach is its uniform treatment of image regions. Whether a region contains intricate textures, such as a cheetah's fur, or a uniform background like a clear sky, it is allocated the same number of codes. This leads to a "double whammy" of inefficiency: complex areas suffer from poor detail reconstruction due to code insufficiency, while simple areas waste computational resources on redundant data.
Furthermore, the rigid grid structure of fixed-length coding necessitates an unnatural raster-scan (top-left to bottom-right) generation order. This order fails to capture the inherent hierarchical structure of images, where global context often informs local details.
Methodology
The proposed framework consists of two primary components: DQ-VAE and DQ-Transformer.
DQ-VAE (Stage 1)
The DQ-VAE replaces the standard fixed-downsampling encoder with a hierarchical encoder. This encoder produces multiple candidate representations at different granularities. A Dynamic Grained Coding (DGC) module then selects the optimal granularity for each local region based on its information density. To ensure efficient code usage, a "budget loss" is incorporated during training, encouraging the model to adhere to a target distribution of granularities rather than simply defaulting to the highest resolution for all regions.
DQ-Transformer (Stage 2)
Because DQ-VAE produces a variable-length, non-grid representation, traditional raster-scan autoregression is inapplicable. The DQ-Transformer addresses this by generating images in a coarse-to-fine order. It utilizes two interleaved transformer modules:
- Position Transformer: Predicts the location of the next code.
- Content Transformer: Predicts the code's value.
This dual-prediction mechanism allows the model to first establish the global structure before refining specific details, mirroring the human artistic process or the way one might solve a jigsaw puzzle.
Experimental Results
The model was evaluated on the FFHQ (unconditional face generation) and ImageNet (class-conditional generation) benchmarks.
Quality and Efficiency: DQ-VAE demonstrates a significant improvement in visual fidelity. On FFHQ, the model achieved a 7.4% improvement in Frechet Inception Distance (FID) over ViT-VQGAN. On ImageNet, it outperformed other million-parameter scale models by 17.3%. Beyond quality, the framework offers substantial speed advantages. By reducing redundancy in simple regions, the DQ-Transformer (base) achieves faster inference times than ViT-VQGAN across various batch sizes.
Key Insights: The success of DQ stems from its adherence to the "Pareto Principle" in pixels: a small fraction of "important" regions often dictates the perceived visual quality. By dynamically routing more "bits" to these high-entropy areas using Gumbel-Softmax, the model learns to prioritize complexity. Additionally, breaking the raster-scan constraint allows for a more semantically meaningful generation process that focuses on importance rather than position.
Conclusion
Dynamic Vector Quantization represents a shift toward more efficient and accurate image coding. By adapting code density to local information, the DQ framework improves both reconstruction quality and generation efficiency. While current implementations rely on pre-defined granularity budgets, future research may explore fully autonomous budget allocation and the application of dynamic quantization to other generative architectures, such as diffusion models or bi-directional transformers.
Summary updated