Conditional Score Guidance for Text-Driven Image-to-Image Translation

Hyunsoo Lee, Minsoo Kang, Bohyung Han

TL;DR

Conditional Score Guidance (CSG) is a novel, training-free algorithm for text-driven image-to-image translation that selectively edits regions of interest while preserving the rest of the image. By mathematically deriving a new conditional score function that accounts for both the source image and source text prompt, CSG achieves high-fidelity edits without requiring costly fine-tuning or optimization at inference time.

What Problem Does This Paper Address?

Text-driven image-to-image translation aims to modify specific objects or attributes within a source image based on a target text prompt (e.g., turning a "cat" into a "dog") while keeping the background and overall layout completely intact.

While large-scale text-to-image diffusion models excel at generating images from scratch, adapting them for precise image editing is notoriously difficult. Naive approaches often suffer from a lack of controllability: changing the text prompt causes the model to generate an entirely new image, completely discarding the original background, composition, and structure.

Figure 1: Image translation results of xtgt based on xsrc using the simple naïve DDIM generative process based on Eq (3).

Existing solutions typically fall into two camps: they either require computationally expensive fine-tuning for every single source image, or they rely on ad-hoc feature blending and optimization steps during inference that can slow down generation and degrade image structure. The authors of this paper introduce a principled, training-free framework that solves this controllability gap mathematically.

Methods

The core innovation is Conditional Score Guidance (CSG). Instead of relying solely on the target text prompt during the reverse diffusion process, the authors derive a new score function conditioned on the source image ($x^{src}$), source prompt ($y^{src}$), and target prompt ($y^{tgt}$):

$$\nabla_{x_t^{tgt}} \log p(x_t^{tgt} | x^{src}, y^{tgt}, y^{src})$$

Through a rigorous mathematical derivation, they decompose this conditional score into two distinct components:

  1. The Standard Score: The typical gradient step conditioned only on the target prompt.
  2. A Guiding Term: A corrective gradient that steers the target latent space toward the source image's invariant regions.

To compute this guiding term analytically without any neural network training, the authors model the posterior distribution as a Gaussian and estimate its mean and variance at each timestep.

Figure 2: Graphical model of the proposed method for target image generation.

To further boost fidelity, the paper introduces Cross-Attention Mixup. Cross-attention maps in diffusion models naturally capture the spatial layout of text tokens. However, standard cross-attention maps often only highlight small, highly discriminative parts of an object (like a cat's head rather than its entire body).

To fix this, CSG smooths the content mask using the model's internal self-attention maps. This regularized mask is then used to adaptively mix the cross-attention maps of the source and target latents at each timestep, seamlessly fusing the modified foreground with the original background.

Datasets

The authors evaluated their method using:

  • LAION 5B: A massive, public image-text dataset. For quantitative evaluation, they selected 250 real images with the highest CLIP similarity scores to generate realistic source prompts.
  • Synthetic Images: Images generated directly via Stable Diffusion to test a wider variety of creative editing tasks (e.g., turning a car into an "old car", or a street into a "snowy street").

Key Insights and Ideas

  • Principled Score Decomposition: Instead of relying on heuristic feature-swapping tricks, CSG provides a solid mathematical foundation for image translation by treating the source image as a formal conditioning variable in the diffusion score function.
  • Attention Regularization for Complete Masks: A key "aha moment" was realizing that cross-attention maps are too sparse for clean object replacement. By multiplying the cross-attention map with the time-averaged self-attention map, the authors created a spatially smooth mask that covers the entire object of interest.
  • Backpropagation-Free Efficiency: Unlike optimization-based methods (such as Pix2Pix-Zero) that require calculating gradients through the U-Net via backpropagation at every inference step, CSG computes its guidance term analytically. This makes it significantly faster and more memory-efficient.

Key Results

The method was compared against state-of-the-art baselines, including Prompt-to-Prompt and Pix2Pix-Zero, using metrics like CLIP-similarity (CS) for text alignment, Structure Distance (SD) for layout preservation, and a newly introduced Relational Distance (RD) metric to measure how well pairwise image relationships are preserved post-translation.

  • Superior Structure Preservation: CSG consistently outperformed all baselines in Structure Distance (SD) and Background LPIPS (BG-LPIPS). For instance, in the cat $\rightarrow$ dog task, CSG achieved an SD of 0.0192, beating Pix2Pix-Zero (0.0226) and Prompt-to-Prompt (0.0338).
  • Excellent Relational Fidelity: On the same task, CSG achieved a Relational Distance of 0.0217, vastly outperforming Pix2Pix-Zero (0.1589), proving that it maintains the underlying semantic context of the original scene far better than existing methods.

Limitations and Future Work

While highly effective, the authors note a few limitations:

  • Complex Prompt Failure: If the underlying pretrained text-to-image model struggles to understand highly complex or convoluted prompts, CSG will inherit those failures.
  • Spatial Transformations: The method is designed to modify content within an existing spatial layout. It cannot handle complex geometric transformations, such as drastically moving an object to a different corner of the image or significantly changing its scale.

The authors suggest that tackling these complex spatial transformations without losing the training-free nature of the algorithm is a promising direction for future research.

Summary updated

BibTeX
@inproceedings{lee2023conditional,
  author = {Hyunsoo Lee and Minsoo Kang and Bohyung Han},
  title = {{Conditional Score Guidance for Text-Driven Image-to-Image Translation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=cBS5CU96Jq},
}
Figure