NP-DRAW: A Non-Parametric Structured Latent Variable Model for Image Generation

Xiaohui Zeng, Raquel Urtasun, Richard S. Zemel, Sanja Fidler, Renjie Liao

Abstract

In this paper, we present a non-parametric structured latent variable model for image generation, called NP-DRAW, which sequentially draws on a latent canvas in a part-by-part fashion and then decodes the image from the canvas. Our key contributions are as follows: 1) We propose a non-parametric prior distribution over the appearance of image parts so that the latent variable “what-to-draw” per step becomes a categorical random variable. This improves expressiveness and eases learning compared to Gaussians used in previous literature. 2) We model the sequential dependency structure of parts via a Transformer, which is more powerful and easier to train compared to RNNs. 3) We propose an effective heuristic parsing algorithm to pre-train the prior. Experiments on MNIST, Omniglot, CIFAR-10, and CelebA show that our method significantly outperforms previous structured image models like DRAW and AIR and is competitive with other generic generative models. Moreover, we show that our model’s inherent compositionality and interpretability bring significant benefits in the low-data learning regime and latent space editing.

Introduction

Most popular generative models, such as standard Variational Autoencoders (VAEs) and Generative Adversarial Networks (GANs), generate all pixels of an image simultaneously in a "one-shot" approach. While effective, these models often operate as "black boxes," where the latent space is a high-dimensional vector that is difficult to interpret or manipulate. In contrast, humans understand and create scenes structurally, drawing one component at a time. Previous "structured" models like DRAW and AIR attempted to mimic this process but relied on Gaussian latent variables and Recurrent Neural Networks (RNNs), which struggled to capture complex, multi-modal appearances and were difficult to train. NP-DRAW aims to bridge this gap by making the generation process explicit, modular, and easier to optimize.

Methodology

NP-DRAW introduces several key innovations to the structured generation pipeline:

  1. Non-Parametric Part Bank: Instead of modeling part appearance with continuous Gaussian distributions, NP-DRAW uses a categorical distribution. A "dictionary" of exemplar parts is built by clustering random patches from the training data (using k-medoids). The model then selects which exemplar to place at each step.
  2. Transformer-Based Prior: Replacing traditional RNNs, a Transformer architecture models the dependencies between parts. This allows the model to better understand spatial and structural relationships while benefiting from the parallel training and stability of Transformers.
  3. The Latent Canvas: The model maintains a canvas updated at each step. It decides what to draw (from the part bank), where to draw it (on a discretized 2D grid), and whether to draw at all (a Bernoulli "skip" variable).
  4. Heuristic Parsing and Refinement: To stabilize training, a heuristic parsing algorithm deconstructs existing images into parts to pre-train the prior. After the sequential process creates a rough latent canvas, a final CNN-based decoder adds fine details to produce the final image.
Overview of the NP-DRAW generation process, illustrating how parts are selected from a bank and sequentially placed on a discretized grid to form a latent canvas.

Experiments and Results

The model was evaluated on four standard benchmarks: MNIST, Omniglot, CIFAR-10, and CelebA. NP-DRAW significantly outperformed previous structured models like DRAW and AIR across all datasets. For example, on MNIST, it achieved an FID score of 2.84, compared to DRAW's 27.07. Furthermore, it remains competitive with top-tier generic models; on CelebA, its FID of 41.10 was nearly on par with WGAN's 40.29.

Key Insights

  • Discrete Expressiveness: By turning part selection into a categorical choice from a bank, the model avoids the blurring common in Gaussian-based models.
  • Compositionality in Low-Data Regimes: NP-DRAW performs exceptionally well when training data is scarce. By learning the "grammar" of how parts combine, it can generate novel images even after seeing very few full examples.
  • Spatial Interpretability: Unlike standard VAEs, NP-DRAW's latent space is spatially grounded, allowing for surgical latent space editing by manipulating specific parts of the canvas.
Qualitative comparison of NP-DRAW (Ours) against VQ-DRAW, WGAN, and VAE across various datasets, demonstrating superior structural clarity.

Conclusion

NP-DRAW demonstrates that a non-parametric, part-based approach to image generation can achieve high performance while maintaining interpretability. While the current model uses a discretized grid and a fixed prior during VAE training, future work could explore joint learning and multi-scale strategies to scale the approach to high-resolution imagery.

Summary updated

BibTeX
@inproceedings{zeng2021np,
  author = {Xiaohui Zeng and Raquel Urtasun and Richard S. Zemel and Sanja Fidler and Renjie Liao},
  title = {{NP-DRAW: A Non-Parametric Structured Latent Variable Model for Image Generation}},
  booktitle = {Conference on Uncertainty in Artificial Intelligence},
  year = {2021},
  url = {https://openreview.net/forum?id=03W1EOsbsx},
}
Figure