Abstract
Style transfer aims to synthesize an image that preserves the structural content of a source image while adopting the artistic characteristics of a reference style. While Diffusion Models have revolutionized image generation, they often struggle to balance this content-style tradeoff without extensive fine-tuning. We present STAM (Style Transfer with Attention Modulation), a training-free, zero-shot framework that utilizes Attention Modulation and Attention Aggregation to achieve high-fidelity style transfer with superior efficiency.
Introduction
In the domain of AI-driven artistic synthesis, the primary challenge of style transfer is the "tug-of-war" between content preservation and style injection. Existing methods often result in either a weak stylistic application that resembles a simple filter or a stylistic overhaul so aggressive that the original content becomes unrecognizable. Furthermore, many state-of-the-art approaches require "latent tuning" or additional training, which are computationally expensive and limit real-time applicability.
STAM addresses these issues by operating directly on the internal attention mechanisms of pre-trained Text-to-Image (T2I) models, such as Stable Diffusion 2.1. By treating style transfer as a modulation problem rather than a simple data-swapping task, STAM enables precise control over artistic influence without requiring any additional training.
Proposed Method
STAM utilizes DDIM Inversion to map input images into the model's latent space. The framework is built upon two primary technical innovations:
1. Attention Modulation (AM)
Rather than simply replacing attention matrices, STAM applies gamma correction to the Query ($Q$), Key ($K$), and Value ($V$) components within the self-attention layers. This component-level control allows for a more stable similarity response compared to modifying the final attention matrix. By adjusting the $\gamma$ hyperparameter, users can treat it as a "tuning knob" to increase or decrease the intensity of the style injection.
2. Attention Aggregation
To ensure the style does not overwrite the underlying structure, STAM employs a dual-path strategy. It calculates two distinct attention pathways—one derived from the content's structural layout and another from the reference style's textures and colors. These pathways are then blended, ensuring the final output retains the exact spatial configuration of the original image while adopting the aesthetic of the reference.
Experimental Results
The researchers evaluated STAM using diverse datasets, including WikiArt for style prompts and PASCAL-VOC for content images, alongside synthetic photorealistic images. STAM was benchmarked against ten leading methods, including CSGO, StyleID, and DiffArtist.
Qualitative and Quantitative Performance
Visual analysis demonstrates that STAM avoids the pixelated artifacts common in CSGO and the structural distortions found in StyleAligned. It successfully handles complex artistic styles such as "Mosaic" and "Terracotta" with high fidelity.
Quantitatively, STAM achieved a CLIP Alignment score of 27.91, the highest among tested training-free methods, indicating superior stylistic faithfulness. It also maintained a low LPIPS score (0.43), confirming its ability to preserve original content structure.
Computational Efficiency
One of STAM's most significant advantages is speed. By avoiding expensive latent tuning, it processes images in approximately 10.7 seconds on an NVIDIA RTX 3090. This is nearly five times faster than PnP (55.3s) and significantly more efficient than hybrid models like CSGO (18.4s).
Conclusion and Future Work
STAM provides a robust, efficient, and zero-shot solution for style transfer by leveraging the latent power of attention modulation. While the framework currently requires some manual hyperparameter selection for the $\gamma$ value, it sets a new standard for training-free image synthesis. Future research will focus on extending this attention modulation framework to video input, addressing the complex challenge of maintaining temporal consistency across stylized frames.
Summary updated