Giter Club home page Giter Club logo

math-formula-recognition's Introduction

Off-Line Math Formula Recognition Using Deep Neural Networks

Based on Multi-Scale Attention with Dense Encoder for Handwritten Mathematical Expression Recognition.

Requirements

All dependencies can be installed with PIP.

pip install -r requirements.txt

If you'd like to use a different installation method or another CUDA version with PyTorch (e.g. CUDA 10) follow the instructions on PyTorch - Getting Started.

Data

CROHME: Competition on Recognition of Online Handwritten Mathematical Expressions has been used. As it is an on-line handwritten dataset, it consists of InkML files, but this architecture is for off-line recognition, which means that images are used as input.

The dataset has been converted to images of size 256x256 and the ground truth has been extracted as well. The converted dataset can be found at Kaggle - crohme-png.

The data needs to be in the data/ directory and a tokens.tsv file defines the available tokens separated by tabs. Training and validation sets are defined in gt_split/train.tsv and gt_split/validation.tsv, where each line is the path to the image and its ground truth.

The training/validation split can be generated by running:

python data_tools/train_validation_split.py -i data/groundtruth_train.tsv -o data/gt_split

Note: The content of the generated images vary greatly in size. As longer expressions are limited to the same width, they will essentially use a smaller font. This makes it much more difficult to correctly predict the sequences, especially since the dataset is quite small. The primary focus was the attention mechanism, to see whether it can handle different sizes. If you want better results, the images need to be normalised.

Usage

Training

Training is done with the train.py script:

python train.py --prefix "some-name-" -n 200 -c checkpoints/example-0022.pth

The --prefix option is used to give it a name, otherwise the checkpoints are just numbered without any given name and -c is to resume from the given checkpoint, if not specified it starts fresh.

For all options see python train.py --help:

Evaluation

To evaluate a model use the evaluate.py script with the desired checkpoint and the dataset it should be tested against (can use multiple sets at once):

For example to evaluate the sets 2014 and 2016 with beam width 5:

python evaluate.py -d 2014 2016 --beam-width 5 -c checkpoints/example-0022.pth

math-formula-recognition's People

Contributors

jungomi avatar dependabot[bot] 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.