ContextGen: Contextual Layout Anchoring for Identity-Consistent Multi-Instance Generation
Paper β’ 2510.11000 β’ Published β’ 10
How to use ruihangxu/ContextGen with Diffusers:
pip install -U diffusers transformers accelerate
import torch
from diffusers import DiffusionPipeline
# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("ruihangxu/ContextGen", dtype=torch.bfloat16, device_map="cuda")
prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
image = pipe(prompt).images[0]import torch
from diffusers import DiffusionPipeline
# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("ruihangxu/ContextGen", dtype=torch.bfloat16, device_map="cuda")
prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
image = pipe(prompt).images[0]
Ruihang Xu,
Dewei Zhou,
Fan Maβ ,
Yi Yang
ReLER Lab, CCAI, Zhejiang University
ContextGen is a novel framework that uses user-provided reference images to generate image with multiple instances, offering layout control over their positions while guaranteeing identity preservation.
Please refer to our GitHub Repository for detailed instructions on how to use ContextGen.
If you find ContextGen helpful to your research, please consider citing our paper:
@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},
}
Base model
black-forest-labs/FLUX.1-Kontext-dev