ContextGen: Contextual Layout Anchoring for Identity-Consistent Multi-Instance Generation

ReLER, CCAI, Zhejiang University
*Corresponding Author
MY ALT TEXT

ContextGen is a novel framework that uses user-provided reference images to generate image with multiple instances, offering precise layout control over their positions while guaranteeing perfect identity preservation.

Abstract

Multi-instance image generation (MIG) remains a significant challenge for modern diffusion models due to key limitations in achieving precise control over object layout and preserving the identity of multiple distinct subjects. To address these limitations, we introduce ContextGen, a novel Diffusion Transformer framework for multi-instance generation based on contextual learning guided by both layout and reference images. Our approach integrates two key technical contributions: a Contextual Layout Anchoring (CLA) mechanism that incorporates the composite layout image into the generation context to robustly anchor the objects in their desired positions, and Identity Consistency Attention (ICA), a innovative attention mechanism which leverages contextual reference images to ensure the identity consistency of multiple instances. Recognizing the lack of large-scale, hierarchically-structured datasets for this task, we introduce IMIG-100K, the first dataset with detailed layout and identity annotations. Extensive experiments demonstrate that ContextGen sets a new state-of-the-art, outperforming existing methods in control precision, identity fidelity, and overall visual quality.

Method

MY ALT TEXT

In our framework, a composite layout image is used for precise spatial control, this layout image can be either user-provided or automatically synthesized in setup stage. Then we integrate reference images to overcome the limitations of layout-only generation, such as instance information loss due to overlaps and dimensional compression. Our method introduces two key innovations: (1) Contextual Layout Anchoring (CLA), which leverages contextual learning to anchor each instance at its desired position by incorporating the layout image into the generation context, thereby achieving robust layout control; and (2) Identity Consistency Attention (ICA), a novel attention mechanism which propagates fine-grained information from contextual reference images to their respective desired locations, thereby preserving the identity of multiple instances. Complementing these mechanisms is an enhanced position indexing strategy that systematically organizes and differentiates multi-image relationships.

Identity-Consistent Subject-Driven Generation

DEMO on LAMICBench++ comparing with existing open-source SOTA on subject-driven generation and closed-source commercial models

MY ALT TEXT

Precise Layout Control for Multi-Instance Scenes

DEMO on COCO-MIG Bench comparing with existing open-source SOTA on Layout-to-Image (L2I) generation
Note: Red dashed boxes indicate the missing, merged, dislocated or incorrectly attributed instances.

MY ALT TEXT

DEMO on LayoutSam-Eval Bench comparing with existing open-source SOTA on Layout-to-Image (L2I) generation

MY ALT TEXT

About IMIG-100K Dataset

The IMIG-100K is a large-scale, structured dataset designed for identity-consistent multi-instance generation, featuring three progressive difficulty levels.

MY ALT TEXT

Quantitative Results on Benchmarks

BibTeX

@article{xu2025contextgencontextuallayoutanchoring,
      title={ContextGen: Contextual Layout Anchoring for Identity-Consistent Multi-Instance Generation}, 
      author={Ruihang Xu and Dewei Zhou and Fan Ma and Yi Yang},
      year={2025},
      eprint={2510.11000},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2510.11000}, 
}