Abstract
In image editing employing diffusion models, it is crucial to preserve the reconstruction fidelity to the original image while changing its style. Although existing methods ensure reconstruction fidelity through optimization, a drawback of these is the significant amount of time required for optimization. In this paper, we propose negative-prompt inversion, a method capable of achieving equivalent reconstruction solely through forward propagation without optimization, thereby enabling ultrafast editing processes. We experimentally demonstrate that the reconstruction fidelity of our method is comparable to that of existing methods, allowing for inversion at a resolution of 512 pixels and with 50 sampling steps within approximately 5 seconds, which is more than 30 times faster than null-text inversion. Reduction of the computation time by the proposed method further allows us to use a larger number of sampling steps in diffusion models to improve the reconstruction fidelity with a moderate increase in computation time.
Introduction
Editing real-world images using text-to-image diffusion models like Stable Diffusion requires "inversion"—finding the specific noise latents that reconstruct the original image when denoised. While standard DDIM inversion is efficient, it struggles with reconstruction fidelity when using Classifier-Free Guidance (CFG), a critical component for high-quality text-guided editing. Previous solutions like Null-text inversion achieve high fidelity by optimizing a "null" text embedding at each diffusion step, but this process is computationally prohibitive, often taking minutes per image. This paper introduces Negative-prompt inversion to bridge the gap between speed and fidelity.
Methodology
The proposed Negative-prompt inversion achieves high-fidelity reconstruction through forward propagation alone, eliminating the need for iterative optimization. The method is based on the theoretical insight that the optimal null-text embedding found via optimization can be approximated by the embedding of the source prompt itself.
In a standard CFG setup, the model predicts directions based on a text prompt and an unconditional "null-text" (usually an empty string). Negative-prompt inversion modifies this:
- Reconstruction Phase: The null-text embedding is replaced with the source prompt embedding in the CFG equation. This "neutralizes" the guidance during inversion, allowing the model to follow the DDIM trajectory more accurately without optimization.
- Editing Phase: The source prompt is used as the "negative prompt," while the edited prompt serves as the target condition.
By removing the optimization loop, the computational cost is reduced to the level of basic DDIM inversion while maintaining the high fidelity associated with optimization-based methods.
Evaluation and Results
The method was evaluated using 100 images from the COCO validation set with Stable Diffusion v1.5. Performance was measured using PSNR and LPIPS for reconstruction accuracy, and CLIP scores for editing alignment.
Key results include:
- Speed: The method processes a 512x512 image in ~5 seconds (50 steps), a 30x speedup over Null-text inversion (~130 seconds).
- Fidelity: Quantitatively, it achieved a PSNR of 23.38, significantly outperforming standard DDIM inversion (14.05) and approaching Null-text inversion (26.11).
- Efficiency: It requires approximately half the memory of Null-text inversion as it avoids storing gradients for optimization.
Discussion and Conclusion
The core innovation lies in shifting image inversion from an optimization-based "training-style" task to an efficient "inference-style" task. This efficiency allows for using more sampling steps (e.g., 500 steps) to further enhance detail while remaining faster than optimized alternatives.
While highly effective, limitations remain. The underlying Stable Diffusion AutoEncoder can struggle with fine details like human fingers or very small objects. Nevertheless, the 30x speedup provided by Negative-prompt inversion offers significant potential for real-time applications and video editing, where processing speed is paramount.
Summary updated