Skip to content

Implementation of the original paper on neural style transfer from Gatys et al.

License

Notifications You must be signed in to change notification settings

gcerar/pytorch-neural-style-transfer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neural Style Transfer

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).

Examples

Some of the hand picked results:

The green bridge + Walk in the rain The green bridge + Starry night The green bridge + Bronze leaf pattern The green bridge + Rainbow swirl Breakfast + Mosaic Breakfast + Bronze leaf lattern Nature + Candy Nature + Starry night

Setup

  1. Clone the repository git clone https://github.com/gcerar/pytorch-neural-style-transfer
  2. Enter directory cd pytorch-neural-style-transfer
  3. Run conda env create -f ./environment.yml
  4. Run conda activate style-transfer

It is recommended to use GPU to accelerate the style transfer process.

Usage

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)

Acknowledgment

Helpful articles with code and code repositories while writing my implementation:

Sample content images:

Gray Bridge and Trees
"Gray Bridge and Trees", Martin Damboldt

Style images to play with:

The Persistence of Memory Colorful whirlpool Mondrian World Map
"The Persistence of Memory", Salvador Dali Colorful whirlpool, ??? "Mondrian World Map", Michael Tompsett
Fractal Patterns The Scream Udnie
Fractal Patterns, ??? "The Scream", Edvard Munch "Udnie", Francis Picabia
Hand with Reflecting Sphere Bamboo forest Mysterious Rain Princess
"Hand with Reflecting Sphere", M. C. Escher Bamboo forest, ??? "Mysterious Rain Princess", Leonid Afremov
June tree La Muse Lady
"June tree", Natasha (Wescoat) Bouchillion "La Muse", Pablo Picasso "Lady", ???
Composition VII Walking in the Rain The Starry Night
"Composition VII", Wassily Kandinsky "Walking in the Rain", Leonid Afremov "The Starry Night", Vincent van Gogh
Edtaonisl Seated Nude The Night Café
"Edtaonisl", Francis Picabia "Seated Nude", Pablo Picasso "The Night Café", Vincent van Gogh
Under the Wave off Kanagawa Flowers Doomguy
"Under the Wave off Kanagawa", Katsushika Hokusai Flowers, ??? "Doomguy", ID Software

Releases

No releases published

Packages

No packages published

Languages