Papers
Topics
Authors
Recent
Search
2000 character limit reached

Confident ODE Editing (CODE)

Updated 22 February 2026
  • The paper introduces CODE, a training-free approach that combines deterministic ODE inversion with Langevin correction to robustly restore and edit corrupted images.
  • It decouples inversion depth and likelihood correction, enabling precise control over the trade-off between input fidelity and generated realism.
  • Empirical results across datasets like CelebA-HQ and LSUN demonstrate that CODE achieves lower FID and higher PSNR compared to traditional SDE-based methods.

Confident Ordinary Differential Editing (CODE) is a method for image synthesis and restoration that enables robust editing guided by noisy or Out-of-Distribution (OoD) images within the diffusion model framework. CODE introduces a pipeline based on probability-flow ordinary differential equations (ODEs), which provides deterministic mappings between input images and latent representations, paired with controlled likelihood ascent using Langevin dynamics. This approach requires no task-specific training or handcrafted modules and is compatible with any pre-trained diffusion model. Positioned at the intersection of conditional image generation and blind image restoration, CODE is designed to maximize the likelihood of the input under the model prior while maintaining fidelity to the possibly corrupted input, introducing a principled alternative to traditional blind restoration techniques (Delft et al., 2024).

1. Problem Setting and Theoretical Goals

CODE addresses the problem of editing or restoring images given a single "guidance" image x0x_0 that may be corrupted, noisy, or otherwise OoD relative to the diffusion model's training distribution. The goal is to output an image x~0\tilde{x}_0 that:

  • Remains faithful to x0x_0: measured via perceptual or pixelwise similarity metrics such as L2L_2, PSNR, or SSIM.
  • Is realistic: the output lies close to the model's learned data manifold, assessed via Fréchet Inception Distance (FID) or perceptual distances like LPIPS.

A principal challenge is managing the fidelity–realism trade-off: Adding noise and denoising (as in SDEdit) may enhance realism but sacrifices input fidelity, while insufficient noise injection may trap the model in a non-natural image mode. CODE explicitly decouples "noise level" (controlled by inversion depth LL) from "correction strength" (handled by the Langevin step size ϵ\epsilon), providing more granular and independent control over this trade-off.

2. Mathematical Principles: ODE-Based Editing and Latent Correction

The generative foundation of CODE is the score-based diffusion model, typically instantiated as a Variance-Preserving SDE:

dx=12β(t)xdt+β(t)dWtdx = -\frac{1}{2} \beta(t)x\,dt + \sqrt{\beta(t)}\,dW_t

with a drift term given by the score estimate sθ(x,t)xlogpt(x)s_\theta(x, t) \approx \nabla_x \log p_t(x).

The associated probability-flow ODE is:

dx=[f(x,t)12g2(t)sθ(x,t)]dtdx = [f(x, t) - \frac{1}{2}g^2(t)\,s_\theta(x, t)]\,dt

where f(x,t)=12β(t)xf(x, t) = -\frac{1}{2}\beta(t)x and g(t)=β(t)g(t) = \sqrt{\beta(t)}. CODE utilizes a discretized ODE inversion, equivalent to DDIM with σt=0\sigma_t = 0, ensuring deterministic bijective mapping between x0x_0 and latent xLx_L for any L[0,T]L \in [0, T].

After ODE inversion to a chosen latent depth, CODE applies Langevin dynamics in the latent space:

xL,k+1=xL,k+ϵsθ(xL,k,L)+2ϵη,ηN(0,I)x_{L, k+1} = x_{L, k} + \epsilon \cdot s_\theta(x_{L, k}, L) + \sqrt{2\epsilon} \cdot \eta, \quad \eta \sim \mathcal{N}(0, I)

The step size ϵ\epsilon modulates the correction strength toward high-density regions without over-injecting noise, directly influencing realism/fidelity independently of LL.

3. Confidence Interval–Based Clipping (CBC)

ODE inversion from corrupted or OoD images can produce intermediate latent values xtx_t containing highly improbable pixel intensities under the forward diffusion process. To suppress the impact of such outliers, CODE introduces confidence interval–based clipping (CBC):

