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.
- Needed Python packages can be installed using
condapackage manager by runningconda env create -f environment.yaml
Available modalities are:
-
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, --helpshow this help message and exit;--content CONTENTpath of the content image (or a directory containing images) to be trasformed;--style STYLEpath of the style image (or a directory containing images) to use;--synthesisflag to syntesize a new texture. Must also provide a texture style image;--stylePair STYLEPAIRpath of two style images (separated by ",") to combine together;--mask MASKpath of the binary mask image (white on black) to use to trasfer the style pair in the corrisponding areas;--contentSize CONTENTSIZEreshape content image to have the new specified maximum size (keeping aspect ratio);--styleSize STYLESIZEreshape style image to have the new specified maximum size (keeping aspect ratio);--outDir OUTDIRpath of the directory where stylized results will be saved (default isoutputs/);--outPrefix OUTPREFIXname prefixed in the saved stylized images;--alpha ALPHAhyperparameter balancing the blending between original content features and WCT-transformed features (default is0.2);--beta BETAhyperparameter balancing the interpolation between the two images in thestylePair(default is0.5;)--no-cudaflag to enable CPU-only computations (default isFalsei.e. GPU (CUDA) accelaration);--single-levelflag to use single-level stylization (default isFalse).
Supported image file formats are: jpg, jpeg, png.

