Scaling Painting Style Transfer

Bruno Galerne, Lara Raad, José Lezama, Jean-Michel Morel

Neural Style Transfer (NST) has come a long way since Gatys et al. first showed us how to blend Van Gogh’s brushstrokes with modern photographs. However, a persistent "memory wall" has long prevented these optimization-based methods from scaling to ultra-high resolution (UHR) images. While fast, feed-forward approximations exist, they often lose the fine-grained textures—the cracks in the paint and the weave of the canvas—that make a painting feel authentic.

In their paper "Scaling Painting Style Transfer," Galerne et al. introduce a way to bring the high-fidelity optimization of original NST to unprecedented scales, reaching resolutions as high as 20,000 x 20,000 pixels.

TL;DR

The authors propose a localized algorithm that enables optimization-based neural style transfer for ultra-high-resolution images by computing gradients block-by-block. This approach bypasses GPU memory limitations while maintaining the global statistics necessary for high-quality results, outperforming fast state-of-the-art methods in both quantitative fidelity and human perceptual studies.

What Problem Does This Paper Address?

Original NST works by minimizing a loss function that matches the "style" (global statistics like Gram matrices of VGG features) and "content" (local geometric features). The catch? Differentiating this loss requires storing the entire image and all intermediate feature maps in GPU memory. For a 4K image, this can easily exceed 40GB of VRAM, making UHR style transfer impossible for most hardware.

Existing solutions usually take one of two paths:

  1. Fast Approximations: Training feed-forward networks. These are fast but often produce "halos," color artifacts, and lack the complex multiscale textures of real paintings.
  2. Patch-based Methods: Processing small chunks of the image. These often suffer from visible seams or a "frequency mismatch" where the style doesn't scale correctly with the image size.

Methods

The core innovation is a two-pass localized gradient computation (Algorithm 1) that allows the model to "think globally but act locally."

1. Localized Neural Feature Calculation

Instead of loading the whole image, the algorithm partitions it into blocks (e.g., 512x512 pixels) with a 256-pixel margin to account for the VGG network's receptive field.

  • Pass 1: It computes global style statistics (Gram matrices, means, and standard deviations) by aggregating contributions from each block one by one.
  • Pass 2: It computes the loss gradient block-by-block. Crucially, the authors prove that the gradient of the style loss at a specific pixel depends only on the local feature value and the global statistics calculated in Pass 1.
Algorithm overview: The localized algorithm (right) emulates the global optimization (left) by processing blocks sequentially.

2. Multiscale Strategy

To capture everything from broad color palettes to tiny canvas textures, the authors use a coarse-to-fine approach across up to six scales. Each scale refines the details of the previous one, ensuring the brushstrokes look natural at any zoom level.

3. Augmented Style Loss

Beyond standard Gram matrices, the authors add explicit matching for the mean and standard deviation of feature channels. This simple correction significantly reduces contrast loss artifacts common in high-res synthesis.

Datasets

The authors evaluated their method using a set of 79 high-resolution paintings used as both content and style images. This formed the basis for their "identity test"—a sanity check where a method must reproduce a painting when given the same image for both content and style.

Key Insights and Ideas

  • Gradient Locality: The "aha moment" is the mathematical realization that while the style loss is global, its gradient is spatially localized once the global statistics are known. This is what allows for exact block-by-block processing without seams.
  • The Multiscale Necessity: For UHR images, a single-scale transfer is insufficient because VGG's receptive field is fixed. A multiscale approach is mandatory to ensure that "brushstrokes" scale proportionally with the image resolution.
  • Stability of Upscaling: The authors observed that style transfer is remarkably stable across scales. This allowed them to create SPST-fast, a variant that uses fewer optimization iterations at higher resolutions to save time without sacrificing much quality.
Figure 1: Ultra-high resolution multiscale style transfer. Top row from left to right: style (4226×5319), content (6048×8064), intermediary transfer at scale 1 (756×1008) and final transfer at scale 4 (6048×8064) (intermediary results at scale 2 (1512×2016) and 3 (3024×4032) are not shown). Bottom row: zoomed in detail of size 1024×1024 for the three UHR images and 128×128 for the low resolution transfer at scale 1. Our method produces a style transfer of unmatched quality for such high resolution. It effectively conveys a pictorial aspect to the output images thanks to fine painting details such as brushstrokes, painting cracks, and canvas texture.

Key Results

  • Resolution: The method successfully stylized images up to 20k x 20k pixels (400 megapixels) on an 80GB GPU by offloading some L-BFGS history to the CPU.
  • Perceptual Superiority: In a blind study with 61 experts, the proposed method (SPST-fast) was chosen as the best style reproduction over 90% of the time compared to leading fast methods like Collaborative Distillation (CD) and URST.
  • Quantitative Fidelity: In the "identity test," SPST achieved significantly higher SSIM and lower LPIPS scores than competitors, proving it stays much truer to the original painting's texture.

Limitations and Future Work

The primary drawback is speed. While fast methods take seconds, SPST takes minutes (e.g., ~74 minutes for a full 6k x 8k image, or ~13 minutes for the "fast" version).

The authors suggest that their high-quality results could serve as a "gold standard" for training future generations of fast, feed-forward UHR models. They also see potential in extending this localized gradient approach to video style transfer and neural radiance fields (NeRFs).

For those interested in the implementation, the source code is available on GitHub.

Summary updated

Abstract

Neural style transfer (NST) is a deep learning technique that produces an unprecedentedly rich style transfer from a style image to a content image. It is particularly impressive when it comes to transferring style from a painting to an image. NST was originally achieved by solving an optimization problem to match the global statistics of the style image while preserving the local geometric features of the content image. The two main drawbacks of this original approach is that it is computationally expensive and that the resolution of the output images is limited by high GPU memory requirements. Many solutions have been proposed to both accelerate NST and produce images with larger size. However, our investigation shows that these accelerated methods all compromise the quality of the produced images in the context of painting style transfer. Indeed, transferring the style of a painting is a complex task involving features at different scales, from the color palette and compositional style to the fine brushstrokes and texture of the canvas. This paper provides a solution to solve the original global optimization for ultra-high resolution (UHR) images, enabling multiscale NST at unprecedented image sizes. This is achieved by spatially localizing the computation of each forward and backward passes through the VGG network. Extensive qualitative and quantitative comparisons, as well as a \textcolor{coverletter}{perceptual study}, show that our method produces style transfer of unmatched quality for such high-resolution painting styles. By a careful comparison, we show that state-of-the-art fast methods are still prone to artifacts, thus suggesting that fast painting style transfer remains an open problem. Source code is available at https://github.com/bgalerne/scaling_painting_style_transfer.
BibTeX
@misc{galerne2022scaling,
  author = {Bruno Galerne and Lara Raad and José Lezama and Jean-Michel Morel},
  title = {{Scaling Painting Style Transfer}},
  year = {2022},
  eprint = {2212.13459},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2212.13459},
}
Figure