Given the forward process xtN(αtx0,(1αt)I)x_t \sim \mathcal{N}(\sqrt{\alpha_t}\,x_0,\, (1-\alpha_t)I) with x0[1,1]x_0 \in [-1, 1], CODE applies per-coordinate clipping:

xtclipped=Clip(xt,  αtη1αt,  +αt+η1αt)x_t^{\text{clipped}} = \text{Clip}\left(x_t,\; -\sqrt{\alpha_t} - \eta \sqrt{1-\alpha_t},\; +\sqrt{\alpha_t} + \eta \sqrt{1-\alpha_t}\right)

where η\eta is chosen (e.g., $1.7$–$2.0$) so that the interval covers at least 95% of mass for η2\eta \geq 2 (P[in interval]Φ(η)Φ(η)P[\text{in interval}] \geq \Phi(\eta) - \Phi(-\eta)). This clipping aggressively removes unlikely pixels before latent-space correction, mitigating the effect of strong corruptions and masks.

4. Comparison to SDE-Based Editing and Empirical Analysis

In contrast to SDEdit, which injects noise to a latent xLq(xLx0)x_L \sim q(x_L|x_0) and reverses stochastically via DDPM, CODE offers:

  • Deterministic inversion: ODE-based mapping from x0xLx_0 \rightarrow x_L incurs no additional fidelity loss.
  • Langevin correction: Targeted log-likelihood ascent in latent space, divorced from forward noise injection.
  • Decoupled trade-off control: Inversion depth LL governs how far the image is mapped into latent space; correction strength ϵ\epsilon controls the degree of movement toward the model prior.

Empirically, using 47 types of corruption on CelebA-HQ, CODE achieves substantial performance improvements:

Method FID↓ PSNR-Input↑ LPIPS-Source↓
Inputs 143.5 0.48
SDEdit 47.8 18.74 0.32
CODE 30.7 19.61 0.30

CODE yields uniformly lower FID at equal or higher PSNR; the trade-off curve for FID vs. L2L_2-distance uniformly dominates that of SDEdit. Qualitative results show CODE reconstructs fine structure and plausible semantics under severe corruptions (e.g., fog, masking), preserving both identity and image realism. The method generalizes across datasets (CelebA-HQ, LSUN Bedroom, LSUN Church). CBC is shown via ablation to be critical for handling extreme outliers; ODE inversion alone or CBC alone is inadequate for optimal performance (Delft et al., 2024).

5. Pipeline Structure and Hyperparameterization

The full CODE algorithm consists of:

  1. ODE Inversion: Deterministically projects x0x_0 to xLx_L via probability-flow ODE, with CBC applied to suppress out-of-range pixels.
  2. Langevin Correction: In latent xLx_L, performs NN Langevin steps, with multi-latent annealing possible via steps at varying latent levels {Lj,...,L1}\{L_j, ..., L_1\}, step-size ϵ0\epsilon_0, annealing factor α\alpha, and KK annealing rounds.
  3. ODE Decoding: Projects corrected latent back to image space via the reverse ODE.
  4. Confidence Parameter Tuning: Hyperparameter η\eta for the CBC interval size; latent depths and correction schedule are user-controlled for fine realism–fidelity balance.

This pipeline is fully training-free and blind with respect to the corruption, relying solely on a pre-trained score network and no ground truth target assumptions.

6. Significance and Context

CODE provides a robust, flexible solution to conditional image editing with corrupted or OoD input guidance, resolving key limitations in existing SDE-based approaches. The decoupling of inversion depth and likelihood correction allows independent steering of output fidelity and realism. Deterministic ODE mapping eliminates unnecessary stochasticity, reducing output variance, and improving reproducibility and metric scores (PSNR, SSIM). The confidence interval–based clipping step significantly strengthens robustness to extreme corruptions, offering a blind restoration mechanism that does not require task-specific design.

This suggests CODE is a principled alternative in the landscape of blind image restoration and conditional generation, applicable across diverse domains and degradations. Its training-free, model-agnostic character and empirical robustness across metrics underscore its utility for practitioners requiring flexible fidelity–realism control in image synthesis workflows (Delft et al., 2024).

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Confident Ordinary Differential Editing (CODE).