Spatial Intelligence
PDF

8.12D Spatial Generation

PDF p. 229· 36 min read

The 2D spatial generation encompasses a broad spectrum of tasks that require synthesizing or editing images under explicit spatial constraints. These constraints may be user-specified (bounding boxes, masks, sketches, keypoints, depth maps) or derived from scene understanding (layout graphs, semantic maps, relational structures), and the overarching goal is to produce images that are not only visually realistic but also faithful to the specified spatial configuration: objects appearing in the correct locations, at the correct scales and orientations, while remaining globally coherent in lighting, perspective, and style. 2D generation is where the most mature semantic-to-pixel prior in contemporary AI is taught to honor spatial structure: it is the proving ground on which large pre-trained visual priors are forced to localize objects, follow geometric scaffolds, respect occlusion ordering, and obey region- or instruction-level edits, all without falling out of the implicit grammar of natural images.

The section follows the 2D pipeline in three steps that share one latent-generator framework. §8.1.1 reviews foundational text-to-image generation, the semantic-to-pixel prior on which everything else here is built, and the three paradigms (adversarial, autoregressive, and diffusion with its flow-matching generalization) that parameterize it. §8.1.2 adds a structural condition (layouts, masks, edges, depth, pose, scene graphs, region phrases) and asks how it is injected into a frozen or co-trained generator. §8.1.3 replaces the empty canvas with an existing image and a mask, so that the generator must change what lies inside the mask while preserving what lies outside it.

8.1.1Text-to-image Generation#

Text-to-image (T2I) generation synthesizes an image from a natural-language description. For the rest of this chapter its importance lies less in the images themselves than in the prior it provides: a high-capacity mapping from compositional language to the visual space of objects, surfaces, layouts, and viewpoints, learned once at web scale and then reused. The spatial controllers of §8.1.2 and the editors of §8.1.3 impose constraints on this prior rather than replacing it, and the text-to-3D pipelines of §8.2 distill it through score distillation or multi-view consistency objectives; whatever relational competence the prior has, or lacks, therefore propagates downstream. The field has passed through three architectural paradigms, from adversarial training to autoregressive token modeling to iterative denoising, with diffusion and its flow-matching generalization now setting the standard for quality and prompt fidelity [185, 1645].

8.1.1.1Task Definition#

We formulate text-to-image generation in a paradigm-agnostic form that exposes the structural choices shared by modern systems. Let 𝒳\mathcal{X} denote the space of tokenized text prompts and 𝒴=[0,1]H×W×3\mathcal{Y}=[0,1]^{H\times W\times 3} the pixel-space image domain. Almost all modern T2I systems operate not directly on 𝒴\mathcal{Y} but on a compressed latent space 𝒵⊂ℝd\mathcal{Z}\subset\mathbb{R}^{d} provided by an autoencoder pair

E:𝒴→𝒵,D:𝒵→𝒴,D∘E≈id𝒴,E:\mathcal{Y}\rightarrow\mathcal{Z},\qquad D:\mathcal{Z}\rightarrow\mathcal{Y}% ,\qquad D\!\circ\!E\approx\mathrm{id}_{\mathcal{Y}}, (8.1)

where EE encodes a training image into a low-dimensional code and DD decodes a code back into a pixel image. A text encoder ϕ:𝒳→ℰ\phi:\mathcal{X}\rightarrow\mathcal{E} maps the prompt into a conditioning embedding ϕ⁢(𝐱)∈ℰ\phi(\mathbf{x})\in\mathcal{E}. The core learning problem is then to train a conditional latent sampler

Gθ:ℰ→𝒵,𝐳^∼pθ⁢(𝐳|ϕ⁢(𝐱)),G_{\theta}:\mathcal{E}\rightarrow\mathcal{Z},\qquad\hat{\mathbf{z}}\sim p_{% \theta}\!\big{(}\mathbf{z}\,\big{|}\,\phi(\mathbf{x})\big{)}, (8.2)

so that, after decoding, the resulting image 𝐲^=D⁢(𝐳^)\hat{\mathbf{y}}=D(\hat{\mathbf{z}}) is both photorealistic and semantically aligned with the prompt 𝐱\mathbf{x}. The three paradigms covered below differ chiefly in how the conditional distribution pθ⁢(𝐳∣ϕ⁢(𝐱))p_{\theta}(\mathbf{z}\mid\phi(\mathbf{x})) is parameterized and optimized; the autoencoder pair (E,D)(E,D) and the text encoder ϕ\phi are largely shared design choices across paradigms. Figure 8.1 schematizes this paradigm-agnostic pipeline and the substrate that the three paradigms share.

Figure 8.1The latent-generator view of text-to-image generation. Top: the shared pipeline of Eqs. (8.1) and (8.2); the encoder EE and the dashed paths are used only in training. Bottom: the sampler GθG_{\theta} as (a) a GAN, (b) an autoregressive token model, and (c) diffusion or flow matching. Not every architecture uses a separate autoencoder; the corgi is a schematic illustration.

8.1.1.2Methodology#

Three generative paradigms, taken in the order in which each dominated T2I, parameterize the sampler GθG_{\theta} of Eq. (8.2) differently; the bottom row of Figure 8.1 draws them against the common pipeline. A second set of advances refines the sampler without redefining it: backbone evolution, sampling acceleration, and the migration of leading systems to proprietary stacks. Structural conditioning interfaces, the fourth such refinement, are the subject of §8.1.2 and are not repeated here.

Generative Adversarial Networks. GAN-based T2I models instantiate GθG_{\theta} as a feed-forward generator Gθ⁢(𝐧,ϕ⁢(𝐱))→𝐳^G_{\theta}(\mathbf{n},\phi(\mathbf{x}))\!\to\!\hat{\mathbf{z}} driven by an auxiliary noise vector 𝐧∼𝒩⁢(0,I)\mathbf{n}\sim\mathcal{N}(0,I); the conditional distribution pθ⁢(𝐳∣ϕ⁢(𝐱))p_{\theta}(\mathbf{z}\mid\phi(\mathbf{x})) is defined only implicitly, as the pushforward of 𝐧\mathbf{n} through GθG_{\theta}. Training follows the two-player game of Goodfellow et al. [1646], pitting the generator against a discriminator DψD_{\psi},

minθ⁡maxψ⁡𝔼𝐲∼pdata⁢[log⁡Dψ⁢(𝐲,ϕ⁢(𝐱))]+𝔼𝐧⁢[log⁡(1−Dψ⁢(D⁢(Gθ⁢(𝐧,ϕ⁢(𝐱))),ϕ⁢(𝐱)))],\min_{\theta}\max_{\psi}\ \mathbb{E}_{\mathbf{y}\sim p_{\text{data}}}\!\big{[}% \log D_{\psi}(\mathbf{y},\phi(\mathbf{x}))\big{]}+\mathbb{E}_{\mathbf{n}}\!% \big{[}\log\!\big{(}1-D_{\psi}(D(G_{\theta}(\mathbf{n},\phi(\mathbf{x}))),\phi% (\mathbf{x}))\big{)}\big{]}, (8.3)

