Srikanth Pagadala

Fun: Style Transfer

04 Feb 2017

Style transfer allows you to take famous paintings, and recreate your own images in their styles! The network learns the underlying techniques of those paintings and figures out how to apply them on its own. This model was trained on the styles of famous paintings and is able to transfer those styles to other images and even videos!

The network has been trained on a few different styles (here) and saved into checkpoint files. Checkpoint files contain all the information about the trained network to apply styles to new images.

I used it to style our family dog Daphne in various styles

collage

To try it out yourself, you can find the code in the fast-style-transfer repo.

Transferring styles

  • Download the Zip archive from the fast-style-transfer repository and extract it. .
  • Download the Rain Princess checkpoint from here. Put it in the fast-style-transfer folder. A checkpoint file is a model that already has tuned parameters. By using this checkpoint file, we won’t need to train the model and can get straight to applying it.
  • Copy the image you want to style into the fast-style-transfer folder.
  • In your terminal, navigate to the fast-style-transfer folder and enter python evaluate.py --checkpoint ./rain-princess.ckpt --in-path <path_to_input_file> --out-path ./output_image.jpg

Note: Be careful with the size of the input image. The style transfer can take quite a while to run on larger images.