Abstract
Transformer's recent integration into style transfer leverages its proficiency in establishing long-range dependencies, albeit at the expense of attenuated local modeling. This paper introduces Strips Window Attention Transformer (S2WAT), a novel hierarchical vision transformer designed for style transfer. S2WAT employs attention computation in diverse window shapes to capture both short- and long-range dependencies. The merged dependencies utilize the "Attn Merge" strategy, which adaptively determines spatial weights based on their relevance to the target. Extensive experiments on representative datasets show the proposed method's effectiveness compared to state-of-the-art (SOTA) transformer-based and other approaches.
Introduction
Image style transfer is the artistic process of applying the aesthetic of a style image to the structural content of another image. While early methods relied on Convolutional Neural Networks (CNNs), recent research has shifted toward Vision Transformers (ViTs) due to their superior ability to model long-range dependencies. However, efficient ViT variants, such as those using window-based attention (e.g., Swin Transformer), often introduce "grid-like" artifacts or blocky textures in stylized outputs. This "locality problem" arises because information flow is restricted within fixed window boundaries.
The Strips Window Attention Transformer (S2WAT) is designed to overcome these limitations. By employing a hierarchical architecture and a novel attention mechanism, S2WAT captures both fine-grained local textures and broad artistic context without sacrificing computational efficiency.
Methodology
S2WAT utilizes a hierarchical encoder-transfer-decoder framework. The innovation lies in two primary components: the Strips Window Attention and the adaptive Attn Merge strategy.
Strips Window Attention (SpW)
To break the limitations of fixed square windows, SpW computes attention in three distinct shapes simultaneously: horizontal strips, vertical strips, and square windows. Horizontal and vertical strips allow the model to capture dependencies across the entire width and height of the image in a single step. This "cross-shaped" attention effectively erases the artificial boundaries created by standard windowing, leading to smoother transitions and more coherent artistic patterns.
Adaptive Attn Merge
Merging features from different window shapes requires more than simple summation. S2WAT introduces the Attn Merge strategy, an adaptive fusion mechanism that calculates spatial correlation scores. This allows the model to dynamically weight the importance of each window shape for specific image regions—for instance, prioritizing horizontal strips for horizons and square windows for intricate local textures.
Experimental Results
The model was trained using the MS-COCO dataset for content and WikiArt for style. Evaluation focused on both quantitative metrics and qualitative visual quality.
Quantitative Performance
S2WAT outperforms existing SOTA methods across several key metrics:
- Content Loss: Achieved a score of 1.66, the lowest among compared models, indicating superior preservation of the original image structure.
- Structural Similarity (SSIM): Earned the highest score of 0.651, confirming its ability to maintain the "bones" of the content image.
- Human Preference: In a user study involving 72 participants, S2WAT received 25.4% of the votes, surpassing the previous leader, StyTr2 (23.6%).
Qualitative Analysis
Visually, S2WAT excels at preserving sharp details that other models often blur, such as text on signs or fine facial features. The resulting images are free from the blocky artifacts common in other window-based Transformer architectures.
Conclusion
S2WAT represents a significant step forward in Transformer-based style transfer. By integrating multi-shape strip windows with an adaptive merging strategy, it effectively resolves the locality problem while maintaining high efficiency. Future research will focus on reducing "content leak" during iterative stylization and further optimizing the model for ultra-high-resolution image processing.
Summary updated