in which DψD_{\psi} scores both photorealism and text-image consistency. The result is sharp high-frequency detail and single-pass inference, bought at the price of unstable training and mode collapse. Within this framework, StackGAN [1647] generated a low-resolution image first and refined it with a second GAN conditioned on both the text and the coarse image; AttnGAN [1648] let the generator attend to individual words while rendering different regions, with an auxiliary image-text matching loss (DAMSM) that reduced attribute errors such as wrongly colored objects; XMC-GAN [1649] replaced that loss with cross-modal contrastive learning and improved multi-object prompts. By 2021 diffusion models had overtaken these systems on COCO, chiefly because they train stably and cover more of the image distribution, and research attention moved on; the GAN emphasis on high-frequency detail survives in hybrid and adversarially fine-tuned samplers.

Autoregressive Models. Autoregressive (AR) models discretize the latent space: the autoencoder EE is realized as a vector-quantized variational autoencoder (VQ-VAE) whose output is a sequence of discrete tokens 𝐳=(z1,…,zN)∈𝒱N\mathbf{z}=(z_{1},\dots,z_{N})\in\mathcal{V}^{N} over a learned codebook 𝒱\mathcal{V}, and GθG_{\theta} is factorized in causal raster order,

pθ⁢(𝐳|ϕ⁢(𝐱))=∏n=1Npθ⁢(zn|z<n,ϕ⁢(𝐱)),p_{\theta}\!\big{(}\mathbf{z}\,\big{|}\,\phi(\mathbf{x})\big{)}\;=\;\prod_{n=1% }^{N}p_{\theta}\!\big{(}z_{n}\,\big{|}\,z_{<n},\,\phi(\mathbf{x})\big{)}, (8.4)

trained by maximum likelihood on the next-token cross-entropy. T2I thus becomes sequence-to-sequence translation, and the transformer that performs it inherits the compositional competence of language models: DALL-E [1650] modeled text and image tokens as a single sequence and showed zero-shot generalization across prompt types. The cost is decoding latency, one forward pass per token, which grows with resolution. Parti [1651] scaled the transformer to 20B parameters, generated at 256×256256\times 256, and reached 1024×10241024\times 1024 with a convolutional super-resolution stage; Muse [1652] abandoned strict sequential order for masked token prediction, filling in many tokens per step over a handful of rounds, and matched diffusion quality on several benchmarks at a fraction of the sampling time. AR generation remains attractive where images are produced jointly with text (interleaved documents, storyboards) and a single sequence model handles both.

Diffusion Models. Diffusion models realize GθG_{\theta} as iterative denoising rather than a single feed-forward pass. A fixed forward process corrupts the clean latent 𝐳0=E⁢(𝐲)\mathbf{z}_{0}=E(\mathbf{y}) along a schedule (αt,σt)t=0T(\alpha_{t},\sigma_{t})_{t=0}^{T}, 𝐳t=αt⁢𝐳0+σt⁢ϵ\mathbf{z}_{t}=\alpha_{t}\mathbf{z}_{0}+\sigma_{t}\epsilon with ϵ∼𝒩⁢(0,I)\epsilon\sim\mathcal{N}(0,I) and 𝐳T≈𝒩⁢(0,I)\mathbf{z}_{T}\!\approx\!\mathcal{N}(0,I); a noise-prediction network ϵθ\epsilon_{\theta} learns to invert it under the denoising score-matching objective

minθ⁡𝔼t,𝐳0,ϵ⁢[‖ϵ−ϵθ⁢(𝐳t,t,ϕ⁢(𝐱))‖22],\min_{\theta}\ \mathbb{E}_{t,\mathbf{z}_{0},\epsilon}\!\left[\left\|\epsilon-% \epsilon_{\theta}\!\big{(}\mathbf{z}_{t},\,t,\,\phi(\mathbf{x})\big{)}\right\|% _{2}^{2}\right], (8.5)

which is the diffusion-specific realization of the training objective implicit in Eq. (8.2). At inference the model starts from 𝐳T∼𝒩⁢(0,I)\mathbf{z}_{T}\sim\mathcal{N}(0,I), applies ϵθ\epsilon_{\theta} for t=T,…,1t=T,\dots,1, and decodes 𝐲^=D⁢(𝐳^0)\hat{\mathbf{y}}=D(\hat{\mathbf{z}}_{0}); each step corrects a small error, which is why the final samples are both detailed and faithful. Running this process in the latent space of Eq. (8.1) rather than in pixels, as Latent Diffusion Models [185] did (e.g., , 4×64×644\times 64\times 64 instead of 3×512×5123\times 512\times 512 for a 512px image), cut memory and compute enough to train on commodity hardware and to release Stable Diffusion openly. Conditioning the denoiser on embeddings from a pretrained language-image model, as in GLIDE [1653] and DALL⋅\cdotE 2 [1654], improved prompt alignment, and classifier-free guidance [1655] supplied a single knob that trades diversity against fidelity by extrapolating the conditional prediction away from the unconditional one. The remaining weakness is sampling cost, dozens of sequential network evaluations per image; higher-order ODE samplers and the distillation methods below address it. Diffusion or flow-matching cores now underlie most leading systems, with the native multimodal autoregressive stacks discussed under proprietary systems the main exception.

Flow Matching and Rectified Flow. Rather than a fourth paradigm, flow matching is diffusion reformulated in continuous time. It parameterizes GθG_{\theta} as a learned velocity field vθ⁢(𝐳t,t,ϕ⁢(𝐱))v_{\theta}(\mathbf{z}_{t},t,\phi(\mathbf{x})) instead of a noise predictor: training picks the straight interpolation 𝐳t=(1−t)⁢𝐳0+t⁢𝐳1\mathbf{z}_{t}=(1-t)\mathbf{z}_{0}+t\mathbf{z}_{1} between a clean latent 𝐳0=E⁢(𝐲)\mathbf{z}_{0}=E(\mathbf{y}) and a Gaussian sample 𝐳1∼𝒩⁢(0,I)\mathbf{z}_{1}\!\sim\!\mathcal{N}(0,I) and regresses the velocity,

minθ⁡𝔼t,(𝐳0,𝐳1)⁢[‖vθ⁢(𝐳t,t,ϕ⁢(𝐱))−(𝐳1−𝐳0)‖22],\min_{\theta}\ \mathbb{E}_{t,(\mathbf{z}_{0},\mathbf{z}_{1})}\!\left[\left\|v_% {\theta}(\mathbf{z}_{t},t,\phi(\mathbf{x}))-(\mathbf{z}_{1}-\mathbf{z}_{0})% \right\|_{2}^{2}\right], (8.6)

and inference integrates the probability-flow ODE d⁢𝐳t/d⁢t=vθ⁢(𝐳t,t,ϕ⁢(𝐱))\mathrm{d}\mathbf{z}_{t}/\mathrm{d}t=v_{\theta}(\mathbf{z}_{t},t,\phi(\mathbf{% x})) from t=1t=1 back to t=0t=0. The formulation was introduced concurrently by Lipman et al. [1656] (Flow Matching) and Liu et al. [1657] (Rectified Flow); Albergo and Vanden-Eijnden [1658] gave the unifying stochastic-interpolant view in which diffusion is the special case of a noisier interpolation schedule. Three consequences matter in practice. Straight-line interpolations yield nearly straight ODE trajectories, so matched quality is reached in noticeably fewer steps (genuine one-step generation still needs a reflow or distillation stage); the objective is a single regression with no noise-schedule design and no per-schedule guidance recalibration; and the loss scales smoothly with model size and resolution. Stable Diffusion 3 [1659] scaled the recipe to T2I on a DiT-style transformer backbone and reported the best GenEval scores among open models together with favorable human preference on Parti-prompts; the Flux family followed the same recipe. Flow matching composes with every refinement below as readily as a noise-predictor core does and has become the default continuous-time formulation in 2024-onwards systems.

