RealCompo: Balancing Realism and Compositionality Improves Text-to-Image Diffusion Models

Xinchen Zhang, Ling Yang, YaQi Cai, Zhaochen Yu, Kai-Ni Wang, xie jiake, Ye Tian, Minkai Xu, Yong Tang, Yujiu Yang, Bin Cui

TL;DR

RealCompo is a training-free framework that combines standard text-to-image (T2I) diffusion models with spatial-aware models to achieve both high realism and accurate multi-object composition. By using a novel "dynamic balancer" to weigh the noise predictions of both models during the denoising process, it achieves state-of-the-art results on complex prompts without requiring any fine-tuning.

The Tug-of-War: Realism vs. Compositionality

Modern T2I diffusion models like Stable Diffusion and DALL-E 3 generate stunningly realistic images but notoriously struggle with compositionality—accurately rendering multiple objects, complex spatial relationships, or specific quantities (e.g., "a cat on the left of a vase, with three apples on the right").

To fix this, researchers have developed spatial-aware models (like GLIGEN or ControlNet) that use bounding boxes, keypoints, or segmentation maps to force objects into specific regions. However, forcing these spatial constraints severely degrades the overall realism, texture, and aesthetic quality of the image.

There is a frustrating tug-of-war: standard T2I models give you realism but ignore your layout, while spatial-aware models follow your layout but generate lower-quality, unrealistic images. Furthermore, previous conventional wisdom suggested that layout control is only needed in the first few denoising steps to "place" the objects, after which the standard T2I model could take over. The authors proved this false; stopping layout injection early still results in poor realism.

The RealCompo Method

RealCompo solves this trade-off by running two models simultaneously during inference and dynamically balancing their outputs.

The RealCompo framework architecture, showcasing the parallel Fidelity and Spatial-aware branches balanced dynamically during denoising.
  1. LLM-Based Layout Generation: First, the framework uses a Large Language Model (like GPT-4) to parse the user's complex prompt and automatically generate a spatial layout (bounding boxes) for the objects mentioned.
  2. Dual-Model Denoising: During the diffusion reverse process, RealCompo uses two pre-trained models in parallel: a standard T2I model (the "Fidelity" branch) and a spatial-aware model (the "Spatial-aware" branch).
  3. The Dynamic Balancer: Instead of just averaging the predicted noise from both models, RealCompo dynamically adjusts their influence at every timestep. It analyzes the cross-attention maps of both models to see how well they are aligning with the target layout. It calculates a loss based on this alignment and uses gradient descent to update the blending coefficients on the fly.
  4. Plug-and-Play: Because this balancing happens entirely during inference, RealCompo is completely training-free. Users can swap in different base models, stylized models, or use keypoints/segmentation maps instead of bounding boxes.

Key Insights

  • The Mathematical Trade-off: The authors found that injecting layout embeddings into a diffusion model literally dilutes the text embeddings. This explains why spatial-aware models lose semantic understanding and generate lower-quality images.
  • Cross-Attention as a Compass: Cross-attention maps contain a wealth of matching information between visual and textual elements. By using these maps to measure layout alignment, the dynamic balancer can continuously self-correct, ensuring the T2I model doesn't "break" the layout constraints while injecting high-fidelity details.
  • Generalizable Region Control: Bounding boxes, keypoints, and segmentation maps are fundamentally just different flavors of "region control." Because RealCompo's math abstracts this concept, the framework seamlessly extends to any spatial condition.

Results and Performance

RealCompo was evaluated on the T2I-CompBench (for compositionality) and a subset of the COCO Validation Set (for realism).

  • State-of-the-Art Compositionality: RealCompo outperformed all baselines across all 7 tasks on T2I-CompBench. For example, it achieved a Numeracy score of 0.6592 (compared to LMD+ at 0.5762) and a Color Binding score of 0.7741 (compared to PixArt-α at 0.6886).
  • Superior Realism: It achieved a higher CLIP score (0.334) and LAION Aesthetic score (5.742) than standard SDXL, GLIGEN, and LMD+.
  • Qualitative Success: In a user study with 1,755 votes, human evaluators overwhelmingly preferred RealCompo's outputs for both realism and compositionality. Visually, it prevents physical impossibilities (like objects floating in mid-air) that standard T2I models often hallucinate when confused by complex prompts.

Limitations and Future Work

Because RealCompo runs two diffusion models in parallel and computes loss/gradients at each denoising step, its computational cost and inference time are higher than running a single model. Future work will explore more efficient computational methods to speed up the balancing process, potentially using fixed coefficients to optimize inference speed, and extending the framework to text-to-video and text-to-3D generation.

Summary updated

BibTeX
@inproceedings{zhang2024realcompo,
  author = {Xinchen Zhang and Ling Yang and YaQi Cai and Zhaochen Yu and Kai-Ni Wang and xie jiake and Ye Tian and Minkai Xu and Yong Tang and Yujiu Yang and Bin CUI},
  title = {{RealCompo: Balancing Realism and Compositionality Improves Text-to-Image Diffusion Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=R8mfn3rHd5},
}
Figure