A Closed-form Solution to Universal Style Transfer

Ming Lu, Hao Zhao, Anbang Yao, Yurong Chen, Feng Xu, Li Zhang

Abstract

Universal style transfer enables the application of arbitrary artistic styles to content images through feed-forward neural networks. While existing methods like Adaptive Instance Normalization (AdaIN) and Whitening and Coloring Transform (WCT) have made significant strides, they often struggle with structural distortions or inadequate style representation. This paper introduces Optimal Style Transfer (OST), a theoretically grounded framework that reframes style transfer as an Optimal Transport problem between feature distributions. By deriving a unique closed-form solution that minimizes the "transportation cost" between content and style features, OST achieves superior stylization quality while maintaining the structural integrity of the original image.

Introduction

Neural Style Transfer (NST) has transitioned from the slow, optimization-based approach pioneered by Gatys et al. to efficient, "universal" feed-forward methods. These modern techniques rely on feature transforms—mathematical operations applied to the intermediate activations of a pre-trained encoder (typically VGG)—to align the statistics of a content image with those of a style image.

However, current universal transforms face a trade-off between speed, structural preservation, and stylization depth. AdaIN simplifies the problem by assuming feature channels are independent, which often fails to capture the complex correlations defining intricate textures. Conversely, WCT matches full covariance matrices but frequently introduces structural artifacts, as it lacks a theoretical constraint to preserve the original content's spatial layout. This paper addresses these gaps by providing a rigorous mathematical foundation for feature transformation based on Optimal Transport theory.

Methods: Optimal Style Transfer (OST)

The core innovation of this work is the treatment of feature activations as samples from Multivariate Gaussian (MVG) distributions. Style transfer is thus viewed as finding a linear transformation $T$ that maps the content distribution $\mathcal{N}(\mu_c, \Sigma_c)$ to the style distribution $\mathcal{N}(\mu_s, \Sigma_s)$.

The Optimal Transport Formulation

The authors observe that there are infinite transformations capable of matching these distributions. To identify the most effective one, they leverage Optimal Transport (OT). By imposing a constraint that minimizes the distance between the original content features and the transformed features (effectively a content loss), they derive a unique, closed-form solution for the transformation matrix $T$:

$$T = \Sigma_c^{-1/2} (\Sigma_c^{1/2} \Sigma_s \Sigma_c^{1/2})^{1/2} \Sigma_c^{-1/2}$$

This specific transformation represents the "shortest path" in the space of Gaussian distributions. By moving the features the minimum distance required to satisfy the style statistics, OST naturally preserves the underlying structure of the content image better than heuristic methods.

Multi-level Pipeline and Training

To capture both fine-grained textures and global stylistic patterns, the authors employ a multi-level pipeline. Features are extracted and transformed at multiple layers of a pre-trained VGG encoder (from layer 5 down to 1).

The decoders are trained on the MS-COCO dataset to reconstruct images from these transformed features. The training objective includes a reconstruction loss and a feature-level loss to ensure the decoder accurately interprets the modified latent space.

Key Results and Discussion

OST was evaluated against state-of-the-art methods through qualitative comparisons, quantitative metrics, and a comprehensive user study.

Qualitative and Quantitative Performance

Visual results demonstrate that OST avoids the "washout" effects and messy artifacts often seen in WCT outputs. It strikes a superior balance, producing images that are recognizably "stylized" while keeping the original objects sharp and clear. In a user study involving 50 participants and 560 images, OST achieved a mean score of 3.07, significantly outperforming WCT (2.67), AdaIN (2.00), and the original Gatys optimization (2.17).

Theoretical Unification

A significant contribution of this work is the unification of previous NST approaches. The authors show that AdaIN and WCT are essentially specific instances or variations within the broader Optimal Transport framework. This provides a theoretical bridge that explains why certain transforms work and how they can be optimized.

Efficiency and Limitations

While the matrix square root operations make OST slightly slower than the channel-wise AdaIN (4.06s vs 0.49s for a 512x512 image), it remains orders of magnitude faster than optimization-based methods (207s) and is comparable to WCT (3.47s).

Current limitations include temporal jitter in video applications—a common issue for frame-independent methods—and a reliance on the VGG encoder's ability to capture detail. Future work may explore more complex distribution models beyond Gaussians and the application of OT to other domain-adaptation tasks in computer vision.

Conclusion

Optimal Style Transfer provides a mathematically rigorous, closed-form solution to a long-standing problem in universal style transfer. By grounding the feature transformation in Optimal Transport theory, the authors have created a method that is not only theoretically elegant but also practically superior in preserving content structure while delivering rich stylistic expression.

Summary updated

BibTeX
@inproceedings{lu2019closed,
  author = {Ming Lu and Hao Zhao and Anbang Yao and Yurong Chen and Feng Xu and Li Zhang},
  title = {{A Closed-form Solution to Universal Style Transfer}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2019},
  doi = {10.1109/iccv.2019.00605},
}
Figure