Backbone Evolution: From U-Net to Diffusion Transformers. Early diffusion models used the U-Net for its multiscale feature fusion and locality bias. The Diffusion Transformer (DiT) of Peebles and Xie [1645] replaced it with a stack of transformer layers over latent patch tokens, giving every denoising step a global receptive field, and showed that FID improves monotonically with depth, width, and token count along predictable scaling laws, reaching FID 2.27 on class-conditional ImageNet at 2562256^{2}. Attention cost grows quadratically with resolution, so hybrid CNN-transformer designs and efficient attention remain active; the DiT lineage nonetheless underlies SD3 and most 2024-onwards systems, and it points toward a single transformer that generates several modalities, differing only in tokenization and training data.

Sampling Acceleration and Distillation. Fifty or more denoising steps rule out interactive use and low-power deployment. Salimans and Ho [1660] distilled a TT-step teacher into a T/2T/2-step student and iterated the halving to reach 11–44 steps. Consistency Models [1661] train a network to map a noisy latent at any timestep directly to the clean image, either from scratch with a consistency loss or by distilling a pretrained diffusion model, and Latent Consistency Models [1662] applied the idea to Stable Diffusion’s latent space, matching 5050-step quality in 22–44 steps. All of these are post-training procedures that leave the architecture untouched, so any strong backbone can be made fast after the fact.

Proprietary and Commercial Systems. Leading systems have migrated to proprietary, industrially scaled stacks of three kinds. Native multimodal models such as OpenAI’s GPT Image 1.5 [1663] and Google’s Gemini 3 Pro Image (Nano Banana Pro) [1664] run a unified transformer over interleaved text and image tokens and emphasize semantic reasoning and multi-turn editing; latent-diffusion iterations such as Imagen 4 [1665] scale the LDM recipe with stronger text encoders and curated data; preference-tuned systems such as Midjourney v7 [1666] and FLUX.2 [max] [1667] fine-tune strong priors on human-preference data (FLUX.2 on the rectified-flow recipe of §8.1.1.2; Midjourney’s architecture is undisclosed). Each reduces to one of the three paradigms plus some of the refinements just listed; because architectural and training detail is withheld, public benchmarking and reproduction still rest on the open SD / DiT stack.

8.1.1.3Benchmarks#

Three independent things are usually conflated under “benchmark”: the training corpora on which models are fit, the evaluation suites of prompts that probe particular capabilities, and the metrics that score the resulting images. A model trained on LAION-5B can be evaluated on GenEval prompts and scored by FID, CLIPScore, or an LLM judge, and disagreement between those scores is itself informative.

Training Corpora. Corpus scale has driven much of T2I progress. Early work fit fine-grained sets with ten captions per image, CUB-200-2011 (11,788 bird images) [1668] and Oxford-102 Flowers (8,189 images) [1669]; MS-COCO Captions [440] (123,287 images, five captions each) became the standard general-scene corpus and, for years, the evaluation set as well, a conflation that the suites below were designed to end. Current models train on web-scale image-text pairs: LAION-5B [1670] releases 5.85 billion CLIP-filtered pairs, and proprietary corpora of similar scale, less documented, underlie DALL-E 2 and Parti. Scale brought duplication, demographic bias, unsafe content, and licensing disputes with it, and filtered subsets such as LAION-Aesthetics and curation pipelines are now part of every training recipe.

Evaluation Benchmark Suites. An evaluation suite is a curated prompt set plus a verification protocol: prompts are adversarial or capability-stratified, reference images are usually absent, and scoring is automatic (an object detector, a VQA model, or an LLM/MLLM judge) rather than reconstruction-based. Table 8.1 lists the main suites since 2022. The earliest, DrawBench [1671] and PartiPrompts [1651], are human-pairwise prompt sets released with Imagen and Parti; HRS-Bench [1672] and HEIM [1673] are holistic, scoring 13 and 12 axes respectively; TIFA [1674], GenEval [1675], and T2I-CompBench [1676] introduced automatic verification by VQA, object detection, and BLIP-VQA plus UniDet, and the latter two are now reported alongside FID and CLIPScore in most papers. For spatial intelligence the salient suite is VISOR [1677], which isolates two-object relations (left/right, above/below) over 25,28025{,}280 prompts and finds that otherwise strong models frequently render the wrong configuration. DPG-Bench [1678] targets dense, long compositional prompts, GenAI-Bench [1679] pairs compositional prompts with VQAScore judging, and WISE [1680] asks whether generated images agree with real-world facts (flag colors, landmarks, anatomy), a knowledge axis orthogonal to compositional binding.

Table 8.1Representative evaluation benchmark suites for text-to-image generation, ordered approximately by year of release. “Scoring” indicates the dominant verification mechanism: detector- or VQA-based automatic checking, learned preference models, MLLM/LLM-as-judge rubric scoring, or aggregated human preference. Several suites combine multiple scoring channels.
Benchmark Year # Prompts Evaluation Axis Scoring
DrawBench [1671] 2022 200 Broad capability + alignment (1111 categories) Human pairwise
PartiPrompts [1651] 2022 1,600 Capability spectrum (1212 categories) Human pairwise
VISOR [1677] 2022 25,280 Two-object spatial relations (left/right, above/below) Object-detector verification
TIFA [1674] 2023 4,081 Faithfulness (VQA over auto-generated questions) VQA / LLM-as-judge
HRS-Bench [1672] 2023 45,000 Holistic; 1313 skills ×\times 5050 scenarios Automatic, mixed
HEIM [1673] 2023 62 scenarios Holistic; 1212 aspects (alignment, quality, knowledge, bias, toxicity, …) Automatic ++ human
GenEval [1675] 2023 553 Object-centric: single/two-obj., counting, color, position, attribute Detector verification
T2I-CompBench [1676] 2023 6,000 Compositional: attribute binding, object relationships, complex prompts BLIP-VQA ++ UniDet
DPG-Bench [1678] 2024 1,065 Dense, long compositional prompts MLLM-based scoring
GenAI-Bench [1679] 2024 1,600 Compositional T2V/T2I prompts VQAScore (LLM-judge)
WISE [1680] 2025 1,000 World-knowledge-informed semantic accuracy LLM-based grading

Evaluation Metrics. Metrics fall into four tiers. Distributional metrics compare the generated and real image populations and say nothing about any individual prompt: the Fréchet Inception Distance (FID) [1681] is the Wasserstein-2 distance between Gaussian fits of Inception-V3 features of generated and real images, the Inception Score rewards images that are individually confidently classified yet collectively diverse, and generative precision/recall [1682, 1683] separate quality from coverage through neighborhood tests in feature space. Alignment metrics score one image against its prompt; CLIPScore [1684], the cosine similarity between the CLIP embeddings of 𝐲^\hat{\mathbf{y}} and 𝐱\mathbf{x}, is cheap and reference-free but inherits CLIP’s insensitivity to attribute binding, counting, and spatial relations. Learned preference models, HPSv2 [1685], ImageReward [1686] (fit to 137137K human comparisons), and PickScore [1687] (fit to the ∼500{\sim}500K real-user comparisons of Pick-a-Pic), regress a scalar that correlates with average user preference, bundling realism, alignment, and aesthetics; they have become the default automatic ranking while inheriting their raters’ biases and degrading out of distribution.

