OCR Util
Collection of utils for
- 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-util eval --help
# corpus management
ocr-util corpus --help
# slice image by image + input OCR
ocr-util slice --help
# render image + input OCR
ocr-util 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 excluded and reported where possible from evaluation.
The term 'invalid' refers to errors in schemas in structured XML-data, i.e. syntax errors and further if included geometrical information includes inconsistencies like missing points or missmatching shapes.
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-util 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-util 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
Platform: 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.1.1.tar.gz.
File metadata
- Download URL: ocr_util-2.1.1.tar.gz
- Upload date:
- Size: 119.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2abbc7b54196483615a5b7fbf28b625a6f604079418aa74e9e827db63aed086
|
|
| MD5 |
04c55676b138d3b006ced7623e64ee1f
|
|
| BLAKE2b-256 |
61efb58ed55b2bfdbb9397acc79c4b0d8c6d0518757c86ebda0fd764ac15cadb
|
File details
Details for the file ocr_util-2.1.1-py3-none-any.whl.
File metadata
- Download URL: ocr_util-2.1.1-py3-none-any.whl
- Upload date:
- Size: 88.9 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 |
b1cb976b7326c7f41c3f51989108d7ac810e01f62148966c0255eca06bf6c2a8
|
|
| MD5 |
c04aed0640c71bc1c827c14ef93fb91f
|
|
| BLAKE2b-256 |
b093a162b4049f2388bc8ab4383fafcedd6add3616610a6747300badc623756d
|