NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Make It Count: Text-to-Image Generation with an Accurate Number of Objects

Lital Binyamin, Yoad Tewel, Hilit Segev, Eran Hirsch, Royi Rassin, Gal Chechik

Abstract

Current text-to-image (T2I) diffusion models excel at generating high-quality textures and styles but struggle with precise numerical constraints. We present CountGen, a novel framework that enhances counting accuracy by leveraging internal "objectness" features within the diffusion process. By identifying where a model intends to place objects and applying a specialized "ReLayout" network to adjust these positions, CountGen significantly improves performance on complex counting tasks, outperforming state-of-the-art models like DALL-E 3.

Introduction: The Counting Challenge in T2I

Generating a specific number of objects—such as "six kittens sitting on a branch"—remains a significant hurdle for modern diffusion models. While these models are proficient at local texture synthesis, they lack an explicit global mechanism for object identity. Consequently, they often over- or under-generate instances, failing to satisfy numerical prompts. This limitation stems from the denoising process, which prioritizes local consistency over global entity counts.

CountGen enables precise control over the number of generated objects across various categories and counts.

Methodology: CountGen

CountGen addresses this by intervening in the generation process through a two-stage pipeline:

1. Discovering Internal "Objectness"

The researchers identified that specific self-attention layers in SDXL (notably $l^{up}_{52}$) contain latent features representing individual object instances early in the denoising process. By clustering these features, CountGen can estimate the number of objects the model is attempting to create before the final image emerges.

2. ReLayout and Guided Generation

If the detected count deviates from the prompt, a specialized U-Net called ReLayout is employed. ReLayout predicts a corrected spatial layout, adding or removing object masks while preserving the original scene's composition. To ensure the final image adheres to this new layout, the model uses an Object Layout Loss and Self-Attention Masking to guide the placement of objects and prevent background artifacts.

An example of CountGen successfully generating exactly six kittens on a branch, a task where standard models often fail.

Evaluation and Results

The framework was evaluated using the T2I-CompBench-Count benchmark and a new, scalable dataset called CoCoCount, which utilizes YOLOv9 for automated object detection.

Key findings include:

  • Significant Accuracy Gains: On CoCoCount, CountGen achieved a human-evaluated accuracy of 52%, nearly doubling SDXL's 26% and surpassing DALL-E 3's 38%.
  • Robustness at Scale: Unlike baseline models whose performance drops sharply as counts increase (e.g., 7+ objects), CountGen maintains higher reliability.
  • Compositional Integrity: By utilizing the model's own visual priors rather than external LLM hallucinations, CountGen produces natural-looking scenes with cohesive layouts.

Conclusion and Future Directions

CountGen represents a major step toward grounding diffusion models in numerical logic. While currently focused on single-class counting up to 10 objects, future work aims to extend this capability to multi-class scenarios (e.g., "three dogs and four cats") and even higher object densities.

Reference: Binyamin, L., et al. "Make It Count: Text-to-Image Generation with an Accurate Number of Objects." CVPR 2024. Project Page

Summary updated

BibTeX
@inproceedings{binyamin2025make,
  author = {Lital Binyamin and Yoad Tewel and Hilit Segev and Eran Hirsch and Royi Rassin and Gal Chechik},
  title = {{Make It Count: Text-to-Image Generation with an Accurate Number of Objects}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.01236},
}
Figure