Training-free Subject-Enhanced Attention Guidance for Compositional Text-to-image Generation

Shengyuan Liu, Bo Wang, Ye Ma, Te Yang, Xipeng Cao, Quan Chen, Han Li, Di Dong, Peng Jiang · DOI

TL;DR

The paper introduces Subject-Enhanced Attention Guidance (SE-Guidance), a training-free inference-time method that enables high-fidelity, zero-shot compositional text-to-image generation. By precisely manipulating cross-attention maps, it eliminates common multi-subject generation errors like "object missing" and "attribute mixing" in under 15 seconds.

What Problem Does This Paper Address?

Subject-driven text-to-image generation allows users to customize images of specific subjects (like a pet cat or a unique toy) using textual prompts. However, existing approaches suffer from two major bottlenecks:

  1. Tedious Fine-Tuning: Methods like DreamBooth require hundreds of optimization steps per subject, making them slow and computationally expensive.
  2. Compositional Failures: When trying to generate multiple custom subjects in a single scene (e.g., "a dog and a cat playing together"), models frequently suffer from object missing (one subject is completely omitted) or attribute mixing (features like fur pattern or color are swapped or blended between subjects).

The authors aim to solve these multi-subject compositional challenges in a completely training-free, zero-shot manner during inference.

Methods

The framework builds on top of a pre-trained Stable Diffusion model equipped with a multi-modal prompt adapter (similar to IP-Adapter) to inject image features. To fix compositional issues without fine-tuning, the authors propose Subject-Enhanced Attention Guidance (SE-Guidance), which splits into two decoupled mechanisms:

  • Forward Guidance (Attribute Binding): During the forward denoising pass, the model extracts spatial cross-attention maps for each subject token. It applies a Gaussian smoothing filter and thresholds the maps to create a binary mask. This mask restricts the injection of subject-specific image features to their designated spatial regions, preventing attributes from bleeding into other objects.
  • Backward Guidance (Object Preservation): To combat "object missing," the authors introduce an inference-time optimization step. They define a loss function that maximizes the minimum attention value across all subject tokens. By backpropagating this loss to update the latent variable $z_t$ during the early denoising steps, they guarantee that every subject token receives sufficient spatial attention to manifest in the final image.
Overall pipeline of the proposed framework

Additionally, the authors introduce GroundingScore, a new evaluation metric. Traditional metrics (CLIP-I, DINO-I) evaluate the whole image and can be easily fooled by background matching. GroundingScore uses an open-set object detector (GroundingDINO) to crop the generated subjects first, then computes similarity scores strictly on the relevant regions.

Datasets

  • CustomConcept101: Used to evaluate single and multi-concept subject-driven generation. It contains 101 concepts with 3–15 images per concept.
  • LAION-2B & COYO-700M: Used to pre-train the baseline multi-modal prompt adapter (IP-Adapter).
  • ChatGPT: Used to generate 10–20 complex compositional prompts for evaluation.

Key Insights and Ideas

  • Disentangled Guidance: Forward and backward guidance tackle separate problems. Backward guidance ensures the object exists by forcing the model to pay attention to it, while forward guidance ensures the object looks right by confining feature injection to the correct mask.
  • The Illusion of High Fidelity: Traditional whole-image similarity metrics often give high scores to overfitted or poorly composed images because they get distracted by background details. Isolating the subject via grounding models reveals the true quality of multi-subject generation.
  • Early Denoising is Critical: The authors found that applying attention guidance only during the initial denoising steps is sufficient to lock in object identity and layout, saving computation time while avoiding out-of-distribution artifacts.

Key Results

  • Speed: SE-Guidance runs entirely at inference time, completing generation in under 15 seconds. This is a massive speedup compared to fine-tuning methods like CustomDiffusion (~10 mins) or DreamBooth (~25 mins).
  • Quantitative Performance: On multi-concept generation tasks, adding SE-Guidance to an IP-Adapter baseline boosted the text-alignment score (CLIP-T) from 0.7250 to 0.7714 and the grounding fidelity score (CLIP-GS) from 0.6012 to 0.6391, outperforming fine-tuned baselines like CustomDiffusion.
  • Qualitative Improvement: Effectively resolves attribute mixing and missing objects, as shown below:
Fig. 1: Compositional subject-driven generation. Existing text-to-image models frequently encounter difficulties in multi-subject generation tasks due to issues such as "object missing" and "attribute mixing", where some subjects in the prompt are not generated or their attributes are incorrectly combined. To address these challenges, our proposed SE-Guidance method effectively preserves the attributes of each subject, ensuring accurate and reliable generation outcomes.

Limitations and Future Work

  • Expressive Power Constraints: Because it is training-free, the method is fundamentally limited by the prior knowledge and expressive capacity of the underlying base diffusion model.
  • Rare & Highly Textured Objects: For highly unique or rare objects, zero-shot generation struggles to capture fine-grained textures accurately without explicit fine-tuning.
  • Complex Relations: Handling fine-grained spatial or compositional relations becomes difficult when scaling beyond two subjects, occasionally leading back to attribute mixing or omission.

Summary updated

BibTeX
@article{liu2024training,
  author = {Shengyuan Liu and Bo Wang and Ye Ma and Te Yang and Xipeng Cao and Quan Chen and Han Li and Di Dong and Peng Jiang},
  title = {{Training-free Subject-Enhanced Attention Guidance for Compositional Text-to-image Generation}},
  journal = {Pattern Recognition},
  year = {2024},
}
Figure