Harmonizing Attention: Training-free Texture-aware Geometry Transfer

Eito Ikuta, Yohan Lee, Akihiro Iohara, Yu Saito, Toshiyuki Tanaka

Abstract

Creating images where surface patterns of one object—such as cracks, holes, or grooves—are precisely transferred onto objects made of different materials remains a challenging task in computer graphics. For example, recreating the exact pattern of wood grain cracks on a metallic surface, while maintaining the realistic metallic texture, requires sophisticated technical solutions. In this study, we introduce Harmonizing Attention, a new method that can automatically extract these surface patterns from photographs and recreate them with different materials, while preserving natural-looking textures. Our approach achieves this through a novel attention mechanism that can process multiple reference images simultaneously, without requiring additional training. This makes the method both practical and efficient for real-world applications, opening up new possibilities in augmented reality, image editing, and beyond.

Introduction

In the field of computer vision, "image harmonization" typically refers to the adjustment of color and lighting of a foreground object to match a background. However, a more complex challenge exists: geometry transfer. This involves taking a specific geometric feature, such as a crack in wood or a droplet on glass, and integrating it into a new material surface (e.g., metal or stone).

Existing style transfer and composition methods often struggle to decouple "geometry" (the shape of the feature) from "texture" (the source material's appearance). Most methods either lose fine geometric details during blending or inadvertently import the source material's texture, resulting in a "sticker-like" appearance rather than a physically integrated feature. We propose Harmonizing Attention, a training-free method that achieves seamless, texture-aware integration by modifying the attention mechanism in pre-trained diffusion models.

Methodology: The Harmonizing Attention Pipeline

Our method leverages a pre-trained Stable Diffusion (SD) inpainting model and introduces a novel dual-phase attention mechanism that requires no additional training or fine-tuning. The process is divided into four primary stages:

  1. Editing and Color Adjustment: The source geometry patch is first transformed (shifted, scaled, or rotated) to fit the target location. Crucially, it is color-shifted to match the target background's mean color. This prevents the diffusion model's inversion process from being dominated by large color discrepancies.
  2. Texture-aligning Attention (Inversion Phase): During DDIM inversion, which converts an image into noise, we replace standard self-attention. The model queries information from both the source geometry and the target texture. This aligns the geometric latent representation with the visual domain of the target material.
  3. Blending: The latent representations of the target and the newly aligned geometry are blended using the geometry mask.
  4. Geometry-preserving Attention (Generation Phase): During denoising, a modified attention block pulls "keys" and "values" from the original source image. This ensures the diffusion process preserves fine geometric details, like sharp edges, while applying the target texture.
The Harmonizing Attention pipeline, illustrating the four stages: Editing, Inversion, Blending, and Generation.

Notably, this method is prompt-free, relying on visual references rather than vague text descriptions to guide the transfer of physical imperfections.

Experimental Setup

The method was evaluated using high-resolution industrial and general-purpose datasets:

  • MVTec AD: Contains detailed images of industrial anomalies like cracks and dents.
  • Pixabay: Provides diverse background and foreground textures.
  • Evaluation Set: A benchmark of 150 generated images (10 foregrounds paired with 15 backgrounds) was used for quantitative analysis.

Key Results and Discussion

Harmonizing Attention was compared against state-of-the-art baselines, including Paint by Example, TF-ICON, and TF-GPH.

Qualitative Performance

As illustrated in the comparative analysis, our method successfully transfers complex geometries—such as wood knots onto concrete or metallic holes onto gears—without importing the original background texture. Baselines often suffer from texture leakage or loss of geometric fidelity.

Qualitative comparison of Harmonizing Attention against state-of-the-art baselines across various materials and geometries.

Quantitative and User Evaluation

In a user study with 105 participants, Harmonizing Attention consistently outperformed competitors across three metrics:

  • Quality of Background: 3.44/5
  • Quality of Foreground: 2.96/5
  • Quality of Composition: 3.56/5

Quantitatively, the method achieved the lowest LPIPS(bg) (0.266) and DISTS(bg) (0.179), indicating superior background preservation. It also recorded the highest CLIP(fg) score (91.352), confirming semantic consistency of the transferred features.

Conclusion and Future Work

Harmonizing Attention provides a robust, training-free solution for geometry transfer by hijacking the self-attention layers of diffusion models to act as a multi-source query system. While highly effective, the method faces challenges with extreme scales (very large or small geometries) and occasional model hallucinations. Future research will focus on dynamic attention mechanisms that can automatically adjust to varying feature sizes, further enhancing the versatility of texture-aware geometry transfer.

Summary updated

BibTeX
@inproceedings{ikuta2025harmonizing,
  author = {Eito Ikuta and Yohan Lee and Akihiro Iohara and Yu Saito and Toshiyuki Tanaka},
  title = {{Harmonizing Attention: Training-free Texture-aware Geometry Transfer}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2025},
  url = {https://openreview.net/forum?id=7lupLH7KuZ},
}
Figure