CountCluster: Training-Free Object Quantity Guidance with Cross-Attention Map Clustering for Text-to-Image Generation
Abstract
Text-to-image diffusion models often fail to generate the exact number of objects specified in prompts. Existing approaches either estimate object counts and optimize the mismatch with the ground truth, or incorporate additional modules or training procedures to encode quantity representations.However, these approaches do not directly intervene in the mechanism that determines object multiplicity.We empirically demonstrate that object quantity is strongly associated with the clustering structure of object cross-attention maps at the earliest denoising stage.Based on this insight, we propose \textbf{CountCluster}, a training-free method that directly controls object multiplicity by shaping early-timestep CAM clusters.Instead of predicting counts, our method explicitly constructs a CAM-aware target map with the intended number of spatial clusters and aligns the object CAM to this structure via a KL-based latent optimization applied only at the first denoising timestep.This simple yet effective strategy enables precise quantity control while preserving image quality. We demonstrate consistent improvements across both UNet-based and Transformer-based diffusion backbones, as well as under complex prompt settings, showing that our method provides a reliable solution to object-count alignment without additional training or external modules.