Abstract
Instruction-based image editing has simplified the process of modifying images through natural language. However, language often lacks the precision required for complex artistic styles or specific transformations. We introduce InstructBrush, a novel framework designed for "instruction inversion"—learning to edit images by observing a small set of "before-and-after" visual examples. By optimizing editing instructions directly within the cross-attention layers of a diffusion model and utilizing a transformation-aware initialization strategy, InstructBrush enables precise, high-fidelity edits that surpass the capabilities of traditional text-based or CLIP-based inversion methods.
Introduction
While models like InstructPix2Pix allow users to edit images using simple text prompts, they often fail when the desired transformation is nuanced or difficult to describe. For instance, achieving a specific "vintage film" aesthetic or a complex local modification might require a level of linguistic detail that is impractical for users.
To address this, researchers have explored instruction inversion, where a model learns a transformation from a few pairs of reference images. Previous methods, such as Visii, typically optimized instructions in the CLIP embedding space. However, this approach often results in "blurry" transformations and "content leakage," where the model inadvertently learns the specific subjects of the reference images rather than the intended edit.
Methodology: The InstructBrush Framework
InstructBrush overcomes these limitations through three primary technical innovations:
1. Attention-based Instruction Optimization (AIO)
Instead of optimizing in the coarse CLIP text-embedding space, InstructBrush targets the Keys ($K$) and Values ($V$) within the U-Net's cross-attention layers. Since these features are more directly involved in the image synthesis process, they can capture and represent much finer details of the transformation.
2. Transformation-oriented Instruction Initialization (TII)
To prevent content leakage, InstructBrush employs a "Unique Phrase Extraction" technique. This ensures the model initializes with words describing the change (e.g., "turn peaches into apples") rather than the static scene. This keeps the learned "brush" focused on the delta between images.
3. Time-aware Instruction
Diffusion models generate images iteratively, moving from global structure to fine texture. InstructBrush acknowledges this by dividing the denoising process into segments and optimizing distinct instructions for each. This allows the model to specialize: learning color shifts in early stages and texture refinements in later ones.
TOP-Bench: A New Standard for Evaluation
The authors introduce the Transformation-Oriented Paired Benchmark (TOP-Bench) to rigorously test instruction inversion.
- Scope: 25 distinct editing effects, covering 14 global and 11 local transformations.
- Scale: 750 images, with 10 training pairs and 5 test pairs per effect.
- Significance: TOP-Bench provides a clean, diverse dataset specifically designed to challenge a model's ability to generalize learned edits to new contexts.
Key Results and Insights
InstructBrush demonstrates significant improvements over both the base InstructPix2Pix and the state-of-the-art Visii method.
- Quantitative Performance: On TOP-Bench, InstructBrush achieved a 20.6% improvement in PSNR and a 16.9% improvement in SSIM compared to Visii. It also showed superior "Directional Similarity," indicating better semantic alignment with the target edit.
- Qualitative Fidelity: Visual evaluations reveal that InstructBrush is exceptionally good at preserving the identity of the input image. Unlike previous methods that might alter a subject's face to match a reference, InstructBrush isolates and applies only the requested transformation.
- Efficiency: The model maintains a significant lead even in "one-shot" scenarios, where only a single reference pair is provided.
Conclusion
InstructBrush represents a significant step forward in controllable image editing. By moving optimization into the cross-attention space and focusing on the transformation rather than the content, it provides a robust tool for users to "teach" models new editing styles through visual examples. Future work will explore integrating these techniques into larger models like SDXL to further enhance resolution and complexity.
Summary updated