EDICT: Exact Diffusion Inversion via Coupled Transformations

Bram Wallace, Akash Gokul, Nikhil NaikCVPR 2022

Abstract

Finding an initial noise vector that produces an input image when fed into the diffusion process (known as inversion) is an important problem in denoising diffusion models (DDMs), with applications for real image editing. The standard approach for real image editing with inversion uses denoising diffusion implicit models (DDIMs) to deterministically noise the image. However, DDIM inversion for real images is unstable as it relies on local linearization assumptions, leading to incorrect image reconstruction and loss of content. We propose Exact Diffusion Inversion via Coupled Transformations (EDICT), an inversion method that draws inspiration from affine coupling layers. EDICT enables mathematically exact inversion of real and model-generated images by maintaining two coupled noise vectors. Using Stable Diffusion, we demonstrate that EDICT successfully reconstructs real images with high fidelity, significantly outperforming DDIM on complex datasets like MS-COCO. EDICT enables a wide range of image edits while maintaining fidelity to the original image structure without requiring model training or prompt tuning.

Introduction

To edit a real image using a diffusion model (like Stable Diffusion), one must first perform inversion: finding the initial noise vector that, when passed through the model, reconstructs the original image. The current standard, DDIM inversion, relies on a "local linearization" assumption. It assumes that the noise at one step is roughly the same as the noise at the next. While this works adequately for simple, unconditioned generation, it often fails under strong text conditioning (Classifier-Free Guidance). In these scenarios, the mathematical "drift" causes reconstructed images to lose fine textures, text, or global structure, making high-fidelity editing nearly impossible for real-world photos.

Methods

EDICT (Exact Diffusion Inversion via Coupled Transformations) addresses these instabilities by drawing inspiration from Affine Coupling Layers used in Normalizing Flows. Instead of tracking a single noise vector $x_t$, EDICT maintains two coupled vectors, $x_t$ and $y_t$. The process uses an alternating update rule:

  1. Update $x$: Calculate a new $x$ using the current $y$ as input to the diffusion model's noise predictor.
  2. Update $y$: Calculate a new $y$ using the newly updated $x$.

This coupled structure makes the process mathematically reversible to machine precision. Unlike DDIM, you don't need to assume the noise is constant between steps; you can simply run the algebra in reverse to get back to the exact starting point.

To ensure the two sequences don't diverge and produce distorted images, the authors introduce an interleaved mixing layer. This layer takes a weighted average of $x$ and $y$ (using a mixing coefficient $p$, typically around 0.93) after each step. This mixing layer is the "secret sauce" that trades a tiny bit of numerical range for massive generative stability, keeping the sequences synchronized while remaining fully invertible.

Key Results

The researchers evaluated EDICT using the MS-COCO 2017 and ImageNet 2012 validation sets, demonstrating significant improvements in both reconstruction accuracy and editing quality.

Superior Reconstruction Fidelity

On the MS-COCO dataset, EDICT achieved a reconstruction Mean Squared Error (MSE) of 0.015, effectively matching the theoretical lower bound of the model's autoencoder. In contrast, conditional DDIM inversion produced an MSE of 0.420—nearly 30 times higher. This indicates that EDICT can perfectly capture the nuances of complex, multi-object scenes.

EDICT reconstruction fidelity compared to DDIM baselines across different image types.

High-Fidelity Semantic Editing

Quantitative benchmarks using LPIPS (visual similarity) and CLIP (semantic alignment) show that EDICT maintains significantly higher fidelity to the original image structure compared to baselines. In dog breed editing tasks, EDICT demonstrated fine-grained semantic control. For instance, it can transform a Pomeranian into a Husky while keeping the background elements—like a birthday cake with the name "PEANUT"—perfectly intact. This preservation of "auxiliary" details not mentioned in the prompt is a direct result of the exact inversion process.

EDICT enables precise semantic edits, such as changing dog breeds, while preserving the original image's structure and background details.

Discussion and Limitations

While EDICT provides exact inversion, it comes with a computational cost, requiring roughly twice the time of standard DDIM due to the dual-sequence maintenance and two model passes per timestep. It is also a deterministic process, which may limit creative exploration compared to stochastic methods. Furthermore, while more robust than DDIM, EDICT still relies on the quality of the text prompts used for inversion. Despite these trade-offs, its zero-shot capability—requiring no training, fine-tuning, or prompt tuning—makes it a powerful and accessible tool for high-fidelity image manipulation with any pretrained diffusion model.

Summary updated

BibTeX
@inproceedings{wallace2022edict,
  author = {Bram Wallace and Akash Gokul and Nikhil Naik},
  title = {{EDICT: Exact Diffusion Inversion via Coupled Transformations}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
  url = {https://openreview.net/forum?id=1Ibz2Rzc0W},
}
Figure