Getting it Right: Improving Spatial Consistency in Text-to-Image Models

Agneet Chatterjee, Gabriela Ben Melech Stan, Estelle Aflalo, Sayak Paul, Dhruba Ghosh, Tejas Gokhale, Ludwig Schmidt, Hannaneh Hajishirzi, Vasudev Lal, Chitta Baral, Yezhou Yang

TL;DR

Current text-to-image models frequently fail to correctly place objects where prompts specify because standard training datasets rarely mention spatial relationships. This paper introduces SPRIGHT (SPatially RIGHT), the first large-scale, spatially focused dataset of 6 million re-captioned images. The authors demonstrate that fine-tuning a model on less than 500 high-object-count images from this dataset yields state-of-the-art spatial generation performance.

What Problem Does This Paper Address?

State-of-the-art text-to-image (T2I) diffusion models like Stable Diffusion and DALL-E 3 generate stunningly realistic images but struggle with basic spatial reasoning. If you ask for "a laptop to the left of a coffee cup," the model will frequently swap their positions or omit one of the objects entirely.

The authors identify a fundamental root cause: a massive data bottleneck in existing vision-language datasets (like COCO or LAION). Human annotators and web alt-text rarely specify fine-grained positions, relative sizes, or background/foreground relationships. Because models aren't trained on spatial descriptions, they fail to learn spatial consistency.

Fig. 1: We find that existing vision-language datasets do not capture spatial relation- ships well. To alleviate this shortcoming, we synthetically re-caption ∼6M images with a spatial focus, and create the SPRIGHT (SPatially RIGHT) dataset. Shown above are samples from the COCO Validation Set, where text in red denotes ground-truth captions and text in green are corresponding captions from SPRIGHT.

Methods

The authors tackle this bottleneck through a two-step approach involving synthetic data generation and highly efficient fine-tuning:

  1. Synthetic Re-captioning: To avoid expensive human annotation, the authors leveraged a large vision-language model (LLaVA-1.5-13B) to re-caption 6 million existing images. They used a strict prompt forcing the model to produce exactly two sentences describing spatial relationships (e.g., left/right, above/below, inside/outside) and relative object sizes.
  2. Object-Threshold Fine-Tuning: Instead of brute-force training on millions of images, the authors designed an ultra-efficient training strategy. They used an open-world image tagging model (Recognize Anything) to count the objects in each image. They discovered that fine-tuning Stable Diffusion 2.1 on a tiny, curated subset of images containing a large number of objects (>18) forced the model to drastically improve its spatial layout capabilities.

Datasets

The paper introduces SPRIGHT, the first large-scale, spatially focused dataset. It was built by re-captioning images from four widely used vision datasets:

  • Segment Anything (SA): 3.5 million images (chosen because they naturally contain high object counts).
  • CC-12M: 2.3 million images.
  • COCO Validation Set: ~40,000 images.
  • LAION-Aesthetics: 50,000 images.

For evaluation, the authors benchmarked their models using VISOR, T2I-CompBench, and GenEval.

Key Insights and Ideas

  • The Object-Density Leverage: Images containing a high number of objects inherently encapsulate a dense web of spatial relationships. Training on just 444 images that contain more than 18 objects outperformed training on thousands of images with fewer objects.
  • The 50/50 Caption Balance: You can have too much of a good thing. Training a model exclusively on spatial captions (100%) causes it to fail at generating the objects themselves. A 50:50 blend of general captions and spatial captions yields the optimal balance between object quality and spatial accuracy.
  • CLIP Layer-Wise Sensitivity: Longer, descriptive spatial captions perform significantly better than short ones. Layer-wise analysis of the CLIP text encoder reveals that fine-tuning specifically alters the MLP and output attention projection layers, allowing the encoder to better differentiate spatial nuances (e.g., distinguishing "an airplane above an apple" from "an apple above an airplane").

Key Results

  • State-of-the-Art Spatial Control: Fine-tuning Stable Diffusion 2.1 on just 444 high-object-count images from SPRIGHT achieved a state-of-the-art spatial score of 0.2133 on T2I-CompBench—a 41% improvement over the baseline model.
  • Massive Spatial Phrase Boost: SPRIGHT dramatically increased the frequency of spatial terms. For example, each re-captioned COCO image went from capturing a fraction of spatial relationships to averaging ~3 spatial phrases per image.
Fig. 2: Compared to ground truth COCO captions,(Left) Word cloud representations showing that SPRIGHT captions significantly amplify the presence of spatial relation- ships. (Right)SPRIGHT captions also capture a higher number of object occurances.
  • Improved Object Accuracy: On the VISOR benchmark, the model achieved a 26.86% increase in Object Accuracy, proving that better spatial awareness also prevents the model from forgetting to generate requested objects.
  • Fidelity Gains: Image quality improved alongside spatial accuracy; fine-tuning on a small subset (~0.25%) of SPRIGHT dropped the Zero-Shot FID from 21.65 to 14.93.

Limitations and Future Work

  • Inherited Dataset Biases: As a derived dataset, SPRIGHT inherits the underlying biases, text-rendering flaws, and artifacts of its base datasets (like LAION and CC-12M).
  • Synthetic Caption Imperfections: The synthetic captions generated by LLaVA are not 100% accurate; crowd-sourced human evaluation indicated a sentence-level accuracy of 66.57%. The authors note that using stronger models (like LLaVA-1.6-34B or GPT-4o) could significantly improve caption quality.
  • Future Scaling: The authors suggest that future work should explore how next-generation T2I models with larger token limits (such as PixArt-Sigma or Stable Diffusion 3) can fully exploit these dense, multi-sentence spatial captions.

Summary updated

BibTeX
@inproceedings{chatterjee2024getting,
  author = {Agneet Chatterjee and Gabriela Ben Melech Stan and Estelle Aflalo and Sayak Paul and Dhruba Ghosh and Tejas Gokhale and Ludwig Schmidt and Hannaneh Hajishirzi and Vasudev Lal and Chitta Baral and Yezhou Yang},
  title = {{Getting it Right: Improving Spatial Consistency in Text-to-Image Models}},
  booktitle = {European Conference on Computer Vision},
  year = {2024},
  doi = {10.1007/978-3-031-72670-5\_12},
}
Figure