• Stars
    star
    692
  • Rank 65,341 (Top 2 %)
  • Language
    Python
  • Created almost 9 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Generative Handwriting using LSTM Mixture Density Network with TensorFlow

Generative Handwriting Demo using TensorFlow

example

example

An attempt to implement the random handwriting generation portion of Alex Graves' paper.

See my blog post at blog.otoro.net for more information.

How to use

I tested the implementation on TensorFlow r0.11 and Pyton 3. I also used the following libraries to help:

svgwrite
IPython.display.SVG
IPython.display.display
xml.etree.ElementTree
argparse
pickle

Training

You will need permission from these wonderful people people to get the IAM On-Line Handwriting data. Unzip lineStrokes-all.tar.gz into the data subdirectory, so that you end up with data/lineStrokes/a01, data/lineStrokes/a02, etc. Afterwards, running python train.py will start the training process.

A number of flags can be set for training if you wish to experiment with the parameters. The default values are in train.py

--rnn_size RNN_SIZE             size of RNN hidden state
--num_layers NUM_LAYERS         number of layers in the RNN
--model MODEL                   rnn, gru, or lstm
--batch_size BATCH_SIZE         minibatch size
--seq_length SEQ_LENGTH         RNN sequence length
--num_epochs NUM_EPOCHS         number of epochs
--save_every SAVE_EVERY         save frequency
--grad_clip GRAD_CLIP           clip gradients at this value
--learning_rate LEARNING_RATE   learning rate
--decay_rate DECAY_RATE         decay rate for rmsprop
--num_mixture NUM_MIXTURE       number of gaussian mixtures
--data_scale DATA_SCALE         factor to scale raw data down by
--keep_prob KEEP_PROB           dropout keep probability

Generating a Handwriting Sample

I've included a pretrained model in /save so it should work out of the box. Running python sample.py --filename example_name --sample_length 1000 will generate 4 .svg files for each example, with 1000 points.

IPython interactive session.

If you wish to experiment with this code interactively, just run %run -i sample.py in an IPython console, and then the following code is an example on how to generate samples and show them inside IPython.

[strokes, params] = model.sample(sess, 800)
draw_strokes(strokes, factor=8, svg_filename = 'sample.normal.svg')
draw_strokes_random_color(strokes, factor=8, svg_filename = 'sample.color.svg')
draw_strokes_random_color(strokes, factor=8, per_stroke_mode = False, svg_filename = 'sample.multi_color.svg')
draw_strokes_eos_weighted(strokes, params, factor=8, svg_filename = 'sample.eos.svg')
draw_strokes_pdf(strokes, params, factor=8, svg_filename = 'sample.pdf.svg')

example1a example1b example1c example1d example1e

Have fun-

License

MIT

More Repositories

1

estool

Evolution Strategies Tool
Jupyter Notebook
901
star
2

sketch-rnn

Multilayer LSTM and Mixture Density Network for modelling path-level SVG Vector Graphics data in TensorFlow
Python
793
star
3

slimevolleygym

A simple OpenAI Gym environment for single and multi-agent reinforcement learning
Python
633
star
4

WorldModelsExperiments

World Models Experiments
Jupyter Notebook
545
star
5

pytorch_notebooks

tutorial notebooks
Jupyter Notebook
371
star
6

cppn-gan-vae-tensorflow

Train CPPNs as a Generative Model, using Generative Adversarial Networks and Variational Autoencoder techniques to produce high resolution images.
Python
346
star
7

cppn-tensorflow

Very Simple and Basic Implementation of Compositional Pattern Producing Network in TensorFlow
Python
311
star
8

sketch-rnn-datasets

optional extra vector image datasets for sketch-rnn
Python
215
star
9

neuralslimevolley

Neural Slime Volleyball
JavaScript
201
star
10

supercell

supercell
Jupyter Notebook
188
star
11

rnn-tutorial

RNN Tutorial for Artists
JavaScript
183
star
12

resnet-cppn-gan-tensorflow

Using Residual Generative Adversarial Networks and Variational Auto-encoder techniques to produce high resolution images.
Python
123
star
13

backprop-neat-js

Neural Network Evolution Playground with Backprop NEAT
JavaScript
122
star
14

astool

Augmented environments with RL
Jupyter Notebook
102
star
15

image-notebook

image-notebook
Jupyter Notebook
87
star
16

gecco-tutorial-2019

2019 talk at GECCO
67
star
17

neurogram

neurogram
JavaScript
64
star
18

mdn_jax_tutorial

Mixture Density Networks (Bishop, 1994) tutorial in JAX
Jupyter Notebook
56
star
19

presentations

presentations
44
star
20

cppn-gan-vae-cifar-tensorflow

First attempt to use the previous CPPN-GAN-VAE model to train on CIFAR-10 images.
Python
39
star
21

netart-js

quick hacked together js demo to implement fixed-topology cppn in the web browser for interactive usage
JavaScript
39
star
22

sketch-rnn-flowchart

trained sketch-rnn / deployed with sketch-rnn-js on flowchart dataset
JavaScript
33
star
23

kanji2kanji

Reproduce domain transfer results in Deep Learning for Classical Japanese Literature
Jupyter Notebook
31
star
24

paperjs_box2d

demo of working with box2d and paper.js
JavaScript
31
star
25

RainbowSlimeVolley

Using Rainbow implementation in Chainer RL for Slime Volleyball Pixel Environment
Python
24
star
26

sketch-rnn-poster

Poster for "A Neural Representation for Sketch Drawings" for ICLR 2018 Conference
22
star
27

rlzoo

fork of rl-baseline-zoo
Python
21
star
28

quickdraw-ndjson-to-npz

Convert RAW Quickdraw datafiles into stroke-based .npz format with RDP at variable epsilon for sketch-rnn
Jupyter Notebook
15
star
29

sema-demo

sketch-rnn demo for seoul mediacity biennale 2018
JavaScript
13
star
30

diff-vae-tensorflow

skeleton variation encoder code in tensorflow
Python
12
star
31

pybullet_animations

pybullet_animations
12
star
32

cma

Fork of cma-es library by Nikolaus Hansen
Python
11
star
33

cantonese-list

List of 4000 Chinese characters sorted by historical usage frequency, with Cantonese yale romanization and definition
11
star
34

creatures

autonomous creatures written in processing / processing.js
Processing
7
star
35

zombie

A* search algorithm example, zombie chasing humans
Python
4
star
36

tshirtai

3
star
37

batchnorm-convnet-mnist-tensorflow

self contained skeleton script for testing and training mnist convnet+batchnorm based classifier in tensorflow
Python
2
star