Code Monkey home page Code Monkey logo

im2latex's Introduction

Im2Latex

Seq2Seq model with Attention + Beam Search for Image to LaTeX, similar to Show, Attend and Tell and Harvard's paper and dataset.

Check the blog post.

Install

Install pdflatex (latex to pdf) and ghostsript + magick (pdf to png) on Linux

make install-linux

(takes a while ~ 10 min, installs from source)

On Mac, assuming you already have a LaTeX distribution installed, you should have pdflatex and ghostscript installed, so you just need to install magick. You can try

make install-mac

Getting Started

We provide a small dataset just to check the pipeline. To build the images, train the model and evaluate

make small

You should observe that the model starts to produce reasonable patterns of LaTeX after a few minutes.

Data

We provide the pre-processed formulas from Harvard but you'll need to produce the images from those formulas (a few hours on a laptop).

make build

Alternatively, you can download the prebuilt dataset from Harvard and use their preprocessing scripts found here

Training on the full dataset

If you already did make build you can just train and evaluate the model with the following commands

make train
make eval

Or, to build the images from the formulas, train the model and evaluate, run

make full

Details

  1. Build the images from the formulas, write the matching file and extract the vocabulary. Run only once for a dataset
python build.py --data=configs/data.json --vocab=configs/vocab.json
  1. Train
python train.py --data=configs/data.json --vocab=configs/vocab.json --training=configs/training.json --model=configs/model.json --output=results/full/
  1. Evaluate the text metrics
python evaluate_txt.py --results=results/full/
  1. Evaluate the image metrics
python evaluate_img.py --results=results/full/

(To get more information on the arguments, run)

python file.py --help

im2latex's People

Contributors

guillaumegenthial avatar

Watchers

James Cloos 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.