Code Monkey home page Code Monkey logo

pytorch_style_transfer's Introduction

pytorch_style_transfer

Built based on the pytorch fast-neural-style example for artistic style transfer, this repository try to re-implemented Conditional Instance Normalization layers to train transfer network with multiple style images at the same time. What I did here is basically replaced all instance normalization layers in fast-neural-style with conditional instance normalization layers

Conditional Instance Normalization was introduced in A Learned Representation For Artistic Style and implemented with Google Magenta TensorFlow. I first learned this paper while reading Joel Moniz Lasagne and Theano implementation. The creation and usage of the method in this repository is based on my limit knowledge in python, pytorch and neural network.

Usage

Please refer to fast-neural-style for more details.

Train

python neural_style.py train --dataset </path/to/train-dataset> --style-image </path/to/style/image> --save-model-dir </path/to/save-model/folder> --epochs 2 --cuda 1 --batch-size 4
  • --style-image: the code will grab all files under the path as style images
  • --batch-size: number of images fed in each batch does not need to be the same to the number of style images

Stylize

python neural_style.py eval --content-image </path/to/content/image> --model </path/to/saved/model> --output-image </path/to/output/image> --cuda 0 --style-num 19 --style-id 18
  • --dataset: path to training dataset, the path should point to a folder containing another folder with all the training images
  • --style-num: total number of style images, must be the same as the amount used in training
  • --style-id: a number from 0 to style_num - 1, indicating which style to transfer to

Results

Training content image datasets

COCO 2014 Training images dataset [83K/13GB]

Training style images

I used 19 style images, most of which are from other great style-transfer-related Github repos I read through:

Pretrained model

Model used in the following examples can be found in the pytorch_models folder

pytorch_style_transfer's People

Contributors

kewellcjj avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.