Mixture-Proportion Guidance for Large-Mask Inpainting

When a diffusion inpainter fills a large hole, the model that denoises random noise into an image does something undesirable: it often paints in an object nobody asked for, or it regenerates the object the user was trying to erase. This proposal treats that failure as a contamination problem. The completions the model proposes for a given context form a mixture: most are plausible background, and some fraction $\pi$ contains an inserted object. If we can estimate $\pi$ and tell, at every noise level, how likely the current sample is to belong to the object part, we can subtract that part from the model's denoising direction exactly, without retraining. A classical condition from label-noise theory says when this is possible. That condition, called irreducibility, requires that the background distribution cannot itself be written as a blend that already contains the object distribution. When it holds, the contamination fraction can be recovered from the model's own samples.

The result is a concrete algorithm and a testable explanation. The widely used "negative prompt" trick subtracts a fixed multiple of an object-conditioned direction. We show that it is exact only when its weight equals a specific, sample-dependent odds ratio. The same analysis predicts that the correct weight grows as context shrinks, which is why fixed negative prompts break down precisely at large masks. We would build the estimator, validate it on synthetic mixtures where the true scores are known, and test it against the strongest removal and anti-hallucination inpainters on MISATO, OpenImages V5, OBER-Test, and Places2.

Core Claim

Fix a visible context $c$, meaning the unmasked pixels. Let $p_{\text{mix},t}(\cdot\mid c)$ be the base inpainter's distribution over noisy completions at diffusion time $t$, $p_{\text{obj},t}$ the distribution of completions that contain an inserted object, and $p_{\text{bg},t}$ the object-free completions we want. Adding Gaussian noise is a linear operation, so the mixture relation $p_{\text{mix},t}=(1-\pi)p_{\text{bg},t}+\pi\,p_{\text{obj},t}$ holds at every $t$ with the same $\pi=\pi(c)$. Taking gradients of the log-density gives an exact identity for the background score, the gradient of log-density that a diffusion sampler follows:

$$\nabla\log p_{\text{bg},t}(x)=\nabla\log p_{\text{mix},t}(x)+w_t(x)\big(\nabla\log p_{\text{mix},t}(x)-\nabla\log p_{\text{obj},t}(x)\big),\qquad w_t(x)=\frac{r_t(x)}{1-r_t(x)},$$

where $r_t(x)=\pi\,p_{\text{obj},t}(x)/p_{\text{mix},t}(x)$ is the probability that a noisy sample $x$ belongs to the object component.

This has the same form as negative classifier-free guidance, which uses a constant $w$. The identity says a constant weight is wrong in both directions. It pushes too hard where an object is unlikely, which distorts legitimate background, and too weakly where an object is likely, which leaves "stubborn objects."

Two quantities are needed. The density ratio $p_{\text{obj},t}/p_{\text{mix},t}$ can be estimated by a noise-level-conditioned classifier trained to separate object-prompted samples from base samples. The proportion $\pi$ is the harder part. Classification with Asymmetric Label Noise: Consistency and Maximal Denoising shows that the largest $\kappa$ with $p_{\text{mix}}-\kappa\,p_{\text{obj}}\ge 0$, namely $\kappa^*=\inf_x p_{\text{mix}}(x)/p_{\text{obj}}(x)$, equals $\pi$ exactly when $p_{\text{bg}}$ is irreducible with respect to $p_{\text{obj}}$. That paper supplies the identifiability result we reuse. We transplant it from scalar label noise into the per-context posterior of a generative model.

The contextual-scarcity prediction follows directly. As the mask grows and the visible boundary constrains the fill less, $\pi(c)$ should rise, and the optimal weight should rise with it.

Relation to Prior Work

Two object-removal systems motivate the problem. Both fix it by changing what the model learns or attends to, rather than by estimating how much contamination is present. Erase Diffusion retrains along an object-to-background trajectory and blocks masked tokens from attending to each other. Aligned Stable Inpainting (ASUKA) injects blurry Masked Auto-Encoder reconstructions through low-rank adapters to suppress unwanted insertion. Neither estimates a contamination level, and neither says when removal is possible. Our method is training-free on the base model, needing only a small auxiliary classifier, and its failure condition is explicit. RevealLayer separates hidden and visible layers empirically with a diffusion transformer and bounding-box attention. It reports failures on translucent objects and repetitive textures. We read those failures as cases where irreducibility is violated, and our synthetic study tests that reading.

The mixture-identifiability line supplies both method and constraints. Mixture Proportion Estimation Beyond Irreducibility shows that irreducibility fails in real domains and repairs it using a known bound on the target posterior plus subsampling. We borrow that repair for scenes where the background legitimately contains object-like content, such as removing one chair from a room full of chairs. MPEIA replaces irreducibility with linear independence in a kernel space. It is an alternative $\pi$-estimator we compare against, but its $n^{-1/4}$ rate is a warning about sample cost. Weak Separation in Mixture Models shows that estimators "pile up" onto a single component when components are weakly separated. This constrains us: when context is extremely scarce, background and object completions may overlap so heavily that $\hat\pi$ becomes unreliable. We treat that regime as something to measure, not assume away.

On the theory side, Learning Mixtures of Gaussians Using the DDPM Objective and Learning general Gaussian mixtures with efficient score matching show that score learning recovers fully observed Gaussian mixtures. We use their setting, with masked coordinates added, as the controlled testbed where exact scores are available. Can Diffusion Models Disentangle? separates factors using paired weak supervision. We instead separate two components of a single conditional distribution, using only samples the model itself generates.

