Mon OCR
Optical Character Recognition for Mon (mnw) text.
Installation
pip install monocr | uv add monocr
Quick Start
Python Usage
from monocr import MonOCR
# Initialize. Downloads the model pinned in config.HF_REVISION on first use.
model = MonOCR()
# A page: segmented into lines, joined with newlines
print(model.predict_page("page.png"))
# A line crop: read whole, never split
print(model.predict_line("line.png"))
# With a confidence score
result = model.predict_with_confidence("page.png")
print(f"Text: {result['text']}")
print(f"Confidence: {result['confidence']:.2%}")
predict and read_text are aliases for predict_page. If you are passing
single-line crops, call predict_line — it is the only path that cannot split
one line into several.
Examples
See the examples/ folder to learn more.
examples/run_ocr.py: A complete script that can process a folder of images or read a full PDF book.- Or a demo notebook to play around with the package
notebooks/demo.ipynb
CLI Usage
You can also use the command line interface:
# Process a single image
monocr read image.png
# Process a folder of images
monocr batch folder/path
# Manually download the model
monocr download
Resources
Development
uv sync
uv run pytest
Release Workflow
The tag has to match [project.version] in pyproject.toml. The release
workflow checks, and fails the build if it does not — this section used to
show git tag v2.2.3 next to a version of 2.2.0, and nothing would have
stopped that going out.
uv version --bump patch # or minor / major
git commit -am "release: $(uv version --short)"
git tag "v$(uv version --short)"
git push origin HEAD --tags
Publishing runs from the tag, through GitHub Actions, using PyPI trusted publishing. It installs from the lockfile and runs the test suite first.
License
MIT - do whatever you want with it.
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 monocr-2.3.0.tar.gz.
File metadata
- Download URL: monocr-2.3.0.tar.gz
- Upload date:
- Size: 117.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9138f0435ea0aecb475a47a0561ccda72a8087b000b6d32d411e1b05e0fa3caf
|
|
| MD5 |
614850765e48f6195ef6a40dcecd43ed
|
|
| BLAKE2b-256 |
9b831f043a91b05b5765cfdfb7ccc165c4c04da23cbbdb43058217878d5b434f
|
File details
Details for the file monocr-2.3.0-py3-none-any.whl.
File metadata
- Download URL: monocr-2.3.0-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ed163d4dc53f9816689eb36c47cf1961ae7f83c91e2d73d65d6107bb77a7ada
|
|
| MD5 |
a4e28e695264a03db5439b82eb1030b6
|
|
| BLAKE2b-256 |
7b59be2b3cc2272c2b4402ec751c723290e2ea2fb988ed8830809f35ab7afea4
|