Towards Better Text-to-Image Generation Alignment via Attention Modulation

Yihang Wu, Xiao Cao, Kaixin Li, Zitan Chen, Haonan Wang, Lei Meng, Zhiyong HuangarXiv 2024

Abstract

In text-to-image generation tasks, the advancements of diffusion models have facilitated the fidelity of generated results. However, these models encounter challenges when processing text prompts containing multiple entities and attributes. The uneven distribution of attention results in the issues of entity leakage and attribute misalignment. Training from scratch to address this issue requires numerous labeled data and is resource-consuming. Motivated by this, we propose an attribution-focusing mechanism, a training-free phase-wise mechanism by modulation of attention for diffusion model. One of our core ideas is to guide the model to concentrate on the corresponding syntactic components of the prompt at distinct timesteps. To achieve this, we incorporate a temperature control mechanism within the early phases of the self-attention modules to mitigate entity leakage issues. An object-focused masking scheme and a phase-wise dynamic weight control mechanism are integrated into the cross-attention modules, enabling the model to discern the affiliation of semantic information between entities more effectively. The experimental results in various alignment scenarios demonstrate that our model attain better image-text alignment with minimal additional computational cost.

Introduction

While state-of-the-art diffusion models like Stable Diffusion XL (SDXL) produce high-fidelity images, they often stumble when faced with complex prompts containing multiple entities and specific attributes. Two primary issues emerge: Entity Leakage, where objects described in the prompt either disappear or merge, and Attribute Misalignment, where descriptive traits "bleed" onto the wrong objects (e.g., a "yellow car and a red house" resulting in a red car). These failures stem from an uneven or conflated distribution of attention. Current solutions often require manual bounding boxes or resource-heavy fine-tuning. This paper introduces a "plug-and-play," training-free attribution-focusing mechanism to resolve these alignment failures.

Methodology

The proposed method employs a three-pronged, phase-wise attention modulation strategy to guide the generation process without requiring additional training data.

Self-attention Temperature Control

In the early stages of the diffusion process, when the global structure is formed, a temperature hyperparameter ($\tau$) is applied to the self-attention mechanism. This "sharpens" the attention distribution, forcing image patches to group more tightly with highly correlated neighbors, which results in cleaner, more distinct entity outlines and reduces leakage.

Object-focused Cross-attention Mask

The system utilizes a syntactic parser to decompose the prompt into specific entity groups and global context. For every image patch, the model identifies which entity has the highest probability of presence and masks out attention from unrelated entities. This ensures that specific tokens (e.g., "red") only influence the intended pixels (e.g., "car").

Phase-wise Dynamic Reweighting

Recognizing that diffusion models generate different types of information at different times, the weights of the masks are varied dynamically. Early timesteps prioritize global layout, while mid-to-late timesteps increase the weight of specific entity details.

Overview of the proposed attribution-focusing mechanism, featuring temperature control and object-focused masking.

Experimental Results

The researchers evaluated the method using the COCO2014 validation set and a GPT-4 Vision-assisted evaluation pipeline to overcome the limitations of automated metrics.

Quantitative Performance

On the COCO dataset, the proposed method achieved a better FID (39.71 vs. 40.37) and CLIP Score (31.74 vs. 31.70) than the base SDXL model. Notably, the mechanism is highly efficient, incurring only a 1.54% increase in generation time compared to standard SDXL.

Alignment Accuracy

In GPT-4 assisted evaluations, the model outperformed both SDXL and "Structured Diffusion" across nearly all categories, achieving 90% accuracy in Context Alignment and 80% in Location Alignment. Qualitative results confirm superior performance in numerical alignment (counting) and attribute confinement.

Evolution of attention maps across diffusion timesteps, demonstrating the temporal focus of the attribution-focusing mechanism.

Discussion and Limitations

The critical insight of this work is the temporal nature of diffusion: attention needs to change over time as the model moves from blocking out "blobs" to refining textures. By leveraging syntactic guidance, the model automatically understands semantic relationships without explicit layout training.

However, limitations remain. The model struggles with nested objects (e.g., a man wearing a hat) where entities occupy the same spatial region, and identical entity types (e.g., two birds of different colors), where text embeddings may blend. Future work will focus on more granular attention separation to handle these complex semantic relationships.

Conclusion

The attribution-focusing mechanism offers a training-free, efficient solution to common alignment problems in diffusion models. By modulating attention through temperature control and object-focused masking, it significantly improves the fidelity of text-to-image generation in complex scenarios.

Summary updated

BibTeX
@misc{wu2024towards,
  author = {Yihang Wu and Xiao Cao and Kaixin Li and Zitan Chen and Haonan Wang and Lei Meng and Zhiyong Huang},
  title = {{Towards Better Text-to-Image Generation Alignment via Attention Modulation}},
  year = {2024},
  eprint = {2404.13899},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.13899},
}
Figure