SONIC: Spectral Optimization of Noise for Inpainting with Consistency

Seungyeon Baek, Erqun Dong, Shadan Namazifard, Mark J. Matthews, Kwang Moo YiarXiv 2025

TL;DR

SONIC is a novel, training-free inpainting method that achieves state-of-the-art consistency by optimizing the initial noise sample of off-the-shelf text-to-image models. By introducing a clever linear approximation of the denoising trajectory and optimizing within the spectral (Fourier) domain, SONIC bypasses expensive backpropagation while ensuring stable, rapid convergence.

What Problem Does This Paper Address?

Image inpainting—filling in missing or masked regions of an image realistically—has advanced significantly with diffusion and flow-matching models. Broadly, approaches fall into two camps: trained models specialized for inpainting, which require expensive training and can fail to generalize to unseen mask shapes, and training-free methods, which leverage generic, off-the-shelf text-to-image models via runtime guidance or conditioning.

While training-free methods are highly versatile, they often suffer from a glaring flaw: the generated content frequently misaligns with the global structure, lighting, or context of the unmasked regions. The authors argue that this is because existing methods overlook a critical factor—the initial noise sample, which heavily dictates the final image layout.

Optimizing this initial noise sample to match the unmasked image seems like an obvious fix, but naively doing so requires backpropagating through the entire iterative denoising chain. For modern, large-scale models like Stable Diffusion 3.5, this "unrolling" is completely impractical due to massive memory and compute requirements.

The initial noise sample heavily influences the final layout and structure of the output.

Methods

SONIC (Spectral Optimization of Noise for Inpainting with Consistency) circumvents the backpropagation bottleneck and stabilizes the optimization process through two core innovations:

  1. Denoising Trajectory Linearization: Modern flow models are explicitly trained to generate linear trajectories. Capitalizing on this, the authors approximate the entire multi-step denoising path as a single linear step. By applying a stop-gradient operator to the denoiser's complex internal updates, they create a straight-through estimator. This allows them to compute gradients from the final output back to the initial noise sample without unrolling the denoiser steps.
  2. Spectral Preconditioning: Directly optimizing noise in the spatial domain using Adam leads to severe instabilities, causing images to flicker or diverge because different spatial frequencies converge at different rates. SONIC maps the optimization into the spectral domain using a Discrete Fourier Transform (DFT). When paired with the Adam optimizer, this acts as a per-frequency preconditioner, normalizing variance and allowing all frequencies to converge stably.

Additionally, to prevent the optimized noise from drifting away from a valid Gaussian distribution, SONIC implements Spatial Constraining, which freezes the latent variables in the unobserved (masked) regions during gradient updates.

Overview of the SONIC pipeline, optimizing initial noise in the spectral domain.

Datasets

The authors evaluated SONIC across three standard benchmarks, each featuring distinct masking challenges:

  • FFHQ: 70,000 high-quality face photographs. Testing used the first 1,000 images masked with a large, fixed central rectangle covering roughly half the face.
  • DIV2K: 1,000 high-resolution natural images. Testing used 800 training images, center-cropped and obscured by six randomly placed rectangular masks.
  • BrushBench: 600 natural and artificial images featuring human-annotated segmentation masks and corresponding text prompts.

Key Insights and Ideas

  • The Initial Seed is Destiny: As visualized in Figure 2, the initial noise sample acts as a structural blueprint. Even with identical text prompts, different initial seeds yield entirely different compositions.
  • Linearization is Enough: Because modern rectified flow models inherently favor straight paths, a simple linear approximation of the trajectory provides gradients accurate enough for effective optimization.
  • Spatial Adam Entangles Frequencies: Optimizing in the spatial domain causes low-frequency components to overshoot, leading to catastrophic color shifts. Moving to the Fourier domain decouples these frequencies, allowing Adam to natively scale updates based on frequency-specific variance.
Spectral preconditioning prevents the optimization from diverging or creating artifacts.

Key Results

SONIC was paired with Stable Diffusion 3.5 and evaluated against prominent training-free baselines (such as FLAIR, FlowChef, and FlowDPS) and specialized trained models (BrushNet).

  • Quantitative Superiority: SONIC outperformed all baselines in structural and perceptual metrics (SSIM, LPIPS, and FID) across all three datasets by a large margin. For example, on FFHQ, SONIC achieved an FID of 12.883, significantly lower than BrushNet (17.950) and FLAIR (18.982).
  • Human Preference: In a single-blind Two-Alternative Forced-Choice (2AFC) user study with 37 raters, SONIC's results were preferred in 90.0% of all pairwise comparisons across the datasets.
  • Computational Efficiency: Because it avoids unrolling the denoiser, SONIC's runtime remains highly practical, taking roughly one minute per image on an NVIDIA RTX 5090—comparable to standard optimization-based methods but with vastly superior quality.

Limitations and Future Work

While highly effective, the authors note a few areas for improvement and expansion:

  • Infill Strategy: For latent space masking, SONIC currently relies on a simple nearest-neighbor color fill before VAE encoding. While sufficient, more sophisticated filling strategies could yield minor performance gains.
  • Broader Inverse Problems: The current implementation focuses strictly on image inpainting. However, the underlying framework of trajectory linearization and spectral preconditioning could theoretically be applied to other inverse problems, such as image super-resolution, deblurring, and video inpainting.

Summary updated

BibTeX
@misc{baek2025sonic,
  author = {Seungyeon Baek and Erqun Dong and Shadan Namazifard and Mark J. Matthews and Kwang Moo Yi},
  title = {{SONIC: Spectral Optimization of Noise for Inpainting with Consistency}},
  year = {2025},
  eprint = {2511.19985},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.19985},
}
Figure