LayerDiff: Exploring Text-Guided Multi-layered Composable Image Synthesis via Layer-Collaborative Diffusion Model

Runhui Huang, Kaixin Cai, Jianhua Han, Xiaodan Liang, Renjing Pei, Guansong Lu, Songcen Xu, Wei Zhang, Hang Xu

Abstract

Most state-of-the-art text-to-image models generate "monolithic" images where all elements are fused into a single flat layer, complicating downstream editing tasks. We present LayerDiff, a novel diffusion-based framework that produces multi-layered, composable images—including backgrounds, foregrounds, and transparency masks—in a single generative pass. By facilitating simultaneous interaction between layers through a Layer-Collaborative Attention Block and a Layer-Specific Prompt Enhancer, LayerDiff achieves granular, object-wise control while maintaining global stylistic and spatial coherence.

Introduction: Beyond Monolithic Image Generation

Standard latent diffusion models, such as Stable Diffusion, excel at creating high-quality visuals but lack the structural flexibility required by digital artists. When elements are fused, adjusting a single object's position or lighting often requires complex post-processing or entirely regenerating the image. While some existing methods attempt layered generation, they are typically restricted to simple foreground-background pairs or rely on pipelines that introduce stylistic inconsistencies.

Overview of the LayerDiff framework, showing the decomposition of a global prompt into layer-specific prompts and the resulting multi-layered output.

LayerDiff addresses these challenges by generating $N$ layers—each with its own image and mask—that are contextually aware of one another. This allows for seamless compositing and independent editing of individual components.

Methodology

LayerDiff adapts the latent diffusion paradigm to a multi-layer setting through several key architectural innovations.

Layer-Collaborative Attention Block

Instead of processing a single image latent, LayerDiff stacks multiple layer latents. It employs Inter-layer Attention to allow pixels to communicate across different layers, ensuring that lighting and shadows remain consistent across the composition. Simultaneously, Text-guided Intra-layer Attention ensures that each specific layer adheres to its individual text prompt.

Layer-Specific Prompt Enhancer

A global prompt (e.g., "a painting of a cartoon character sitting on a rock looking at a flower") is decomposed into specific layer prompts ("a cartoon character," "a flower," "the background"). The Layer-Specific Prompt Enhancer uses cross-attention to allow individual layer prompts to "borrow" relevant context from the global description, ensuring that the "character" layer, for instance, understands its seated posture relative to the "rock" in the background.

The LayerDiff architecture, featuring the Image/Mask Encoders, the Layer-Collaborative Diffusion Model with specialized attention blocks, and the Layer-Specific Prompt Enhancer.

Self-Mask Guidance (SMG) Sampling

During denoising, the model predicts masks for each layer. SMG uses these intermediate masks to "shield" the background while refining foreground objects. This forces the model to concentrate generative energy on the correct spatial regions, improving the clarity and boundary precision of each object.

The MLCID Dataset

To train LayerDiff, the authors introduced the Multi-Layered Composable Image Dataset (MLCID), derived from 2 million images (LAION-400M and private sources). The construction pipeline utilized DetCLIP for detection, Segment Anything Model (SAM) for masking, and InstructBLIP for layer-specific captioning. Stable Diffusion Inpainting was used to fill the "holes" left by extracted foreground objects, creating clean background layers. The resulting dataset includes 1.7M two-layer, 0.3M three-layer, and 80k four-layer samples.

Key Results and Insights

LayerDiff demonstrates significant improvements in both quantitative and qualitative metrics:

  • Quantitative Performance: On two-layer synthesis, LayerDiff achieved an FID of 21.3, outperforming Stable Diffusion V1.5 (FID 27.0). This suggests that generating layers explicitly helps the model produce more coherent overall compositions.
  • Layer-wise Style Transfer: Users can apply different styles to different layers (e.g., a realistic character on a Van Gogh background) without bleeding between elements.
  • Efficient Editing: Because layers are decoupled, users can regenerate a single layer—such as changing a character's clothing—without affecting the background or other objects.

Conclusion and Future Work

LayerDiff represents a significant step toward professional-grade generative tools by moving from flat images to structured, multi-layered assets. While highly effective for 2-layer compositions, performance on higher layer counts (4+) is currently limited by data scarcity. Future work will focus on scaling the data pipeline and improving the handling of complex occlusions where multiple objects overlap significantly.

Summary updated

BibTeX
@inproceedings{huang2024layerdiff,
  author = {Runhui Huang and Kaixin Cai and Jianhua Han and Xiaodan Liang and Renjing Pei and Guansong Lu and Songcen Xu and Wei Zhang and Hang Xu},
  title = {{LayerDiff: Exploring Text-Guided Multi-layered Composable Image Synthesis via Layer-Collaborative Diffusion Model}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-73116-7\_9},
}
Figure