lukas-blecher

    lukas-blecher/LaTeX-OCR

    pix2tex: Using a ViT to convert images of equations into LaTeX code.

    deep-learning
    computer-vision
    machine-learning
    dataset
    im2latex
    im2markup
    im2text
    image-processing
    Python
    MIT
    16.6K stars
    1.3K forks
    16.6K GitHub watchers
    Updated Oct 31, 2026
    View on GitHub

    Build with Backblaze B2

    SDKs, agent skills, IDE extensions, and reference pipelines from Backblaze Labs. All open source.

    Explore Backblaze Labs

    Loading star history...

    Where it stands

    Rank, growth pace and release cadence relative to everything GStars tracks.

    The project lists 21 contributors on GitHub.

    Peaked at #81 in the weekly ranking the week of Oct 5, its best in the past year.

    Use Cases & Benefits

    • Converts images of mathematical equations into LaTeX code using a Vision Transformer-based OCR model.
    • Provides automatic resolution optimization and multiple interfaces including CLI, GUI, API, and Python integration for flexible usage.
    • Use for extracting LaTeX code from screenshots or scanned images of printed math formulas for academic papers.
    • Use for integrating math OCR capabilities into educational software or digital note-taking apps to convert handwritten or typed math to LaTeX.
    • Use for training custom OCR models on specialized math datasets to improve recognition accuracy or support new fonts and handwritten formulas.

    Should you depend on it?

    License terms, project hygiene and risks, from GitHub metadata and GStars' snapshots.

    License

    MIT

    Permissive: commercial use, modification and redistribution are allowed with attribution.

    Community files

    • README: present

    Watch-outs

    • Warning: No commits in over a year (last push Jan 2025).

    General guidance from repository metadata, not legal advice. How we score

    From the README

    The goal of this project is to create a learning based system that takes an image of a math formula and returns corresponding LaTeX code.

    To run the model you need Python 3.7+

    If you don't have PyTorch installed. Follow their instructions here.

    Model checkpoints will be downloaded automatically.

    There are three ways to get a prediction from an image.

    The model works best with images of smaller resolution. That's why I added a preprocessing step where another neural network predicts the optimal resolution of the input image. This model will automatically resize the custom image to best resemble the training data and thus increase performance of images found in the wild. Still it's not perfect and might not be able to handle huge images optimally, so don't zoom in all the way before taking a picture.

    Always double check the result carefully. You can try to redo the prediction with an other resolution if the answer was wrong.

    Want to use the package?

    I'm trying to compile a documentation right now.

    Install a couple of dependencies pip install "pix2tex[train]".

    To use your own tokenizer pass it via --tokenizer (See below).

    You can find my generated training data on the Google Drive as well (formulae.zip - images, math.txt - labels). Repeat the step for the validation and test data. All use the same label text file.

    If you want to use your own data you might be interested in creating your own tokenizer with

    Excerpt from the lukas-blecher/LaTeX-OCR README on GitHub (MIT license). © its authors.Read the full README on GitHub

    Daily snapshots

    Stars gained per day, and how forks and open issues moved, from GStars' daily snapshots

    Forks

    1.3K-5

    Open issues

    158-1

    Compared with peers in Deep Learning

    Fastest-growing repositories GStars tracks in this cohort for the week of Nov 1, by 7-day star growth

    lukas-blecher/LaTeX-OCR compared with Deep Learning repositories by stars, 7-day star growth, health score and last release
    RepositoryStars+7dHealthLast release
    onnx/onnx21.6K—6331 days ago
    mlc-ai/web-llm19.3K—5916 days ago
    lukas-blecher/LaTeX-OCR16.6K—18—
    milesial/Pytorch-UNet11.7K—18—
    SharpAI/DeepCamera3.1K—31227 days ago
    vercel-labs/vgpu2.6K—5916 days ago
    Category median11.7K—59—

    Discover Repositories

    Search across tracked repositories by name or description