Domain Enhanced Arbitrary Image Style Transfer via Contrastive Learning

Yuxin Zhang, Fan Tang, Weiming Dong, Haibin Huang, Chongyang Ma, Tong-Yee Lee, Changsheng Xu

Introduction

Neural Style Transfer (NST) has traditionally relied on second-order statistics—such as Gram matrices or mean and variance—to represent artistic style. While these heuristic descriptors effectively capture simple textures, they often fail to encapsulate the "soul" of a painting. Artistic elements like specific brushstroke techniques, intentional use of negative space, and complex global layouts are frequently lost, resulting in "muddy" outputs or repetitive patterns where the unique characteristics of the reference style are diminished.

To address these limitations, we present CAST (Contrastive Arbitrary Style Transfer). CAST shifts the paradigm from predefined mathematical summaries to a learning-based approach. By utilizing contrastive learning, the model learns to identify style by comparing similarities and differences across a vast corpus of artworks, capturing nuances that statistical methods typically overlook.

The CAST Framework

The CAST architecture is built upon an encoder-transformation-decoder backbone, designed for arbitrary style transfer. It introduces three primary innovations:

1. Multi-layer Style Projector (MSP)

Traditional methods often extract features from a single layer of a pre-trained network. In contrast, the MSP projects features from multiple layers into distinct latent style spaces. This hierarchical approach enables the model to capture a spectrum of stylistic cues, ranging from fine-grained local details (e.g., individual pencil strokes) to global compositional elements (e.g., color palettes and spatial arrangements).

2. Contrastive Style Learning

The core of CAST lies in its use of contrastive learning to define style. Rather than calculating a fixed statistic, the model is trained to maximize the similarity between a style image and its augmented versions (positive samples) while minimizing similarity to unrelated styles (negative samples). This "learning by comparison" allows the network to autonomously discover the unique characteristics of a style without human-defined heuristics.

3. Domain Enhancement (DE)

Bridging the gap between realistic photographs and artistic paintings is a significant challenge. CAST employs a Domain Enhancement strategy using an adversarial setup. Two discriminators—one focused on the realistic domain and the other on the artistic domain—guide the generator to navigate the significant gap between photos and paintings, ensuring the output authentically adopts the artistic domain's characteristics.

Experimental Setup

The model was trained using two primary datasets:

  • WikiArt: A collection of 100,000 images across various artistic styles, with 20,000 images sampled for training.
  • Places365: A dataset of 20,000 images representing diverse natural scenes for the realistic content domain.

CAST was benchmarked against several state-of-the-art (SOTA) methods, including AdaAttN, SANet, and IEST.

Results and Discussion

Qualitative Performance

Visual evaluations demonstrate that CAST effectively avoids common artifacts such as the repetitive patterns seen in SANet or the color distortions prevalent in IEST. Notably, CAST excels in handling "negative space"—a hallmark of styles like Chinese ink wash painting (e.g., the works of Baishi Qi). While statistical methods attempt to fill every pixel with texture, CAST recognizes that emptiness can be a deliberate stylistic choice.

Quantitative Metrics

In a "Turing-style" deception test, a VGG-19 network was trained to classify real artist styles. CAST achieved a 62.00% deception rate, significantly outperforming the next best method, IEST (56.42%). This indicates that CAST's outputs are more frequently indistinguishable from genuine artwork by automated classifiers.

Efficiency

Despite its sophisticated training logic, CAST maintains high inference efficiency. On an NVIDIA RTX 3090, the model processes images in approximately 11ms, making it highly suitable for real-time style transfer applications.

Conclusion and Future Work

CAST represents a significant step forward in arbitrary style transfer by treating style as a relative, learnable concept rather than a fixed mathematical property. By leveraging contrastive learning and multi-layer projections, it captures the structural and stylistic nuances of diverse art forms more effectively than previous methods.

While successful, the framework currently relies on a large dictionary of negative samples (4,096), which increases the memory footprint during training. Future work will explore incorporating semantic awareness—such as specific object categories or artist-specific information—to further refine the style representation.

Summary updated

BibTeX
@inproceedings{zhang2022domain,
  author = {Yuxin Zhang and Fan Tang and Weiming Dong and Haibin Huang and Chongyang Ma and Tong-Yee Lee and Changsheng Xu},
  title = {{Domain Enhanced Arbitrary Image Style Transfer via Contrastive Learning}},
  booktitle = {SIGGRAPH (Conference Paper Track)},
  year = {2022},
}
Figure