Modeling Image Composition for Complex Scene Generation

Zuopeng Yang, Daqing Liu, Chaoyue Wang, Jie Yang, Dacheng Tao

Abstract

Generating photo-realistic images from spatial layouts—a task known as Layout-to-Image (L2I) generation—remains a significant challenge due to the "entanglement" of object structures and background textures. This paper introduces the Transformer with Focal Attention (TwFA), a novel architecture that utilizes spatial priors to constrain the attention mechanism. By guiding the model to focus on relevant object-patch relationships, TwFA achieves sharper object boundaries and more coherent scene compositions. Our experiments on COCO-stuff and Visual Genome demonstrate state-of-the-art performance, including a 25% improvement in FID scores on COCO-stuff and the first effective demonstration of few-shot generation for novel object categories in the L2I domain.

1. Introduction

The goal of Layout-to-Image (L2I) generation is to synthesize realistic images from a set of bounding boxes and category labels. While Generative Adversarial Networks (GANs) and standard Transformers have made significant strides, they often struggle with complex scenes containing multiple overlapping objects. Two primary issues persist: CNN-based models frequently conflate pixel-level textures with object-level structures, resulting in "crumpled" or blurry objects; meanwhile, vanilla Transformers treat all image patches equally, leading to a lack of focus where unrelated patches (e.g., a distant bird) distract the model from learning the internal structure of a primary object (e.g., a bus).

This paper proposes the Transformer with Focal Attention (TwFA) to address these "entanglement" problems by incorporating structural constraints directly into the attention mechanism.

2. Methodology

The TwFA framework operates through a three-stage pipeline designed to separate global context from local structural integrity.

2.1 Tokenization and Composition

The system utilizes a pre-trained VQ-GAN to compress images into discrete "patch tokens" and layouts into "object tokens." The core innovation lies in the composition stage, where a specialized Connectivity Matrix guides the Focal Attention mechanism rather than allowing standard, unconstrained self-attention.

2.2 The Focal Attention Mechanism

To ensure the model respects spatial boundaries, TwFA categorizes interactions into three distinct types:

  • Object-Object Interactions: All object tokens attend to one another to establish global context and understand inter-object relationships (e.g., a person positioned on a surfboard).
  • Object-Patch Interactions: Patches belonging to specific "instances" (e.g., a car) are constrained to attend only to their corresponding object token. Conversely, "stuff" patches (e.g., sky or grass) attend to all object tokens to maintain background consistency.
  • Patch-Patch Interactions: Patches are restricted to attending to their immediate neighbors within the same object or background area, preserving local structural integrity and preventing interference from unrelated spatial regions.

3. Experimental Setup

3.1 Datasets

The model was evaluated on two benchmark datasets for scene understanding:

  • COCO-stuff: An expansion of MS-COCO featuring 80 object classes and 91 "stuff" (background) classes.
  • Visual Genome (VG): A dataset characterized by dense annotations for objects, attributes, and complex relationships.

3.2 Few-Shot Learning Benchmark

To test the model's ability to generalize to novel categories, the authors established a few-shot L2I benchmark. This involved removing all "zebra" images from the COCO-stuff training set and evaluating the model's ability to generate recognizable zebras after being exposed to only 20–50 examples.

4. Results and Discussion

4.1 Quantitative and Qualitative Performance

TwFA established new state-of-the-art benchmarks across multiple metrics. On the COCO-stuff dataset, TwFA improved the Frechet Inception Distance (FID) score—a key metric for image quality and diversity—from 29.56 to 22.15. Qualitatively, the model produces significantly sharper object boundaries. Unlike previous models that often generated amorphous shapes for complex animals, TwFA successfully renders distinct limbs and features.

4.2 Few-Shot Success

In the 20-shot zebra generation test, TwFA achieved an FID of 36.34, notably outperforming the baseline of 39.47. The model was able to capture complex patterns, such as stripes, which baseline models failed to represent accurately with limited data.

5. Conclusion

The Transformer with Focal Attention demonstrates that layouts should be treated as structural constraints within the learning process rather than mere conditional targets. By disentangling object and background modeling, TwFA achieves superior data efficiency and image realism. While the model currently depends on provided bounding boxes, future work may extend this focal approach to direct text-to-image generation and other multi-modal tasks where spatial priors can mitigate the challenges of complex scene dependency.

Summary updated

BibTeX
@inproceedings{yang2022modeling,
  author = {Zuopeng Yang and Daqing Liu and Chaoyue Wang and Jie Yang and Dacheng Tao},
  title = {{Modeling Image Composition for Complex Scene Generation}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
}
Figure