Scale-Routed Cross-Attention for Small Objects in Text-to-Image Diffusion

Text-to-image diffusion models generate an image by gradually denoising random noise. They tie words to image regions through cross-attention, a mechanism in which each spatial location of the image features "looks up" the text tokens most relevant to it. In a standard Stable Diffusion U-Net this lookup happens at several resolutions. At the coarsest one, an object covering a 64×64 patch of a 512×512 image is a single feature pixel, as Towards Small Object Editing (Pan et al.) shows. The words describing that object then cannot be pinned to it, so small objects vanish or their attributes leak onto neighbours. Current fixes run gradient descent on the latent image at test time to reshape attention maps. This roughly doubles runtime (Training-Free Layout Control with Cross-Attention Guidance) and is bounded by what the frozen model already knows.

We propose borrowing the central idea of feature pyramid networks, the detection architecture that passes information between resolutions through lateral connections so small objects survive deep layers. The new part is that we apply it per text token inside the denoiser's cross-attention. Each grounded token is assigned a "home" resolution at which its box is still several feature pixels wide. Its attention map is computed reliably there, and a small learned, gated lateral path then supplies that map to coarser levels in place of their degraded native maps. The layout supervision that prior work applies at test time moves to training time, so inference needs only a single forward pass with no backpropagation. The claim is testable. On objects under 3% of image area, a light adapter trained this way should match or beat test-time attention optimization on fidelity and prompt alignment, at roughly base-model inference cost.

Core Claim

Small-object failures in layout-guided diffusion come mainly from asking coarse cross-attention layers to localize tokens they physically cannot resolve. We think the fix is scale routing rather than more guidance: each token's spatial binding should be decided at the level that can resolve it and passed to the other levels. Two things distinguish this from the closest work. Pan et al. build a similar "larger-scale reference map" only as an ad-hoc test-time proxy, obtained by temporarily enlarging the mask and then optimizing the latents. Frido builds a true pyramid diffusion model, but it conditions from coarse to fine scales with adaptive instance normalization, which rescales feature statistics globally. Frido has no token-level cross-attention across scales and never targets tiny objects. We keep a pretrained single-latent U-Net, add routing only to its cross-attention, and train the routing.

Research Program

The work starts with a diagnostic, because the mechanism rests on an assumption that could be false. On SOEBench-style boxes (objects under 3% of the image), we will measure how much of each target token's attention mass falls inside its box at each U-Net resolution and timestep in Stable Diffusion. We will then correlate those per-level measurements with whether the object appears, detected by an open-vocabulary detector. If fine-level maps are already well localized and failures track the coarse levels, routing is justified. If fine levels are also diffuse, the bottleneck is semantic rather than spatial, and the project changes course toward the crop-and-zoom baseline described below.

The mechanism is defined as follows. For token $i$ with box $b_i$, its home level $\ell^*(i)$ is the coarsest resolution at which $b_i$ spans at least $s$ feature pixels per side, with $s$ around 4. At any coarser level $\ell$, the token's attention map is replaced by

$$A_i^{\ell} = g_i \,\mathrm{Pool}_{\ell^*\to\ell}\big(W A_i^{\ell^*}\big) + (1-g_i)\,\hat A_i^{\ell}.$$

Here $\hat A_i^{\ell}$ is the model's native map, $W$ is a learned 1×1 lateral transform, $\mathrm{Pool}$ is area pooling to the coarser grid, and $g_i\in[0,1]$ is a gate computed by a tiny network from the box area and the timestep. At the home level itself, a gated residual adds extra value injection for the token, in the convex form used by gated cross attention for drug-target interaction to stop a dominant stream from drowning a weak one. That paper supplies our gating method. Here the dominant stream is the large objects and the background tokens. Coarse-to-fine information still flows through the U-Net's ordinary decoder, so global layout is untouched.

Only $W$, the gate, and the residual projections are trained; the base model stays frozen. The training data are grounded caption and box pairs from MS-COCO and OpenImages, oversampled toward small boxes. The objective is the standard denoising loss plus an attention-in-box energy of the kind Chen et al. backpropagate at test time, applied only at each token's home level. Inference then needs no latent optimization.

Baselines

