ocrd_kraken
OCR-D wrapper for the Kraken OCR engine
Introduction
This package offers OCR-D compliant workspace processors for (some of) the functionality of Kraken.
(Each processor is a parameterizable step in a configurable workflow of the OCR-D functional model. There are usually various alternative processor implementations for each step. Data is represented with METS and PAGE.)
It includes image preprocessing (binarization), layout analysis (region and line+baseline segmentation), and text recognition.
Installation
With Docker
This is the best option if you want to run the software in a container.
You need to have Docker
docker pull ocrd/kraken
To run with Docker:
docker run --rm \
-v path/to/workspaces:/data \
-v path/to/models:/usr/local/share/ocrd-resources \
ocrd/kraken ocrd-kraken-recognize ...
# or ocrd-kraken-segment or ocrd-kraken-binarize
Native, from PyPI
This is the best option if you want to use the stable, released version.
pip install ocrd_kraken
Native, from git
Use this option if you want to change the source code or install the latest, unpublished changes.
We strongly recommend to use venv.
git clone https://github.com/OCR-D/ocrd_kraken
cd ocrd_kraken
sudo make deps-ubuntu # or manually from git or via ocrd_all
make deps # or pip install -r requirements.txt
make install # or pip install .
Models
Kraken uses data-driven (neural) models for segmentation and recognition, but comes with no pretrained "official" models.
There is a public repository of community-provided models, which can also
be queried and downloaded from via kraken standalone CLI.
(See Kraken docs for details.)
For the OCR-D wrapper, since all OCR-D processors must resolve file/data resources in a standardized way, there is a general mechanism for managing models, i.e. installing and using them by name. We currently manage our own list of recommended models (without delegating to the above repo).
Models always use the filename suffix .mlmodel, but are just loaded by their basename.
See the OCR-D model guide and
ocrd resmgr --help
Usage
For details, see docstrings in the individual processors and ocrd-tool.json descriptions,
or simply --help.
Available OCR-D processors are:
- ocrd-kraken-binarize (nlbin – not recommended)
- adds
AlternativeImagefiles (per page, region or line) to the output fileGrp
- adds
- ocrd-kraken-segment (all-in-one segmentation – recommended for handwriting and simply layouted prints, or as pure line segmentation)
- adds
TextRegions toPage(iflevel-of-operation=page) orTableRegions (iftable) - adds
TextLines (withBaseline) toTextRegions (for alllevel-of-operation) - masks existing segments during detection (unless
overwrite_segments)
- adds
- ocrd-kraken-recognize (benefits from annotated
Baselines, falls back to center-normalized bboxes)- adds
Words toTextLines - adds
Glyphs toWords - adds
TextEquiv(removing existingTextEquivifoverwrite_text)
- adds
Testing
make test
This downloads test data from https://github.com/OCR-D/assets under repo/assets, and runs some basic tests of the Python API.
Set PYTEST_ARGS="-s --verbose" to see log output (-s) and individual test results (--verbose).
Metadata
Release files for ocrd-kraken 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ocrd_kraken-1.0.1.tar.gz | 26.3 kB | Without provenance | Details for ocrd_kraken-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ocrd_kraken-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for ocrd_kraken-1.0.1-py3-none-any.whl |
Total release size: 50.3 kB
Release files / ocrd_kraken-1.0.1.tar.gz
| Download URL | ocrd_kraken-1.0.1.tar.gz |
|---|---|
| Size | 26.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c7516758d91d51a26da18571bb2918f8e047688cbf6c3e0aee375ebe6e4c32e7
|
|
BLAKE2b-256 checksum How to use checksums |
3178b538b9c588005e9f7ab84b5672b70d36c5e46f7749aa3c94de41242cd179
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Release files / ocrd_kraken-1.0.1-py3-none-any.whl
| Download URL | ocrd_kraken-1.0.1-py3-none-any.whl |
|---|---|
| Size | 23.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
48a996baeb5526082f5d744f974b86165638ed3590ee56e7b07af726c4f37670
|
|
BLAKE2b-256 checksum How to use checksums |
c24c5926185972754e269b1a5401ea2b706451002e5ad2ee77823b07f3d1627f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Security for ocrd-kraken 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.