The newest tier uses a vision-language model as judge. TIFA [1674] has a language model write verification questions from the prompt and a VQA model answer them against the image, the score being the fraction answered correctly; VQAScore [1688] collapses this to a single yes/no probability under a fine-tuned CLIP-FlanT5 model and reports the best human correlation on compositional suites; VIEScore [1689] and LLMScore [1690] prompt a multimodal LLM with a structured rubric and return per-axis scores with brief rationales, and direct prompting of frontier VLMs with custom rubrics has become routine for ad-hoc capability probes. Judge metrics track human preference on compositional and spatial prompts far better than CLIPScore, at the cost of a frontier-model call per image, sensitivity to rubric wording, and drift across judge-model versions that makes numbers from different papers hard to compare. No single tier suffices, and current papers report a tuple (FID or IS, CLIPScore, one or two preference scores, one judge score) on several suites plus a small human study; cross-metric disagreement is read as a warning rather than averaged away.

8.1.1.4Challenges and Trends#

The weakness that matters most for this handbook is spatial-relation faithfulness, a sub-problem of compositionality. Models frequently misplace objects relative to one another: a prompt that puts a cup to the left of a laptop is often rendered with the two swapped or stacked, and VISOR [1677] shows that language-specified relations are frequently ignored outright. Data-centric remedies help; SPRIGHT [1691] re-captions training images with explicit spatial descriptions and measurably improves consistency, but reliable control over where objects appear remains open. Because layout-conditioned generation (§8.1.2) and text-to-3D (§8.2) inherit whatever relational competence this prior provides, the limitation is foundational rather than cosmetic. Fine structure is a second gap: legible text, hands, and faces still fail in otherwise strong models and appear to need architectural or data-specific fixes rather than scale alone.

Evaluation reliability is the third. Automatic scores correlate imperfectly with human judgment precisely on the compositional, counting, and spatial-relation prompts that matter here; judge-based metrics close part of the gap but add rubric sensitivity and judge-version drift, so headline numbers across papers are not directly comparable. As GenEval and T2I-CompBench become standard, their prompts risk leaking into web-scraped training corpora, in which case high scores increasingly measure memorization rather than capability; periodic refresh of held-out prompts, blinded judges, and explicit train/test decontamination are the obvious countermeasures and are not yet routine.

Societal concerns follow the data. Models inherit demographic bias from their corpora and will produce unsafe content on request; prompt classifiers, safety filters, and fine-tuning on curated subsets reduce but do not remove the problem, and photorealistic synthesis raises misinformation and intellectual-property questions that watermarking and data curation address only in part. The extension of these priors along the time axis, where identity and motion must stay consistent across frames, is the subject of §8.3; the next two subsections stay in the image plane and ask how the prior can be made to obey spatial constraints and local edits.

8.1.22D Spatial-aware Image Generation#

2D spatial-aware image generation synthesizes images that are faithful not only to a text prompt but to explicit spatial constraints in the image plane: where objects appear, how large they are, what shape they take, and how they relate to one another (left of, on, behind). The constraint may be a set of boxes or a scene layout, an instance or semantic mask, an edge or sketch map, a depth or normal map, 2D keypoints, a scene graph, or a phrase bound to a region, and the pipelines that honor it are almost all diffusion models augmented with a conditioning pathway or a guidance term. The tension that organizes the subfield is three-way: adherence to hard constraints against perceptual realism and diversity, and both against compositionality when many small or occluding objects carry discrete relations. Depth and normal maps enter here as structural guides for occlusion ordering and surface orientation, not as metric measurements; recovering true distance belongs to reconstruction (§8.2).

8.1.2.1Task Definition#

We inherit the latent-generator framework of §8.1.1. Let 𝒳\mathcal{X} denote tokenized prompts, 𝒵\mathcal{Z} the latent space induced by the autoencoder pair (E,D)(E,D) of Eq. (8.1), and ϕ:𝒳→ℰ\phi:\mathcal{X}\!\rightarrow\!\mathcal{E} the text encoder. Spatial-aware generation augments this framework with a structural condition 𝐜∈𝒞\mathbf{c}\in\mathcal{C} drawn from one or more conditioning channels (boxes, masks, edges, depth, pose, scene graphs, region phrases, reference images), encoded by a condition encoder κ:𝒞→𝒞′\kappa:\mathcal{C}\!\rightarrow\!\mathcal{C}^{\prime}. The conditional latent sampler of Eq. (8.2) is extended to a joint conditional

Gθ:ℰ×𝒞′→𝒵,𝐳^∼pθ⁢(𝐳|ϕ⁢(𝐱),κ⁢(𝐜)),G_{\theta}:\mathcal{E}\times\mathcal{C}^{\prime}\rightarrow\mathcal{Z},\qquad% \hat{\mathbf{z}}\sim p_{\theta}\!\big{(}\mathbf{z}\,\big{|}\,\phi(\mathbf{x}),% \,\kappa(\mathbf{c})\big{)}, (8.7)

and the generated image 𝐲^=D⁢(𝐳^)\hat{\mathbf{y}}=D(\hat{\mathbf{z}}) is required to be (i) photorealistic, (ii) semantically aligned with 𝐱\mathbf{x}, and (iii) faithful to the structural condition 𝐜\mathbf{c} in placement, scale, shape, and pairwise relation. The unconditional limit 𝐜=∅\mathbf{c}=\varnothing recovers pure T2I generation as in §8.1.1; the substance of the present subsection lies in how κ\kappa is realized for each conditioning channel and how its output is injected into GθG_{\theta}. Which channel populates 𝐜\mathbf{c}, and how densely, ranges from pixel-level maps (masks, edges, depth) through coordinate-level scaffolds (boxes, keypoints) to discrete symbols (scene graphs, region phrases); the modality survey below follows that ordering. Interactive constraints supplied by dragging handles during generation belong to the editing regime of §8.1.3.

8.1.2.2Methodology#

Two axes organize the methods: the conditioning modality (what kind of structural input 𝐜\mathbf{c} is consumed) and the injection mechanism (how κ⁢(𝐜)\kappa(\mathbf{c}) enters the latent sampler GθG_{\theta}). They are nearly independent. One mechanism, a ControlNet-style side branch, serves canny edges, pose skeletons, depth, and segmentation alike, and one modality, bounding boxes, is served by side branches, grounded cross-attention, or inference-time attention shaping, so the design space is a matrix of (modality ×\times mechanism) cells rather than a list of monolithic methods. Figure 8.2 draws the five mechanisms on one backbone silhouette.

