Task-Oriented Diffusion Inversion for High-Fidelity Text-based Editing

Yangyang Xu, Wenqi Shao, Yong Du, Haiming Zhu, Yang Zhou, Ping Luo, Shengfeng He · DOI

Abstract

Text-based image editing using diffusion models requires an inversion process to map real images into the model's latent space. Traditional methods often struggle with a trade-off between reconstruction fidelity and editing flexibility. We present Task-Oriented Diffusion Inversion (TODInv), a framework that resolves this by selectively optimizing prompt embeddings based on the specific editing task. By targeting only the U-Net layers irrelevant to the desired change, TODInv achieves high-fidelity reconstruction while maintaining the "editability" of relevant features.

Introduction

Editing real-world images with models like Stable Diffusion involves finding an initial noise map that reconstructs the original image—a process known as inversion. Standard DDIM inversion often fails when using Classifier-Free Guidance (CFG), leading to "drift" where unedited regions change unexpectedly. Existing solutions typically optimize latent codes or text embeddings but face a fundamental "fidelity-editability trade-off": perfect reconstruction often results in a "stiff" image that resists text-guided changes, while flexible models often lose original details. TODInv identifies the lack of task awareness in inversion as the root cause of this conflict.

Methodology: Task-Oriented Prompt Optimization (TOPO)

The core of TODInv is Task-Oriented Prompt Optimization (TOPO), which tailors the inversion process to the intended edit.

Extended $P^*$ Space

TODInv utilizes an extended embedding space ($P^*$), where distinct embeddings are assigned to every U-Net layer and every timestep. This increased dimensionality provides the necessary degrees of freedom to absorb reconstruction errors without over-constraining the model.

Hierarchical Layer Selection

The framework exploits the architectural priors of the U-Net:

  • Low-resolution layers (8x8, 16x16): Govern structural layout.
  • High-resolution layers (32x32, 64x64): Govern appearance, color, and texture.

Task-Specific Optimization

TODInv categorizes edits into three types and optimizes only the "irrelevant" layers:

  1. Structure Edits: Appearance layers are optimized to fix the background, leaving structural layers flexible for shape changes.
  2. Appearance Edits: Structural layers are optimized to lock the layout, allowing colors and textures to change freely.
  3. Global Edits: All layers are optimized for tasks like style transfer.

Results and Evaluation

TODInv was evaluated on PIE-Bench using Stable Diffusion V1.4 and SDXL-Turbo. It consistently outperformed state-of-the-art methods like Null-text Inversion (NTI) and Negative-prompt Inversion (NPI).

Qualitative comparison of TODInv against baseline methods for content addition (lightning) and style transfer (watercolor).

Quantitatively, TODInv achieved a superior balance between Structure Distance and CLIP Similarity. For appearance-based tasks, it reached a PSNR of 29.07, significantly higher than DDIM's 17.97. Qualitatively, as shown in the figure above, TODInv preserves the original image's integrity (e.g., the woman's face and background) while successfully applying complex edits like "watercolor style" or adding lightning to a scene, where other methods either fail to edit or distort the source.

Conclusion

TODInv introduces a smarter, task-aware approach to diffusion inversion. By leveraging the U-Net's hierarchical structure to disentangle appearance and structure during optimization, it effectively breaks the fidelity-editability trade-off. Future work includes automating task classification and extending the method to multi-attribute edits and video processing.

Summary updated

BibTeX
@misc{xu2024task,
  author = {Yangyang Xu and Wenqi Shao and Yong Du and Haiming Zhu and Yang Zhou and Ping Luo and Shengfeng He},
  title = {{Task-Oriented Diffusion Inversion for High-Fidelity Text-based Editing}},
  year = {2024},
  eprint = {2408.13395},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.13395},
}
Figure