mittagessen/kraken

OCR engine for all the languages

What is kraken?

kraken is an open‑source OCR (optical character recognition) toolkit aimed at digitising historical documents and any scripts that aren’t well‑served by mainstream OCR engines. It bundles a trainable layout analyser, a reading‑order detector and a neural‑network recogniser that can handle right‑to‑left, bidirectional and top‑to‑bottom scripts.


Key capabilities

Feature Why it matters
Fully trainable pipeline – you can teach the system new page layouts, reading orders and character sets, which is essential for old manuscripts, non‑Latin alphabets, or custom fonts.
Bi‑directional & vertical script support – works with Arabic, Hebrew, CJK vertical text, etc.
Multiple output formats – ALTO, PageXML, abbyyXML, hOCR – ready to drop into digital‑library workflows.
Word‑level bounding boxes & character cuts – gives fine‑grained localisation useful for scholarly annotation.
Model zoo on Zenodo – a public repository of pre‑trained models (e.g., printed French, historic fonts) that can be fetched with a single command.
Pluggable network architecture – you can swap the recogniser backbone to suit speed or accuracy needs.
Cross‑platform – runs on Linux and macOS, on both x86_64 and ARM CPUs.

Getting started (quick install)

# Recommended: isolated environment via pipx
sudo apt install pipx            # on Debian/Ubuntu
pipx install kraken               # pulls the package and its deps

If you prefer a classic virtual environment:

python -m venv venv && source venv/bin/activate
pip install kraken               # or `pip install .` from the repo

For PDF or multi‑image TIFF support add the optional extra:

pip install kraken[pdf]

Running OCR in a single line

kraken -i image.tif image.txt binarize segment ocr

The command does three things automatically:

  1. Binarises the image (nlbin algorithm).
  2. Segments the page into text lines (baseline segmenter).
  3. Recognises the text using the default model and writes a plain‑text file.

You can also call each step individually (e.g., kraken -i img.tif bw.png binarize).


Extending with your own models

# Grab a ready‑made model from the public Zenodo collection
kraken get 10.5281/zenodo.10592716

# List all available community models
kraken list

For custom projects you can train a new model on your own annotated data (the docs at https://kraken.re cover the full workflow).


Who uses it?

kraken is developed by the eScripta research group (École Pratique des Hautes Études, Université PSL) and is tightly integrated with the eScriptorium web interface, which provides a GUI for annotating training data and running inference. It is funded by several EU research programmes (ATRIUM, ERC MiDRASH, RESILIENCE, and the French ANR Biblissima+), underscoring its relevance for digital humanities and cultural‑heritage projects.


Where to learn more


TL;DR

kraken is a Python‑based, fully trainable OCR engine specialised for historic and non‑Latin scripts, offering end‑to‑end processing (binarisation → layout analysis → recognition) and a library of open models. Install with pipx install kraken, fetch a model, and run kraken -i file.tif out.txt binarize segment ocr to start digitising old texts.

Related

  • Project
  • Project
  • Project
  • Project
  • Project