StructLayoutFormer:Conditional Structured Layout Generation via Structure Serialization and Disentanglement

Xin Hu, Pengfei Xu, Jin Zhou, Hongbo Fu, Hui HuangIEEE TVCG 2025

Abstract

Automated layout design has traditionally focused on generating "flat" sets of bounding boxes, a method that fails to capture the inherent hierarchical logic of professional design. We introduce StructLayoutFormer, a novel Transformer-based framework designed to generate fully structured layouts for GUIs and webpages. By employing structure serialization and a disentangled latent space for structural "skeletons," the model enables sophisticated design tasks such as structure transfer and organization-conditioned generation. Our approach significantly outperforms existing baselines in structural fidelity and layout quality on the RICO and WebForest benchmarks.

Introduction

In modern UI/UX design, layouts are rarely just a collection of rectangles; they are hierarchical trees. A "Search Bar" is not merely a box, but a container housing an icon and a text input. Existing automated tools—utilizing GANs, VAEs, or Diffusion models—often ignore this internal logic, treating layouts as flat lists. This lack of structure presents two major hurdles: it makes layouts difficult to edit (as grouped elements are not linked) and complicates responsive design, where hierarchical groups must reflow across different screen sizes.

While Recursive Neural Networks (RvNNs) have been used to address hierarchy, they are computationally expensive and struggle with long-range dependencies. StructLayoutFormer bridges this gap by adapting the Transformer architecture to handle tree-like structures through sequence-based serialization and structural disentanglement.

Methodology

1. Structure Serialization

To process hierarchical trees within a sequence-based Transformer, StructLayoutFormer "flattens" the tree level-by-level. The model utilizes specific binary flags for each node to indicate whether it is a leaf (a visible element) or an internal node (an invisible container). It also tracks whether a node is the final child of its parent. A special <nl> (next level) token is used to guide the model through the hierarchy, allowing it to maintain the tree's integrity during generation.

2. Structure-Placement Disentanglement

A core innovation of the model is the separation of the layout's "skeleton" from its specific element placement. This is achieved through a Structure Encoder (a Transformer-VAE) that compresses the high-level organizational logic into a latent code ($z$). This code serves as a condition for the Conditional Layout Generator. By deciding on the general structure before placing specific buttons or text boxes, the model mimics the human design process of wireframing before detailing.

3. Contextual Awareness

The model incorporates a Context Encoder that monitors both local relationships (parent and sibling nodes) and global patterns. This ensures that as each new element is generated, it fits logically within both its immediate group and the overall design composition.

Experimental Setup and Metrics

The model was evaluated on two primary benchmarks:

  • RICO: Over 66,000 mobile GUI layouts.
  • WebForest: 4,500 structured webpage layouts.

Traditional metrics focus on bounding box overlap (IoU) or alignment. To better assess hierarchical quality, the authors introduced new Structure Metrics, including S-Align and S-Inclusion, which measure how well the generated hierarchies reflect real-world design logic.

Key Results and Discussion

StructLayoutFormer demonstrates a significant improvement over state-of-the-art baselines like LayoutFormer++ and LayoutDM.

  • Structural Fidelity: On the RICO dataset, the model achieved a W S-Label (Wasserstein distance for structure labels) of 4.90, notably better than the next best baseline's 7.57.
  • Functional Versatility: The disentangled architecture allows for unique workflows. In Structure Transfer, the model can take the organizational logic of a complex site and apply it to a new set of user-provided assets. It also excels in GenO (generation based on grouping constraints) and StructExtr (inferring hierarchy from a flat set of elements).
  • Efficiency: Despite the hierarchical complexity, the model remains performant, generating a complete structured layout in approximately 1.51 seconds on standard hardware.

One notable insight is the treatment of invisible structural containers (e.g., "LinearLayout") as elements themselves. This allows the model to learn the placement of "groups" with the same ease as individual buttons, leading to more explicit and editable hierarchies compared to post-processed "flat" models.

Conclusion and Future Work

StructLayoutFormer represents a shift toward more intelligent, design-aware automation. While the model is highly flexible, the authors note that randomly sampled structure codes may not always perfectly match highly specific, high-density user constraints (e.g., fitting 50 elements into a 5-element structure). Future research will explore the application of this framework to 3D scene generation and the integration of Diffusion models to further enhance the diversity and realism of generated structures.

Summary updated

BibTeX
@article{hu2025structlayoutformer,
  author = {Xin Hu and Pengfei Xu and Jin Zhou and Hongbo Fu and Hui Huang},
  title = {{StructLayoutFormer:Conditional Structured Layout Generation via Structure Serialization and Disentanglement}},
  journal = {IEEE Trans. Vis. Comput. Graph.},
  year = {2025},
}
Figure