OCR Util
Collection of utils to
- evaluation of OCR data for the masses
- generation of extended OCR-Evaluation Corpora
- generation of pair-wise Trainingdata for OCR-Backends
Requirements
- recent *nix-OS
- Python3.10+ Environment
Usage
Each section contains detailed usage help instructions:
# evaluation
ocr eval --help
# corpus management
ocr corpus --help
# slice image by image + input OCR
ocr slice --help
# render image + input OCR
ocr show --help
Data problems
Inconsistent OCR Groundtruth with empty texts (ALTO String elements missing CONTENT or PAGE without TextEquiv) or invalid geometrical coordinates (less than 3 points or even empty) will lead to evaluation errors if geometry must be respected.
Please note:
Invalid data files are tried(!) to be excluded from evaluation.
Evaluation Filter-Then-Aggregate
The evaluation CLI supports a single pre-aggregation filter using metadata extractors.
Example: keep only entries where MODS language is exactly German, then aggregate by publication century:
ocr eval <candidates> \
--reference <groundtruth> \
--mets-file <mets.xml> \
--filter-by "mods:language=ger" \
--aggregate-by "mods:dateIssued:century"
Multi-language filter values are interpreted as sets:
ocr eval <candidates> \
--reference <groundtruth> \
--mets-file <mets.xml> \
--filter-by "mods:language=ger+eng" \
--aggregate-by "mods:dateIssued:century"
Behavior:
- single filter value -> exact match (e.g.
gerdoes not matchger+eng) - multi-value filter -> all filter values must be present in any order
- entries missing the filter criterion are reported as WARNING and discarded
Development
Plattform: Intel(R) Core(TM) i5-6500 CPU@3.20GHz, 16GB RAM, Ubuntu 22.04 LTS, Python 3.10+
# clone local
git clone <repository-url> <local-dir>
cd <local-dir>
# enable virtual python 3 environment (linux)
# and update pip itself
python3.10 -m venv venv
. venv/bin/activate
python -m pip install -U pip
# install with dev dependencies
python -m pip install -e ".[dev,test]"
# run tests with coverage
python -m pytest --cov=src
# run tests faster (parallel, auto worker count)
python -m pytest -q -n auto
Contribution
Contributions, suggestions and proposals welcome!
License
Under terms of the MIT license.
NOTE: This software depends on packages that might be licensed under different terms.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ocr_util-2.0.1.tar.gz.
File metadata
- Download URL: ocr_util-2.0.1.tar.gz
- Upload date:
- Size: 115.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4816dc28ad26d6002eadbf8e35638bb4151ad16eca240afdb366e3ba8761182c
|
|
| MD5 |
36356fe632e46e8c7c1c463fa2953e9e
|
|
| BLAKE2b-256 |
d5f00bc36e66dcf814e606cb6708490ec71d173922b361fef69df0aefc942ab5
|
File details
Details for the file ocr_util-2.0.1-py3-none-any.whl.
File metadata
- Download URL: ocr_util-2.0.1-py3-none-any.whl
- Upload date:
- Size: 86.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29905e85eb9f4694d9be030bd3c72bc40a858a76256cc0426134d06d90f3965f
|
|
| MD5 |
62b3dc078a51bf92e3cd885ccc8c813f
|
|
| BLAKE2b-256 |
8db5915678be4f98ed38854484e32865c030b941dbbb970ce83b4c81ec4113a2
|