Semantic Image Inversion and Editing using Rectified Stochastic Differential Equations

Litu Rout, Yujia Chen, Nataniel Ruiz, Constantine Caramanis, Sanjay Shakkottai, Wen-Sheng Chu

Introduction

Generative models have revolutionized our ability to turn random noise into high-quality images. However, the reverse process—inversion—remains a significant challenge. Inversion involves taking a real image and finding the specific "structured noise" that can recreate it. Mastering this process is the holy grail for image editing: if you can accurately find that initial noise, you can tweak the text prompt and generate a seamlessly modified version of the original image.

This paper introduces RF-Inversion, a zero-shot framework for image inversion and editing using Rectified Flow (RF) models like Flux. By framing inversion as a dynamic optimal control problem, the authors achieve state-of-the-art faithfulness and editability without the need for costly test-time optimization or additional training.

The Challenge of Image Inversion

While Diffusion Models (DMs) currently dominate generative modeling, they struggle with inversion. Their "nonlinear drift"—the complex, curved paths they take through data space—makes it difficult to perfectly reconstruct an image (faithfulness) while still allowing for significant prompt-driven changes (editability). Existing solutions usually require slow "test-time optimization" (tweaking variables for every single image) or training extra adapter layers.

Rectified Flows (RFs) offer a promising alternative because they learn to connect noise and data via straight-line paths. However, how to properly invert these models for high-quality editing has remained an open question.

Methodology: RF-Inversion

The authors propose RF-Inversion based on two main pillars:

  1. Dynamic Optimal Control: Instead of simply running the model backward, the authors treat inversion as a control problem. They utilize a Linear Quadratic Regulator (LQR)—a classic tool from control theory—to find the "minimum energy path" from an image to a "typical" noise sample. This ensures the resulting noise resembles the standard Gaussian noise the model was trained on, rather than an "atypical" outlier.
  2. Rectified SDEs: They prove that their controlled vector field is mathematically equivalent to a Rectified Stochastic Differential Equation (SDE). This mathematical foundation allows them to design a new stochastic sampler for models like Flux, adding robustness to the generation process.
Conceptual diagram of RF-Inversion mapping atypical data to typical noise.

The workflow involves a Controlled Forward ODE to extract the noise and a Controlled Reverse ODE to generate the edited image. Two tunable parameters, $\gamma$ and $\eta$, allow users to precisely balance how much the output should resemble the original image versus how much it should follow the new text prompt.

Key Insights

  • Typicality Matters: A major breakthrough in this work is the realization that standard inversion often leads to "atypical" noise. Even if that noise can reconstruct the original image perfectly, the model struggles to edit it because it falls outside the training distribution. By using LQR to force the noise to be "typical," the model remains highly editable.
  • Straight Paths are Better: Because RFs utilize straighter trajectories than DMs, they are less prone to the drift errors that plague diffusion inversion. This enables much more faithful reconstructions, even with fewer processing steps.
  • Zero-Shot Efficiency: Unlike methods such as Null-text Inversion (NTI) that solve an optimization problem for every image, RF-Inversion is purely analytical. It acts as a "plug-and-play" solution that works instantly with pre-trained models.

Experimental Results

The researchers evaluated RF-Inversion across several standard benchmarks, including LSUN-Bedroom, LSUN-Church, SFHQ (Synthetic Faces High Quality), and the SDEdit dataset.

Comparison of original images and their RF-Inversion reconstructions.

Key performance highlights include:

  • Superior Photorealism: In stroke-to-image tasks, RF-Inversion outperformed the previous state-of-the-art (NTI) by 89% in human preference evaluations for photorealism.
  • Better Faithfulness: On the LSUN-bedroom dataset, the method was 4.7% more faithful to the original image and 13.8% more realistic than standard Diffusion Model inversion.
  • Speed: For face editing, RF-Inversion achieved superior results in just 39 seconds, compared to the 85 seconds required by optimization-based methods (NTI+P2P).
  • Human Preference: Large-scale user studies on Amazon Mechanical Turk confirmed that users significantly preferred RF-Inversion's results over SDEdit, DDIM, and NTI across both realism and faithfulness metrics.

Limitations and Future Directions

Like all ODE/SDE-based models, RF-Inversion faces discretization errors; quality drops if too few steps are used. While the authors demonstrated success with an 8-step distilled model, very low-step regimes remain challenging. Additionally, the authors note that they couldn't compare against some expensive diffusion-based editors because those implementations are not yet compatible with the unique multi-modal architecture of the Flux model.

Future work may integrate "accelerated iteration" procedures (similar to those used in ReNoise) to further reduce the number of steps needed, potentially enabling real-time applications.

Summary updated

BibTeX
@inproceedings{rout2025semantic,
  author = {Litu Rout and Yujia Chen and Nataniel Ruiz and Constantine Caramanis and Sanjay Shakkottai and Wen-Sheng Chu},
  title = {{Semantic Image Inversion and Editing using Rectified Stochastic Differential Equations}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=Hu0FSOSEyS},
}
Figure