Occlusion-Aware Text-To-Image Generation

Bach Hoang Ngo, Ngo Tri Si, Hieu Le, Trung-Nghia LeNeurIPS 2026

TL;DR

Ask a modern text-to-image model for "3 swans" and you’ll get a masterpiece; ask for "13 people and 15 cans in a kitchen" and you’ll get a chaotic, melted crowd of over 50 objects. This paper diagnoses why generative models lose count in crowded scenes—their training objectives essentially ignore hidden objects while their attention mechanisms let overlapping items bleed together—and fixes both issues without adding heavy test-time compute. The result is sharp, countable, photorealistic generation even when objects are stacked on top of one another.

What Problem Does This Paper Address?

Text-to-image diffusion models are notoriously bad at counting as scenes get crowded. Even if you give the model a spatial cheat sheet—like explicit bounding boxes showing where each object should go (layout-to-image generation)—things fall apart once boxes overlap. Instead of crisp, distinct entities, neighboring objects fuse into indistinguishable blobs or vanish entirely.

Figure 1: Count-preserving multi-category compositional generation. Standard diffusion models (top) succeed on simple prompts (3/3 swans) but fail as scene complexity grows - overcounting single-category scenes (7/6 apples), dropping instances in multi-category compositions (7/12 across bottles, plates, and glasses), and catastrophically merging objects in dense scenes (50+/28 across persons and cans). Our approach (bottom) achieves exact or near-exact counts across all density levels (3/3, 6/6, 12/12, 24/28) while preserving photorealistic quality and natural inter-object occlusion.

The authors call this instance ownership collapse, driven by two culprits inside Diffusion Transformers (DiTs):

  1. Feature leakage in attention: Self-attention allows image tokens in overlapping regions to talk freely to one another, blending the visual textures of adjacent objects into a single mass.
  2. Occlusion blindness in training: Standard diffusion training penalizes every pixel equally. Imagine a sofa taking up 40% of an image and a pillow behind it with only 5% of its pixels peeking out. The sofa generates roughly $8\times$ more gradient signal than the pillow. Over time, the model learns that heavily occluded objects barely affect the loss, so it stops bothering to render them distinctly.

Methods

The authors fine-tune a FLUX.2-Klein-base-4B backbone (using lightweight LoRA adapters) with two complementary upgrades:

  • Ownership-Aware Layout Attention (Training & Inference): Using a classic computer-graphics "painter's algorithm," bounding boxes are layered from back to front so every spatial token is owned by the frontmost object covering it. Instead of adding new trainable layers, the authors inject a parameter-free bias directly into the transformer's attention logits (paired with a gentle Gaussian spatial falloff). Tokens belonging to the same object get a cohesion boost to stick together, while tokens from different objects get a separation penalty to prevent feature bleeding—especially in contested overlap zones.
  • Amodal-Aware Instance-Balanced Loss, or AIBL (Training Only): Amodal simply means the full shape of an object, including the parts hidden behind something else. During training, AIBL compares an object's full amodal mask to its actually visible mask. If an object is 90% hidden, its few visible pixels get a boosted loss weight (tempered by a dampening exponent $\gamma = 0.5$ so gradients don't explode). The pixel weights are mean-normalized across the whole image so the overall learning rate stays stable. Crucially, because AIBL only alters the training loss, the model needs zero mask inputs at inference time.

Datasets

  • OverlapDepth-45K (New Benchmark): Existing datasets like MS-COCO or Visual Genome don't have dense, strictly controlled occlusion metadata. The authors built a synthetic dataset of 45,000 images (44K train, 1K test) spanning 92 categories in crowded settings like supermarkets and streets. It averages 13.2 objects per image with a 26.6% average occlusion rate, complete with visible masks, full amodal masks, and depth-ordered ownership maps.
  • External Benchmarks: To test real-world generalization, the authors also evaluate on CoCoCount and the counting subset of T2I-Compbench.

Key Insights and Ideas

  • Spatial anchors can't fix an optimization blindspot: Giving a model exact bounding boxes isn't enough when objects overlap; until you rebalance the gradient math, the model has little incentive to draw the tricky, partially hidden items.
  • Propagating repulsion stops merging at the root: When two bounding boxes overlap, the attention separation penalty isn't just applied to the overlapping pixels—it's applied across the entire regions of both involved objects. This stops textures from blending along the whole boundary interface.
  • The "Goldilocks" zone of loss boosting: In testing the dampening exponent $\gamma$ (from $0.0$ to $1.0$), performance followed a clean inverted-U curve. Raw, undampened ratios ($\gamma = 1.0$) give a 90%-occluded object a $10\times$ gradient spike, destabilizing training right back to baseline error levels. Taking the square root ($\gamma = 0.5$) hits the sweet spot.

Key Results

  • Crushing catastrophic failures: On OverlapDepth-45K, adding AIBL and ownership-bias drops Counting RMSE by 35.3% (from 9.26 down to 5.99) compared to a basic layout-attention baseline. Because RMSE heavily penalizes massive outliers, this shows the model stops merging dozens of items into giant blobs.
  • Beating layout-to-image SOTA: Under a fair test protocol where all layout models receive identical bounding boxes generated by Gemini 3 Flash, the proposed method beats GLIGEN, MIGC, and 3DIS across every metric, reaching 15.32% Exact Match accuracy (up from 12.88% for 3DIS).
  • Out-of-distribution generalization: Despite training on synthetic data, human evaluation on T2I-Compbench shows 65% counting accuracy—jumping +17% over specialized counting pipeline CountGen (48%) and +29% over DALL-E 3 (36%).

Limitations and Future Work

  • Extreme density saturation: Once scenes exceed 23+ objects, performance dips slightly below the layout-only baseline (8.3% vs. 8.7% counting score). At extreme densities, the compressed latent grid simply runs out of spatial resolution to keep features separate.
  • Thin and articulated objects: Skinny items like bicycles or umbrellas lose structural detail during latent compression, leading to higher count errors than blocky shapes like bags.
  • Synthetic domain shift: Because OverlapDepth-45K is synthetic, it can carry unnatural lighting or layout quirks. Future work aims to incorporate explicit 3D occlusion reasoning, category-aware loss weighting, and hybrid real-world datasets.

Summary updated

Abstract

Text-to-image diffusion models fail to generate correct object counts in dense scenes, where overlapping instances collapse into indistinguishable structures despite appearing visually plausible. We identify this as instance ownership collapse: tokens from overlapping objects interact freely through attention, while heavily occluded instances receive weak supervision due to their small visible areas. We address this through layout-aware attention biases that softly bias token interactions toward region-consistent grouping and suppress cross-instance leakage, paired with an amodal-balanced loss that amplifies gradients for occluded objects based on their occlusion level. To enable systematic evaluation, we introduce OverlapDepth-45K, a benchmark of densely overlapping scenes with amodal supervision. Our approach substantially improves count accuracy and prevents instance merging while preserving image quality.
BibTeX
@inproceedings{ngo2026occlusion,
  author = {Bach Hoang Ngo and Ngo Tri Si and Hieu Le and Trung-Nghia Le},
  title = {{Occlusion-Aware Text-To-Image Generation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=KXKtTAY4Fb},
}

Loading related content...

Figure