Coder Social home page Coder Social logo

rakshit-shetty / multimodal-style-transfer-via-graph-cuts Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 3.0 24.92 MB

Implementing the MST Research Paper in PyTorch

Python 46.77% Jupyter Notebook 53.23%
graph-cuts pytorch paper gpu dataset pytorch-implementation multimodal-style-transfer style-transfer generative-model vgg16-model

multimodal-style-transfer-via-graph-cuts's Introduction

Multimodal Style Transfer via Graph Cuts

Pytorch(1.0+) implementation(unofficial) of ICCV 2019 paper "Multimodal Style Transfer via Graph Cuts".

Original tensorflow implementations from the author can be found here.

This repository provides a pre-trained model for you to generate your own image given content image and style image. Also, you can download the training dataset or prepare your own dataset to train the model from scratch.

Requirements

  • Python 3.6+
  • PyTorch 1.0+
  • PyMaxflow
  • Pillow
  • TorchVision

Optional but recommended for training

  • GPU environment

I have provided a jupyter notebook with instructions to run the training and testing python files using the Google Colab's free GPU.

If you wish to run them on your local machine you can follow the instructions below. Note: Testing does not require GPU.

train

  1. Download COCO for content dataset and Wikiart for style dataset and unzip them, rename them as content and style respectively (recommended).

  2. Modify the argument in the train.py such as the path of directory, epoch, learning_rate or you can add your own training code.

  3. Train the model using gpu.

  4. python train.py
     usage: train.py [-h] [--batch_size BATCH_SIZE] [--epoch EPOCH] [--gpu GPU]
                     [--learning_rate LEARNING_RATE]
                     [--snapshot_interval SNAPSHOT_INTERVAL]
                     [--n_cluster N_CLUSTER] [--alpha ALPHA] [--lam LAM]
                     [--max_cycles MAX_CYCLES] [--gamma GAMMA]
                     [--train_content_dir TRAIN_CONTENT_DIR]
                     [--train_style_dir TRAIN_STYLE_DIR]
                     [--test_content_dir TEST_CONTENT_DIR]
                     [--test_style_dir TEST_STYLE_DIR] 
                     [--save_dir SAVE_DIR] [--reuse REUSE]
    

test

  1. Clone this repository

    git clone https://github.com/Rakshit-Shetty/Multimodal-Style-Transfer-via-Graph-Cuts.git
    cd Multimodal-Style-Transfer-via-Graph-Cuts
  2. Prepare your content image and style image. I provide some in the content and style and you can try to use them easily.

  3. Download the pretrained model here

  4. Generate the output image. 3 outputs in total. A transferred output image with and without style image and a nested_demo_like image like those before and after image will be generated.

    python test.py -c content_image_path -s style_image_path
     usage: test.py [-h] [--content CONTENT] [--style STYLE]
                 [--output_name OUTPUT_NAME] [--n_cluster N_CLUSTER]
                 [--alpha ALPHA] [--lam LAM] [--max_cycles MAX_CYCLES]
                 [--gpu GPU] [--model_state_path MODEL_STATE_PATH]
    

    If output_name is not given, it will use the combination of content image name and style image name.


Result

Some results of content image will be shown here.

image

multimodal-style-transfer-via-graph-cuts's People

Contributors

rakshit-shetty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

multimodal-style-transfer-via-graph-cuts's Issues

Unavailable link for pretrained model

Hi,
I was testing to run your python file on colab.
But I aware that the link of the pretrained model your provided is not available. It just directed to my own google drive.
Can you please update the new link?

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.