Abstract
Traditional image style transfer methods often rely on global feature statistics, which frequently results in the loss of spatial detail and the introduction of structural distortions. This paper presents the STyle TRansformer (STTR), a novel framework that treats style transfer as a sequence-to-sequence problem. By representing images as sequences of "visual tokens" and utilizing self- and cross-attention mechanisms, STTR achieves precise, fine-grained style mapping. The model learns semantic-level correspondences between content and style, preserving complex structures while avoiding common artifacts. Experimental results demonstrate that STTR outperforms existing methods in both qualitative visual quality and user preference studies, while maintaining real-time processing speeds.
Introduction
Image style transfer aims to synthesize an image that preserves the semantic content of a target image while adopting the artistic style of a reference image. Early breakthroughs in this field, such as AdaIN (Adaptive Instance Normalization) and WCT (Whiten and Color Transform), relied on matching global feature distributions—specifically the mean and variance of deep features. While computationally efficient, these "global" approaches often fail to capture local, fine-grained textures and can lead to a "washed-out" appearance or significant structural degradation.
Recent attempts to utilize Transformer architectures, such as StyTr², have sought to address these limitations. However, many still struggle with region-level artifacts due to shallow feature extraction. The STyle TRansformer (STTR) addresses these gaps by leveraging deep backbones and attention mechanisms to establish meaningful semantic correspondences between the content and style domains.
Methodology
The STTR architecture is comprised of a four-stage pipeline designed to facilitate adaptive, local style mapping:
1. Filter-based Tokenizer
Unlike standard Vision Transformers that split images into a simple grid of patches—often resulting in blocky artifacts—STTR employs a filter-based tokenizer. It utilizes two ResNet-50 backbones to extract features. The content backbone focuses on shallower layers to retain high-resolution spatial details, while the style backbone utilizes deeper layers to capture high-level semantic concepts. These features are then flattened into a sequence of visual tokens.
2. Transformer Encoder (Self-Attention)
The encoder applies self-attention to the style tokens. This process encourages tokens with similar semantic or textural meanings (e.g., specific brushstroke patterns or color clusters) to group together. This effectively organizes the style information into distinct semantic vectors, creating a structured "palette" for the transfer process.
3. Transformer Decoder (Cross-Attention)
The decoder acts as the core mapping engine. It uses content tokens as queries to perform a lookup against the style patterns organized by the encoder. This cross-attention mechanism allows for a highly local and adaptive mapping, ensuring that the style applied to a specific region of the content image is semantically appropriate.
4. CNN-based Reconstruction
Finally, the combined features are passed to a CNN-based decoder. This component upsamples the tokens and reconstructs the final stylized image at the original resolution, ensuring smooth transitions and visual coherence.
Experimental Setup
The model was trained using two large-scale datasets: MSCOCO for content images and WikiArt for style reference images, each containing approximately 80,000 samples. Training involved a multi-faceted loss function, including Euclidean distance in VGG-19 space for content preservation and a multi-level style loss based on mean and standard deviation across several VGG layers.
To evaluate performance, the authors conducted a large-scale user study on Amazon Mechanical Turk (AMT). Fifty subjects provided 1,000 total votes comparing STTR against several state-of-the-art baselines.
Results and Discussion
Qualitative Performance
STTR demonstrates a significant reduction in common style transfer artifacts. Specifically, it avoids "texture bleeding" (e.g., incorrectly applying ground textures to the sky) by maintaining semantic awareness. Because the model understands the difference between distinct objects (like a sail versus the sea), it applies style patterns more logically than global distribution-matching methods.
User Preference and Efficiency
In the AMT user study, STTR emerged as the most preferred method, capturing 19.6% of the votes. This outperformed other competitive models such as AAST (9.8%) and SANET (9.6%).
Despite the inherent complexity of Transformer architectures, STTR is optimized for real-time applications. It processes 512x512 images at approximately 4 frames per second (0.28s per image). This is significantly faster than optimization-based methods, which can take over 100 seconds per image. Furthermore, the method exhibits high temporal consistency, making it suitable for video style transfer with minimal flickering or motion blur.
Conclusion
The STyle TRansformer (STTR) represents a shift toward semantic-aware, fine-grained image synthesis. By moving beyond global statistics and utilizing the relational power of attention mechanisms, STTR preserves the integrity of content images while applying complex artistic styles. Future work will focus on extending the architecture to support multi-style blending and developing lightweight versions for mobile and edge deployment.
Summary updated