LayoutTransformer: Layout Generation and Completion with Self-attention

Kamal Gupta, Justin Lazarow, Alessandro Achille, Larry Davis, Vijay Mahadevan, Abhinav Shrivastava

Introduction

Generating realistic scenes—whether they are natural images, 3D models, or user interface (UI) wireframes—requires more than just high-fidelity pixel synthesis. It necessitates an understanding of the underlying spatial schema, or the "layout." While modern generative models excel at appearance, they often struggle with the complex contextual relationships between objects, such as the alignment of UI elements or the structural integrity of 3D parts.

LayoutTransformer addresses this by treating layout generation as a domain-agnostic sequence modeling problem. By framing spatial arrangement as a language, the model can generate new layouts from scratch or complete partial ones across diverse domains.

Methodology

LayoutTransformer is an autoregressive framework based on a masked Transformer Decoder. It represents a layout as a set of graphical primitives (bounding boxes or 3D parts), where each primitive is factorized into discrete attributes: a semantic category and geometric fields (position and scale).

The LayoutTransformer architecture treats layout attributes as a sequence of discrete tokens, using masked self-attention to predict subsequent elements.

A key innovation is the discretization of geometric parameters. Instead of regressing continuous coordinates, the authors apply 8-bit uniform quantization to spatial values. This converts spatial coordinates into discrete tokens modeled by a categorical distribution. This discretization allows the model to capture multi-modal distributions and maintain the precise alignments necessary for structured domains like document and UI design.

Domain-Agnostic Evaluation

To demonstrate the model's versatility, it was evaluated on four highly diverse datasets:

  • PartNet: 3D shapes (Chairs and Lamps) decomposed into semantic parts.
  • COCO Bounding Boxes: Natural scene layouts featuring 171 categories.
  • Rico Mobile App Wireframes: UI layouts for Android apps containing elements like text, images, and buttons.
  • PubLayNet: Scientific document layouts containing text, titles, lists, and figures.

Key Insights

The research highlights several critical advantages of the self-attention approach for layouts:

  1. Discretization for Alignment: Unlike continuous models that produce "blurry" predictions, discrete tokens allow for the exact grid-based alignments found in professional layouts and mobile apps.
  2. Decoupled Attributes: Predicting coordinates as separate tokens enables the self-attention mechanism to focus on specific dimensions. For instance, it can attend specifically to the x-coordinate of a previous element to align a new one.
  3. Emergent Semantics: The model learns semantic co-occurrence patterns (e.g., a "snowboard" appearing near "snow") purely from geometric data, without needing explicit text embeddings or external semantic knowledge.

Results and Applications

LayoutTransformer demonstrates strong performance in both unconditional generation and layout completion. In 3D tasks, it matches or exceeds state-of-the-art point cloud metrics, effectively learning how to assemble complex objects from individual components.

Autoregressive completion of a 3D chair layout, where the model predicts and places parts sequentially to form a coherent object.

In natural image synthesis (COCO), layouts generated by the model achieved a state-of-the-art Frechet Inception Distance (FID) of 57.0 when rendered into images. For structured data like Rico and PubLayNet, the model maintained superior spatial statistics and canvas coverage compared to VAE and GAN baselines, which often struggle with the strict constraints of UI and document design.

Conclusion and Future Work

LayoutTransformer provides a unified, powerful approach to scene synthesis by framing layout as a sequence. While the model currently relies on a heuristic raster-scan ordering for training, its ability to learn complex spatial relationships across 2D and 3D domains marks a significant step toward more intelligent and structured generative systems. Future research will likely focus on developing truly order-invariant models for arbitrary sets of primitives.

Summary updated

BibTeX
@inproceedings{gupta2021layouttransformer,
  author = {Kamal Gupta and Justin Lazarow and Alessandro Achille and Larry Davis and Vijay Mahadevan and Abhinav Shrivastava},
  title = {{LayoutTransformer: Layout Generation and Completion with Self-attention}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2021},
  doi = {10.1109/iccv48922.2021.00104},
}
Figure