Conditioning Modalities. Dense pixel-level scaffolds supply a value at every location, which makes them the easiest channels to follow and the most restrictive on creativity. Instance and semantic masks drive region-conditioned synthesis, with MultiDiffusion [1692] offering a training-free protocol that samples jointly over overlapping mask windows; edges, sketches, and line art, popularized by the canny and soft-edge variants of ControlNet [1693] and the edge head of T2I-Adapter [1694], fix only the location of intensity discontinuities and leave texture and appearance to the prompt; depth and normal maps, served by ControlNet’s depth variant, impose coarse occlusion ordering and surface orientation without requiring a metric reconstruction. Coordinate-level scaffolds drop to per-region or per-point supervision. Boxes with labels are the most studied channel, a set of (box,label)(\text{box},\text{label}) tuples fixing location and rough scale, with LayoutDiffusion [1695], LayoutLLM [1696], and the open-set GLIGEN [1697] as representatives; 2D keypoints (typically human pose) are sparser still, a handful of joint coordinates, injected through ControlNet or handled by GLIGEN as a special case of grounding. Discrete symbolic structure carries no pixel- or coordinate-level information at all, and the model must map it onto the image plane itself. Scene graphs reach back to the sg2im line of Johnson et al. [1698] and re-emerged in the diffusion era through LLM-emitted layouts, as in LayoutLLM, where the graph is first decoded into a coordinate-level layout; region phrases and referring expressions bind a text span to a box, mask, or free-form polygon and are served by GLIGEN’s grounded cross-attention and by phrase-grounding heads attached to SD and SDXL [1699].

Injection Mechanisms. Five mechanism families cover the literature; production pipelines routinely stack a side branch for dense geometric channels, an adapter for style or a reference image, and inference-time guidance to sharpen adherence on adversarial prompts.

Side-branch controllers. The backbone weights stay frozen and an auxiliary branch mirroring the encoder half of the base U-Net is trained, connected through zero-convolution layers whose weights are initialized to zero so that the augmented model reproduces the base model exactly at the start of training and degrades gracefully if the branch is poorly tuned. ControlNet [1693] is the prototype and the first widely adopted retrofit pathway for non-text structural control: the condition (a canny edge map, an OpenPose skeleton, a depth or normal map, a segmentation mask, or a scribble) is encoded by the side branch in parallel with the noisy latent and injected into the base U-Net through additive residual connections at each scale. One branch is trained per modality on labeled image–condition pairs, which produced a library of plug-in controllers for SD 1.5 and SDXL [1699] that compose with prompt conditioning at inference time without retraining the backbone; most later designs either shrink this recipe or fold it into a unified adapter library.

Lightweight adapters. Where the side branch spends capacity (half a U-Net per modality), T2I-Adapter [1694], developed concurrently with the same goal of plug-in control over a frozen backbone, spends as little as possible: a few residual blocks per modality whose multi-scale features are added directly into the corresponding encoder stages. Several adapters can be combined at inference, an image conditioned simultaneously on an OpenPose skeleton, a depth map, and a color palette with a scalar weight on each, so the adapter is preferred for multi-channel fusion and fast iteration, and the side branch where maximum single-channel fidelity matters.

Grounded cross-attention. Side branches and adapters run an external pathway alongside the backbone; the next two families intervene inside its attention stack. GLIGEN [1697] inserts a new gated self-attention layer between the existing self-attention and cross-attention of each U-Net transformer block; the layer attends jointly over the visual tokens and a set of grounding tokens that encode each (phrase,box)(\text{phrase},\text{box}) pair, a learned scalar gate controls how strongly the grounding signal enters the residual stream, and only the new layer is trained, so the network falls back to ungrounded behavior when no constraint is supplied. The problem it solves is complementary to the side branch: not how to inject a dense pixel-level scaffold, but how to introduce open-set symbolic grounding (any category named in text, localized by a box, keypoints, or a reference image) into a frozen T2I backbone, with several grounding channels interleaved within one mechanism.

Layout-aware cross-attention. LayoutDiffusion [1695] is the dense-supervised cousin of grounded attention: rather than gating a new layer onto a frozen backbone, it co-trains a layout-aware cross-attention block end to end for layout-to-image (L2I) generation specifically. A structured layout, a set of (box,class label)(\text{box},\text{class label}) tuples, becomes a sequence of region tokens fused with the noisy latent at every denoising step, and an explicit object–scene factorization models global scene context separately from per-object features so that object identity, scale, and pairwise relations survive in cluttered scenes. It reports stronger layout IoU and relation satisfaction than ControlNet or T2I-Adapter on multi-object COCO benchmarks, at the cost of being specialized to box-and-label input rather than the broader modality library.

Inference-time guidance. The fifth family adds no parameters and modifies only sampling. BoxDiff [1700] is the canonical training-free spatial controller: it shapes the cross-attention maps so that activations of box-localized prompt tokens concentrate inside their boxes while the backbone stays untouched. MultiDiffusion [1692] fuses overlapping mask windows at sampling time, and composing scores from several conditional models or tuning the classifier-free guidance scale per region are related strategies. Because nothing is retrained, these methods suit rapid prototyping, backbones whose weights are unavailable for fine-tuning, and per-prompt sharpening on top of the trained mechanisms above.

Figure 8.2Five mechanisms for injecting a spatial condition κ⁢(𝐜)\kappa(\mathbf{c}) into a text-to-image denoiser: (a) side-branch control (ControlNet [1693]), (b) lightweight adapters (T2I-Adapter [1694]), (c) gated grounding (GLIGEN [1697]), (d) layout-aware cross-attention (LayoutDiffusion [1695]), and (e) inference-time guidance (BoxDiff [1700]). The corgi example is illustrative, not a comparison of outputs.

8.1.2.3Benchmarks#

Two things change relative to §8.1.1. The ground truth is a structural annotation (a layout, a mask, a keypoint set) rather than a reference image, so reconstruction-style metrics give way to adherence metrics that score how closely the generated image honors 𝐜\mathbf{c}; and every channel admits its own adherence metric, so a meaningful report combines a channel-specific score with the realism and alignment scores inherited from the previous subsection.

Training Corpora. Spatial-aware models are typically trained on corpora that pair images with rich structural annotations: COCO Captions [440] for layouts and captions; ADE20K [492] (2020K images, 150150 classes) for semantic and instance masks; Visual Genome [796] for object boxes, attributes, and pairwise relations supporting scene-graph conditioning; RefCOCO / RefCOCO+ / RefCOCOg [1082] for phrase grounding; and PhraseCut [1092] for region-prompt mask supervision. Additional structure (canny edges, depth, normals, OpenPose skeletons) is typically derived on the fly from these base corpora by running pretrained predictors over each image, producing the paired image–condition data on which ControlNet-style and adapter-style pipelines are trained.

Evaluation Benchmark Suites. Most of the suites surveyed in §8.1.1 (Table 8.1) include axes that probe spatial-aware generation directly and serve as its primary out-of-the-box benchmarks. GenEval [1675] exposes a position subset that scores whether two objects appear in a specified relation (left of, above); T2I-CompBench [1676] provides explicit spatial and non-spatial relationship categories with BLIP-VQA and UniDet scoring; HRS-Bench [1672] includes a spatial skill among its thirteen; GenAI-Bench [1679] offers compositional prompts on which spatial relations are a frequent failure of CLIP-based scoring; and WISE [1680] measures knowledge-grounded location accuracy. Beyond these, the L2I literature reports task-specific evaluations on COCO layouts: detection-based AP for box-localized objects alongside FID and CLIPScore.

