TL;DR
This paper addresses a fundamental issue in neural style transfer: the pre-trained encoders used often create a latent space where visual style is not accurately represented, leading to suboptimal results. The authors introduce two novel contrastive training schemes to refine these encoders, making them more style-consistent and better at preserving content details, significantly improving existing style transfer methods.
What Problem Does This Paper Address?
Neural style transfer (NST) aims to imbue a content image with the artistic style of a reference image. Modern NST methods typically rely on features extracted by a pre-trained convolutional neural network (like VGG-19) to represent both content and style. Style is often captured by the statistics of these features (e.g., Gram matrices). However, the authors observe a critical flaw: the "style distance" between images of different styles can be smaller than the distance between images of the same style within this pre-trained encoder's latent space. This means the encoder's representation is not aligned with human perception of style. Consequently, optimizing for style transfer in this "inappropriate latent space" can lead to visually inconsistent results. Furthermore, these pre-trained encoders can lose fine-grained content details, leading to "content leak" in the stylized output.
Methods
The core contribution of this paper is a novel contrastive training framework designed to refine the encoder used in style transfer. This framework consists of two main components:
- Style Contrastive Loss: This loss aims to make the encoder's latent space more "style-consistent." It works by treating the stylized output and the target style image as "positive" examples, pulling their representations closer in the latent space. Simultaneously, it pushes the representation of the original content image (and other negative examples) away. To create more robust positive examples, they employ a clever technique of spatially rearranging blocks of the style image, assuming these rearranged versions retain the style but have different content. This helps decouple style from content more effectively.
- Identity Preserve Content Contrastive Loss: To combat the "content leak" problem, this loss focuses on ensuring the encoder retains local details. It's a local-wise contrastive loss that compares image patches from the same spatial locations in the original content image and a restored version of it. By pulling these corresponding local features together and pushing apart features from different locations, the encoder is encouraged to preserve fine-grained structural information.
These contrastive losses are added to the existing style transfer objective function. The pre-trained encoder is fine-tuned, with the original pre-trained encoder acting as a feature regularizer to keep the new features within a reasonable scale.
Datasets
The paper uses standard datasets for training and evaluation:
- MS-COCO: Used for content images.
- WikiArt: Used for style images.
No new benchmarks are introduced; instead, the authors integrate their method with existing style transfer architectures and evaluate on these common datasets.
Key Insights and Ideas
- The "Inappropriate Latent Space" Problem: The most striking insight is that standard pre-trained encoders, while good for general image recognition, are not inherently optimized for representing visual style in a way that aligns with human perception. This misalignment is a root cause of many style transfer failures.
- Contrastive Learning for Style Alignment: The paper demonstrates that contrastive learning, a technique popular in self-supervised learning, can be effectively repurposed to align an encoder's latent space with perceptual style.
- De-coupling Style and Content: The proposed style contrastive loss, particularly with the use of spatially rearranged style images as positive examples, offers a novel way to disentangle style from content in the encoder's representations.
- Local Contrastive Loss for Content Preservation: The identity preserve content contrastive loss highlights the importance of local feature consistency for retaining fine details, addressing a common weakness in NST.
Key Results
The authors integrate their proposed training schemes into existing style transfer methods like AdaIN and SANet, demonstrating significant improvements:
- Qualitative Improvements: Stylized images produced by their enhanced methods show better style consistency and significantly less content loss compared to the original methods. Figures 4 and 5 visually showcase these improvements.
- User Study: A user study with 100 stylized images and 50 participants revealed that their method's outputs were significantly more preferred than those of the original methods (Table 1 shows preference scores, e.g., 0.377 for "Our SANet" vs. 0.242 for "SANet").
- Ablation Studies: Experiments confirmed the effectiveness of the style contrastive loss, showing that increasing the number of positive examples improves style embedding decoupling. Removing the style contrastive loss led to inconsistent style. Visualizations in Figure 8 also confirmed that their encoder preserves more fine-grained content details.
Limitations and Future Work
- Integration Dependency: The proposed training scheme needs to be added to existing encoder-decoder-based style transfer methods. It cannot be directly applied to optimization-based methods.
- Training Efficiency: Loading style positive examples during contrastive training can reduce overall training efficiency.
- Future Work: The authors suggest exploring a pre-training scheme to obtain an encoder that can be directly applicable to various style transfer tasks without needing to be fine-tuned for each specific method.
Summary updated