GithubHelp home page GithubHelp logo

gabeochieng / image2latex-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sxdkxgwan/image2latex

0.0 1.0 0.0 317 KB

Attention based model ( variation of Show Attend and Tell) for LateX code generation in Tensorflow

Shell 0.18% Python 90.74% JavaScript 9.08%

image2latex-1's Introduction

Img2Latex

Install

Install ghostsript and magick (from source depending on your linux distribution) and pdflatex for evaluation

https://www.imagemagick.org/script/install-source.php

sudo pip install -r requirements.txt
sudo apt-get install texlive-latex-base
sudo apt-get install texlive-latex-extra

sudo apt-get install ghostscript
sudo apt-get install libgs-dev

wget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar -xvf ImageMagick.tar.gz
cd ImageMagick-7.*
./configure --with-gslib=yes 
make
sudo make install
sudo ldconfig /usr/local/lib

Data and Preprocessing

We use Harvard preprocessing scripts that can be found at http://lstm.seas.harvard.edu/latex/

First, crop + downsampling of images + group by similar shape

python scripts/preprocessing/preprocess_images.py --input-dir data/formula_images --output-dir data/images_processed

Second, parse formulas with KaTeX parser

python scripts/preprocessing/preprocess_formulas.py --mode normalize --input-file data/im2latex_formulas.lst --output-file data/norm.formulas.lst

Third, filter formulas

python scripts/preprocessing/preprocess_filter.py --filter --image-dir data/images_processed --label-path data/norm.formulas.lst --data-path data/im2latex_train.lst  --output-path data/train_filter.lst
python scripts/preprocessing/preprocess_filter.py --filter --image-dir data/images_processed --label-path data/norm.formulas.lst --data-path data/im2latex_validate.lst  --output-path data/val_filter.lst
python scripts/preprocessing/preprocess_filter.py --filter --image-dir data/images_processed --label-path data/norm.formulas.lst --data-path data/im2latex_test.lst  --output-path data/test_filter.lst

Train

Edit the config file in configs/

python main.py

image2latex-1's People

Contributors

guillaumegenthial avatar romainsauvestre 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.