All Projects → xunhuang1995 → Adain Style

xunhuang1995 / Adain Style

Licence: mit
Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to Adain Style

worlds
Building Virtual Reality Worlds using Three.js
Stars: ✭ 23 (-97.81%)
Mutual labels:  generative-model, generative-art
favorite-research-papers
Listing my favorite research papers 📝 from different fields as I read them.
Stars: ✭ 12 (-98.86%)
Mutual labels:  style-transfer, generative-model
eccv16 attr2img
Torch Implemention of ECCV'16 paper: Attribute2Image
Stars: ✭ 93 (-91.13%)
Mutual labels:  generative-model, generative-art
Vincent Ai Artist
Style transfer using deep convolutional neural nets
Stars: ✭ 176 (-83.22%)
Mutual labels:  generative-model, style-transfer
Tensorflow Style Transfer
A simple, concise tensorflow implementation of style transfer (neural style)
Stars: ✭ 278 (-73.5%)
Mutual labels:  style-transfer, neural-style
Neural-Tile
A better tiling script for Neural-Style
Stars: ✭ 35 (-96.66%)
Mutual labels:  style-transfer, neural-style
Keras-Style-Transfer
An implementation of "A Neural Algorithm of Artistic Style" in Keras
Stars: ✭ 36 (-96.57%)
Mutual labels:  style-transfer, neural-style
Faststyle
Tensorflow implementation of fast neural style transfer.
Stars: ✭ 170 (-83.79%)
Mutual labels:  style-transfer, neural-style
Neural-Zoom-Legacy
Infinite Zoom For Style Transfer
Stars: ✭ 14 (-98.67%)
Mutual labels:  style-transfer, neural-style
neural-style-pytorch
Neural Style implementation in PyTorch! 🎨
Stars: ✭ 50 (-95.23%)
Mutual labels:  style-transfer, neural-style
Msg Net
Multi-style Generative Network for Real-time Transfer
Stars: ✭ 152 (-85.51%)
Mutual labels:  generative-model, style-transfer
Neural Style Pt
PyTorch implementation of neural style transfer algorithm
Stars: ✭ 456 (-56.53%)
Mutual labels:  style-transfer, neural-style
Conditional Animegan
Conditional GAN for Anime face generation.
Stars: ✭ 70 (-93.33%)
Mutual labels:  generative-model, generative-art
MeuralPaint
TensorFlow implementation of CNN fast neural style transfer ⚡️ 🎨 🌌
Stars: ✭ 19 (-98.19%)
Mutual labels:  style-transfer, neural-style
Tensorflow Fast Style Transfer
A simple, concise tensorflow implementation of fast style transfer
Stars: ✭ 224 (-78.65%)
Mutual labels:  style-transfer, neural-style
mix-stage
Official Repository for the paper Style Transfer for Co-Speech Gesture Animation: A Multi-Speaker Conditional-Mixture Approach published in ECCV 2020 (https://arxiv.org/abs/2007.12553)
Stars: ✭ 22 (-97.9%)
Mutual labels:  style-transfer, generative-model
Neural Style Audio Torch
Torch implementation for audio neural style.
Stars: ✭ 130 (-87.61%)
Mutual labels:  style-transfer, neural-style
Neural Tools
Tools made for usage alongside artistic style transfer projects
Stars: ✭ 150 (-85.7%)
Mutual labels:  style-transfer, neural-style
py-msa-kdenlive
Python script to load a Kdenlive (OSS NLE video editor) project file, and conform the edit on video or numpy arrays.
Stars: ✭ 25 (-97.62%)
Mutual labels:  generative-model, generative-art
Neural Style Audio Tf
TensorFlow implementation for audio neural style.
Stars: ✭ 413 (-60.63%)
Mutual labels:  style-transfer, neural-style

AdaIN-style

This repository contains the code (in Torch) for the paper:

Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization
Xun Huang, Serge Belongie
ICCV 2017 (Oral)

This paper proposes the first real-time style transfer algorithm that can transfer arbitrary new styles, in contrast to a single style or 32 styles. Our algorithm runs at 15 FPS with 512x512 images on a Pascal Titan X. This is around 720x speedup compared with the original algorithm of Gatys et al., without sacrificing any flexibility. We accomplish this with a novel adaptive instance normalization (AdaIN) layer, which is similar to instance normalization but with affine parameters adaptively computed from the feature representations of an arbitrary style image.

Examples

Dependencies

Optionally:

Download

bash models/download_models.sh

This command will download a pre-trained decoder as well as a modified VGG-19 network. Our style transfer network consists of the first few layers of VGG, an AdaIN layer, and the provided decoder.

Usage

Basic usage

Use -content and -style to provide the respective path to the content and style image, for example:

th test.lua -content input/content/cornell.jpg -style input/style/woman_with_hat_matisse.jpg

You can also run the code on directories of content and style images using -contentDir and -styleDir. It will save every possible combination of content and styles to the output directory.

th test.lua -contentDir input/content -styleDir input/style

Some other options:

  • -crop: Center crop both content and style images beforehand.
  • -contentSize: New (minimum) size for the content image. Keeping the original size if set to 0.
  • -styleSize: New (minimum) size for the content image. Keeping the original size if set to 0.

To see all available options, type:

th test.lua -help

Content-style trade-off

Use -alpha to adjust the degree of stylization. It should be a value between 0 and 1 (default). Example usage:

th test.lua -content input/content/chicago.jpg -style input/style/asheville.jpg -alpha 0.5 -crop

By changing -alpha, you should be able to reproduce the following results.

Transfer style but not color

Add -preserveColor to preserve the color of the content image. Example usage:

th test.lua -content input/content/newyork.jpg -style input/style/brushstrokes.jpg -contentSize 0 -styleSize 0 -preserveColor

Style interpolation

It is possible to interpolate between several styles using -styleInterpWeights that controls the relative weight of each style. Note that you also to need to provide the same number of style images separated be commas. Example usage:

th test.lua -content input/content/avril.jpg \
-style input/style/picasso_self_portrait.jpg,input/style/impronte_d_artista.jpg,input/style/trial.jpg,input/style/antimonocromatismo.jpg \
-styleInterpWeights 1,1,1,1 -crop

You should be able to reproduce the following results shown in our paper by changing -styleInterpWeights.

Spatial control

Use -mask to provide the path to a binary foreground mask. You can transfer the foreground and background of the content image to different styles. Note that you also to need to provide two style images separated be comma, in which the first one is applied to foreground and the second one is applied to background. Example usage:

th test.lua -content input/content/blonde_girl.jpg -style input/style/woman_in_peasant_dress_cropped.jpg,input/style/mondrian_cropped.jpg \
-mask input/mask/mask.png -contentSize 0 -styleSize 0

Video Stylization

Use styVid.sh to process videos, example usage:

th testVid.lua -contentDir videoprocessing/${filename} -style ${styleimage} -outputDir videoprocessing/${filename}-${stylename}

This generates 1 mp4 for each image present in style-dir-path. Other video formats are also supported. To change other parameters like alpha, edit line 53 of styVid.sh. An example video with some results can be seen here on youtube.

Training

  1. Download MSCOCO images and Wikiart images.
  2. Use th train.lua -contentDir COCO_TRAIN_DIR -styleDir WIKIART_TRAIN_DIR to start training with default hyperparameters. Replace COCO_TRAIN_DIR with the path to COCO training images and WIKIART_TRAIN_DIR with the path to Wikiart training images. The default hyperparameters are the same as the ones used to train decoder-content-similar.t7. To reproduce the results from decoder.t7, add -styleWeight 1e-1.

Citation

If you find this code useful for your research, please cite the paper:

@inproceedings{huang2017adain,
  title={Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization},
  author={Huang, Xun and Belongie, Serge},
  booktitle={ICCV},
  year={2017}
}

Acknowledgement

This project is inspired by many existing style transfer methods and their open-source implementations, including:

Contact

If you have any questions or suggestions about the paper, feel free to reach me ([email protected]).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].