UniLayDiff: A Unified Diffusion Transformer for Content-Aware Layout Generation

Zeyang Liu, Le Wang, Sanping Zhou, Yuxuan Wu, Xiaolong Sun, Gang Hua, Haoxiang Li

TL;DR

UniLayDiff is the first unified diffusion transformer capable of handling the entire spectrum of content-aware layout generation tasks—from unconditional generation to complex relational constraints—using a single set of weights. By treating layout constraints as distinct input modalities and employing a two-stage pre-training and LoRA fine-tuning strategy, it achieves state-of-the-art performance without the parameter bloat of previous task-specific methods.

What Problem Does This Paper Address?

Content-aware layout generation involves automatically arranging graphic elements (like text, logos, and background underlays) so they harmonize with a background image. It is a challenging multi-modal task because the model must respect both the visual semantics of the background (e.g., not covering important product images) and user-defined constraints (e.g., "place text A below logo B").

Existing approaches are highly fragmented. Most models only handle a subset of layout tasks, while others (like LayoutDiT or RALF) require separate models or distinct parameter sets for different types of constraints.

Figure 1. Previous models like RALF and LayoutDiT handle dif- ferent conditional generation tasks with different parameters or only support a part of conditional tasks, whereas our proposed model, UniLayDiff, is able to handle various content-aware con- ditional generation tasks in a unified diffusion model.

Furthermore, trying to train a single model on both general layout tasks and complex relational constraints simultaneously usually leads to optimization conflicts, causing severe performance degradation or mode collapse.

Methods

UniLayDiff addresses these challenges through a novel architecture and a strategic two-stage training paradigm:

  • Explicit Constraint Modalities: Instead of feeding partial layouts directly as noisy inputs, UniLayDiff treats layout constraints as explicit, distinct input modalities: a Partial Constraint Mask ($M_P$) and a Relation Matrix ($M_R$).
  • Dual-Path MM-Attention: Fusing image, layout, and mask features into a single attention path can dilute key interactions. To prevent this, the authors implement a dual-path Multi-Modal Diffusion Transformer (MM-DiT). One branch models image-layout interactions, while a parallel branch models mask-layout interactions. The outputs are then combined via element-wise summation.
Figure 2. Overview of UniLayDiff. (a) Our framework takes inputs including the image I with its saliency map S, a noisy layout xt, a partial constraint mask MP (sampled from various tasks), and a relation matrix MR. (b) Features FI, FL, and FM interact via the dual-path MM-Attention module. (c) Relational constraints are integrated via a block-diagonal relative positional bias (where Li denotes the i-th layout element,Mi the i-th mask element, and L0 represents the canvas). This relation module, and parts of the mask interaction branch, are activated during the LoRA fine-tuning stage. Our model is first pre-trained on four fundamental tasks (a.2), then fine-tuned for the relation task and enhanced quality. The resulting, fine-tuned model is used for inference on all tasks.
  • Two-Stage Training Strategy:
    1. Pre-training: The model is first trained across a pool of four fundamental tasks (unconditional, category-conditioned, category+size-conditioned, and layout completion).
  • LoRA Fine-tuning: To inject relational constraints without destroying the learned generative priors, the authors freeze the base model and apply Low-Rank Adaptation (LoRA) to the mask interaction branch. Relational constraints are injected via a block-diagonal relative positional bias mechanism and enforced using a differentiable relational loss ($L_{rel}$).
  • Content-Aware Losses: During fine-tuning, they introduce a content-constraint loss ($L_{ctn}$) that uses a soft-mask approximation of bounding boxes to penalize layouts that obscure salient regions of the background image.

Datasets

The model was evaluated on two public e-commerce poster benchmarks:

  • PKU: Contains three element categories: logo, text, and underlay (7,735 training, 1,000 validation, and 1,000 testing samples).
  • CGL: A larger dataset that includes an additional "embellishment" category (48,544 training, 6,002 validation, and 6,002 testing samples).

Key Insights and Ideas

  • The Relational Conflict: Jointly training discrete relational constraints (like "A is larger than B") alongside continuous diffusion processes forces the model to compromise, dropping layout diversity.
  • LoRA as a Regularizer: Using LoRA to introduce relational constraints acts as an effective regularizer. It allows the model to adapt to strict geometric rules while preserving the rich, diverse generative priors learned during pre-training.
Figure 4. Visual ablation study on the relationship injection strat- egy on the PKU dataset.
  • Parallel Paths Win: Separating the attention mechanism into parallel image-layout and mask-layout paths captures structural skeletons much better than a single-path merge.

Key Results

  • State-of-the-Art Performance: UniLayDiff achieves SOTA results across almost all metrics on both datasets. For PKU unconditional generation, it achieves a Fréchet Inception Distance (FID) of 3.15, significantly outperforming LayoutDiT (5.79).
  • Relational Adherence without Sacrificing Diversity: In relationship-conditioned tasks, UniLayDiff achieves a low Relation Violation Rate (Vio%) of 2.15% on PKU, while maintaining high layout diversity (whereas joint training completely collapses diversity).
  • Qualitative Excellence: Visual comparisons demonstrate that UniLayDiff generates coherent layouts that avoid overlapping elements, neatly dodge salient background objects, and faithfully execute complex spatial instructions.
Figure 3. Visual comparison with baselines on the PKU annotated test split.

Limitations and Future Work

  • Complex Size Constraints: The authors note that relying purely on relative position encoding can sometimes be insufficient for highly complex spatial arrangements without explicit loss supervision.
  • Inference Overhead: While much cheaper than LLM-based layout generators, UniLayDiff still inherits the iterative sampling overhead typical of diffusion models.
  • Future Directions: Promising next steps include extending this unified framework to multi-page document layouts and incorporating textual semantic understanding directly into the layout generation process.

Summary updated

BibTeX
@inproceedings{liu2026unilaydiff,
  author = {Zeyang Liu and Le Wang and Sanping Zhou and Yuxuan Wu and Xiaolong Sun and Gang Hua and Haoxiang Li},
  title = {{UniLayDiff: A Unified Diffusion Transformer for Content-Aware Layout Generation}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2026},
  url = {https://openreview.net/forum?id=xeZ72x89EI},
}
Figure