The repository contains PyTorch implementation of the Gatys et al. paper with some modifications. In the paper, the authors proposed algorithm that transfers style from one input image (the style image) into second image (the content image).
Some of the hand picked results:
- Clone the repository
git clone https://github.com/gcerar/pytorch-neural-style-transfer
- Enter directory
cd pytorch-neural-style-transfer
- Run
conda env create -f ./environment.yml
- Run
conda activate style-transfer
It is recommended to use GPU to accelerate the style transfer process.
python style_transfer.py --input <TargetImgPath> --style <StyleImgPath>
Optional parameters:
--help
or-h
print help with all available parameters--epochs <number>
(default: 7000)--seed <number>
(default: 1)--no-cuda
disables CUDA acceleration and use CPU instead--optimizer <adam|adamw|lbfgs|sgd>
(default: adam)--init <input|noise>
decide on what is init of output image (default: input)
Helpful articles with code and code repositories while writing my implementation:
- Gregor Koehler et al. gkoehler/pytorch-neural-style-transfer (best resource in my opinion)
- Ritul's Medium article (good resource)
- Pragati Baheti blog visually present style extraction
- Aleksa Gordić (gordicaleksa/pytorch-neural-style-transfer)
- ProGamerGov/neural-style-pt
- Katherine Crowson (rowsonkb/style-transfer-pytorch)
- Derrick Mwiti's Medium article
- Aman Kumar Mallik's Medium article
Sample content images:
"Gray Bridge and Trees", Martin Damboldt |
Style images to play with:
"The Persistence of Memory", Salvador Dali | Colorful whirlpool, ??? | "Mondrian World Map", Michael Tompsett |
Fractal Patterns, ??? | "The Scream", Edvard Munch | "Udnie", Francis Picabia |
"Hand with Reflecting Sphere", M. C. Escher | Bamboo forest, ??? | "Mysterious Rain Princess", Leonid Afremov |
"June tree", Natasha (Wescoat) Bouchillion | "La Muse", Pablo Picasso | "Lady", ??? |
"Composition VII", Wassily Kandinsky | "Walking in the Rain", Leonid Afremov | "The Starry Night", Vincent van Gogh |
"Edtaonisl", Francis Picabia | "Seated Nude", Pablo Picasso | "The Night Café", Vincent van Gogh |
"Under the Wave off Kanagawa", Katsushika Hokusai | Flowers, ??? | "Doomguy", ID Software |