This project has been archived by its maintainers, and is no longer receiving any updates.
khocr-gen
Synthetic OCR training data generator for mixed Khmer/English text.
Installation
pip install khocr-gen
Requirements
- Python >= 3.12
- Rust toolchain (
cargo/rustc, edition 2021) - only needed to build the optional acceleration extension
Quick Start
1. Prepare fonts
fonts/
├── khmer/ <- .ttf / .otf Khmer fonts
└── english/ <- .ttf / .otf English fonts
Fonts placed directly in fonts/ (not in a subdirectory) are added to both pools as fallbacks.
2. Prepare corpus
A plain UTF-8 text file, one string per line:
សួស្តី
Hello World
ស្វាគមន៍ Welcome
3. Generate a dataset
khocr-gen generate --corpus corpus/corpus.txt --fonts fonts --output data --copies 3 --storage lmdb
4. View generated images
# Summary of an LMDB database
khocr-gen view --lmdb data/train/lmdb
# Extract images
khocr-gen view --lmdb data/train/lmdb --output-dir extracted
# Show labels only
khocr-gen view --lmdb data/train/lmdb --labels-only
Configuration
All generation parameters can be specified via CLI flags, a YAML config file, or both (CLI overrides YAML). See CONFIG.md for details. Example: generate.yml
Config loading order (highest priority wins):
- argparse built-in defaults
- YAML config file values
- Explicit CLI flags
CLI Reference
See CLI_REFERENCE.md for complete command documentation.
Documentation
- Getting Started for a first dataset.
- GitHub wiki for usage guides and troubleshooting.
- In-repository references for the CLI, configuration, augmentation, and Rust extension.
Acknowledgments
khocr-gen builds on these open-source libraries:
- khmernormalizer (MIT) - Khmer text normalization
- OpenCV (Apache 2.0) - Image processing and augmentation
- Pillow (HPND) - Font rendering and image creation
- Albumentations (MIT) - Augmentation primitives
- NumPy (BSD-3-Clause) - Numerical operations
- LMDB (OpenLDAP 2.8) - Embedded database for training pipelines
License
MIT
Metadata
Release files for khocr-gen 0.1.13
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 |
|---|---|---|---|---|
| khocr_gen-0.1.13.tar.gz | 200.0 kB | Without provenance | Details for khocr_gen-0.1.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| khocr_gen-0.1.13-py3-none-any.whl | Python 3 | none | any | Details for khocr_gen-0.1.13-py3-none-any.whl |
Total release size: 284.9 kB
Release files / khocr_gen-0.1.13.tar.gz
| Download URL | khocr_gen-0.1.13.tar.gz |
|---|---|
| Size | 200.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e9ddbccb2e0c3ae532c5427273f8ee772009d8effd3ebedddcbfe41909b62b4
|
|
BLAKE2b-256 checksum How to use checksums |
b23f7126cd7099b9a1c367061b7749c95881ef8a483b534f12bb3da657cff5b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / khocr_gen-0.1.13-py3-none-any.whl
| Download URL | khocr_gen-0.1.13-py3-none-any.whl |
|---|---|
| Size | 84.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5267df7f3bfa8d39dc4e38440f2f96017cea91ceda43d0d15580c6b1b7618037
|
|
BLAKE2b-256 checksum How to use checksums |
b66adb23a5e88015f45f7d3712eb429bc4f2fe50c611d4b65ec771ba84f23b0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for khocr-gen 0.1.13
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.