Type of software algorithm for image manipulation
Neural style transfer (NST) refers to a class of software algorithms that manipulate digital images, or videos, in order to adopt the appearance or visual style of another image. NST algorithms are characterized by their use of deep neural networks for the sake of image transformation. Common uses for NST are the creation of artificial artwork from photographs, for example by transferring the appearance of famous paintings to user-supplied photographs. Several notable mobile apps use NST techniques for this purpose, including DeepArt and Prisma. This method has been used by artists and designers around the globe to develop new artwork based on existent style(s).
History.
NST is an example of image stylization, a problem studied for over two decades within the field of non-photorealistic rendering. The first two example-based style transfer algorithms were image analogies and image quilting. Both of these methods were based on patch-based texture synthesis algorithms.
Given a training pair of images–a photo and an artwork depicting that photo–a transformation could be learned and then applied to create new artwork from a new photo, by analogy. If no training photo was available, it would need to be produced by processing the input artwork; image quilting did not require this processing step, though it was demonstrated on only one style.
NST was first published in the paper "A Neural Algorithm of Artistic Style" by Leon Gatys et al., originally released to ArXiv 2015, and subsequently accepted by the peer-reviewed CVPR conference in 2016. The original paper used a VGG-19 architecture that has been pre-trained to perform object recognition using the ImageNet dataset.
In 2017, Google AI introduced a method that allows a single deep convolutional style transfer network to learn multiple styles at the same time. This algorithm permits style interpolation in real-time, even when done on video media.
Mathematics.
This section closely follows the original paper.
Overview.
The idea of Neural Style Transfer (NST) is to take two images—a content image formula_1 and a style image formula_2—and generate a third image formula_3 that minimizes a weighted combination of two loss functions: a content loss formula_4 and a style loss formula_5.
The total loss is a linear sum of the two:formula_6By jointly minimizing the content and style losses, NST generates an image that blends the content of the content image with the style of the style image.
Both the content loss and the style loss measures the similarity of two images. The content similarity is the weighted sum of squared-differences between the neural activations of a single convolutional neural network (CNN) on two images. The style similarity is the weighted sum of Gram matrices within each layer (see below for details).
The original paper used a VGG-19 CNN, but the method works for any CNN.
Symbols.
Let formula_7 be an image input to a CNN.
Let formula_8 be the matrix of filter responses in layer formula_9 to the image formula_7, where:
A given input image formula_7 is encoded in each layer of the CNN by the filter responses to that image, with higher layers encoding more global features, but losing details on local features.
Content loss.
Let formula_20 be an original image. Let formula_7 be an image that is generated to match the content of formula_20. Let formula_23 be the matrix of filter responses in layer formula_9 to the image formula_20.
The content loss is defined as the squared-error loss between the feature representations of the generated image and the content image at a chosen layer formula_26 of a CNN:
formula_27
where formula_28 and formula_29 are the activations of the formula_30 filter at position formula_31 in layer formula_26 for the generated and content images, respectively. Minimizing this loss encourages the generated image to have similar content to the content image, as captured by the feature activations in the chosen layer.
The total content loss is a linear sum of the content losses of each layer: formula_33, where the formula_34 are positive real numbers chosen as hyperparameters.
Style loss.
The style loss is based on the Gram matrices of the generated and style images, which capture the correlations between different filter responses at different layers of the CNN:
formula_35
where
formula_36Here, formula_37 and formula_38 are the entries of the Gram matrices for the generated and style images at layer formula_26. Explicitly, formula_40
Minimizing this loss encourages the generated image to have similar style characteristics to the style image, as captured by the correlations between feature responses in each layer. The idea is that activation pattern correlations between filters in a single layer captures the "style" on the order of the receptive fields at that layer.
Similarly to the previous case, the formula_41 are positive real numbers chosen as hyperparameters.
Hyperparameters.
In the original paper, they used a particular choice of hyperparameters.
The style loss is computed by formula_42 for the outputs of layers codice_1, codice_2, codice_3, codice_4, codice_5 in the VGG-19 network, and zero otherwise. The content loss is computed by formula_43 for codice_6, and zero otherwise.
The ratio formula_44.
Training.
Image formula_45 is initially approximated by adding a small amount of white noise to input image formula_46 and feeding it through the CNN. Then we successively backpropagate this loss through the network with the CNN weights fixed in order to update the pixels of formula_45. After several thousand epochs of training, an formula_45 (hopefully) emerges that matches the style of formula_49 and the content of formula_46.
As of 2017[ [update]], when implemented on a GPU, it takes a few minutes to converge.
Extensions.
In some practical implementations, it is noted that the resulting image has too much high-frequency artifact, which can be suppressed by adding the total variation to the total loss.
Compared to VGGNet, AlexNet does not work well for neural style transfer.
NST has also been extended to videos.
Subsequent work improved the speed of NST for images by using special-purpose normalizations.
In a paper by Fei-Fei Li et al. adopted a different regularized loss metric and accelerated method for training to produce results in real-time (three orders of magnitude faster than Gatys). Their idea was to use not the "pixel-based loss" defined above but rather a 'perceptual loss' measuring the differences between higher-level layers within the CNN. They used a symmetric convolution-deconvolution CNN. Training uses a similar loss function to the basic NST method but also regularizes the output for smoothness using a total variation (TV) loss. Once trained, the network may be used to transform an image into the style used during training, using a single feed-forward pass of the network. However the network is restricted to the single style in which it has been trained.
In a work by Chen Dongdong et al. they explored the fusion of optical flow information into feedforward networks in order to improve the temporal coherence of the output.
Most recently, feature transform based NST methods have been explored for fast stylization that are not coupled to single specific style and enable user-controllable "blending" of styles, for example the whitening and coloring transform (WCT).
References.
 ;templatestyles src="Reflist/styles.css" / ;