glyphly
OCR for Python with nothing to install but the package: words, boxes and confidences, no Tesseract.
Downloads & Community Adoption
Health & Engineering Analysis (5 Pillars)
1. Governance & Community50 / 200 ▾
2. PEP Metadata & Packaging200 / 200 ▾
3. Security & Supply Chain200 / 200 ▾
4. Documentation, SEO & Ecosystem105 / 200 ▾
5. Engineering, CI & Quality0 / 200 ▾
Official Documentation & Usage Guide — glyphly
Show full original documentation (English README) ▾
glyphly
OCR for Python with nothing to install but the package. Reads scans, photos and
images into text, with every word's position and confidence. No Tesseract, no OpenCV, no
system programs: pip install glyphly brings NumPy, Pillow and ONNX Runtime, all as
wheels for Windows, macOS and Linux.
Pre-alpha. The engine works and is measured, but the API may change and it is not on PyPI yet. Feedback is very welcome.
import glyphly
page = glyphly.read("scan.png") # path, bytes, PIL image or NumPy array
print(page.text) # lines in reading order
print(page.confidence) # 0..1, character-weighted
for word in page.lines[0].words:
print(word.text, word.box, word.confidence) # box = (x0, top, x1, bottom) in pixels
glyphly read scan.png # text
glyphly read scan.png --json # lines, words, boxes, confidences
glyphly download # fetch the model files now, for offline use later
For many images, create one glyphly.Reader() and call reader.read(...) on each: the
models load once.
How it works
- Find text lines. A small segmentation network (PP-OCRv6 detection) marks text pixels. glyphly's own post-processing, written in NumPy, groups them into lines and measures each line's direction, so tilted pages (skewed scans, phone photos) are cut out straight instead of slicing through neighbouring lines.
- Read each line. A recognition network (PP-OCRv6) reads each straightened line at its full width (no width cap, so long lines and wide fonts are not squeezed), and CTC decoding turns its output into characters.
- Locate words. Each character comes from a known column of the line, so every word gets its own box on the page.
The model files (31 MB) are downloaded once into ~/.cache/glyphly (or GLYPHLY_HOME) and
checked against a pinned SHA-256 fingerprint before use. They come from PaddleOCR via the
RapidOCR project, both Apache-2.0 (see NOTICE). Replacing the recognition model
with one trained by this project is on the roadmap.
Accuracy
Measured with bench/ocr.py on pages rendered from known text in 5 fonts, so the ground
truth is exact. Held-out test split (pages never used while building), character error
rate, lower is better:
| glyphly | gleanly + Tesseract | RapidOCR (same models) | plain Tesseract | |
|---|---|---|---|---|
| Standard: clean, fax, blur, noise, 3° skew, JPEG, faint + shadow, phone photo (120 pages) | under 0.05% | 0.6% | 5.1% | 16.1% |
| Hard: small print, white on dark, colour, perspective, cheap scan, two columns, table (105 pages) | 0.1% | 0.0% | 15.1% | 0.5% |
Two columns are read one after the other and tables row by row (each row on one line). Weak spot left on the hard suite: cheap scans (0.3%). These are generated pages: real scans and a comparison with docTR, EasyOCR, PaddleOCR and a paid OCR service come next (see docs/review.md).
Languages
glyphly.read() works out the script by itself: Latin-script languages, Chinese and
Japanese are read by the default model; lines that look misread are re-read with the
matching script model (downloaded the first time a page needs it, about 8 MB each, checked
by SHA-256), right-to-left lines are put in reading order, and numbers skipped by the
Arabic-script model are read back in. Or choose: Reader(lang="ru"),
Reader(lang=["hi", "en"]), glyphly read scan.png --lang ar; glyphly download --all
fetches every model for offline use.
Measured with bench/languages.py (the same short notice with a date and an amount,
written in each language and drawn by a browser so every script is shaped correctly),
character error rate:
| Script | Languages measured | CER |
|---|---|---|
| Latin | English, German, French, Spanish, Portuguese, Polish, Turkish | 0% |
| Latin | Vietnamese | 5.4% (stacked accents dropped) |
| Chinese, Japanese, Korean | zh, ja, ko | 0% |
| Greek, Thai, Tamil | el, th, ta | 0% |
| Cyrillic | Russian, Ukrainian | 5.0%, 1.2% |
| Devanagari, Telugu | Hindi, Telugu | 1.4%, 4.2% |
| Arabic script | Arabic, Persian | 5.3%, 6.3% |
| Not supported yet | Hebrew, Bengali (and other scripts without an open model) | 83%, 76% |
Average over the 20 supported languages: 1.4%. One sentence per language is a smoke test, not a full benchmark: real documents per language are on the roadmap.
Status and roadmap
- Engine on ONNX Runtime with no system dependencies; rotated lines; word boxes
- Held-out and hard-suite results; two-column reading order; table rows
- 20 languages in 11 scripts, detected automatically
- Table structure (cells), page orientation, real-scan benchmark
- Hebrew, Bengali and other scripts without an open model
- Release on PyPI; used by gleanly for OCR
- glyphly's own trained recognition model
- Real-scan benchmark; comparison with Docling, Marker and a paid OCR service
Development
uv sync # package + dev tools
uv run glyphly download # model files
uv run pytest
uv sync --group bench # + RapidOCR baseline; gleanly[ocr] and Tesseract optional
uv run python -m bench.ocr --split dev