
Fast Neural Style Transfer
Diffusion and generative54 ops1.7M params
A feed-forward image transformation network trained with perceptual losses for real-time style transfer.
Diffusion and generative · 64 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
This is the PyTorch project's own example reimplementation from pytorch/examples.
About this model's family
Fast Neural Style is the network that made artistic style transfer run in real time: a convolutional image transformation network in which a feed-forward network is trained to solve the optimization problem proposed by Gatys et al in real-time. The idea is to change the training signal rather than the architecture: instead of a per-pixel loss, the network is trained with perceptual loss functions based on high-level features extracted from pretrained networks. Compared to the optimization-based method, the network gives similar qualitative results but is three orders of magnitude faster.
Those features come from a pretrained VGG-16 loss network that is used only in training; the graph here is the transformation network. The transformation network has no pooling layers, instead using strided and fractionally strided convolutions for in-network downsampling and upsampling. Its body consists of five residual blocks, and other than the first and last layers which use 9 × 9 kernels, all convolutional layers use 3 × 3 kernels. The output layer uses a scaled tanh to ensure that the output image has pixels in the range [0, 255]. For style transfer the input and output are both color images of shape 3 × 256 × 256, which is the size traced here.
Two copies are captured: the authors' original repository, which also includes an implementation of instance normalization, a simple trick that significantly improves the quality of feedforward style transfer models. The second is the PyTorch project's own example, listed in pytorch/examples under Implement the Neural Style Transfer algorithm on images. With the authors' code, stylizing a 1200x630 image of the Stanford campus takes 50 milliseconds on a Pascal Titan X.
Key idea. Training a feed-forward image transformation network with perceptual losses from a fixed pretrained loss network, so style transfer runs three orders of magnitude faster than optimization.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@misc{johnson2016perceptuallossesrealtimestyle,
title={Perceptual Losses for Real-Time Style Transfer and Super-Resolution},
author={Justin Johnson and Alexandre Alahi and Li Fei-Fei},
year={2016},
eprint={1603.08155},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/1603.08155},
}