Training-free subject-enhanced attention guidance for compositional text-to-image generation

Shengyuan Liu, Bo Wang, Ye Ma, Te Yang, Quan Chen, Di Dong

TL;DR

This paper introduces SE-Guidance, a novel training-free method to improve compositional text-to-image generation. It tackles the common issues of missing objects and attribute mixing in complex prompts by enhancing attention mechanisms during inference, leading to more accurate and consistent image generation without requiring additional training.

What Problem Does This Paper Address?

Current text-to-image generation models have made impressive strides, but generating images with multiple subjects (compositional generation) remains a significant challenge. Existing "subject-driven" methods often require extensive fine-tuning for each new subject, making them impractical for broad use. Even when fine-tuning is avoided, models struggle with "object missing" (subjects not appearing) and "attribute mixing" (attributes of different subjects getting jumbled). This is largely due to the difficulty in precisely aligning textual descriptions with specific image regions and injecting subject-specific features without disrupting the overall composition. The authors aim to solve this by developing a training-free approach that enhances the generation process during inference.

Methods

The core of the proposed method, SE-Guidance, is a training-free strategy that leverages attention maps within diffusion models. It operates in two main phases:

  • Representation Injection in the Forward Process: This involves using a multi-modal prompts adapter (inspired by IP-Adapter) to inject subject image features into the diffusion model. The adapter uses a CLIP image encoder to extract features and a cross-attention module to embed them. Crucially, to avoid attribute mixing when dealing with multiple subjects, they propose a method to selectively inject these features based on spatial attention maps, preventing a direct summation that can lead to confusion.
  • Attention Enhancement in the Backward Process: This phase focuses on refining the attention maps themselves. The authors extract spatial attention maps for subject tokens and apply Gaussian smoothing to focus on relevant regions. They then use this enhanced attention to guide the denoising process, ensuring that subjects are more likely to be generated and their attributes are correctly associated. This guidance is applied during the backward denoising steps, aiming to maximize attention for subject tokens.

The entire process is "training-free," meaning it doesn't require any additional fine-tuning of the diffusion model or the adapter for new subjects.

Datasets

  • CustomConcept101: Used for evaluating model customization methods. It contains 101 concepts with 3-15 images per concept. The authors note that they removed placeholder tokens present in the original dataset to achieve zero-shot generation.
  • ChatGPT: Used to generate prompts for single and multiple concept generation.

Key Insights and Ideas

  • Attention Maps as a Key to Composition: The fundamental insight is that attention maps within diffusion models inherently capture spatial relationships and semantic importance. By strategically manipulating these maps, one can guide the generation process to respect compositional structures.
  • Training-Free Guidance is Feasible and Effective: The paper demonstrates that significant improvements in compositional generation can be achieved during inference without the need for computationally expensive fine-tuning for each new subject. This is a major step towards more accessible and scalable subject-driven generation.
  • Disentangling Forward and Backward Guidance: The authors propose separate but complementary forward (feature injection) and backward (attention refinement) guidance mechanisms. This modularity allows for independent or combined use, offering flexibility and demonstrating that both aspects are crucial for optimal results.
  • GroundingScore as a Better Metric: Existing metrics for subject alignment can be fooled by background information or overfitting. The authors introduce "GroundingScore," inspired by image grounding tasks, to provide a more accurate assessment of subject fidelity in compositional generation.

Key Results

  • Superior Compositional Generation: SE-Guidance achieves state-of-the-art results, particularly in compositional generation scenarios, outperforming other zero-shot methods and being competitive with fine-tuned approaches.
  • Improved Image-Text Alignment and Subject Fidelity: Quantitative results (Table 1) show strong performance on CLIP-T (text-image alignment) and CLIP-GS/DINO-GS (subject alignment/fidelity), often surpassing baselines.
  • Reduced Generation Time: The training-free nature significantly reduces generation time, with inference taking around 15 seconds.
  • Generalizability: The method works across different Stable Diffusion checkpoints and can be applied to both single and multi-subject generation tasks.
  • User Study Validation: A user study (Table 2) indicates that their method performs best in alignment and fidelity for multi-subject generation.

Limitations and Future Work

  • Expressive Power of Generative Model: The zero-shot method is constrained by the inherent expressive power of the base generative model. For unique or rare objects, ensuring high consistency in details can be challenging.
  • Realism with Unnatural Combinations: Synthesizing subjects that naturally don't appear together might result in images lacking realism.
  • Fine-grained Composition Relations: Handling complex compositional relations, especially with more than two subjects, can still lead to attribute mixing or missing objects.
  • Future Work: The authors plan to explore more versatile approaches for incorporating image features and aim for better alignment between images and textual prompts. They also suggest that fine-tuning can further improve detail generation for rare objects.

Summary updated

BibTeX
@article{liu2024training,
  author = {Shengyuan Liu and Bo Wang and Ye Ma and Te Yang and Quan Chen and Di Dong},
  title = {{Training-free subject-enhanced attention guidance for compositional text-to-image generation}},
  journal = {Pattern Recognition},
  year = {2024},
}
Figure