Z*: Zero-shot Style Transfer via Attention Rearrangement.

Yingying Deng, Xiangyu He, Fan Tang, Weiming Dong

Introduction

Image style transfer aims to merge the structural content of one image with the artistic texture of another. While diffusion models have revolutionized image generation, applying them to style transfer often requires expensive per-image fine-tuning or relies on imprecise text prompts. Z-STAR ($Z^*$) introduces a training-free, zero-shot approach that leverages the internal generative priors of pre-trained diffusion models through a novel Attention Rearrangement strategy.

The Attention Rearrangement Framework

Z-STAR operates within the latent space of Stable Diffusion, utilizing a dual-path denoising process. By performing DDIM inversion on both content and style images, the model extracts latent codes representing their respective features.

The core innovation lies in how these features are fused. Standard cross-attention mechanisms often prioritize global style at the expense of local content structure. Z-STAR addresses this by "rearranging" the attention mechanism. It modifies the Softmax operation to simultaneously process content self-attention and style cross-attention. This ensures that style patterns are integrated only where they do not compromise the "skeleton" of the content image.

Example of a complex artistic style reference used for transfer.

Experimental Evaluation

The method was evaluated using the CelebA-HQ dataset for facial content preservation and a variety of Arbitrary Artworks for style references. A user study involving 55 participants compared Z-STAR against 10 state-of-the-art methods, focusing on both stylistic fidelity and structural integrity.

Results and Insights

Z-STAR demonstrates significant advantages in both efficiency and quality:

  • Zero-Shot Efficiency: Unlike optimization-based methods (e.g., InST, VCT) that require ~20 minutes of training per style, Z-STAR requires no training.
  • Superior Content Preservation: The attention rearrangement strategy effectively suppresses style "noise" that would otherwise distort recognizable features, such as facial identities.
  • Painterly Aesthetics: Compared to traditional CNN-based methods like AdaIN, Z-STAR produces sophisticated, non-linear textures that mimic real brushstrokes.
  • Controllability: The framework allows for conditional control, such as creating gradients where style intensity varies across the image.
Stylized result demonstrating high-fidelity content preservation and painterly texture.

The authors also identified that the timing of style injection is critical; the "sweet spot" for maintaining structure while applying style occurs between denoising steps 5 and 30.

Conclusion and Future Work

Z-STAR proves that pre-trained diffusion models possess an inherent understanding of style-content relationships. By steering these models with image-based attention rather than text, Z-STAR achieves high-quality results without the need for fine-tuning. Future research may explore multi-style blending and further optimization of computational overhead.

Summary updated

BibTeX
@misc{deng2023z,
  author = {Yingying Deng and Xiangyu He and Fan Tang and Weiming Dong},
  title = {{Z*: Zero-shot Style Transfer via Attention Rearrangement.}},
  year = {2023},
  eprint = {2311.16491},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2311.16491},
}
Figure