tree: 2c110fcf56d4d1cd5171f6e0e52780843814f824 [path history] [tgz]
  1. dataset/
  2. models/
  3. data.py
  4. download_images.py
  5. main.py
  6. net.py
  7. option.py
  8. README.md
  9. utils.py
example/gluon/style_transfer/README.md

MXNet-Gluon-Style-Transfer

This repo provides MXNet Implementation of Neural Style Transfer and MSG-Net.

Tabe of content

Neural Style

A Neural Algorithm of Artistic Style by Leon A. Gatys, Alexander S. Ecker, and Matthias Bethge.

Download the images

python download_images.py 

Neural style transfer

python main.py optim --content-image images/content/venice-boat.jpg --style-image images/styles/candy.jpg
  • --content-image: path to content image.
  • --style-image: path to style image.
  • --output-image: path for saving the output image.
  • --content-size: the content image size to test on.
  • --style-size: the style image size to test on.
  • --cuda: set it to 1 for running on GPU, 0 for CPU.

Real-time Style Transfer

Stylize Images Using Pre-trained MSG-Net

  1. Download the images and pre-trained model
    python download_images.py 
    	python models/download_model.py
    
  2. Test the model
    	python main.py eval --content-image images/content/venice-boat.jpg --style-image images/styles/candy.jpg --model models/21styles.params --content-size 1024
    
  • If you don't have a GPU, simply set --cuda=0. For a different style, set --style-image path/to/style. If you would to stylize your own photo, change the --content-image path/to/your/photo. More options:

    • --content-image: path to content image you want to stylize.
    • --style-image: path to style image (typically covered during the training).
    • --model: path to the pre-trained model to be used for stylizing the image.
    • --output-image: path for saving the output image.
    • --content-size: the content image size to test on.
    • --cuda: set it to 1 for running on GPU, 0 for CPU.

Train Your Own MSG-Net Model

  1. Download the style images and COCO dataset
    python download_images.py 
    	python dataset/download_dataset.py
    
  2. Train the model
    	python main.py train --epochs 4
    
  • If you would like to customize styles, set --style-folder path/to/your/styles. More options:
    • --style-folder: path to the folder style images.
    • --vgg-model-dir: path to folder where the vgg model will be downloaded.
    • --save-model-dir: path to folder where trained model will be saved.
    • --cuda: set it to 1 for running on GPU, 0 for CPU.

The code is mainly modified from PyTorch-Style-Transfer.