Abstract
StyleFormer is a novel real-time arbitrary style transfer (AST) framework that leverages a transformer-inspired architecture to compose style patterns. By representing styles as a compact bank of learnable parametric codes, it achieves a superior balance between fine-grained style detail and semantic content preservation, outperforming existing state-of-the-art methods in both visual quality and execution speed.
Introduction
Arbitrary Style Transfer (AST) aims to apply the artistic style of any reference image to a content image. Historically, this has been a "pick two" problem between quality, diversity, and speed. Optimization-based methods produce high-quality results but are too slow for real-time use. Feed-forward methods are fast but often rely on global statistics, leading to "washed out" details. Patch-based methods capture detail but often distort the underlying structure of the content image.
StyleFormer addresses the need for a method that is fast enough for high-resolution real-time applications (1024x1024) while maintaining the intricate "strokes" of an artist without breaking the shapes of the original photo.
Methodology
StyleFormer moves away from simple statistical matching and instead treats style transfer as a parametric composition problem using three main modules:
- Style Bank Generation: Instead of using the entire style feature map, the model extracts a sparse, compact set of "style codes." Each code consists of a Key (representing the pattern) and a Value (containing affine transformation parameters: scaling and shifting).
- Transformer-driven Style Composition: Using the Multi-Head Attention mechanism, the content features act as the Query, while the style bank provides the Keys and Values. This allows the model to "attend" to specific style patterns that best fit different regions of the content image.
- Parametric Content Modulation: The composed style codes are applied to the content features via group-wise affine transforms. A "guide map" is generated to help interpolate these transforms spatially, ensuring that the stylization is flexible but remains faithful to the content's edges and structures.
The system uses a fixed VGG-16 encoder to extract features and a learnable decoder to reconstruct the final stylized image.
Experimental Setup
The model was trained and evaluated using standard large-scale benchmarks:
- MS-COCO: Source content images (~80,000 images).
- WikiArt: Source style images (~80,000 artworks).
- User Study: A dataset of 100 content-style pairs was used for a comprehensive user preference study involving 57 participants and 1,140 total votes.
Results and Discussion
StyleFormer produces results that are more "painterly" and detailed than previous methods like AdaIN or WCT, while avoiding the messy artifacts of patch-swapping methods.
Quantitative and Qualitative Performance
- Visual Quality: The model successfully disentangles strokes and background. The affine matrix tends to capture detailed brushstrokes, while the bias vector captures the holistic background color.
- Style Loss: StyleFormer achieved a score of 1.14, lower (better) than all compared SOTA methods (e.g., STROTSS at 1.22, SANet at 1.41).
- User Preference: In a blind study, StyleFormer was preferred 30.79% of the time, nearly triple the preference of the next closest real-time method.
- Real-time Speed: The model processes a 1024x1024 image in just 0.071 seconds on a single Tesla V100 GPU.
Conclusion
StyleFormer demonstrates that treating style as a set of parameters rather than raw pixels allows for more precise and efficient stylization. While it relies on a fixed VGG-16 encoder and lacks explicit semantic knowledge, its parametric nature offers a robust foundation for real-time applications and future extensions like multi-style blending.
Summary updated