CODE: Confident Ordinary Differential Editing

Bastien Van Delft, Tommaso Martorella, Alexandre Alahi

Confident Ordinary Differential Editing (CODE) is a novel "blind" image restoration framework that leverages pre-trained diffusion models to repair corrupted or out-of-distribution images. Unlike traditional methods that require knowledge of the specific corruption type, CODE operates without task-specific training. By replacing stochastic noise injection with deterministic ODE inversion and introducing a novel "Confidence-based Clipping" mechanism, CODE achieves a superior balance between maintaining fidelity to the original input and generating high-quality, realistic outputs.

The Challenge of Blind Image Restoration

Blind Image Restoration (BIR) is a significant challenge in computer vision. It involves restoring an image that has been degraded by unknown factors—such as noise, blur, fog, or partial masking—to a clean state.

Existing approaches often struggle with the Realism-Fidelity Trade-off. If a model adheres too strictly to a heavily corrupted input, the resulting output remains noisy or distorted. Conversely, if the model prioritizes realism, it may generate a visually pleasing image that loses the identity of the original subject. Current solutions like SDEdit rely on random noise injection to "reset" the image, which frequently destroys essential structural details. Furthermore, many methods require expensive, task-specific training for every unique type of corruption, making them impractical for unpredictable real-world scenarios.

Methods: ODE Inversion and Confidence-based Clipping

CODE introduces two primary technical innovations to address these limitations:

  1. From SDE to ODE Inversion: Rather than adding random Gaussian noise (Stochastic Differential Equations or SDE), CODE utilizes the Probability-Flow Ordinary Differential Equation (ODE). This provides a deterministic, bijective mapping between the image and its latent representation. This precision allows the model to move an image into latent space and back while preserving its underlying structure. Once in latent space, "score-based" updates (using Langevin dynamics) nudge the representation toward a more realistic, "in-distribution" state.
  2. Confidence-based Clipping (CBC): This mechanism addresses the observation that corrupted pixels often fall statistically outside the range of "normal" images. During the encoding process, CBC applies a clipping method based on a calculated confidence interval. It effectively filters out pixels or information mathematically unlikely to belong to a clean image. Crucially, CBC is "blind"; it identifies corruption based on statistical likelihood rather than requiring an explicit mask.
The CODE framework: Deterministic ODE encoding followed by score-based updates in the latent space, guided by confidence intervals.

By decoupling the depth of the inversion from the step size of the correction, CODE offers researchers significantly finer control over the editing and restoration process compared to previous state-of-the-art methods.

Experimental Setup and Results

The researchers evaluated CODE using pre-trained DDPM models on three standard benchmarks: CelebA-HQ (faces), LSUN-Bedroom, and LSUN-Church. To test robustness, they utilized a suite of 47 different corruption types, including standard noise, blur, weather effects, and digital artifacts. They also introduced custom masking challenges, such as vertical lines and random colored pixels, to evaluate the model's ability to synthesize missing data.

Key Results

CODE consistently outperformed the primary baseline, SDEdit, across both qualitative and quantitative metrics:

  • Realism: CODE improved the FID score by 36% compared to SDEdit, indicating significantly higher image realism.
  • Fidelity: It maintained a 5% higher PSNR (Peak Signal-to-Noise Ratio), demonstrating better preservation of the original input's colors and shapes.
  • Versatility: While domain-specific models (like GFPGAN) excel at specific tasks, they often fail on general corruptions like fog or contrast. CODE was the only method that performed reliably across all 47 corruption types without any task-specific tuning.
CODE demonstrates robust blind restoration across diverse corruption types, including fog, low-light artifacts, and digital noise, without task-specific tuning.

Insights and Future Directions

A key insight from this research is that deterministic trajectories are superior for restoration; random noise injection is often too imprecise. Furthermore, the authors found that the choice of latent space depth is critical: "shallow" spaces are ideal for fixing fine details like blur, while "deeper" spaces allow for significant semantic changes, such as removing heavy fog.

Despite its success, CODE faces challenges regarding computational cost and hyperparameter complexity. Running hundreds of Langevin dynamics iterations is slower than one-pass restoration methods, and finding the optimal settings for specific images currently requires extensive searching. Future work will focus on automating hyperparameter selection and integrating CODE with text-to-image models for guided restoration tasks.

Summary updated

BibTeX
@inproceedings{delft2025code,
  author = {Bastien Van Delft and Tommaso Martorella and Alexandre Alahi},
  title = {{CODE: Confident Ordinary Differential Editing}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i20.35392},
}
Figure