All Projects → patrickgadd → Feel The Kern

patrickgadd / Feel The Kern

Generating proportional fonts with deep learning

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Feel The Kern

Agentnet
Deep Reinforcement Learning library for humans
Stars: ✭ 298 (+405.08%)
Mutual labels:  lasagne, theano
Deepalignmentnetwork
A deep neural network for face alignment
Stars: ✭ 480 (+713.56%)
Mutual labels:  lasagne, theano
Personality Detection
Implementation of a hierarchical CNN based model to detect Big Five personality traits
Stars: ✭ 338 (+472.88%)
Mutual labels:  convolutional-neural-networks, theano
2D-and-3D-Deep-Autoencoder
Convolutional AutoEncoder application on MRI images
Stars: ✭ 57 (-3.39%)
Mutual labels:  lasagne, theano
Theano Xnor Net
Theano implementation of XNOR-Net
Stars: ✭ 23 (-61.02%)
Mutual labels:  lasagne, theano
Improved-Wasserstein-GAN-application-on-MRI-images
Improved Wasserstein GAN (WGAN-GP) application on medical (MRI) images
Stars: ✭ 23 (-61.02%)
Mutual labels:  lasagne, theano
Practical rl
A course in reinforcement learning in the wild
Stars: ✭ 4,741 (+7935.59%)
Mutual labels:  lasagne, theano
Hyperdensenet
This repository contains the code of HyperDenseNet, a hyper-densely connected CNN to segment medical images in multi-modal image scenarios.
Stars: ✭ 124 (+110.17%)
Mutual labels:  convolutional-neural-networks, theano
Csc deeplearning
3-day dive into deep learning at csc
Stars: ✭ 22 (-62.71%)
Mutual labels:  lasagne, theano
Machine Learning Curriculum
💻 Make machines learn so that you don't have to struggle to program them; The ultimate list
Stars: ✭ 761 (+1189.83%)
Mutual labels:  convolutional-neural-networks, theano
rnn benchmarks
RNN benchmarks of pytorch, tensorflow and theano
Stars: ✭ 85 (+44.07%)
Mutual labels:  lasagne, theano
Practical dl
DL course co-developed by YSDA, HSE and Skoltech
Stars: ✭ 1,006 (+1605.08%)
Mutual labels:  lasagne, theano
Livianet
This repository contains the code of LiviaNET, a 3D fully convolutional neural network that was employed in our work: "3D fully convolutional networks for subcortical segmentation in MRI: A large-scale study"
Stars: ✭ 143 (+142.37%)
Mutual labels:  convolutional-neural-networks, theano
SymJAX
Documentation:
Stars: ✭ 103 (+74.58%)
Mutual labels:  lasagne, theano
Handwritten Digit Recognition Using Deep Learning
Handwritten Digit Recognition using Machine Learning and Deep Learning
Stars: ✭ 127 (+115.25%)
Mutual labels:  convolutional-neural-networks, theano
Deepconvsep
Deep Convolutional Neural Networks for Musical Source Separation
Stars: ✭ 424 (+618.64%)
Mutual labels:  convolutional-neural-networks, theano
Alphazero gomoku
An implementation of the AlphaZero algorithm for Gomoku (also called Gobang or Five in a Row)
Stars: ✭ 2,570 (+4255.93%)
Mutual labels:  lasagne, theano
Alexnet Experiments Keras
Code examples for training AlexNet using Keras and Theano
Stars: ✭ 109 (+84.75%)
Mutual labels:  convolutional-neural-networks, theano
Deepo
Setup and customize deep learning environment in seconds.
Stars: ✭ 6,145 (+10315.25%)
Mutual labels:  lasagne, theano
Iris Python
Collection of iris classifcation program for teaching purpose
Stars: ✭ 33 (-44.07%)
Mutual labels:  lasagne, theano

Feel The Kern - Generating fonts with kerning

What is this?

