Improving Explicit Spatial Relationships in Text-to-Image Generation through an Automatically Derived Dataset

Ander Salaberria, Gorka Azkune, Oier Lopez de Lacalle, Aitor Soroa, Eneko Agirre, Frank KellerarXiv 2024 · DOI

Abstract

Modern text-to-image (T2I) models often struggle with precise spatial reasoning, frequently failing to place objects according to explicit relational prompts (e.g., "A to the left of B"). This paper demonstrates that this "spatial blindness" stems from a lack of spatially descriptive training data rather than architectural limitations. By introducing SR4G, a synthetic dataset of 9.9 million image-caption pairs with explicit spatial labels, the authors fine-tune Stable Diffusion to significantly outperform larger, more complex state-of-the-art systems.

The Problem: Spatial Blindness in Diffusion Models

While models like DALL-E 3 and Stable Diffusion generate high-fidelity images, they often ignore spatial constraints. Analysis of the standard LAION-2B dataset reveals that only 0.72% of captions contain explicit spatial relations. Furthermore, common data augmentation techniques like random horizontal flipping inadvertently teach models that "left" and "right" are interchangeable, further degrading spatial accuracy.

Methodology: The SR4G Dataset

To address this data scarcity, the researchers developed an automated pipeline to generate the Spatial Relation for Generation (SR4G) dataset. Using the COCO 2017 dataset as a foundation, they leveraged human-verified bounding boxes to derive spatial relationships between object pairs based on heuristic rules.

The dataset covers 14 distinct spatial relations categorized into three types:

  • Projective: left of, right of, above, below.
  • Topological: overlapping, separated, surrounding, inside.
  • Scale: taller, shorter, wider, narrower, larger, smaller.

Stable Diffusion (v1.4 and v2.1) was fine-tuned on these 9.9 million synthetic captions. Performance was measured using the VISOR metric, which utilizes an automated object detector to verify if generated images adhere to the requested spatial constraints.

Key Results and Performance

The fine-tuned model, SD-SR4G, achieved state-of-the-art performance, reaching a VISOR Cond score of 69.5%. This surpasses specialized multi-stage pipeline systems like LayoutGPT and VPGen, despite SD-SR4G having significantly fewer parameters (1.3B vs. up to 14.1B).

Comparison of VISOR Cond scores across different models and Stable Diffusion versions.

The improvements were consistent across nearly all 14 relations. Notably, the model showed significant gains in "separated" and "scale" relations (e.g., taller/shorter), which are traditionally difficult for standard diffusion models.

Delta VISOR Cond scores showing improvements across various spatial relations for SD v2.1 and SD-SR4G.

Generalization and Insights

A critical finding was the model's ability to generalize. When tested on an "unseen split"—where object pairs in the test set never appeared together in the spatial training data—the model's performance remained high. This suggests that the model learned the underlying geometric concepts of spatial relations rather than just memorizing specific object combinations.

However, the researchers also noted a strong correlation between the frequency of object triplets in the training data and generation accuracy. While the synthetic dataset helps, the "long tail" of rare object combinations remains a challenge for future research.

Conclusion and Future Work

This work proves that data quality is a primary driver for spatial reasoning in T2I models. By providing explicit spatial supervision, standard diffusion models can achieve superior performance without the need for complex external layouts or LLM-guided pipelines. Future directions include incorporating 3D depth information to handle depth-based relations like "in front of" and expanding the dataset to include non-English languages.

Summary updated

BibTeX
@misc{salaberria2024improving,
  author = {Ander Salaberria and Gorka Azkune and Oier Lopez de Lacalle and Aitor Soroa and Eneko Agirre and Frank Keller},
  title = {{Improving Explicit Spatial Relationships in Text-to-Image Generation through an Automatically Derived Dataset}},
  year = {2024},
  eprint = {2403.00587},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.00587},
}
Figure