[Paper Review] StyTr$^2$: Image Style Transfer with Transformers
StyTr^2 introduces a transformer-based style transfer framework with two domain-specific encoders (content and style) and a content-aware positional encoding (CAPE), achieving better content preservation and style fidelity than CNN- and flow-based methods.
The goal of image style transfer is to render an image with artistic features guided by a style reference while maintaining the original content. Owing to the locality in convolutional neural networks (CNNs), extracting and maintaining the global information of input images is difficult. Therefore, traditional neural style transfer methods face biased content representation. To address this critical issue, we take long-range dependencies of input images into account for image style transfer by proposing a transformer-based approach called StyTr$^2$. In contrast with visual transformers for other vision tasks, StyTr$^2$ contains two different transformer encoders to generate domain-specific sequences for content and style, respectively. Following the encoders, a multi-layer transformer decoder is adopted to stylize the content sequence according to the style sequence. We also analyze the deficiency of existing positional encoding methods and propose the content-aware positional encoding (CAPE), which is scale-invariant and more suitable for image style transfer tasks. Qualitative and quantitative experiments demonstrate the effectiveness of the proposed StyTr$^2$ compared with state-of-the-art CNN-based and flow-based approaches. Code and models are available at https://github.com/diyiiyiii/StyTR-2.
Motivation & Objective
- Address content-biased representations in CNN-based style transfer by capturing long-range dependencies.
- Propose a dual-transformer encoder architecture to separately model content and style domains.
- Introduce CAPE (content-aware positional encoding) to achieve scale-invariant, semantics-driven encoding for images.
- Enable progressive stylization through a transformer decoder and a CNN upsampling decoder for high-resolution outputs.
- Demonstrate superior qualitative and quantitative performance against state-of-the-art methods.
Proposed method
- Split content and style images into patches and project them into sequential embeddings.
- Use two transformer encoders to extract domain-specific content and style representations.
- Apply a multi-layer transformer decoder to translate the content sequence according to the style sequence.
- Introduce CAPE to provide scale-invariant, semantics-aware positional encoding conditioned on content.
- Use a CNN-based upsampling decoder to produce high-resolution stylized outputs.
- Optimize with perceptual content/style losses and identity losses to preserve content and style.
Experimental results
Research questions
- RQ1Can a dual-transformer (content and style encoders) better model relationships between content and style than CNN-based encoders?
- RQ2Does content-aware positional encoding (CAPE) improve scale invariance and stylization quality for variable image resolutions?
- RQ3How does StyTr^2 perform in preserving content structures while applying diverse style references compared with state-of-the-art methods?
- RQ4What is the impact of the proposed losses (content, style, identity) on content preservation and style fidelity?
Key findings
- StyTr^2 achieves lower content loss than competing methods (with IEST as second-best) and competitive style loss, indicating strong content preservation and style adherence.
- Qualitative results show StyTr^2 yields well-preserved content structures and desirable style patterns, reducing common artifacts seen in CNN- and flow-based approaches.
- A user study with 100 participants and 4,000 votes indicates StyTr^2 is preferred for overall quality, content preservation, and style consistency over several baselines.
- Content leak is mitigated with the transformer-based architecture, maintaining sharp content details across multiple stylization rounds.
- CAPE demonstrates improved robustness to image scale changes and repetitive patterns compared with sinusoidal positional encoding.
- The study demonstrates StyTr^2’s superior balance of content fidelity and stylistic alignment compared with multiple CNN- and transformer-based baselines.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.