Mer (មើល)
Mer (មើល) is a lightweight bilingual (Khmer/English) OCR recognizer built around my custom CNN-Transformer network exported to ONNX.
This repository now focuses exclusively on line-level OCR — the Surya-powered layout, table, and LaTeX helpers have been removed, so the package is small and easy to embed anywhere you just need text from a single line image.
Installation
pip install mer
Getting started
from mer import Mer, postprocess_text
ocr = Mer()
ocr.load() # optional; kept for backwards compatibility
text = ocr.recognize_line("samples/sample_1.png")
print("Line text:", text)
# predict() is an alias for recognize_line()
json_result = ocr.predict("samples/sample_1.png", json_result=True)
print(json_result["text"])
# Optional extra cleanup
print(postprocess_text("ទៀតផង ។")) # -> "ទៀតផង។"
Configuration options
All options control the ONNX Runtime predictor:
device:"cpu","cuda", or specific device strings. Defaults to"cuda"with automatic CPU fallback.providers: optional explicit ONNX Runtime provider list. When omitted, providers are derived fromdevice.model_path: point to a directory containingkhmer_ocr.onnxandconfig.jsonto skip Hugging Face downloads.cache_dir/repo_id: control where artifacts are downloaded from Hugging Face Hub (metythorn/ocr-stn-cnn-transformer-baseby default).max_length: override the configured maximum decoding length.postprocess: disable built-in whitespace cleanup if you prefer the raw model output.json_result: default return type forpredict(). WhenTrue,predict()returns{"text": ...}; otherwise it returns a raw string. You can always override this per-call.
Using local model files
If you already have the ONNX weights and config on disk, point Mer at the folder to skip any Hugging Face download:
from mer import Mer
ocr = Mer(model_path="/path/to/local/model_dir", device="cpu")
ocr.load()
print(ocr.recognize_line("line.png"))
Post-processing helper
postprocess_text is exposed as a standalone helper so you can reuse the same Khmer punctuation cleanup on your own strings:
from mer import postprocess_text
assert postprocess_text(" ទៀត\tផង ។ ") == "ទៀត ផង។"
Sample data
The samples/ directory contains a few PNGs you can use for quick manual testing. They are untouched and meant purely for experimentation with the line recognizer.
Metadata
Release files for mer 1.2.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 | |
|---|---|---|---|---|
| mer-1.2.1.tar.gz | 14.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mer-1.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.8 kB
Release files / mer-1.2.1.tar.gz
| Download URL | mer-1.2.1.tar.gz |
|---|---|
| Size | 14.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9966755bdff9ec356bf5610d95fb895437da5241c610ae42686f44c484c6ddd6
|
|
BLAKE2b-256 checksum How to use checksums |
78155aa2857406eb720d2a80638b50b0f980206b1bef80c6662afe3bdd84d3c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / mer-1.2.1-py3-none-any.whl
| Download URL | mer-1.2.1-py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4cfb717b0705e6326e283af72a93113bd991318646974f1c54cc30a385cb53cb
|
|
BLAKE2b-256 checksum How to use checksums |
fd9e7eb2c3d8d856be960d2d95706ef0774c3517e80164f4706bd0dd5afbbe6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for mer 1.2.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.