Semantic Image Synthesis with Semantically Coupled VQ-Model

Stephan Alaniz, Thomas Hummel, Zeynep Akata

TL;DR

Standard two-stage generative pipelines (like VQGAN + Transformer) for semantic image synthesis typically train separate vector-quantized autoencoders for images and semantic maps, leaving the autoregressive Transformer with the heavy burden of learning cross-modal correspondences from scratch. This paper introduces a semantically coupled VQ-model that jointly encodes images and segmentation maps into shared, complementary discrete latent spaces. By tying the modalities during the autoencoding stage, the downstream Transformer generates images that adhere far more accurately to semantic layouts and preserve subtle object details.

What Problem Does This Paper Address?

Semantic image synthesis tasks a generative model with creating realistic images that follow a user-defined semantic layout (e.g., specifying where the sky, roads, buildings, or people should appear). Recent state-of-the-art approaches decompose this into a two-stage process:

  1. Compress high-resolution images and semantic maps into discrete tokens using Vector-Quantized (VQ) autoencoders (such as VQVAE or VQGAN).
  2. Train an autoregressive Transformer to predict image tokens conditioned on semantic tokens.

Prior work trained two completely separate VQ models: one for semantic masks and one for RGB images. Because the image decoder never sees the semantic tokens during training, the Transformer must learn every cross-modal correlation entirely on its own. Consequently, synthesized images often omit fine semantic details (e.g., missing street lamps, lost vehicles, or deformed boundaries).

Methods

The authors propose coupling the modalities directly within the first-stage autoencoder:

  • Joint Encoder ($f_{sEnc}$): A shared convolutional encoder takes the channel concatenation of the image $x$ and the semantic map $s$ as input, simultaneously extracting two discrete latent feature maps: image latents $z^{(x)}$ and semantic latents $z^{(s)}$.
  • Asymmetric Decoders with Gradient Detachment:
  • The semantic decoder $f_{sDec}(z^{(s)})$ reconstructs only the segmentation map $\hat{s}$.
  • The image decoder $f_{xDec}(z^{(x)}, \text{sg}(z^{(s)}))$ reconstructs the RGB image $\hat{x}$ by conditioning on both image and semantic latents.
  • A stop-gradient operator ($\text{sg}$) blocks gradients flowing from the image decoder into the semantic latent space. This prevents image noise from corrupting semantic token semantics while forcing image latents to store complementary details not already captured by the semantic latents.
  • Joint Loss Formulation: The model is trained end-to-end on a weighted objective combining the image reconstruction loss (standard VQVAE or VQGAN with an adversarial patch discriminator) and a cross-entropy semantic reconstruction loss balanced by hyperparameter $\lambda$.
  • Autoregressive Synthesis: A causal Transformer is trained to maximize the conditional likelihood $p(z^{(x)} \mid z^{(s)})$ using standard next-token cross-entropy.

Datasets

The authors train and benchmark their models on a unified dense semantic dataset combining three popular semantic segmentation benchmarks:

  • Cityscapes (20 classes)
  • ADE20k (150 classes)
  • COCO-Stuff (183 classes)

By merging overlapping category definitions (e.g., person, car, building), they construct a unified 243-class vocabulary evaluated at $256 \times 256$ resolution.

Key Insights and Ideas

  • Representation Synergy vs. Pure Autoencoding: Interestingly, training an autoencoder on both modalities slightly decreases raw image reconstruction metrics compared to an image-only autoencoder. However, for conditional generation, the joint representations make it substantially easier for the autoregressive Transformer to capture dependencies between semantics and pixel distributions.
  • Asymmetric Architectural Priors: Tying the image decoder directly to the semantic tokens relieves the image latent space from having to redundantly encode category boundaries. The image latents instead capture texture, style, and high-frequency appearance.
  • Preserving Complex Objects: Standard conditional VQGAN models frequently "hallucinate" over small or complex semantic masks (e.g., turning a bridge into water or omitting an airplane entirely). Coupling the latents forces the generator to respect fine-grained semantic boundaries.

Key Results

Evaluating conditional generation across Cityscapes, ADE20k, and COCO-Stuff using Fréchet Inception Distance (FID), Structural Similarity (SSIM), and Perceptual Similarity (LPIPS):

  • Significant Generative Improvements: The semantically coupled model (sVQGAN-T) consistently outperformed the baseline VQGAN-T across all datasets:
  • ADE20k: FID dropped from $46.50 \to 38.36$; SSIM increased from $0.0667 \to 0.0987$; LPIPS improved from $0.6460 \to 0.5534$ (lower is better).
  • COCO-Stuff: FID dropped from $33.38 \to 28.80$; SSIM increased from $0.0638 \to 0.0984$; LPIPS improved from $0.6533 \to 0.5583$.
  • Better Semantic Reconstructions with GAN Priors: When autoencoding semantic masks, sVQGAN achieved higher mean Intersection-over-Union (mIoU) than an isolated semantic VQVAE (e.g., $93.40\%$ vs. $92.38\%$ on COCO-Stuff with $\lambda=0.1$), showing that image features can act as beneficial context for semantic representations.

Limitations and Future Work

  • Reference Image Requirement: The authors note that their current inference formulation still relies on a reference image input to the VQ-model encoder, which they aim to eliminate in future iterations.
  • Quantization Information Loss: Operating at a compact $16 \times 16$ latent grid can bottleneck extremely small or intricate semantic regions, which occasionally leads to blurred segment outlines prior to decoding.

Summary updated

Abstract

Semantic image synthesis enables control over unconditional image generation by allowing guidance on what is being generated. We conditionally synthesize the latent space from a vector quantized model (VQ-model) pre-trained to autoencode images. Instead of training an autoregressive Transformer on separately learned conditioning latents and image latents, we find that jointly learning the conditioning and image latents significantly improves the modeling capabilities of the Transformer model. While our jointly trained VQ-model achieves a similar reconstruction performance to a vanilla VQ-model for both semantic and image latents, tying the two modalities at the autoencoding stage proves to be an important ingredient to improve autoregressive modeling performance. We show that our model improves semantic image synthesis using autoregressive models on popular semantic image datasets ADE20k, Cityscapes and COCO-Stuff.
BibTeX
@inproceedings{alaniz2022semantic,
  author = {Stephan Alaniz and Thomas Hummel and Zeynep Akata},
  title = {{Semantic Image Synthesis with Semantically Coupled VQ-Model}},
  booktitle = {DGM4HSD @ ICLR},
  year = {2022},
  url = {https://openreview.net/forum?id=HVlG62EdvWc},
}
Figure