Assignment #4 - Neural Style Transfer

In this assignment, I will implement neural style transfer which resembles specific content in a certain artistic style. For example, generate cat images in Ukiyo-e style. The algorithm takes in a content image, a style image, and another input image. The input image is optimized to match the previous two target images in content and style distance space.

Part 1: Content Reconstruction

Effect of optimizing content loss at different layers:

Original Imagelayer: conv_2layer: conv_4
layer: conv_6layer: conv_7layer: conv_8
layer: conv_10layer: conv_12layer: conv_14

Here the conv naming convention is defined in a way that the smaller the number the closer it is to the end of the network. i.e, conv_2 is last second conv layer of the VGG.

As we can see, content loss after conv_2 and conv_4 work the best.

 

Take two random noises as two input images, optimize them only with content loss:

NoiseReconstructed ImageContent Image

 

Part 2: Texture Synthesis

Effect of optimizing texture loss at different layers.

Looking at the below results I used conv_1, conv_2, conv_3, conv_4, conv_5.

Original Imagelayer: conv 1,2,3,4,5layer: conv 1,2,4,7,11
layer: conv 1,3,5,7,9layer: conv 2,4,6,8,10layer: conv 3,6,9,12,15

Random noises as two input images, optimize them only with style loss.

NoiseSynthesized ImageStyle Image

 

Part 3: Style Transfer

Hyper-parameters Tuning

Hyper PrametersRandom InitializationContent based Initialization
style weight: 1
style weight : 1000
style weight: 1e6
style weight: 1e9
style weight: 1e12

As we can see content based initialization with style weight 100000 gives us the best result.

 

More Style transfer results:

Style Images >>
Content Images    

 

Random Noise VS Content Image

Content ImageStyle ImageRandom InitializationContent based Initialization
  Inference time: 16.5 secsInference time: 11.23 secs

 

Style transfer on some of your favourite images.

Content ImageStyle ImageStylized Image
pixelsstarry_night

 

 

Bells & Whistles (Extra Points)

Stylized grump cats

Content ImageStyle ImageStylized Image