Constraint-specific Metrics. Layout adherence is box IoU between the conditioning layout and the boxes recovered by a frozen detector on 𝐲^\hat{\mathbf{y}}, often with per-object center distance; mask adherence uses mask IoU and boundary FF-score against the conditioning mask; edge and sketch adherence report recall (sometimes precision) of edges re-extracted from 𝐲^\hat{\mathbf{y}}; geometry adherence reports depth RMSE and normal angular error where ground-truth geometry exists; pose adherence reports keypoint reprojection error or PCK; and relational adherence reports relation-satisfaction accuracy and per-entity object AP for scene-graph and phrase-grounded settings. These numbers do not aggregate: averaging layout IoU with mask IoU has no operational meaning, since the two live on different scales and reward different shape regimes, and most papers report a different subset of them, which is the main obstacle to cross-paper comparison in this subfield.

8.1.2.4Challenges and Trends#

Spatial-aware T2I inherits the compositionality and evaluation problems of §8.1.1 and sharpens them.

Faithful multi-object composition. Crowded scenes with many small or partially occluded objects and hard relations (support, containment, depth ordering) fail in three recognizable ways: attention dilution, in which a prompt token’s cross-attention spreads across the canvas and no object is well localized; attribute leakage, in which color, material, or count attaches to the wrong object (the canonical “red cube on a blue sphere” confusion); and object dropping, in which small or rare entities in a multi-object layout are simply omitted. On GenEval the position and counting subsets remain the weakest axes across SD 1.5, SDXL, and SD 3 [1659]. Remedies work at three levels: Attend-and-Excite [1701] reweights cross-attention at inference so that every subject token is strongly activated somewhere in the canvas; StructureDiffusion [1702] uses prompt syntax to constrain attention structure without training; and LLM-emitted layouts, LayoutGPT [1703] and the multimodal-LLM-driven RPG of Yang et al. [1704], plan a structured layout from the free-form prompt and hand it to an L2I renderer. Whether the gap closes through a stronger compositional prior in the backbone or through planning as a separate stage is unresolved, and the two are not exclusive.

Constraint satisfaction against creativity and diversity. Turning guidance up tightens adherence until, past a model-dependent threshold, edges oversharpen, textures flatten, and variation across seeds collapses; the same curve appears for the ControlNet conditioning weight, GLIGEN’s gating strength, and the classifier-free guidance scale, leaving practitioners to tune two or three knobs at once. Annealing the control weight along the denoising trajectory, per-region or per-token guidance scales, and down-weighting guidance where the base model is already confident are the current responses; how to expose such schedules to end users without overwhelming the interface is open. Chaining spatial-aware generation with repeated local edits adds a drift problem of its own, treated in §8.1.3.

Geometry-aware realism in 2D. Depth and normal conditioning fix coarse occlusion but introduce their own artifacts: boundary banding where a sharp depth discontinuity meets a smooth gradient in the generated image, scale ambiguity because a monocular depth map carries no absolute scale and two objects at the same depth value can be rendered at incompatible physical sizes, and lighting incoherence because the map fixes geometry but not the light field, so shadows disagree with the implied surface orientations. Better estimators are the first lever, with the diffusion-prior Marigold [636] producing sharper and more globally consistent depth than CNN baselines and Depth Anything [140] staying robust on out-of-distribution conditioning images; differentiable geometry proxies that translate depth into shading constraints are the second, explored at the boundary with full 3D synthesis (§8.2) but not yet integrated into general T2I backbones. Region grounding also changes the safety picture, since a harmful edit can be confined to a footprint that whole-image forensics miss; that concern belongs to editing and is taken up in §8.1.3.

8.1.32D Spatial Inpainting & Editing#

2D spatial inpainting & editing modifies an image inside a specified region while leaving the rest intact: filling holes and occlusions, removing or inserting objects, changing attributes (color, material, texture, text), adjusting layout, or harmonizing pasted content with its new background. The intent arrives as a mask, a structural hint (edges, sketches), a geometry proxy (depth, normals), or a natural-language instruction, and the tensions are between local editability and global consistency of lighting, perspective, and shadow, between constraint adherence and realism, and between semantic plausibility and identity preservation for person- or product-centric edits. Editing holds the model to its strongest geometric account: the unedited region of II supplies ground-truth pixels that any plausible edit must respect, exposing failure modes that pure synthesis can hide, among them color drift, lighting reflow, identity loss, and attribute leakage across the mask boundary.

8.1.3.1Task Definition#

We inherit the latent-generator framework of §8.1.1. Let (E,D)(E,D) denote the autoencoder pair of Eq. (8.1), ϕ:𝒳→ℰ\phi:\mathcal{X}\!\rightarrow\!\mathcal{E} the text encoder, and GθG_{\theta} the conditional latent sampler of Eq. (8.2). Inpainting and editing depart from de-novo generation in one crucial respect: the input is no longer the empty set but an existing image I∈𝒴I\in\mathcal{Y}, encoded into 𝐳in=E⁢(I)\mathbf{z}^{\text{in}}=E(I). A mask ℳ∈{0,1}H×W\mathcal{M}\in\{0,1\}^{H\times W} designates the editable region, and an editing control set 𝐜∈𝒞\mathbf{c}\in\mathcal{C} (text prompts, structural cues, exemplar patches, or drag-style handles) populates the conditioning channel, encoded by κ:𝒞→𝒞′\kappa:\mathcal{C}\!\rightarrow\!\mathcal{C}^{\prime}. The conditional latent sampler is extended to

Gθ:𝒵×{0,1}H×W×ℰ×𝒞′→𝒵,𝐳^∼pθ⁢(𝐳|𝐳in,ℳ,ϕ⁢(𝐱),κ⁢(𝐜)),G_{\theta}:\mathcal{Z}\times\{0,1\}^{H\times W}\times\mathcal{E}\times\mathcal% {C}^{\prime}\!\rightarrow\!\mathcal{Z},\qquad\hat{\mathbf{z}}\sim p_{\theta}\!% \big{(}\mathbf{z}\,\big{|}\,\mathbf{z}^{\text{in}},\,\mathcal{M},\,\phi(% \mathbf{x}),\,\kappa(\mathbf{c})\big{)}, (8.8)

and the edited image I^=D⁢(𝐳^)\hat{I}=D(\hat{\mathbf{z}}) is required to (i) realize the requested change inside ℳ\mathcal{M}, (ii) preserve II outside ℳ\mathcal{M} up to imperceptible deviations, and (iii) remain globally coherent in color, lighting, geometry, and semantics. Setting 𝐳in=∅\mathbf{z}^{\text{in}}=\varnothing and ℳ=𝟏\mathcal{M}=\mathbf{1} recovers the spatial-aware synthesis of §8.1.2 (Eq. (8.7)); the distinctive substance of editing therefore lies in the interplay between the preservation constraint outside ℳ\mathcal{M} and the change constraint inside it. The mask may be hard, soft, inferred from a referring expression, or implicit (whole-image instruction editing with ℳ=𝟏\mathcal{M}=\mathbf{1}).

