Coder Social home page Coder Social logo

markmohr / sketch-photo2seq Goto Github PK

View Code? Open in Web Editor NEW
17.0 1.0 5.0 328 KB

Reimplementation of paper "Learning to Sketch with Shortcut Cycle Consistency"(CVPR 2018)

Python 100.00%
sketch sketch-generation sketch-synthesis vector-sketch photo-to-sketch cycle-consistency

sketch-photo2seq's Introduction

sketch-photo2seq

This is the reimplementation code of CVPR'2018 paper Learning to Sketch with Shortcut Cycle Consistency.

Photo Generated examples
example1 example1-sketch
example2 example2-sketch

Requirements

  • Python 3

  • Tensorflow (>= 1.4.0)

  • InkScape or CairoSVG (For vector sketch rendering. Choose one of them is ok.)

    sudo apt-get install inkscape
    # or
    pip3 install cairosvg
    

Data Preparations

From the paper, we need to pre-train the model on the QuickDraw dataset. So we need to preprocess both the QuickDraw-shoes and QMUL-shoes data following these steps:

  1. QuickDraw-shoes

    • Download the sketchrnn_shoes.npz data from QuickDraw
    • Place the package under datasets/QuickDraw/shoes/npz/ directory
    • run the command:
      python quickdraw_data_processing.py
      
  2. QMUL-shoes

    • Download the photo data from QMUL-Shoe-Chair-V2
    • Unzip the ShoeV2_photo package and place all .png under datasets/QMUL/shoes/photos/ directory
    • Download the preprocessed sketch data from here and place the two .h5 packages under datasets/QMUL/shoes/ directory

Training

  1. QuickDraw-shoes pre-training

    • Change the value to QuickDraw in model.py-get_default_hparams-data_type
    • run the command:
      python sketch_p2s_train.py
      
  2. QMUL-shoes training

    • Change the value to QMUL in model.py-get_default_hparams-data_type
    • Make sure the QuickDraw-shoes pre-training models/checkpoint are placed under outputs/snapshot/ directory
    • Change the value to True in sketch_p2s_train.py-resume_training
    • run the command:
      python sketch_p2s_train.py
      

Training loss

The following figure shows the total loss, KL loss and reconstruction loss during training with QuickDraw-shoes pre-trained within 30k iterations and the following QMUL-shoes trained within 40k iterations.

loss

Sampling

  1. QuickDraw-shoes

    • Make sure the value of data_type to be QuickDraw in model.py
    • Place models/checkpoint/config under outputs/snapshot/QuickDraw/ directory
    • run the command:
      python sketch_p2s_sampling.py
      
  2. QMUL-shoes

    • Make sure the value of data_type to be QMUL in model.py
    • Place models/checkpoint/config under outputs/snapshot/QMUL/ directory
    • run the command:
      python sketch_p2s_sampling.py
      

All results can be found under outputs/sampling/ dir.

Credits

sketch-photo2seq's People

Contributors

markmohr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

sketch-photo2seq's Issues

dataset download

Thanks for your code.
But the address of QMUL_shoe can not open.
If you have time, could you offer the dataset?

Thanks for your help~~~~

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.