[![built with nix](https://builtwithnix.org/badge.svg)](https://builtwithnix.org)

![deploying](https://github.com/DieracDelta/DieracDelta.github.io/workflows/Build/badge.svg)

Using OCR to generate Typst code based on images of math formulas as a fully client-side webapp.

# Getting started

## Using the model
The model is hosted here.

## Installation

## Obtaining data

We use oxen to version control our data. To get the oxen executable, run `nix develop`. Then, from the root of this repo, clone the oxen repo:

```sh
oxen clone https://hub.oxen.ai/DiracDelta/data
```

The datasets we use for this project will now be available in `data/`.

## Training the model

Detypstify uses a custom dataset which was generated by transpiling the
[im2latex-230k](https://www.kaggle.com/datasets/gregoryeritsyan/im2latex-230k) with pandoc and
cleaning the resulting data (see `scraper/`). The final dataset is available on
[Kaggle](https://www.kaggle.com/datasets/jachymp/im2typst-230k).

1. Download the dataset and unzip it
2. Run `poetry run train_val_split` to perform a train validation split
3. Generate `formulas.txt` by running `scripts/mk_formulas_txt.sh` on the `train` and `val` directories
4. Install `pix2tex`
    1. Follow the instructions to generate `tokenizer, train.pkl, val.pkl`
    2. Create a `config.yaml` based on the [template](https://github.com/lukas-blecher/LaTeX-OCR/blob/main/pix2tex/model/settings/config.yaml)
    3. Train the model with `python -m pix2tex.train --config config.yaml`

