Skip to content

Train neural networks to generate watercolour paintings from pencil sketches.

License

Notifications You must be signed in to change notification settings

yingzwang/pix2pix-watercolor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Watercolor paintings by neural networks

I trained neural networks to generate watercolor paintings from pencil sketches. The input is a pencil sketch drawn by me, and the outputs are watercolor paintings generated by neural networks. See an example below:

Observe how GAN learns to paint

GAN initially generates grayish and noisy pixels, and gradually comes up with more colors and details. See an example below:

It is interesting that the learning process of GAN resembles the actual watercolor painting process: start with flat and smooth colors over large areas, and then add more shades and details.

GAN is difficult to train because the loss curves often look weird. For tuning hyper parameters it is helpful (and fun) to watch the generated paintings during training. It seems that if the learning process resembles more the natural painting process, then it results in a better model that can generate better looking paintings in testing phase.

pix2pix

This image-to-image transfer idea (also known as "pix2pix") is proposed by: Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, Alexei A. Efros. Image-to-Image Translation with Conditional Adversarial Networks. CVPR 2017.

It designs a conditional variant of generative adversarial networks (GAN) to learn a mapping from input images to output images. Some example applications from the original "pix2pix" paper:

Tensorflow implementation

The implementation is based on the Tensorflow port by Christopher Hesse. I made the following changes,

  • GAN Discriminator: Multiply discriminator loss by 0.5, as suggested in the original paper. The discriminator tends to learn too fast. Slowing it down indeed improves my results.
  • GAN Generator: Add one more layer in encoder and one more layer in decoder, to work with larger images. My training set is very limited, and learning from higher resolution image helps.
  • Some clean-up to make the code more “light weight” for my application.

Prerequisites

  • Tensorflow 1.9.0

Recommended

  • Linux with Tensorflow GPU edition + cuDNN