Research Program

The first step is a synthetic study. Background and object components are Gaussian mixtures in $d$ dimensions, and a random fraction of coordinates is masked. We vary two things: the mask fraction, and how much the object component overlaps the background, from irreducible to deliberately reducible. For each setting we estimate $\hat\pi$ with the $\kappa^*$ estimator, SuMPE, and MPEIA. We estimate the responsibility $r_t$ with a classifier. We then compare the recovered background score with the analytic one. This tests three claims: the identity is exact when the inputs are exact, estimation error in $\hat\pi$ degrades as the pile-up analysis predicts, and over-removal appears exactly when irreducibility fails.

The second step is the image system. The base model is FLUX-Fill, the base model used in ASUKA's MISATO results. The object component is sampled from the same model with object-class text prompts. An open-vocabulary detector is used only to check that prompted and unprompted object samples resemble each other. It is never used at test time.

A single classifier conditioned on noise level and context is trained once across many contexts, using features from the inpainter. It distinguishes base samples from object-prompted samples at every $t$. Its clean-level outputs give $\hat\pi(c)$ through the $\kappa^*$ estimator, computed on a small per-context batch of samples. Its noisy-level outputs give $r_t(x)$, clipped near 1.

At sampling time the cost is two model passes per step, the same as standard classifier-free guidance, plus one small classifier pass. The optional reducible-case variant uses a posterior upper bound in the style of SuMPE.

Baselines

The do-nothing reference is FLUX-Fill with its default sampler. On MISATO, ASUKA reports an FID of 12.17 for this base and a G@e color-shift score of 69.4.

The most direct competitor is constant-weight negative guidance with the same object prompts. We sweep $w$ on a held-out split and report its best value, so the comparison tests only whether adapting the weight to each sample and noise level matters.

The strongest trained anti-hallucination method is ASUKA, which reports MISATO FID 10.68 (ASUKA-II-FLUX) and G@e 48.7. Beating it means lower FID and fewer unwanted insertions with no fine-tuning of the base model. We apply our guidance on the same FLUX-Fill base at identical resolution.

For removal, the strongest reported systems are Erase Diffusion on OpenImages V5, with local FID 3.799 and LPIPS 0.192, and RevealLayer on OBER-Test, with PSNR 30.16 against 29.05 for OmniPaint. We evaluate on their reported protocols and masks. On these benchmarks, matching them without task-specific training would already be a meaningful result.

We include LaMa (FID 2.21 on Places with wide masks) as the deterministic large-receptive-field reference on Places2. We also run best-of-N detector rejection at matched compute.

Two ablations isolate the key ingredient. One replaces $r_t(x)$ by its per-image average, which keeps $\hat\pi$ but removes variation across samples and noise levels. The other replaces $\hat\pi$ with a detector-counted oracle proportion, which tests whether the estimator or the guidance form is the bottleneck.

Why not just…?

Why not just use a negative prompt with a tuned constant weight? This is the method our identity generalizes, so it is the cleanest test. The prediction is specific. The best constant weight should be close to optimal on small masks, where $\pi(c)$ is small and nearly uniform. It should fall behind on masks covering 50% or more of the image, and on backgrounds whose textures resemble objects, where it over-subtracts. If the tuned constant matches our method across a mask-ratio sweep from 10% to 70%, the adaptive weight is not worth the cost. The contribution would then shrink to the diagnostic $\hat\pi(c)$, and we would report that.

Why not just sample N completions and reject those an object detector flags? This is the most serious practical threat, because it needs no theory. It has three weaknesses. It spends N full sampling runs. It cannot help when every sample contains an object, which is exactly the regime where $\pi(c)$ is large under scarce context. And evaluating with the same detector used for rejection is circular. We compare at matched model passes with N between 2 and 4, and evaluate with a different detector plus human raters. If best-of-N wins at equal compute, we will say so.

Why not just fine-tune, as ASUKA and Erase Diffusion do? Fine-tuning changes the prior, but it does not say how much contamination remains or when removal is impossible. ASUKA itself describes its MAE anchor as blurry and coarse. Our method is complementary and can be stacked on the ASUKA model. A gain on top of ASUKA would show that its prior still carries an identifiable object component.

Why not just run better posterior inference such as VIPaint? VIPaint states that its output inherits the biases of its pretrained prior. Sampling the conditional distribution more accurately therefore samples the contaminated mixture more accurately. Our method changes the target distribution rather than the inference quality, and we expect VIPaint-style inference to leave insertion rates unchanged.

Decisive Checks

On MISATO, OpenImages V5, OBER-Test, and Places2 we report FID, local FID, LPIPS, PSNR where ground-truth backgrounds exist, G@e, held-out-detector insertion rate, and human preference, each as a function of mask ratio.

Four results would settle the proposal. First, in the synthetic study the recovered background score must match the true one within estimation error under irreducibility, and must over-remove, as predicted, when irreducibility is violated. Second, the estimated $\hat\pi(c)$ on real images must be calibrated. It should predict the held-out-detector insertion rate of base samples, and it should rise with mask area; a flat or uncalibrated $\hat\pi$ would falsify the scarcity account. Third, on MISATO our method must beat the best constant negative weight and best-of-N at matched compute on both FID and insertion rate. Fourth, on OBER-Test scenes where the background legitimately shares object-like content, the SuMPE-bounded variant should preserve background PSNR where the plain $\kappa^*$ version and constant negative guidance degrade it.