Git Product home page Git Product logo

scribe's Introduction

Scribe: Realistic Handwriting in Tensorflow

See blog post

Samples

"A project by Sam Greydanus" Sample output 1 "You know nothing Jon Snow" (print) Sample output 2 "You know nothing Jon Snow" (cursive) Sample output 3

"lowering the bias" Sample output 4 "makes the writing messier" Sample output 5 "but more random" Sample output 6

Jupyter Notebooks

For an easy intro to the code (along with equations and explanations) check out these Jupyter notebooks:

Getting started

  • install dependencies (see below).
  • download the repo
  • navigate to the repo in bash
  • download and unzip folder containing pretrained models: Google Drive link
    • place in this directory

Now you have two options:

  1. Run the sampler in bash: mkdir -p ./logs/figures && python run.py --sample --tsteps 700
  2. Open the sample.ipynb jupyter notebook and run cell-by-cell (it includes equations and text to explain how the model works)

About

This model is trained on the IAM handwriting dataset and was inspired by the model described by the famous 2014 Alex Graves paper. It consists of a three-layer recurrent neural network (LSTM cells) with a Gaussian Mixture Density Network (MDN) cap on top. I have also implemented the attention mechanism from the paper which allows the network to 'focus' on character at a time in a sequence as it draws them.

The model at one time step looks like this

Rolled model

Unrolling in time, we get Unrolled model

I've implemented the attention mechanism from the paper: Attention mechanism

Dependencies

  • All code is written in python 2.7. You will need:
  • Numpy
  • Matplotlib
  • TensorFlow 1.0
  • OPTIONAL: Jupyter (if you want to run sample.ipynb and dataloader.ipynb)

scribe's People

Contributors

dribnet avatar greydanus avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scribe's Issues

pretrained model?

Looking for the pretrained model as the sampling notebook indicates I can "Look on this project's Github page for instructions on how to download a pretrained model." Is this available somewhere?

I'd like to try to replicate your results on sampling. I've trained my own model, but my results thus far are lackluster:

notebook screenshot

I'm guessing that I might need to train with different hyperparamaters (I used the run.py defaults), and having a model that worked would help me figure out what's going on.

Getting started

Hi! ๐Ÿ‘‹

How long does training the model typically take (following the instructions in the README.md) on a GPU device (I'm using Microsoft Azure)? What is the expected output, and how would one use that output to then generate handwriting sequences? Just trying to get a sense of whether I'm doing this correctly.

Thanks!

Tensorflow 1.5.0?

hi, this is a great work.

Is there any chances of making this work with Tensorflow 1.5.x?

Thanks

not compatible

This code is not compatible with newer version of the tensorflow and python i will try to work on this repository to make it campatible with the newer version of tensorflow and python wish me luck

Some issues with pre-trained model

So I downloaded the model from your google drive file, and ran the command from the README, however, I am getting errors saying several keys are not found in the checkpoint file. Any ideas?

SAMPLING MODE...
loading data...
building model...
	using alphabet abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
2017-11-06 15:22:18.599963: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-11-06 15:22:18.599998: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-11-06 15:22:18.600003: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-11-06 15:22:18.600007: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
attempt to load saved model...
2017-11-06 15:22:19.147508: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell0/lstm_cell/bias/RMSProp_1 not found in checkpoint
2017-11-06 15:22:19.147508: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell0/lstm_cell/kernel not found in checkpoint
2017-11-06 15:22:19.147531: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell0/lstm_cell/bias/RMSProp not found in checkpoint
2017-11-06 15:22:19.147531: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell0/lstm_cell/bias not found in checkpoint
2017-11-06 15:22:19.148667: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell0/lstm_cell/kernel/RMSProp not found in checkpoint
2017-11-06 15:22:19.148974: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell0/lstm_cell/kernel/RMSProp_1 not found in checkpoint
2017-11-06 15:22:19.149021: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell1/lstm_cell/bias/RMSProp_1 not found in checkpoint
2017-11-06 15:22:19.149158: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell1/lstm_cell/kernel not found in checkpoint
2017-11-06 15:22:19.149188: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell1/lstm_cell/bias not found in checkpoint
2017-11-06 15:22:19.149322: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell1/lstm_cell/kernel/RMSProp not found in checkpoint
2017-11-06 15:22:19.149756: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell1/lstm_cell/kernel/RMSProp_1 not found in checkpoint
2017-11-06 15:22:19.150055: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell2/lstm_cell/bias not found in checkpoint
2017-11-06 15:22:19.150250: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell2/lstm_cell/kernel/RMSProp not found in checkpoint
2017-11-06 15:22:19.150263: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell2/lstm_cell/bias/RMSProp_1 not found in checkpoint
2017-11-06 15:22:19.150283: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell2/lstm_cell/bias/RMSProp not found in checkpoint
2017-11-06 15:22:19.150464: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell1/lstm_cell/bias/RMSProp not found in checkpoint
2017-11-06 15:22:19.150513: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell2/lstm_cell/kernel not found in checkpoint
2017-11-06 15:22:19.150638: W tensorflow/core/framework/op_kernel.cc:1192] Not found: Key cell2/lstm_cell/kernel/RMSProp_1 not found in checkpoint
no saved model to load. starting new session
load failed, sampling canceled
^CTraceback (most recent call last):
  File "run.py", line 152, in <module>
    main()
  File "run.py", line 56, in main
    train_model(args) if args.train else sample_model(args)
  File "run.py", line 148, in sample_model
    time.sleep(args.sleep_time)
KeyboardInterrupt

please add requirements.txt to be compatible with mybinder.org

Hello! This is quite an interesting project.

I noticed you added the dependencie son the README.md file.
Would you mind adding them on a requirements.txt file?

With this it would then be possible to send the mybinder URL from your repo to friends such that they can try it out without having a python environment with tensorflow on their local machine:
https://mybinder.org/v2/gh/greydanus/scribe/master?filepath=sample.ipynb
At the moment without requirements.txt file the mybinder does not include numpy etc in the build.

Thanks for considering it!

Adding new style

Hello,

I want to know how I can add new style for handwriting synthesis ?

Thanks

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.