Tuatara is a deep learning based OCR engine built on CRAFT for text detection, and PARSEQ for text recognition. This project is mainly a way for me to explore and experiment with vision and NPL model performance.
This code is currently a work in progress and is not intended for production use.
The project is named after the tuatara, a lizard-like (rhynchocephalia) reptile native to New Zealand. Like it's lizard cousin's the tuatara has a parietal eye/third eye, symbolic of prescient abilities.
- Easy to understand and hackable - All the main code is in tuatara.cpp and is currently about 500 LOC
- Preference for targeting CPU over GPU and focus on CPU performance
- Minimal dependencies and small binary - The plan is to replace both the two main dependencies OpenCV and LibTorch with Eigen. I believe this will support goals 1 and 2.
Run ./setup.sh
or do following steps
- Download model weights
git clone https://huggingface.co/jackvial/tuatara-ocr-craft-and-parseq weights
- Download LibTorch
curl -O https://download.pytorch.org/libtorch/cpu/libtorch-macos-2.0.0.zip && unzip libtorch-macos-2.0.0.zip
- Install opencv
brew install opencv
- Download and build pybind11
git clone https://github.com/pybind/pybind11.git && cd pybind11 && mkdir build && cd build && cmake .. && make
mkdir -p build
cd build
cmake ..
cd bindings && python3 run_ocr.py
- Install the CodeLLDB VSCode extension
- Set a breakpoint in examples/resume.cpp or tuatara.cpp
- Run the "Debug Resume Example" under the VSCode "Run and Debug" tab
- Replace LibTorch dependency with Eigen implementations of CRAFT and PARSEQ models.
- Replace OpenCV dependency with Eigen. OpenCV is mainly used for connected component labeling and other post processing after the CRAFT model based text detection stage. OpenCV may still be used in python examples for debugging results.
- Retrain PARSEQ model to support a larger character set. The current model does not support the space character.
- Performance improvements: weight quantization, memory mapping, experiment with alternative model architectures, etc.