The naive reference point is Stable Diffusion, or Stable Diffusion Inpainting for editing, with standard classifier-free guidance and prompt-only conditioning. Benchmarking Spatial Relationships in Text-to-Image Generation shows how weak this is on composition: the best model tested scored 7.49% on VISOR$_4$. Chen et al. report roughly 60% VISOR conditional accuracy for base Stable Diffusion.

The strongest existing method on the small-object question is Pan et al.'s Joint Attention Guidance. It combines a local term, which guides the small region toward a cleaner attention map computed on an enlarged mask, with a global term that penalizes the target token's attention outside the mask, and it optimizes latents during the early timesteps. On SOE-2k it improves FID by "nearly 1 point" over SD Inpainting and raises CLIPScore. The file gives no absolute FID, so we will rerun it with the authors' settings.

For layout generation more broadly, the strongest competitor is Chen et al.'s backward guidance. It reports 95.95% VISOR conditional accuracy and beats BoxDiff by 9.6 AP on Flickr30k Entities, at 8–9 seconds per image against 4 seconds for forward guidance. All methods will share the same base checkpoint, sampler, step count, seeds, and prompt and box sets. Each guidance method gets the same hyperparameter search budget over its scale, measured in GPU-hours, as our adapter's training sweep.

Beating the baselines means two things on SOE-2k and SOE-4k. First, FID and CLIPScore at least as good as Pan et al.'s. Second, higher small-object detection recall, measured with a fixed open-vocabulary detector applied inside the target boxes, at no more than about 1.2× base per-image latency.

Two ablations isolate the key ingredient. In the uniform adapter, the same parameters and the same training loss are applied to every level with no routing. This tests whether the benefit comes from the extra supervision or from routing. In the ungated version, $g_i=1$, which tests whether the gate prevents small-token maps from overwriting large objects in crowded scenes.

Why not just…?

Why not just use Pan et al.'s or Chen et al.'s test-time guidance? Both work, and Chen et al.'s reported VISOR number is very high. For small objects, though, the gradient signal passes through the same collapsed coarse maps we are trying to fix. Chen et al. also report degradation with dense, overlapping boxes, and backward guidance doubles runtime. This is a real threat on quality alone. If our adapter only matches them on quality, the contribution shrinks to speed, and we will report it that way. The dense-box split of the benchmark, described below, is where we expect the clearest separation.

Why not just generate the small object at a larger scale and paste it back? This means cropping the box region, upsampling it, inpainting at full resolution, downsampling, and blending. It is the simplest plausible fix and may be the strongest competitor, since it sidesteps the resolution problem entirely. Its likely weaknesses are lighting and context mismatch at the seams, plus cost that grows linearly with the number of objects. We will run it as a first-class baseline with identical compute. If it wins on SOEBench FID and CLIPScore, the architectural route is not justified for editing, and we would restrict our claims to full-scene generation with many small objects, where per-object passes become expensive.

Why not just raise the guidance scale, or diffuse at higher latent resolution? In the file, larger guidance scales cause oversaturation and lost diversity (TAG; Semantic Diffusion Guidance), and do not fix spatial composition (VISOR). Frido argues that single-scale high-resolution diffusion is costly and treats structure and texture alike. We include a higher guidance-scale sweep in the naive baseline, but we expect it to trade diversity for alignment rather than recover vanished objects.

Proposed Experiments

The primary benchmark is SOEBench (SOE-2k from OpenImages, SOE-4k from MSCOCO), used in the editing setting with FID, CLIPScore, in-box detection recall, and per-image latency. The second benchmark is layout-to-image generation on COCO boxes, stratified by box area. It uses FID alongside the Flickr30k Entities layout AP protocol from Chen et al. For reference, Frido reports a COCO layout-to-image FID of 37.14, though it is a different model family. The third benchmark is VISOR on SR2D prompts, which checks that routing does not harm spatial relations between large objects.

The first decisive check is a stratification of every metric by box area (under 1%, 1–3%, over 3%). Our method should gain mostly in the smallest bins and be neutral above 3%. Gains that are uniform across sizes would indicate the uniform-adapter ablation explains the result.

The second is a dense-box split: COCO images with at least five overlapping small boxes. Here the gated version should beat both the ungated version and Chen et al.

The third is a replacement test. Using the diagnostic's measurements, we swap in the ground-truth-derived fine map at coarse levels without any training. If this oracle routing recovers most of the gain, the mechanism is confirmed. If it does not, coarse-level collapse was not the cause, and the result is itself informative.