Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zhanghang1989/pytorch-multi-style-transfer

Neural Style and MSG-Net
https://github.com/zhanghang1989/pytorch-multi-style-transfer

deep-neural-networks real-time style-transfer

Last synced: 4 days ago
JSON representation

Neural Style and MSG-Net

Awesome Lists containing this project

README

        

# PyTorch-Style-Transfer

This repo provides PyTorch Implementation of **[MSG-Net (ours)](#msg-net)** and **[Neural Style (Gatys et al. CVPR 2016)](#neural-style)**, which has been included by [ModelDepot](https://modeldepot.io/zhanghang/multi-style-generative-network-for-real-time-transfer/overview). We also provide [Torch implementation](https://github.com/zhanghang1989/MSG-Net/) and [MXNet implementation](https://github.com/zhanghang1989/MXNet-Gluon-Style-Transfer).

**Tabe of content**

* [Real-time Style Transfer using MSG-Net](#msg-net)
- [Stylize Images using Pre-trained Model](#stylize-images-using-pre-trained-msg-net)
- [Train Your Own MSG-Net Model](#train-your-own-msg-net-model)
* [Slow Neural Style Transfer](#neural-style)

## MSG-Net




Multi-style Generative Network for Real-time Transfer [arXiv] [project]

Hang Zhang, Kristin Dana


@article{zhang2017multistyle,
title={Multi-style Generative Network for Real-time Transfer},
author={Zhang, Hang and Dana, Kristin},
journal={arXiv preprint arXiv:1703.06953},
year={2017}
}




### Stylize Images Using Pre-trained MSG-Net
0. Download the pre-trained model
```bash
git clone [email protected]:zhanghang1989/PyTorch-Style-Transfer.git
cd PyTorch-Style-Transfer/experiments
bash models/download_model.sh
```
0. Camera Demo
```bash
python camera_demo.py demo --model models/21styles.model
```
![](images/myimage.gif)
0. Test the model
```bash
python main.py eval --content-image images/content/venice-boat.jpg --style-image images/21styles/candy.jpg --model models/21styles.model --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
0. Download the COCO dataset
```bash
bash dataset/download_dataset.sh
```
0. Train the model
```bash
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.

## Neural Style

[Image Style Transfer Using Convolutional Neural Networks](http://www.cv-foundation.org/openaccess/content_cvpr_2016/papers/Gatys_Image_Style_Transfer_CVPR_2016_paper.pdf) by Leon A. Gatys, Alexander S. Ecker, and Matthias Bethge.

```bash
python main.py optim --content-image images/content/venice-boat.jpg --style-image images/21styles/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.








### Acknowledgement
The code benefits from outstanding prior work and their implementations including:
- [Texture Networks: Feed-forward Synthesis of Textures and Stylized Images](https://arxiv.org/pdf/1603.03417.pdf) by Ulyanov *et al. ICML 2016*. ([code](https://github.com/DmitryUlyanov/texture_nets))
- [Perceptual Losses for Real-Time Style Transfer and Super-Resolution](https://arxiv.org/pdf/1603.08155.pdf) by Johnson *et al. ECCV 2016* ([code](https://github.com/jcjohnson/fast-neural-style)) and its pytorch implementation [code](https://github.com/darkstar112358/fast-neural-style) by Abhishek.
- [Image Style Transfer Using Convolutional Neural Networks](http://www.cv-foundation.org/openaccess/content_cvpr_2016/papers/Gatys_Image_Style_Transfer_CVPR_2016_paper.pdf) by Gatys *et al. CVPR 2016* and its torch implementation [code](https://github.com/jcjohnson/neural-style) by Johnson.