Installation¶
Tetrak is a Python package. It needs Python 3.11 or later, two system tools that are not Python packages, and whichever optional OCR engines you intend to use.
The package¶
pip install tetrak
The distribution is tetrak; the command it installs is tetrak-ocr, and
the import package is tetrak_ocr. A plain install gives you Tesseract (via
pytesseract), image handling, PDF rasterisation, the searchable-PDF
writer, and the check that every scan passes before any of them opens it
(sillybos: the file really is a
JPEG, PNG, TIFF or PDF, within size and page limits, with nothing in its
header or its PDF features that a scan never has; anything else goes to
triage with the reason): enough to process a folder of scans offline.
Most people want more than that. The install we recommend adds quality
scoring, which is what turns on auto-local, the backend that runs every
engine you have and keeps the best transcript per file:
pip install 'tetrak[qa]'
[qa] installs no extra engines. With core plus [qa], auto-local is
choosing between one engine. Add the extras below to give it a choice.
System dependencies¶
Two things must be installed separately, because they are binaries rather
than Python packages. Tesseract is the OCR engine itself; pytesseract
only wraps it. Poppler provides pdfinfo, which the check reads a PDF’s
page count and page sizes from, and pdftoppm, which pdf2image shells out
to when rasterising the pages. Without poppler, the first PDF stops with a
message that says to install it.
macOS:
brew install tesseract poppler
Debian or Ubuntu:
sudo apt-get install tesseract-ocr poppler-utils
Optional backends¶
Every heavy engine is an extra, so you install only what you intend to use.
The difference is not marginal: the core install is a few tens of megabytes,
while [all] pulls PyTorch, PaddlePaddle and several sets of model weights,
well over a gigabyte before any model downloads at first run.
Extra |
Enables |
What it installs |
|---|---|---|
|
|
pyspellchecker, transformers, torch |
|
|
EasyOCR |
|
|
our Armenian recogniser, as an EasyOCR custom network (pulls in EasyOCR) |
|
|
PaddleOCR and PaddlePaddle |
|
|
PaddleOCR-VL, the document vision-language model in the same package |
|
|
withdrawn for now; see below |
|
|
|
|
|
the Anthropic SDK |
|
|
NumPy and OpenCV, which EasyOCR brings in anyway |
|
everything above except |
|
|
the same as |
pip install 'tetrak[qa,easyocr]' # a choice of two local engines
pip install 'tetrak[qa,vision]' # on a Mac: the strongest local engine measured
pip install 'tetrak[all]' # everything, several gigabytes
pip install 'tetrak[armenian]' # Armenian material
If you ask for a backend you have not installed, the error names the extra
rather than raising ModuleNotFoundError:
$ tetrak-ocr ocr scan.jpg --backend paddle
error: The 'paddle' backend needs the 'paddleocr' and 'paddlepaddle' packages, not installed here.
Install with: pip install 'tetrak[paddle]'
Note
The marker extra is withdrawn for now. Every marker-pdf release, and
surya-ocr under it, requires Pillow below 11, and Tetrak requires Pillow 13
for the security fixes in that release, so the two cannot share an
environment. tetrak-ocr backends lists marker as unavailable and says
why. The extra comes back once marker-pdf allows Pillow 13. Until then,
use tetrak 5.20 or earlier for Marker, in an environment of its own.
Warning
The marker extra is copyleft. marker-pdf and its Surya models are, as of
writing, GPL-3.0, with a commercial-use exception offered by their author.
That does not affect Tetrak itself, since extras are optional dependencies
resolved at install time and never vendored, but it does affect anyone
redistributing a bundle that includes them. Check the current terms upstream;
licence terms change. See licensing.
Model weights¶
The deep-learning backends download their weights on first use and cache them locally, so the first call in a fresh environment is slow and later ones are not. Approximate sizes:
Backend |
Download |
Cached under |
|---|---|---|
|
~100 MB |
|
|
~15 MB for the recogniser, plus EasyOCR’s detector |
the EasyOCR cache |
|
~100 MB |
|
|
~1 GB |
|
|
~500 MB to 1 GB |
|
|
~500 MB for GPT-2, used by the quality score |
|
vision downloads nothing: the model ships with macOS. tesseract uses the
language data installed with the Tesseract binary.
Check what you have¶
$ tetrak-ocr backends
✓ tesseract
✓ tesseract-auto
· claude (extra not installed)
· claude-haiku (extra not installed)
· easyocr (extra not installed)
✓ easyocr-hy
· paddle (extra not installed)
· paddle-vl (extra not installed)
· marker (extra not installed)
✓ vision
✓ auto-local
A tick means installed and usable here; a dot names an extra that is
missing. The list is honest about more than packages: auto-local reports
as missing without the qa extra, because it cannot score transcripts
without it, and vision never appears usable off macOS.
To see which release is installed:
python -c "import tetrak_ocr; print(tetrak_ocr.__version__)"
API credentials¶
Only the Claude backend makes network calls. It needs an API key, read with
python-dotenv from a .env file in your working directory, or from the
environment:
ANTHROPIC_API_KEY=sk-ant-...
If you are not using claude, nothing else in the package needs this.
For development¶
git clone https://github.com/scattercode/tetrak.git
cd tetrak
uv sync --extra dev # add extras as needed: --extra all --extra armenian is everything
uv run pytest -m "not slow"
uv creates .venv from the committed
uv.lock, so every checkout gets the same versions. A plain python3 -m venv
followed by pip install -e '.[dev]' works too.
-m "not slow" skips the tests that read the evaluation corpus and invoke a
real OCR engine; it runs in well under a second. The evaluation corpus and
harness live in evaluation/ and are not part of the installed package, so
tetrak-ocr evaluate only works from a checkout.