Code Monkey home page Code Monkey logo

ascii-net's Introduction

ascii-net

An experiment in generating ASCII Art from images with an artificial neural network.

IN PROGRESS

Usage

Currently only a hard-coded test image is converted:

$ python test_ocr.py

Source:

source image

Generated:

screenshot

Implementation

This experiment trains a neural network model as an optical character recognizer.

The model is a simple 2 layer neural network:

  • 99 inputs (glyphs in the font are 9x11 pixels)
  • fully connected hidden layer with 99 nodes with bias and sigmoid activation
  • fully connected output layer with 92 nodes (number of different characters used) with bias and softmax activation
  • cross entrophy loss function

It is trained with rendered glyphs of a font and corresponding labels as inputs, e.g.:

a b #
a b #

And uses those to predict the best label for the tiles in an input image, e.g.:

_ , # * 7
_ , # * 7

Two implementations of the model were made:

NNet Model

This is my own implementation of MLPs using only numpy arrays. It supports batch learning with stochastic gradient descent.

Developing this has been a great help in understanding the maths behind the back propagation algorithm and why it is so efficient for calculating the loss derivates necessary for gradient descent. I highly recommend the blog post Calculus on Computational Graphs: Backpropagation for further reading.

Keras Model

This is an implementation using the Keras Deep Learning Library. It is trained using stochastic gradient descent with Nesterov momentum.

Training this model is quite a bit faster then for my numpy implementation and really simple to implement.

Future work

  • Use deep convolutional neural nets to detect more abstract features for better selection of ASCII character
  • generate more general training data by randomly transforming the glyphs (translation, scale, shear)
  • use overlapping segments of input image to include surrounding pixels into selection of ASCII character

ascii-net's People

Contributors

a-metz avatar

Stargazers

Josh Baillie avatar grace avatar Acemir Sousa Mendes avatar Allan Savolainen avatar  avatar Pushpendra Kumar avatar  avatar Nathan Weddle avatar Peer David avatar Gennaro Farina avatar  avatar  avatar Branden On avatar Derrick avatar Austin Packer avatar  avatar Larry Gilliam avatar Filippo Giunchedi avatar gio avatar Isay Katsman avatar Egor Zvorykin avatar  avatar Liam Ronan avatar Isaac Rodman avatar

Watchers

 avatar  avatar

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.