Code and data for paper:
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Stroke Controllable Fast Style Transfer

This repository contains the public release of the Python implementation of

Stroke Controllable Fast Style Transfer with Adaptive Receptive Fields [Project] [arXiv]

Yongcheng Jing*, Yang Liu*, Yezhou Yang, Zunlei Feng, Yizhou Yu, Dacheng Tao, Mingli Song (* indicates equal contribution)

If you use this code or find this work useful for your research, please cite:

  title={Stroke Controllable Fast Style Transfer with Adaptive Receptive Fields},
  author={Jing, Yongcheng and Liu, Yang and Yang, Yezhou and Feng, Zunlei and Yu, Yizhou and Tao, Dacheng and Song, Mingli},
  booktitle={European conference on computer vision},

Getting Started

Implemented and tested on Ubuntu 14.04 with Python 2.7 and Tensorflow 1.4.1.


Download pre-trained VGG-19 model

The VGG-19 model of tensorflow is adopted from VGG Tensorflow with few modifications on the class interface. The VGG-19 model weights is stored as .npy file and could be download from Google Drive or BaiduYun Pan. After downloading, copy the weight file to the /vgg19 directory

Basic Usage

Train the network

Use to train a new stroke controllable style transfer network. Run python -h to view all the possible parameters. The dataset used for training is MSCOCO train 2014 and could be download from here, or you can use a random selected 2k images from MSCOCO (download from here) for quick setup. Example usage:

$ python \
    --style /path/to/style_image.jpg \
    --train_path /path/to/MSCOCO_dataset \
    --sample_path /path/to/content_image.jpg

Freeze model

Use to freeze the saved checkpoint. Run python -h to view all parameter. Example usage:

$ python \
    --checkpoint_dir ./examples/checkpoint/some_style \
    --output ./examples/model/some_style.pb

We also provide some pre-trained style model for fast forwarding, which is stored under ./examples/model/pre-trained/.


Use to inference the content image based on the freezed style model. Set --interp N to enable interpolation inference where N is the number of the continuous stroke results.

$ python \
    --model ./examples/model/some_style.pb \
    --serial ./examples/serial/default/ \
    --content ./examples/content/some_content.jpg

For CPU-users, please set os.environ["CUDA_VISIBLE_DEVICES"]="" in the source code.


Discrete Stroke Size Control

From left to right are content, style, 256-stroke-size result, 512-stroke-size result, 768-stroke-size result.

Spatial Stroke Size Control

From left to right are content&style, mask, same stroke size across image result and spatial stroke size control result.

Continuous Stroke Size Control

Stroke grows from left to right. We zoom in on the same region (red frame) to observe the variations of stroke sizes


© Alibaba-Zhejiang University Joint Research Institute of Frontier Technologies, 2018. For academic and non-commercial use only.


Feel free to contact us if there is any question (Yang Liu