Lightning-Fast Image Inversion and Editing for Text-to-Image Diffusion Models

Dvir Samuel, Barak Meiri, Haggai Maron, Yoad Tewel, Nir Darshan, Shai Avidan, Gal Chechik, Rami Ben-Ari

Introduction

This paper introduces Guided Newton-Raphson Inversion (GNRI), a lightning-fast method for inverting real images into the latent space of text-to-image diffusion models. By framing inversion as a root-finding problem and applying a guided numerical solver, GNRI achieves state-of-the-art reconstruction and editing quality in a fraction of a second (0.4s on an A100 GPU). This breakthrough unlocks real-time, interactive image editing for modern few-step models like SDXL-Turbo and Flux.1.

Sequential real-time image editing enabled by Guided Newton-Raphson Inversion.

The Bottleneck in Diffusion Inversion

To edit a real photograph using a text-to-image diffusion model, you first have to "invert" it. This means finding the exact initial noise seed that, when run through the model's denoising process alongside a descriptive text prompt, perfectly recreates the original image. Once you have this noise seed, you can tweak the text prompt to seamlessly edit the image.

Historically, the standard approach (DDIM inversion) relies on a linear approximation that accumulates errors at every step. This leads to poor image reconstructions—a problem that is severely magnified in modern "few-step" models, which generate images in just 2 to 4 steps. Recent iterative methods fix this accuracy issue by treating inversion as an optimization problem, but they are painfully slow, taking up to dozens of seconds per image. This paper tackles the trade-off head-on, aiming to achieve the high accuracy of iterative optimization with speeds fast enough to support real-time, on-the-fly editing.

Methods: Guided Newton-Raphson Inversion

The authors formulate deterministic diffusion inversion as finding the roots of an implicit equation. Essentially, they are looking for a latent state where the residual error between the forward and backward diffusion steps is zero.

Diagram illustrating the Newton-Raphson iterations applied between latent diffusion steps.

To solve this, they turn to the Newton-Raphson (NR) method, a classic and incredibly fast numerical technique for root-finding. However, applying NR directly to high-dimensional latent spaces is computationally impossible because it requires computing and inverting a massive Jacobian matrix.

  • The Tractable Fix: The authors apply an $L_1$ norm to the residual, collapsing the problem into a multi-variable scalar function that can be computed efficiently.
  • The "Guided" Innovation: Vanilla NR converges fast, but in the highly non-convex landscape of diffusion models, it tends to "extrapolate" into out-of-distribution (OOD) garbage, finding mathematically valid roots that produce terrible images. To fix this, the authors introduce a guidance term. Because the forward diffusion process adds Gaussian noise, the exact distribution of the noise at any given step is a known prior. By adding this prior to the objective function, GNRI steers the NR solver away from OOD artifacts and toward high-likelihood, in-distribution solutions.

Key Insights

  • Priors are powerful regularizers: The core insight of the paper is realizing that we don't just need any mathematical root to the inversion equation; we need a root that the diffusion model expects to see. Injecting the known Gaussian noise distribution as a guidance term forces the solver to pick the correct root without sacrificing Newton-Raphson's quadratic convergence speed.
  • Plug-and-play compatibility: GNRI requires zero model training, fine-tuning, or prompt optimization. It is a purely mathematical upgrade that works out-of-the-box with any pre-trained diffusion or flow-matching model that uses a deterministic scheduler (like DDIM or Euler).
  • Unlocking few-step models: Because few-step models (like SDXL-Turbo) have massive gaps between diffusion timesteps, standard inversion fails spectacularly. GNRI bridges this gap, making few-step models viable for high-fidelity real-image editing.

Key Results

The researchers evaluated GNRI across several datasets, including the MS-COCO-2017 validation set for reconstruction quality and PIE-Bench for editing performance.

  • Blazing Speed: GNRI inverts images in just 0.4 seconds on an A100 GPU for 4-step models (SDXL-Turbo, Flux.1). This represents a 2x to 40x speedup over baseline iterative methods like ExactDPM or ReNoise.
  • State-of-the-Art Reconstruction: It achieves the highest PSNR among competing methods, nearly hitting the theoretical upper bound limit imposed by the Stable Diffusion VAE itself.
  • Superior Editing: On the PIE-Bench dataset, GNRI outperformed competitors in both background preservation (PSNR, LPIPS) and prompt alignment (CLIP similarity). In human evaluations, GNRI edits were preferred 71.6% of the time over ReNoise (15.9%) and ExactDPM (12.5%).
  • Downstream Utility: When used to find initial seeds for rare concept generation (tail classes from LAION2B/ImageNet1k), GNRI significantly boosted both classification accuracy and FID scores compared to standard DDIM inversion.

Limitations and Future Work

While highly effective, the authors note that GNRI fails to converge in about 4.6% of cases. Upon analysis, they found that these failures almost exclusively occur when the input text prompt is severely misaligned with the actual contents of the image. For future work, they suggest investigating methods to handle text-image misalignment more gracefully, as well as exploring ways to incorporate even more domain knowledge into the inversion root-finding process.

Summary updated

BibTeX
@inproceedings{samuel2025lightning,
  author = {Dvir Samuel and Barak Meiri and Haggai Maron and Yoad Tewel and Nir Darshan and Shai Avidan and Gal Chechik and Rami Ben-Ari},
  title = {{Lightning-Fast Image Inversion and Editing for Text-to-Image Diffusion Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=t9l63huPRt},
}
Figure