Convolutional Neural Networks and Neural Style Transfer

Convolutional Neural Networks (otherwise known as CNNs) are becoming increasingly powerful in their capabilities to recognize complex features such as faces in images. Recently, a CNN released for Google Photos can categorize images by comparing similar faces between the photos and dropping them into categories such as those of your pets, those taken during the holidays and of food. However, for those more art inclined or challenged, there is another feature that convolutional neural networks can do.

Have you ever wanted to paint like Van Gogh or Picasso?

With the power of neural style transfer, convolutional neural networks can finally visualize a provided input image in the style of your favorite artist with no experience necessary.

Demonstration of Neural Style Transfer between a content image and style image.
An example of Neural Style Transfer. The content image [the author of PyImageSearch] and the style image [Starry Night] are combined to form the style transfer.

Neural style transfer involves three figures. The first is the content image, the picture that you would like to colorize. The second is the style image, the picture you would like to copy the style from. Thousands of images are available from artists in any art form, ranging from cubism to impressionism and you are free to use whatever genre you would like for the style. Finally, there is the input/output image, which gets stylized as the process occurs.

Neural style transfer is usually done with the VGG19 CNN, which is the second best convolutional neural network that one can use to recognize images. Similar to regression, the CNN computes a loss function (i.e MSE) on the feature maps (lines, curves and polygons) of the content image and output image to measure the differences between the two and adds features accordingly using backpropagation. In addition, the CNN also computes the loss of the style image and the output image using the Gram Matrix (the dot product of the image pixel vectors) to add the style using backpropagation.

Neural style transfer as done by a Keras VGG19 CNN.
The process of neural style transfer in real time.

Altogether, with just an intermediate degree in machine learning frameworks, you can let the computer digitally create the art of your dreams, no experience necessary. As convolutional neural networks evolve and researchers find new ways to optimize them, they might bridge into a task you might not have even thought before.



Leave a Comment

Your email address will not be published. Required fields are marked *