Giter VIP home page Giter VIP logo

deep-photo-styletransfer-tf's Introduction

deep-photo-styletransfer-tf

This is a pure Tensorflow implementation of Deep Photo Styletransfer, the torch implementation could be found here

This implementation support L-BFGS-B (which is what the original authors used) and Adam in case the ScipyOptimizerInterface incompatible when Tensorflow upgrades to higher version.

This implementation may seem to be a little bit simpler thanks to Tensorflow's automatic differentiation

Additionally, there is no dependency on MATLAB thanks to another repository computing Matting Laplacian Sparse Matrix. Below is example of transferring the photo style to another photograph.

Disclaimer

This software is published for academic and non-commercial use only.

Setup

Dependencies

It is recommended to use Anaconda Python, since you only need to install Tensorflow and PyCUDA manually to setup. The CUDA is optional but really recommended

Download the VGG-19 model weights

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 here. After downloading, copy the weight file to the ./project/vgg19 directory

Usage

Basic Usage

You need to specify the path of content image, style image, content image segmentation, style image segmentation and then run the command

python deep_photostyle.py --content_image_path <path_to_content_image> --style_image_path <path_to_style_image> --content_seg_path <path_to_content_segmentation> --style_seg_path <path_to_style_segmentation> --style_option 2

Example:

python deep_photostyle.py --content_image_path ./examples/input/in11.png --style_image_path ./examples/style/tar11.png --content_seg_path ./examples/segmentation/in11.png --style_seg_path ./examples/segmentation/tar11.png --style_option 2

Other Options

--style_option specifies three different ways of style transferring. --style_option 0 is to generate segmented intermediate result like torch file neuralstyle_seg.lua in torch. --style_option 1 uses this intermediate result to generate final result like torch file deepmatting_seg.lua. --style_option 2 combines these two steps as a one line command to generate the final result directly.

Run python deep_photostyle.py --help to see a list of all options

Image Segmentation

This repository doesn't offer image segmentation script and simply use the segmentation image from the torch version. The mask colors used are also the same as them. You could specify your own segmentation model and mask color to customize your own style transfer.

Examples

Here are more results from tensorflow algorithm (from left to right are input, style, torch results and tensorflow results)

Acknowledgement

  • This work was done when Yang Liu was a research intern at Alibaba-Zhejiang University Joint Research Institute of Frontier Technologies, under the supervision of Prof. Mingli Song and Yongcheng Jing.

  • Our tensorflow implementation basically follows the torch code.

  • We use martinbenson's python code to compute Matting Laplacian.

Citation

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

@misc{YangPhotoStyle2017,
  author = {Yang Liu},
  title = {deep-photo-style-transfer-tf},
  publisher = {GitHub},
  organization={Alibaba-Zhejiang University Joint Research Institute of Frontier Technologies},
  year = {2017},
  howpublished = {\url{https://github.com/LouieYang/deep-photo-styletransfer-tf}}
}

Contact

Feel free to contact me if there is any question (Yang Liu [email protected]).

deep-photo-styletransfer-tf's People

Contributors

louieyang avatar

Watchers

James Cloos avatar Juner 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.