Fast neural style transfer II.- 2 mins
Updates on previous posts
Fast neural style transfer
Since I already wrote a blog post about fast neural style transfer I’ll just sum up the main idea here quickly. Taking a transform network and a loss network jointly where only the weights of the transform network is updated. After convergence the transfrom model can be used in a feed-forward manner to generate stilizied images.
To make the content resamble the output image we simple take the Euclidian squared distance between the extracted feautres from the original image and the transformed image .
The style loss is a bit trickier. Since we want to keep the style of the style image and not its spatial features we drop spatial structure in a way that was introduced in the original neural style transfer paper the Gram matrix:
Where is a feature map extracted at some intermediate layer from the loss network. Given these Gram-metrices from several intermediate layers we can take the Forbenius-norm of the difference between the Gram-matrix of the style image through the loss net and the transformed image thourgh the loss net.
To train the network with the
pipenv shell pipenv install pipenv run python train.py --starry_night --width=<width_int> --height=<height-int>
- Heidelberg - images
- Outside scene with friends
- Mount Vesuvio’s inside
There are some burn-out probably due to the original images I’ve taken because the transfer model cannot handle the extreme pixel values. In the Van Gogh stilizied images the whites are overexposed while in the Picasso stilizied images the sky seems to mess with algorithm.
My implementation is available here