jcjohnson/fast-neural-style is an open-source project on GitHub with 4.4k stars, written primarily in Lua. Feedforward style transfer
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Perceptual Losses for Real-Time Style Transfer and Super-Resolution
Justin Johnson,
Alexandre Alahi,
Li Fei-Fei
Presented at ECCV 2016
The paper builds on
A Neural Algorithm of Artistic Style
by Leon A. Gatys, Alexander S. Ecker, and Matthias Bethge by training
feedforward neural networks that apply artistic styles to images.
After training, our feedforward networks can stylize images
hundreds of times faster than the optimization-based method presented
by Gatys et al.
This repository also includes an implementation of instance normalization as
described in the paper Instance Normalization: The Missing Ingredient for Fast Stylization
by Dmitry Ulyanov, Andrea Vedaldi, and Victor Lempitsky. This simple trick
significantly improves the quality of feedforward style transfer models.
Stylizing this image of the Stanford campus at a resolution of 1200x630
takes 50 milliseconds on a Pascal Titan X:
In this repository we provide:
The style transfer models used in the paper
Additional models using instance normalization
Code for running models on new images
A demo that runs models in real-time off a webcam
Code for training new feedforward style transfer models
An implementation of optimization-based style transfer
method described by Gatys et al.
If you find this code useful for your research, please cite
@inproceedings{Johnson2016Perceptual,
title={Perceptual losses for real-time style transfer and super-resolution},
author={Johnson, Justin and Alahi, Alexandre and Fei-Fei, Li},
booktitle={European Conference on Computer Vision},
year={2016}
}
Setup
All code is implemented in Torch.
First install Torch, then
update / install the following packages:
If you have an NVIDIA GPU, you can accelerate all operations with CUDA.
First install CUDA, then
update / install the following packages:
luarocks install cutorch
luarocks install cunn
(Optional) cuDNN
When using CUDA, you can use cuDNN to accelerate convolutions.
First download cuDNN and copy the
libraries to /usr/local/cuda/lib64/. Then install the Torch bindings for cuDNN:
luarocks install cudnn
Pretrained Models
Download all pretrained style transfer models by running the script
bash models/download_style_transfer_models.sh
This will download ten model files (~200MB) to the folder models/.
Models from the paper
The style transfer models we used in the paper will be located in the folder models/eccv16.
Here are some example results where we use these models to stylize this
image of the Chicago skyline with at an image size of 512:
Models with instance normalization
As discussed in the paper
Instance Normalization: The Missing Ingredient for Fast Stylization
by Dmitry Ulyanov, Andrea Vedaldi, and Victor Lempitsky, replacing batch
normalization with instance normalization significantly improves the quality
of feedforward style transfer models.
We have trained several models with instance normalization; after downloading
pretrained models they will be in the folder models/instance_norm.
These models use the same architecture as those used in our paper, except with
half the number of filters per layer and with instance normalization instead of
batch normalization. Using narrower layers makes the models smaller and faster
without sacrificing model quality.
Here are some example outputs from these models, with an image size of 1024:
Running on new images
The script fast_neural_style.lua lets you use a trained model to stylize new images:
You can control the size of the output images using the -image_size flag.
By default this script runs on CPU; to run on GPU, add the flag -gpu
specifying the GPU on which to run.
The full set of options for this script is described here.
Webcam demo
You can use the script webcam_demo.lua to run one or more models in real-time
off a webcam stream. To run this demo you need to use qlua instead of th:
With a Pascal Titan X you can easily run four models in realtime at 640x480:
The webcam demo depends on a few extra Lua packages:
clementfarabet/lua---camera
torch/qtlua
You can install / update these packages by running:
luarocks install camera
luarocks install qtlua
The full set of options for this script is described here.
Training new models
You can find instructions for training new models here.
Optimization-based Style Transfer
The script slow_neural_style.lua is similar to the
original neural-style, and uses
the optimization-based style-transfer method described by Gatys et al.
This script uses the same code for computing losses as the feedforward training
script, allowing for fair comparisons between feedforward style transfer networks
and optimization-based style transfer.
Compared to the original neural-style,
this script has the following improvements:
Remove dependency on protobuf and loadcaffe
Support for many more CNN architectures, including ResNets
The full set of options for this script is described here.
License
Free for personal or research use; for commercial use please contact me.
TopGit's last sync did not record any GitHub topics for jcjohnson/fast-neural-style. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How active is development on jcjohnson/fast-neural-style?
The most recent commit recorded on jcjohnson/fast-neural-style was 3.1 years ago, based on the GitHub push timestamp. The repository has 800 forks — one of the better signals of community interest.
How many stars does jcjohnson/fast-neural-style have?
jcjohnson/fast-neural-style has 4.4k GitHub stars — refresh the page for the live number, or check github.com/jcjohnson/fast-neural-style. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What language is jcjohnson/fast-neural-style written in?
jcjohnson/fast-neural-style is written primarily in Lua. GitHub's language field is based on the largest share of bytes in the default branch.
Where do I read more about jcjohnson/fast-neural-style?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/jcjohnson/fast-neural-style is the definitive source.
Read full README in the tab above.
Is fast-neural-style worth your time?
ChatGPT, Claude and Perplexity can all read this page. Ask one of them what it makes of fast-neural-style.