Variants by Task Type. The tasks differ in what populates 𝐜\mathbf{c} and ℳ\mathcal{M} and in whether ground-truth pixels exist for evaluation. Reconstruction-style completion carries no semantic intent: hole filling repairs scratches and occlusions from (I,ℳ)(I,\mathcal{M}) alone, and object removal reconstructs the background behind a specified instance. Constraint-driven local synthesis adds intent inside ℳ\mathcal{M}: text-guided local editing follows an instruction scoped to a region (“make the left cup red”), structure-guided inpainting takes edges, sketches, or semantic maps as a scaffold for shape and boundary, and geometry-guided inpainting conditions on depth or normals to respect occlusion ordering. Object-level edits treat the region as an object whose identity or embedding in the scene is the unit of change: insertion with harmonization of color, grain, lighting, shadows, and reflections; attribute and appearance editing that changes material or style while preserving identity (garments, products, logos); and exemplar-guided transfer that drives content or style from a reference patch. Interactive workflows replace declarative constraints with actions taken at edit time: point- or handle-based reshaping, and multi-round, multi-region sessions in which stability across rounds is itself the requirement. The metrics appropriate to each are collected in §Benchmarks.

8.1.3.2Methodology#

Methods are organized by editing mechanism, that is, by how GθG_{\theta} of Eq. (8.8) is realized so that change is confined to ℳ\mathcal{M} and preservation is enforced outside it. The mechanism is largely independent of the task type above, since text-guided local editing can be served by masked denoising, by inversion and rewrite, or by an instruction-tuned editor, and one mechanism such as inversion serves both attribute edits and structure-guided ones. Figure 8.3 sets the five mechanisms against a single example edit.

Figure 8.3Local 2D editing with context preservation (top) and five editing mechanisms: (a) masked denoising, where M=1M=1 marks the editable region; (b) inversion and rewrite; (c) instruction-tuned editing; (d) exemplar / reference-guided editing; and (e) drag-based optimization. The cup images are illustrative, not outputs of the surveyed methods.

Editing Mechanisms. Masked latent denoising. The most direct realization of Eq. (8.8) runs the diffusion sampler only inside ℳ\mathcal{M} while clamping the latent outside ℳ\mathcal{M} to a noise-perturbed copy of 𝐳in\mathbf{z}^{\text{in}} at every step. RePaint [1705] does this with a pretrained, unconditional DDPM and no retraining, replacing the known-region pixels with a forward-noised sample of the input at each reverse step and adding a resampling schedule that re-injects noise periodically so the in-fill can re-harmonize with its context over several rounds. Blended Diffusion [1706] made the same scheme text-driven by interleaving a CLIP-guided gradient step that steers the content inside ℳ\mathcal{M} toward a target prompt with the context-clamping step outside it, the first widely cited text-guided local editor. LaMa [1707] predates the diffusion line and is instead a feed-forward inpainter whose fast Fourier convolutions give every layer an image-wide receptive field, a Fourier-domain inductive bias that stays robust on the very large holes that defeat purely local CNN backbones. Region-aware noise schedules and classifier-free guidance are standard add-ons, and ControlNet-inpaint and the inpainting variants of T2I-Adapter (§8.1.2.2) compose with masked denoising by supplying the inside-ℳ\mathcal{M} condition.

Inversion + rewrite. A complementary strategy first recovers the noise trajectory that the model would have used to generate II (inversion) and then re-runs the reverse process under an edited prompt while reusing or swapping the attention maps of the original (rewrite). Prompt-to-Prompt [1708] reuses or reweights source cross-attention maps during generation under the edited prompt, which preserves spatial structure while changing selected semantic content; for a real image an inversion step first supplies a suitable noise trajectory. Imagic [1709] jointly optimizes the text embedding and lightly fine-tunes the model to reconstruct II, then interpolates the embedding toward the target prompt, preserving identity-level features (faces, garments) under non-rigid edits. Null-Text Inversion [1710] fixes the practical failure that plain DDIM inversion drifts away from II under classifier-free guidance, by optimizing the null-text embeddings used in the inverse pass so that exact reconstruction holds at ordinary guidance scales. The family needs no full backbone fine-tune for Prompt-to-Prompt or Null-Text and dominates attribute, style, and structure-preserving real-image edits.

Instruction-tuned editing. A third family avoids inversion entirely by retraining a diffusion editor on paired (before, instruction, after) triplets, mapping II directly to I^\hat{I} from a natural-language instruction with no explicit mask. InstructPix2Pix [1711] built its corpus by pairing GPT-3-generated edit instructions with Prompt-to-Prompt edits of Stable Diffusion samples and fine-tuned Stable Diffusion on the triplets, so that at inference the user supplies only (I,instruction)(I,\text{instruction}) and the editor localizes the change itself. MagicBrush [1712] replaced the synthetic data with about 10K manually annotated real-image edits across multi-turn sessions, yielding both a stronger supervised editor and the standard instruction-editing test set. Emu Edit [1713] trained a single model on a heterogeneous mixture of recognition (segmentation, detection) and generation (insertion, removal, style change) tasks with learned task embeddings that route each input, and leads its own benchmark on precision and instruction following. Instruction editors are the most user-friendly mechanism, no mask and no inversion, at the cost of large supervised retraining.

Exemplar / reference-guided editing. A visual exemplar, an example image or patch encoding the desired content or style, replaces the textual instruction and enters through an auxiliary cross-attention pathway beside the standard text conditioning. Paint-by-Example [1714] fine-tunes Stable Diffusion to fill ℳ\mathcal{M} with the content of an exemplar whose identity is encoded by a CLIP image encoder, with strong exemplar augmentation (cropping, color jitter) at training time to prevent copy-paste behavior and force semantic rather than pixel-level transfer. IP-Adapter [1715] generalizes this into a plug-in reference channel: a lightweight decoupled cross-attention head consumes a CLIP image embedding of the exemplar and is inserted into a frozen SD or SDXL backbone, so that any number of reference images can be combined with text prompts and with structural adapters such as ControlNet at inference time. It is the standard route for subject personalization and style transfer when the desired content is hard to describe in words.

Drag-based latent optimization. The most interactive family takes user-supplied (source point, target point) pairs and iteratively optimizes the latent so that the features at each source point migrate to the corresponding target while a locality regularizer pins the latent outside the user-marked region. DragGAN [1716] introduced the recipe on a StyleGAN backbone: a motion-supervision loss tracks the source feature and pulls it toward the target by gradient descent in the 𝒲+\mathcal{W}^{+} latent space, and a point-tracking step re-localizes the moved feature at each iteration to prevent drift. DragDiffusion [1717] ported the recipe to the LDM latent space, running a per-timestep latent-update loop together with an identity-preserving LoRA fine-tune of the U-Net so that both the dragged subject and the unmarked context survive. Both are inference-time optimizers with latency proportional to the number of drag iterations, and no other family yet offers the same directness of spatial control.

Read across the five families, the mechanisms track the generative substrate: feed-forward inpainters such as LaMa gave way to inversion-based diffusion editors (Prompt-to-Prompt, Imagic), which in turn yielded to supervised instruction-tuned editors (InstructPix2Pix, Emu Edit) as paired data became available at scale. Orthogonal to that migration, the structural conditioning interfaces of §8.1.2 compose with every mechanism here, so a production pipeline pairs a mechanism with a structural channel rather than choosing one: Blended Diffusion with ControlNet-depth for geometry-aware text-guided edits, or IP-Adapter with DragDiffusion for exemplar-driven drag edits.

8.1.3.3Benchmarks#

