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.
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.
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