Compositional Text-to-Image Synthesis with Attention Map Control of Diffusion Models

Ruichen Wang, Zekang Chen, Chen Chen 0015, Jian Ma, Haonan Lu, Xiaodong Lin

Abstract

Current text-to-image diffusion models often struggle with compositional prompts, leading to issues like attribute leakage and missing entities. This paper introduces a "ready-to-use plugin" featuring a lightweight BoxNet and a unique attention masking strategy. By dynamically predicting object bounding boxes and constraining attention maps, the proposed method significantly improves semantic accuracy without requiring user-provided layouts or expensive retraining.

Introduction

While models like Stable Diffusion (SD) generate high-quality images, they frequently fail on complex prompts involving multiple objects with specific attributes. These failures generally fall into three categories:

  1. Attribute Leakage: Attributes of one object bleed into another (e.g., a "yellow dog" becoming black in the presence of a "black cat").
  2. Entity Leakage: Objects merge or overlap incorrectly, creating hybrids.
  3. Missing Entities: The model fails to generate one or more requested objects.
Figure 1: Examples of compositional generation showing a black cat and a yellow dog, illustrating successful attribute binding.

These issues arise because standard diffusion models lack explicit spatial constraints, allowing attention regions to overlap and cause semantic confusion.

Methodology

The proposed solution integrates two main components into the diffusion process:

BoxNet

Unlike layout-to-image models that require manual input, the authors developed BoxNet. This module predicts the location of entities mentioned in the prompt at each timestep of the diffusion process. It utilizes a U-Net feature extractor and an encoder-decoder transformer to estimate object positions based on the current noisy latent image.

Attention Mask Control

Predicted boxes are converted into Unique Masks using a 2D Gaussian mapping followed by an argmax operation. This ensures each pixel is primarily assigned to a single entity. These masks are then applied to:

  • Cross-Attention: Ensuring text tokens (e.g., "yellow") only influence their assigned spatial regions.
  • Self-Attention: Preventing different image regions from blending, which effectively stops entity leakage.

This approach functions as a plugin, compatible with existing models like Stable Diffusion or Attend-and-Excite during inference without modifying base weights.

Evaluation and Results

The method was evaluated using the MS-COCO dataset and a new benchmark specifically designed for attribute binding (e.g., "a [colorA] [entityA] and a [colorB] [entityB]").

Figure 2: Diverse generation results showcasing the model's ability to handle various breeds, colors, and accessories across different entities.

Quantitative Performance

On the COCO evaluation set, the method achieved a Minimum Object Score (DINO) of 0.603, outperforming Stable Diffusion (0.397) and Attend-and-Excite (0.444). This demonstrates a higher success rate in generating all requested objects.

Qualitative and User Studies

A user study showed that humans rated the proposed method's prompt alignment at 43.3%, compared to 30.2% for standard SD. Importantly, the FID score remained competitive (17.47 vs. 17.79), indicating that semantic control does not sacrifice aesthetic quality.

Discussion

A key insight is the importance of dynamic layouts. BoxNet predicts boxes at each denoising step, allowing the layout to evolve naturally. Furthermore, the results highlight that masking self-attention is as vital as cross-attention for maintaining structural integrity. Despite being trained on COCO categories, the model shows impressive zero-shot generalization to unseen objects.

Limitations

The system's performance is tied to BoxNet's accuracy; early failures in box prediction can lead to incorrect masking. Additionally, running BoxNet at every step introduces some computational overhead. Future work may explore performance in extremely crowded scenes where the argmax uniqueness strategy might face challenges.

Conclusion

By introducing spatial constraints through dynamic box prediction and attention masking, this work provides a robust, training-free solution to the compositional challenges of modern diffusion models, paving the way for more controllable and accurate text-to-image synthesis.

Summary updated

BibTeX
@inproceedings{wang2024compositional,
  author = {Ruichen Wang and Zekang Chen and Chen Chen and Jian Ma and Haonan Lu and Xiaodong Lin},
  title = {{Compositional Text-to-Image Synthesis with Attention Map Control of Diffusion Models}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2024},
  doi = {10.1609/aaai.v38i6.28364},
}
Figure