Editing is evaluated in two regimes: reference-based, where a held-out ground-truth region exists (holes synthesized over real images), and reference-free, where only constraint satisfaction and human preference are available (instruction editing). No single suite covers both, so the field keeps a small library of task-specific benchmarks next to the holistic T2I suites of §8.1.1.

Training Corpora. Inpainting draws on Places2 [609] and Paris StreetView for scene-level masks, DIV2K for high-resolution patches, and the COCO / ADE20K mask supervision of §8.1.2 [440, 492]. Constraint-driven local synthesis reuses the structural channels of the previous subsection, RefCOCO / RefCOCO+ / RefCOCOg [1082] and PhraseCut [1092] for referring-expression masks, SA-1B masks [138], and COCO edge and depth predictions, with the convention that the mask is supplied or derived from the expression; geometry-guided editing adds depth and normal supervision from NYUv2 [504], Replica [339], and synthetic corpora, and insertion with harmonization uses composite datasets such as iHarmony4. Instruction editing has its own data ecology: the synthetic InstructPix2Pix corpus of Prompt-to-Prompt-generated triplets, the manually annotated MagicBrush triplets [1712], and the multi-task Emu Edit training mixture [1713].

Evaluation Benchmark Suites. The holistic suites of §8.1.1 (Table 8.1) carry over in part: T2I-CompBench [1676] and GenAI-Bench [1679] score the attribute and compositional fidelity that edited images must also satisfy, and HEIM [1673] includes alignment and quality axes that apply to edits. The dedicated suites are EditBench [1718], released with Imagen Editor, a curated set of text-guided inpainting prompts over object, attribute, and scene categories that serves as the standard evaluation for text-driven mask inpainting; the MagicBrush test set [1712], 1,0531{,}053 manually annotated single- and multi-turn triplets, which is the standard for instruction-tuned editors; and the Emu Edit benchmark [1713], which extends instruction editing to per-task subsets (insertion, removal, style change, color change, global change). Drag-based methods evaluate on small custom test sets curated by Pan et al. [1716] and Shi et al. [1717]; a community-wide drag-editing benchmark has not yet emerged.

Constraint-specific Metrics. Reconstruction quality (PSNR / SSIM / LPIPS against ground truth, with FID / KID for diverse-completion settings) is defined only where held-out content exists. Region adherence uses mask-restricted CLIPScore or region-level VQAScore to ask whether the edit honors the prompt inside ℳ\mathcal{M}; edit locality measures ℓ1\ell_{1} or LPIPS outside ℳ\mathcal{M} against II, lower being better; harmonization is scored by color-statistic divergence, shadow-direction consistency, and the rate at which an off-the-shelf forgery detector flags the composite; identity preservation uses feature-cosine similarity over face or landmark regions for people and CLIP-image similarity for products and characters; and instruction following is paired accuracy, whether I^\hat{I} honors the instruction better than II, judged by human raters or by a VLM over a structured rubric, as is now standard on MagicBrush and Emu Edit. Change inside ℳ\mathcal{M} and preservation outside it are reported together; a method that wins on one and loses on the other has not solved the task.

8.1.3.4Challenges and Trends#

Several problems are specific to editing an existing image.

Structure-faithful hallucination in large holes. Large irregular holes and rare structures remain the hardest case: inpainters tile a salient local texture across the hole instead of synthesizing appropriate content, straight lines, perspective cues, and silhouettes break at the mask seam, and in-fills that are locally plausible contradict the global scene (a patch of grass inside a room). Quality degrades sharply with hole size. LaMa’s image-wide Fourier convolutions and RePaint’s resampling schedule (§8.1.3.2) are the established responses; retrieval-augmented priors, which search a paired corpus for candidate completions and use them as soft conditioning, are an emerging one at the intersection of editing and retrieval.

Edit locality against drift across rounds. A single well-calibrated edit does not guarantee a stable session. Across rounds the unedited background shifts in white balance or saturation (color drift), shadows and highlights migrate as if the edit had changed the global illumination (lighting reflow), and salient textures from the edited region reappear in nearby unedited regions through attention leakage (texture replication); the errors compound even when each round individually meets its locality budget. Hard attention masking that confines non-edit tokens to ℳ\mathcal{M}, mask-aware noise schedules that anneal noise inside ℳ\mathcal{M} only, and edit-history-aware sampling that conditions on the trajectory of prior edits are the active mitigations. Inversion-based editors (Null-Text Inversion [1710], Imagic [1709]) carry a variant of the problem: any residual reconstruction error in the inverted trajectory leaks into the edit and accumulates.

Harmonization under complex illumination. Inserted content betrays itself when the host scene has structured light: its shadow disagrees with the dominant light direction recoverable from the scene, there is no interreflection between the object and adjacent surfaces, and its albedo is tone-mapped inconsistently with the host, producing the cut-and-paste look that off-the-shelf forgery detectors flag. Differentiable rendering proxies that turn depth and normals into shading constraints and back-propagate harmonization losses into the editor, illumination maps as an additional conditioning channel, and explicit shadow-synthesis modules are being explored; integration with the 3D-aware methods of §8.2 is the natural next step and remains nascent.

Language grounding and safety. Region-level instructions must be grounded reliably: an edit aimed at one object spills onto neighbors with similar attributes, spatial referring expressions are misparsed (“the left cup” lands on the right one), and mildly perturbed instructions produce large deviations in the edit trajectory. Borrowing GLIGEN’s gated grounding [1697] (§8.1.2.2) to confine edit attention, and using LLM-emitted layouts to harden the grounding before the edit is applied, are the current responses. The same precision cuts the other way for safety. A harmful edit (an identity swap inside one bounding box, watermark removal inside one mask) can be confined to a footprint that whole-image forensic detectors miss; large generative models reproduce individual training images under targeted prompting [1719], which becomes acute when the training set contains copyrighted artwork or identifiable faces and motivates artist-side defenses such as Glaze [1720], which perturbs source artworks so that downstream fine-tunes mimic a different style; and most pipelines still lack robust per-image watermarking, so a photograph with a small synthesized region cannot be told from a wholly synthetic one. Watermarking, region-aware safety filters, and licensing frameworks for the underlying corpora are all needed, and none is settled.

Evaluation under plausibility ambiguity. Ground-truth pixels are often not the only plausible completion: a removed pedestrian leaves a hole that could contain road, curb, or shadow, and any reconstruction metric that compares against one ground truth over-penalizes good alternatives, while PSNR and SSIM rate sharp but contextually wrong in-fills highly. The field is converging on paired evaluation, asking whether I^\hat{I} honors the instruction better than II under a held-out judge, now standard on MagicBrush [1712] and Emu Edit [1713]; the judge-prompt sensitivity and benchmark-contamination caveats of §8.1.1 apply here as well.

Scalability and interactive latency. Inversion-based methods store cross-attention activations at every timestep, multi-step sampling at 44K and above scales with image area for standard U-Net backbones, and drag editors run an inner optimization loop per operation, so interactive editing lags behind the user’s hand by hundreds of milliseconds. Consistency-style distillation [1661, 1662] (§8.1.1) compresses the reverse trajectory to a handful of steps, memory-efficient adaptive patching runs the denoiser only in a window around ℳ\mathcal{M}, and progressive-refinement schedules return a coarse preview within a perceptual-latency budget and refine in the background. Closing the gap to the responsiveness of a photo editor is increasingly a systems problem shared with production T2I inference stacks.