Package: pastiche
pasticheA PyTorch-based Python implementation of Neural Style Transfer [1].FeaturesSupport for saving intermediate images during optimizationAn option for preserving colors from the content imageMultiple-device computation (--supplemental-device)Style transfers utilizing multiple style imagesInstallationRequirementsPython 3.6 or greaterInstall$pip3installpasticheUpdate$pip3install--upgradepasticheUsageThe program is intended to be used from the command line.The general command line usage is shown below.$pastiche--contentCONTENT--stylesSTYLE[STYLE...]--outputOUTPUTCONTENTis the path to the content image,STYLEis the path to the style image, andOUTPUTis the path to save
the synthesized pastiche PNG file.If the launcher script was not installed within a directory on your PATH, pastiche can be launched by passing its
module name to Python.$python3-mpastiche--contentCONTENT--stylesSTYLE[STYLE...]--outputOUTPUTThere are various options, including but not limited to:Devices (GPU, CPU, and/or a multi-device assortment)Number of optimization iterationsVGG layers to utilizeLoss function term weightsFor the full list of options and the corresponding documentation, see the source code or use--help.$pastiche--helpExampleThe image above was generated by applying the style from Vincent van Gogh'sThe Starry Nightto a photo I took in
Boston in 2015. The high-resolution image was generated incrementally, with increasing resolution, using the
coarse-to-fine approach described in [2]. Example commands are shown below. Depending on GPU memory availability, the
commands may necessitate execution partially on a CPU (e.g.,--device cuda:0 --supplemental-device cuda:1 10 --supplemental-device cpu 20would configure GPU 0 for layers 0 through 9, GPU 1 for layers 10 through 19, and the
CPU for layers 20 through 36).$pastiche\--devicecuda\--num-steps2000\--contentboston.jpg\--stylesvangogh_starry_night.jpg\--outputpastiche0.png

$pastiche\--devicecuda\--size1024\--num-steps1000\--initpastiche0.png\--contentboston.jpg\--stylesvangogh_starry_night.jpg\--outputpastiche1.png# Split the computation across a GPU (layers 0 through 5 and 10 through 19), another GPU (layers 6# through 9), and a CPU (layers 20 through 36). This device strategy is for the purpose of# illustration. Tuning would be required for an actual device setup.$pastiche\--devicecuda:0\--supplemental-devicecuda:16\--supplemental-devicecuda:010\--supplemental-devicecpu20\--info-step10\--size2048\--num-steps500\--initpastiche1.png\--contentboston.jpg\--stylesvangogh_starry_night.jpg\--outputpastiche2.png# Split the computation across a GPU (layers 0 through 3) and CPU (layers 4 through 36). This# device strategy is for the purpose of illustration. Tuning would be required for an actual# device setup.$pastiche\--devicecuda\--supplemental-devicecpu4\--info-step1\--size4096\--num-steps100\--initpastiche2.png\--contentboston.jpg\--stylesvangogh_starry_night.jpg\--outputpastiche3.png

$convertpastiche3.pngpastiche.jpg# requires ImageMagickThe--preserve-coloroption can be used to retain colors from the content image. The image below was generated
using the same commands as above (up to--size 2048), with the addition of--preserve-color.LicenseThe source code has anMIT License.SeeLICENSE.References[1] Gatys, Leon A., Alexander S. Ecker, and Matthias Bethge. "A Neural Algorithm of Artistic Style."
ArXiv:1508.06576 [Cs, q-Bio], August 26, 2015.http://arxiv.org/abs/1508.06576.[2] Gatys, Leon A., Alexander S. Ecker, Matthias Bethge, Aaron Hertzmann, and Eli Shechtman.
"Controlling Perceptual Factors in Neural Style Transfer." ArXiv:1611.07865 [Cs], November 23, 2016.http://arxiv.org/abs/1611.07865.