This is a Pytorch implementation of the "Universal Style Transfer via Feature Trasforms" NIPS17 paper.
Given a content image and an arbitrary style image, the program attempts to transfer the visual style characteristics extracted from the style image to the content image generating stylized ouput.
The core architecture is a VGG19 Convolutional Autoencoder performing Whitening and Coloring Transformation on the content and style features in the bottleneck layer.
conda
package manager by running conda env create -f environment.yaml
Available modalities are:
style transfer (inputs: a content image and a style image);
texture synthesis (inputs: a texture style image);
style transfer interpolation (inputs: a content image and 2 style images);
texture synthesis interpolation (inputs: 2 texture style images);
spatial control over stylization (inputs: a content image, a binary mask of the same size and 2 style images for background-foreground stylization).
python main.py ARGS
Possible ARGS are:
-h, --help
show this help message and exit;--content CONTENT
path of the content image (or a directory containing images) to be trasformed;--style STYLE
path of the style image (or a directory containing images) to use;--synthesis
flag to syntesize a new texture. Must also provide a texture style image;--stylePair STYLEPAIR
path of two style images (separated by ",") to combine together;--mask MASK
path of the binary mask image (white on black) to use to trasfer the style pair in the corrisponding areas;--contentSize CONTENTSIZE
reshape content image to have the new specified maximum size (keeping aspect ratio);--styleSize STYLESIZE
reshape style image to have the new specified maximum size (keeping aspect ratio);--outDir OUTDIR
path of the directory where stylized results will be saved (default is outputs/
);--outPrefix OUTPREFIX
name prefixed in the saved stylized images;--alpha ALPHA
hyperparameter balancing the blending between original content features and WCT-transformed features (default is 0.2
);--beta BETA
hyperparameter balancing the interpolation between the two images in the stylePair
(default is 0.5
;)--no-cuda
flag to enable CPU-only computations (default is False
i.e. GPU (CUDA) accelaration);--single-level
flag to use single-level stylization (default is False
).Supported image file formats are: jpg, jpeg, png.