In-Context LoRA for Diffusion Transformers

Lianghua Huang, Wei Wang, Zhi-Fan Wu, Yupeng Shi, Huanzhang Dou, Chen Liang, Yutong Feng, Yu Liu, Jingren ZhouarXiv 2024 · DOI

In-Context LoRA for Diffusion Transformers

Abstract

State-of-the-art Diffusion Transformers (DiTs) possess latent "in-context learning" capabilities that can be activated through simple data formatting and minimal tuning. By concatenating multiple images into a single "mega-image" and applying Low-Rank Adaptation (LoRA) on small, high-quality datasets, complex tasks requiring cross-image coherence—such as storyboarding and consistent font design—become achievable without architectural modifications.

Introduction

Adapting text-to-image (T2I) models to generate coherent image sets remains a significant challenge. Tasks like creating a storyboard with a consistent character or applying a specific font style across various objects typically require complex architectural changes or massive computational resources. This paper introduces In-Context LoRA (IC-LoRA), a method that leverages the inherent structural understanding of Diffusion Transformers to solve these problems efficiently.

Methodology

The IC-LoRA pipeline is built on the hypothesis that DiTs are natural in-context learners. The approach consists of four primary steps:

  1. Image Concatenation: Multiple images are merged into a single large canvas. Since DiTs process images as patches, this "mega-image" format allows the model to attend to tokens across different panels naturally.
  2. Prompt Concatenation: Captions for each panel are joined into a unified prompt, often starting with a global description.
  3. Minimal LoRA Tuning: The model (e.g., FLUX.1-dev) is tuned using LoRA on tiny datasets of 20–100 high-quality image sets. This process "triggers" the model's ability to maintain consistency across the concatenated panels.
  4. Image-Conditional Generation: For tasks requiring a reference, SDEdit is used to inpaint new panels based on existing ones within the canvas.
Example of a concatenated 'mega-image' for the home decoration task, demonstrating consistency across multiple panels.

Key Results

The researchers demonstrated the versatility of IC-LoRA across several demanding domains:

  • Film Storyboarding: The model maintains character identity (e.g., using placeholders like <Liam>) across diverse cinematic frames.
  • Font Design: IC-LoRA generates consistent, stylized text that remains legible across different surfaces and backgrounds.
  • Visual Identity: Logos can be realistically applied to various products in a single generation step.
Consistent font design ('Throwback') applied to a vintage radio, showcasing the model's ability to handle stylized text and object integration.

The efficiency of this method is notable; training requires only a single A100 GPU for approximately 5,000 steps, making high-quality, coherent generation accessible without massive compute clusters.

Discussion and Limitations

While IC-LoRA is highly effective for text-to-image tasks, image-conditional generation via SDEdit remains somewhat unstable, occasionally failing to preserve exact identities. Furthermore, while the pipeline is task-agnostic, a specific LoRA must still be trained for each new domain. Future work may focus on developing a "universal" in-context generator that requires zero-shot adaptation for any new task.

Conclusion

In-Context LoRA demonstrates that the power of Diffusion Transformers lies not just in their scale, but in their inherent ability to understand relationships between visual tokens. By treating multi-image generation as a data-formatting problem rather than an architectural one, IC-LoRA provides a simple, efficient, and high-fidelity path toward coherent visual storytelling.

Summary updated

BibTeX
@misc{huang2024context,
  author = {Lianghua Huang and Wei Wang and Zhi-Fan Wu and Yupeng Shi and Huanzhang Dou and Chen Liang and Yutong Feng and Yu Liu and Jingren Zhou},
  title = {{In-Context LoRA for Diffusion Transformers}},
  year = {2024},
  eprint = {2410.23775},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.23775},
}
Figure