This is the code relating to my blog post on generating proportional fonts with kerning using deep learning. People have previously generated plenty of characters that can be used as monospaced fonts, but as far as I am aware, none with kerning.

Animation of continuum of monospaced fonts

The above is similar what to previously has been done; generating smooth interpolations between the characters of generated fonts, but disregarding the inter-character spacing used in most fonts used in practise.

So I generated bigrams of fonts, as this would force the model to also learn a notion of proper kerning of the proportional fonts which we use for most purposes.

These bigrams were then overlapped using simulated annealing to create words and sentences from the randomly generated fonts:

Animation of bigram matching using simulated annealing

Ultimately, this allowed me to generate smooth interpolations between different styles of fonts that incorporate kerning:

Interpolations between generated fonts

Note how "X" and "A" for some of the generated fonts touch, but for others are quite far apart. This goes to show that the model did learn to kern fonts according to their style.

How to get this running

In short, the process to generate sentences in generated fonts is the following:

  1. Map the fonts you have to z-dimensional vectors expressing their "style" (using t-SNE or whatever you prefer. It would be interesting to see if using an autoencoder would yield better results)
  2. Train a convolutional neural network to take a vector describing the font-style and one-hot encoding of bigrams and output the corresponding bigram
  3. Generate bigrams of new styles, and use simulated annealing to overlap the bigrams to full words

Batteries not included - The missing parts

This won't quite work out of the box as a few parts are intentionally left out. Sort this out and you can follow the instructions up next

  • an implementation of t-SNE in the directory "/1-font-to-vector/src/tsne/". Go fetch the Python implementation of t-SNE from the author's website and dump it in that directory.
  • fonts under the path "/shared-data/fonts/". Go fetch some of in the .ttf format and put them there.
  • a JSON-file, "/shared-data/font_infos.json", which is a list of dicts with the fields "font_name", "font_path", "id", e.g. [ {"font_name": "Aclonica.ttf", "font_path": "RELATIVE_PATH_TO_FONTS_DIR/FONT_NAME.ttf", "id": "rTT3NMUL"} ]

Installation requirements

Further to the few missing bits, this requires the following to be installed:

I ran this on AWS EC2 p2.xlarge and g2.2xlarge instances, Ubuntu 16.04.1 LTS, with the following installed:

  • Python (2.7.12), CUDA (8.0.44), Numpy (1.12.0), Theano (0.7.0), Lasagne (0.2.dev1), Pillow (3.1.2), Matplotlib

How to actually run it

Now that you have installed and gotten the missing parts, it is time to run this thing.

Steps 1 and 2 are mapping fonts to a style-vector, steps 3 and 4 are on training a convnet to generate bigrams, and generate these, while steps 5 and 6 are matching the bigrams and merging them into a final image.

  1. Run "/1-font-to-vector/src/generate_imgs.py" to generate images of fonts for t-SNE to map to a low-dimensional space. It will dump .pngs under "/1-font-to-vector/data/text-imgs/"

  2. Run "/1-font-to-vector/src/tsne/tsne_main.py". It will map the images generated of the fonts to a 10-dimensional space (or whatever you set it to), and store this mapping under "/shared-data/tsne_dump_10d_48px.json"

  3. Run "/2-generating-bigrams/src/supervised_learner.py" to train a convnet to generate bigrams, and store the network under "/2-generating-bigrams/data/networks/" during training

  4. Run "/2-generating-bigrams/src/visualiser.py" to generate bigrams of the sentence "MACHINE-LEARNING" and dump these under "/visualisations/sentence-bigrams/MACHINE-LEARNING/"

  5. Run "/3-matching-bigrams/src/match-imgs.py" to match the generated bigrams. The results from this will be used in the next and final step to create images of the full sentence

  6. Run "/3-matching-bigrams/src/generate-sentence.py" to combine the matched bigrams into a single image like the one below:

Interpolations between generated fonts

And that's it!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].