Awesome
deep-transfer
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.
Installation
- Needed Python packages can be installed using
conda
package manager by runningconda env create -f environment.yaml
Functionalities
Available modalities are:
-
style transfer (inputs: a content image and a style image); <br><img src="outputs/pair-grid/grid-transfer.jpg" width="400" height="300" />
-
texture synthesis (inputs: a texture style image); <br><img src="outputs/pairtex-grid/grid-synthesis.jpg" width="400" height="300" />
-
style transfer interpolation (inputs: a content image and 2 style images); <br><img src="outputs/triplet-grid/grid-twostyles.jpg" width="600" height="300" />
-
texture synthesis interpolation (inputs: 2 texture style images); <br>
-
spatial control over stylization (inputs: a content image, a binary mask of the same size and 2 style images for background-foreground stylization). <br><img src="outputs/spatial-grid/grid-face_cubism-spatial.jpg" width="600" height="300" />
Usage
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 isoutputs/
);--outPrefix OUTPREFIX
name prefixed in the saved stylized images;--alpha ALPHA
hyperparameter balancing the blending between original content features and WCT-transformed features (default is0.2
);--beta BETA
hyperparameter balancing the interpolation between the two images in thestylePair
(default is0.5
;)--no-cuda
flag to enable CPU-only computations (default isFalse
i.e. GPU (CUDA) accelaration);--single-level
flag to use single-level stylization (default isFalse
).
Supported image file formats are: jpg, jpeg, png.