In this repository I aim to give a brief description and demonstration of the approach to neural style transfer described by Kolkin, Salavon, and Shakhnarovich in their 2019 article Style Transfer by Relaxed Optimal Transport and Self-Similarity.
The implementation I use here is part of my python package
nstesia
and can be found in its
module kolkin_2019
.
Note
There are two simple ways to run the demo notebook yourself without installing any software on your local machine:
- View the notebook on GitHub and click the Open in Colab button (requires a Google account).
- Create a GitHub Codespace for this repository and run the notebook in VSCode (requires a GitHub account & access to the Codespaces GPU Beta).
Kolkin's approach to neural style transfer is optimization based: Given a
content image
where the parameter
Denote by [H,W,3]
as input and produces a feature
tensor [H,W,C]
as output. This feature tensor
consists of the feature responses for a subset of layers of the VGG16 network,
linearly upsampled to the spatial dimensions of the image and concatenated
along the channels axis. Below, I will use a bar over a tensor to denote its
flattened version, e.g., I will write [H*W,3]
, and I will use the shorthand notation
Let
The REMD loss
between the style and pastiche feature tensors with respect to the cosine
distance
The color matching loss
this time for the style and pastiche image tensors and with respect to the
euclidian distance
The moment matching loss
where, for a feature tensor [N,C]
, [C]
and [C,C]
.
Finally, the content loss
where
To try Kolkin's optimal transport based approach to neural stylization, have a
look at the notebook style-transport.ipynb
. The
images below were produced using it.
Note The images included here are lower quality jpeg files. I have linked them to their lossless png versions.
This first image shows a range of stylization for various different values of the content weight parameter. Kolkin implemented guided transfer, something I plan to add to my implementation in the future. With it, one could significantly improve these stylizations.
The following are two sets of stylizations of the same content images in the
same styles as used to demonstrate various other style transfer methods. See,
e.g., my repositories
johnson-fast-style-transfer
,
dumoulin-multi-style-transfer
, and
ghiasi-arbitrary-style-transfer
.
Note that Kolkin's approach to neural stylization seems to transfer style image patches. The method works very well for some content/style combinations while requiring careful parameter tuning for others. E.g., in the first style below (Petitjean's femmes au bain) a lower content weight or lower learning rate should significantly improve the stylization.