Abstract
Large-scale text-to-image generative models have been a revolutionary breakthrough in the evolution of generative AI, synthesizing diverse images with highly complex visual concepts. However, a pivotal challenge in leveraging such models for real-world content creation is providing users with control over the generated content. In this paper, we present a new framework that takes text-to-image synthesis to the realm of image-to-image translation - given a guidance image and a target text prompt as input, our method harnesses the power of a pre-trained text-to-image diffusion model to generate a new image that complies with the target text, while preserving the semantic layout of the guidance image. Specifically, we observe and empirically demonstrate that fine-grained control over the generated structure can be achieved by manipulating spatial features and their self-attention inside the model. This results in a simple and effective approach, where features extracted from the guidance image are directly injected into the generation process of the translated image, requiring no training or fine-tuning. We demonstrate high-quality results on versatile text-guided image translation tasks, including translating sketches, rough drawings and animations into realistic images, changing the class and appearance of objects in a given image, and modifying global qualities such as lighting and color.
Introduction
Large-scale text-to-image models like Stable Diffusion are incredibly expressive, but they are notoriously difficult to steer. If a user has a specific photo and wants to change an object's class or style while keeping the exact same pose and background layout, standard text-to-image models often generate a completely different composition. Existing Image-to-Image (I2I) methods usually struggle to balance fidelity to the original structure with faithfulness to the new text prompt, or they require expensive per-image fine-tuning.
Researchers from the Weizmann Institute of Science have unveiled "Plug-and-Play" (PnP) diffusion, a zero-shot framework that transforms images using text prompts without any training. By "hijacking" the internal spatial features and self-attention maps of a pre-trained model, the method allows users to modify an image's content while perfectly preserving the original scene's layout.
Methodology: Feature Injection
The core of the PnP approach is feature injection. The process works in two main branches:
- The Guidance Branch: The researchers take a real input image and use DDIM inversion to turn it back into "noise." As the model then tries to "denoise" this image back to its original state, the researchers extract two key components from the U-Net: spatial features (raw data at specific layers) and self-attention matrices (which define how different parts of the image relate to each other).
- The Translation Branch: Simultaneously, they start a new generation process using a target text prompt. Instead of letting the model decide the layout, they inject the features and attention maps saved from the guidance branch directly into this new process.
Crucially, they found that injecting features at Layer 4 of the U-Net decoder provided the best "semantic" anchor, while injecting self-attention maps across all layers ensured the fine-grained geometry remained intact without "leaking" the original colors or textures.
Versatile Translation and Benchmarking
To prove their method works across diverse scenarios, the authors introduced two new benchmarks: Wild-TI2I, a collection of 148 diverse text-image pairs (including real photos, sketches, and animations), and ImageNet-R-TI2I, consisting of 150 pairs derived from ImageNet-R.
The PnP method was compared against established baselines like SDEdit and Prompt-to-Prompt. Quantitative results using CLIP scores (for text faithfulness) and DINO-ViT self-similarity (for structure preservation) showed that PnP consistently occupies the "sweet spot" on the Pareto front, outperforming others in balancing these two conflicting goals.
Key Insights
- The U-Net "Knows" Semantics: By performing PCA (Principal Component Analysis) on the model's internal features, the authors discovered that intermediate layers naturally group semantic parts. In the model's "mind," the legs of a real horse and a sketch of a horse share similar feature values.
- Self-Attention is the Skeleton: While spatial features provide the "what," self-attention provides the "where." It acts as a structural blueprint that keeps the generated object in the exact pose of the original.
- Negative Prompting for Primitives: For very simple guidance images (like silhouettes), "negative prompting"—telling the model what not to look like—was essential to prevent the original "emptiness" of the guidance image from washing out the generated result.
Limitations and Future Work
Despite its power, PnP relies on the diffusion model's ability to see a semantic link between the source and target. If the gap is too large (e.g., a solid color mask to a complex scene), the translation may fail. Additionally, the method is dependent on the quality of DDIM inversion, which can occasionally introduce artifacts in high-frequency textures. Future work could explore using these features for video-to-video translation or more granular localized editing.
Summary updated