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

TL;DR

Guided Newton-Raphson Inversion (GNRI) enables high-fidelity image inversion and editing in under 0.4 seconds for few-step diffusion models like Flux.1 and SDXL-Turbo. By framing inversion as a root-finding problem and introducing a distribution-aware guidance term, the authors achieve state-of-the-art reconstruction quality at speeds up to 40x faster than previous iterative methods.

What Problem Does This Paper Address?

Diffusion models are fantastic at generating images from noise, but the inverse task—finding the specific noise latent (the "seed") that produces a given real-world image—is surprisingly difficult. This process, called inversion, is the backbone of high-quality image editing. If your inversion is slightly off, the "reconstructed" image won't look like the original, and any edits you make will be inconsistent.

Existing methods fall into two camps:

  1. Fast but inaccurate: Methods like DDIM inversion use linear approximations that accumulate errors, especially in "few-step" models where the gaps between diffusion timesteps are large.
  2. Accurate but slow: Iterative methods (like fixed-point iterations or gradient descent) can find better latents but often take tens of seconds, making interactive editing impossible.

The authors aim to bridge this gap, providing a method that is fast enough for real-time use without sacrificing the "pixel-perfect" reconstruction needed for professional editing.

Methods

The authors treat inversion as finding the root of an implicit equation. If the denoising step is $z_{t-1} = \text{Denoise}(z_t)$, then inversion is finding $z_t$ such that the equation holds.

1. Newton-Raphson (NR) for Root Finding

They employ the Newton-Raphson method, a classic numerical technique known for quadratic convergence. However, applying vanilla NR to high-dimensional image latents is computationally ruinous because it requires calculating and inverting a massive Jacobian matrix. To solve this, they apply a norm to the residual, turning it into a scalar root-finding problem. This allows them to compute the necessary derivatives efficiently using standard automatic differentiation (like PyTorch's autograd).

2. The Guidance Term

A major discovery in the paper is that "mathematical" convergence isn't enough. A solver might find a latent that perfectly satisfies the equation but lies far outside the distribution of noise the model was trained on. This results in "garbage" reconstructions.

To fix this, they introduce Guided Newton-Raphson Inversion (GNRI). They add a guidance term to the objective function based on the known Gaussian distribution of the diffusion process. This term "steers" the NR iterations toward solutions that are both mathematically correct and "in-distribution."

Figure 2: The GNRI process uses Newton-Raphson iterations at each timestep, guided by a noise prior to stay in-distribution.

Datasets

The authors evaluated GNRI across several benchmarks:

  • MS-COCO 2017: 5,000 image-caption pairs used to measure reconstruction accuracy (PSNR) and runtime.
  • PIE-Bench: A specialized benchmark for evaluating real-world image editing.
  • ImageNet1k (in LAION2B): Used to test the method's ability to generate "rare concepts" (objects the model rarely saw during training).

Key Insights and Ideas

  • Convergence vs. Quality: Figure 3 demonstrates that while unguided NR (green line) converges to low residuals quickly, its reconstruction quality (PSNR) is poor because it finds out-of-distribution latents. The guidance term (blue line) is the "secret sauce" that ensures visual fidelity.
  • Efficiency of Few-Step Models: GNRI is particularly potent for models like Flux.1-schnell and SDXL-Turbo. Because these models only require ~4 steps, GNRI can complete a full inversion in roughly 0.4 seconds on an A100 GPU.
  • Zero-Training Required: Unlike some inversion methods that require fine-tuning the model or optimizing text embeddings (which can add millions of parameters), GNRI works out-of-the-box with any pre-trained deterministic diffusion model.
Figure 3: The effect of GNRI guiding term on NR inversion, and comparison to other iterative inversion methods. All results are averages computed with SDXL-Turbo applied to 5,000 COCO images. (a) Average residuals throughout optimization. NR-based methods are the fastest to converge. Gradient-descent was run with the largest learning rate that was stable but still is slowest. (b) Reconstruction quality (PSNR). Adding guidance (blue) to NRI (green) significantly improves the quality of the converged solution. (c) Likelihood of inferred noise. Without the guiding term, NRI (green) finds solutions that are substantially different from those found by other methods, which explains the low reconstruction quality.

Key Results

  • Speed: GNRI achieves a 2x speedup over DDIM and a staggering 10x to 40x speedup over other high-quality iterative methods like ExactDPM.
  • Reconstruction Quality: On the COCO dataset, GNRI achieved the highest PSNR among all tested deterministic methods, approaching the theoretical upper bound set by the model's VAE.
  • Interactive Editing: The speed of GNRI allows for "consecutive" editing. As shown in Figure 1, a user can change a pizza to bread, add a knife, and change the wine type in a single interactive session, with each step taking less than half a second.
Figure 1: Consecutive real image inversions and editing using our GNRI with Flux.1-schnell (Black- Forest, 2024) (0.4 sec on an A100 GPU).

Limitations and Future Work

  • Prompt Alignment: The authors noted that GNRI fails to converge if the text prompt is completely unrelated to the image (e.g., a prompt describing a dog for an image of a car). Interestingly, they suggest that this "failure" could be used as a diagnostic tool to detect image-text misalignment.
  • Numerical Theory: While the method works empirically, the authors leave the formal numerical analysis of NR convergence toward local minima (rather than zero-crossings) for future research.
  • Stochastic Schedulers: The current formulation is designed for deterministic schedulers (DDIM, Euler). Extending this to stochastic (DDPM-style) inversion remains an open challenge.

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