Detector Guidance for Multi-Object Text-to-Image Generation

Luping Liu, Zijian Zhang, Yi Ren, Rongjie Huang, Xiang Yin, Zhou ZhaoarXiv 2023 · DOI

Introduction

Modern diffusion models like Stable Diffusion and DALL-E 2 have revolutionized image synthesis, yet they frequently falter when tasked with generating multiple distinct objects. A common failure mode is "attribute bleeding," where characteristics of one object (e.g., tiger stripes) are erroneously applied to another (e.g., a leopard). Additionally, models often struggle with "object mixing," resulting in hybrid creatures or the complete disappearance of requested entities.

These issues stem from a lack of global spatial comprehension. Diffusion models rely on pixel-level cross-attention, where different text prompts compete for the same spatial regions without a high-level understanding of object boundaries. To address this, we introduce Detector Guidance (DG), a plug-and-play method that integrates a latent object detector into the generation process to enforce logical consistency.

Methodology: The DG Framework

Detector Guidance operates by intervening in the model's internal attention mechanisms during the denoising process. Unlike previous methods that require manual bounding boxes, DG is entirely automated and follows a three-stage pipeline:

  1. Latent Object Detection: DG utilizes a modified YOLOv1 model to analyze Cross-Attention Maps (CAMs). These maps reveal which parts of the latent space the model is associating with specific tokens (e.g., "cat" or "dog") long before the final image is formed.
  2. Alignment and Detection: The system identifies where objects are beginning to emerge. By the time 20% of the denoising steps are complete, CAMs typically contain sufficient spatial information for reliable detection.
  3. CAM Correction: Once objects are located, DG applies three corrective interventions:
  4. Boundary Correction: Refines rough detections into precise masks.
  5. Conflict Elimination: Suppresses irrelevant prompts in a given region (e.g., removing "leopard" influence from the "tiger" region).
  6. Target Enhancement: Boosts the intended prompt's signal within its assigned mask.
The DG pipeline: Alignment of cross-attention maps, Detection of latent objects, and Correction of attention weights.

To ensure stability, a Smooth Involvement strategy is employed, gradually introducing guidance to prevent visual artifacts or jittering.

Experimental Results

We evaluated DG across several benchmarks, including COCO, Concept Conjunction (CC), and a new Multi-Related Object (MRO) benchmark designed to test visually similar pairs (e.g., "a swift cheetah and a lumbering bear").

Qualitative Performance

As shown in the comparisons below, base models like Stable Diffusion 2.1 and Midjourney v5 often merge attributes when presented with complex prompts. In contrast, SD+DG successfully isolates attributes, producing distinct animals with correct textures.

Qualitative comparison between state-of-the-art models and SD+DG. Note the successful separation of tiger stripes and leopard spots in the top row.

Quantitative and Human Evaluation

In head-to-head human preference trials, DG-enhanced models were preferred over base versions by a margin of 8% to 22%. Furthermore, the latent detector demonstrated impressive zero-shot generalization, accurately identifying object categories it was not explicitly trained on during its initial COCO-based training phase.

Conclusion

Detector Guidance provides a robust, automated solution to the long-standing problem of attribute bleeding in text-to-image generation. By leveraging the internal "intent" visible in cross-attention maps, DG ensures that multi-object prompts result in logically coherent and visually accurate images without requiring additional human input. Future work may extend this framework to multi-modal guidance, incorporating audio or depth data to further refine the generative process.

Summary updated

BibTeX
@misc{liu2023detector,
  author = {Luping Liu and Zijian Zhang and Yi Ren and Rongjie Huang and Xiang Yin and Zhou Zhao},
  title = {{Detector Guidance for Multi-Object Text-to-Image Generation}},
  year = {2023},
  eprint = {2306.02236},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.02236},
}
Figure