Modelimage-to-text
Remtir

Remtir/AksonOCR-Lite

AksonOCR-Lite ▶ Try the live demo Code, docs and issues: github.com/Remtir/AksonOCR-Lite Fast, open-source Thai document OCR with a grapheme-cluster CTC recognizer. Turns PDFs and images into Markdown, plain text or JSON with layout blocks, reading...

17thích
10.6ktải xuống
0lượt xem

Thành tựu nổi bật

Những danh hiệu mới nhất của dự án

1
TINIX TRENDING·Chủ đề: thai

#1 Repository Của Ngày

1
TINIX TRENDING·Chủ đề: aksonocr-lite

#1 Repository Của Ngày

1
TINIX TRENDING·Chủ đề: text-recognition

#1 Repository Của Ngày

AksonOCR

AksonOCR-Lite

▶ Try the live demo

Code, docs and issues: github.com/Remtir/AksonOCR-Lite

Fast, open-source Thai document OCR with a grapheme-cluster CTC recognizer. Turns PDFs and images into Markdown, plain text or JSON with layout blocks, reading order, text-line boxes and tables. Runs on ONNX Runtime, on CPU or GPU, with no PyTorch or Paddle install.

Try it in your browser → Upload a page image or PDF (up to 7 MB) and see the Markdown, layout and tables. No install.

81M params, runs on CPU: ~3× faster per page than 2B-param OCR VLMs on a GPU, and more accurate than VLMs on average across MDPBench, ThaiOCRBench and SEA-DocBench (benchmarks).

pip install git+https://github.com/Remtir/AksonOCR-Lite
aksonocr invoice.pdf > invoice.md

The PyPI package (pip install aksonocr-lite) is coming soon; until then, install from GitHub as above.

  • Thai first: the text recognizer is trained for Thai (with English), predicting whole grapheme clusters so stacked vowels and tone marks come out in the right order.
  • Document structure: 25 layout classes (titles, paragraphs, tables, figures, headers/footers, ...) and reading order from PP-DocLayoutV3; tables become HTML with row/column spans.
  • Photos too: page-orientation correction, upside-down line detection, and optional page dewarping.
  • Light: about 330 MB of weights by default (≈620 MB with dewarping), fetched from the Hugging Face Hub on first run.
Layout blocks and text lines on a Thai government letterLayout blocks and text lines on a handwritten page photoLayout blocks and text lines on a financial statement

Layout blocks in reading order, table cells (TATR grid), then detected text lines. Made with tools/visualize_gif.py.

Benchmarks

MDPBench-th 85.6 with --dewarp (79.5 default) · ThaiOCRBench DP 0.640 · SEA-DocBench-th text NED 0.058 · 1.5 s per page on CPU only.

Accuracy of AksonOCR-Lite vs 12 other Thai OCR systems: average of MDPBench-th, ThaiOCRBench Document parsing and SEA-DocBench-th

Speed of AksonOCR-Lite vs three VLMs, average over three benchmarks: seconds per page one at a time, pages per second batched

Averages over MDPBench-th, ThaiOCRBench Document parsing and SEA-DocBench-th. Full benchmark → per-benchmark charts, default vs --dewarp, speed tables, text recognition only.

Requirements

Python3.10 or newer (CI tests 3.10 and 3.13)
OSLinux, macOS (Apple Silicon). Windows is untested so far.
HardwareAny x86-64 or ARM64 CPU. No GPU needed; NVIDIA GPU optional (see GPU).
RAMabout 1.3 GB peak for one page, about 2.8 GB with --dewarp
Diskabout 330 MB of model weights, plus 290 MB for --dewarp, in the Hugging Face cache (~/.cache/huggingface)
Networkonly on first run, to download the weights. Use AKSONOCR_WEIGHTS for fully offline machines.

No PyTorch, Paddle or system packages are needed. pip installs everything else: onnxruntime, numpy, opencv-python-headless, pillow, pypdfium2 (PDF rendering), pyclipper, shapely and huggingface_hub.

For the GPU build (onnxruntime-gpu): an NVIDIA driver with CUDA 12 and cuDNN 9, the versions current onnxruntime-gpu wheels are built against.

Usage

Command line

aksonocr page.jpg                        # Markdown to stdout
aksonocr report.pdf --out out/           # out/report.md (every page of the PDF)
aksonocr scan.png -f json -o out/        # boxes, blocks, lines, confidences
aksonocr photo.jpg --dewarp              # flatten a photographed / curled page
aksonocr doc.pdf --device cpu --dpi 200 --max-pages 10

Python

import aksonocr_lite

conv = aksonocr_lite.load()                 # device="auto" | "cpu" | "cuda", dewarp=False, tables=True, ...
for page in conv.convert("report.pdf"):     # path, bytes, PIL.Image or BGR numpy array
    print(page.markdown)
    for block in page.blocks:               # reading order
        print(block.label, block.bbox, block.text or block.html)
    for line in page.lines:
        print(line.text, line.confidence, line.poly)

lines = conv.ocr(bgr_image)                  # text lines only, no layout

Page fields: markdown, text, blocks (label, bbox, score, order, text, html, line_ids), lines (text, confidence, bbox, poly), rotation, dewarped, width, height, timings. All coordinates are in the pixel space of the (rotated, dewarped) page image.

GPU

The default install runs on CPU, on Linux and macOS (Apple Silicon). For CUDA, swap ONNX Runtime for its GPU build:

pip uninstall -y onnxruntime && pip install onnxruntime-gpu

device="auto" then picks CUDA. Inputs have variable shapes, so the CPU path is often just as fast for single pages; the GPU pays off mostly with dewarping and large batches.

Offline / custom weights

Set AKSONOCR_WEIGHTS=/path/to/dir to load models from a local folder instead of the Hub. It must contain layout.onnx det.onnx doc_ori.onnx textline_ori.onnx rec.onnx rec_charset.json tatr.onnx, plus dewarp_mask.onnx dewarp_grid.onnx for --dewarp.

How it works

page image ─┬─ (dewarp: MonkeyOCRv2 preprocessor)            optional
            ├─ page orientation: PP-LCNet doc_ori             0/90/180/270
            ├─ layout + reading order: PP-DocLayoutV3        ┐
            ├─ text lines: PP-OCRv6_medium_det (DB)           │ run on the same page
            │    └─ line orientation (PP-LCNet textline_ori)  │
            │    └─ recognition: AksonOCR Thai CTC (+180° re-read, keeps the more confident reading)
            ├─ tables: re-detect text in the crop → TATR v1.1 grid → fill cells with OCR lines → HTML
            └─ merge: each line → the layout block holding its centre (nearest block as fallback),
                      blocks in reading order → Markdown

Thai recognizer: grapheme-cluster CTC

Thai stacks vowels and tone marks on the consonant, so one glyph can be 2–3 code points (ผู้ = ผ + ู + ้). Instead of emitting them one by one, the recognizer predicts the whole cluster as one token.

Step by step: the recognizer's real CTC output on a Thai line, spelled as character tokens (22 symbols, stacked marks as 2–3 symbols in one spot) and as cluster tokens (15 symbols, one per glyph column)

Real CTC output of the recognizer on a photographed line; made with tools/cluster_gif.py.

  • Correct order, always: marks inside a cluster always come out in Unicode order, never swapped.
  • No impossible output: only real clusters are in the vocabulary (2,149 of 2,455 classes).
  • Shorter sequence: one token per glyph (15 vs 22 on the line above).
  • Tiny and fast: 1.5M parameters, 88.6% exact match at 8 ms per line on one CPU thread (comparison).

Details worth knowing:

  • Text in tables is read by the Thai recognizer, not by the table model: TATR only provides the grid.
  • The detector often boxes a lone Thai vowel or tone mark; such fragments are dropped before recognition.
  • Lines are batched only with lines of nearly the same width. Padding changes the recognizer's attention and cost about 3 points of exact-match accuracy when widths were mixed freely.

Limitations

  • Photographed pages are harder than digital ones. On MDPBench-th the default pipeline scores 89.5 on digital pages but 76.2 on photos (curl, shadow, glare, perspective). --dewarp brings photos to 84.3 at about twice the weights and extra time per page; very dark, folded or blurred photos still lose text.
  • Handwriting is weak. The recognizer was trained for printed Thai and English; handwritten notes and filled-in forms come out with many errors.
  • No formula or picture understanding. Math is read as plain text lines (no LaTeX). Figures and charts become <figure> blocks holding only the text printed in them, with no description of the picture.
  • Dense multi-column layouts such as newspapers often get the reading order or column split wrong.
  • Thai and English only. Other scripts and vertical text are not supported.

Models and licenses

StageModelLicense
Layout + reading orderPP-DocLayoutV3Apache-2.0
Text detectionPP-OCRv6_medium_detApache-2.0
Page / line orientationPP-LCNet_x1_0_doc_ori, textline_oriApache-2.0
Text recognitionAksonOCR Thai recognizer (fine-tuned PP-OCRv6_tiny_rec), model cardApache-2.0
Table structureTable Transformer v1.1-all (Microsoft)MIT
Dewarping (optional)MonkeyOCRv2 document preprocessorApache-2.0

All weights download from one Hugging Face repo, Remtir/AksonOCR-Lite; the PaddlePaddle models there are unmodified copies of the official ONNX exports linked above. The code is Apache-2.0 (LICENSE); third-party attributions are in NOTICE. Every model is permissively licensed, so AksonOCR-Lite can be used commercially. PDFs are rendered with pypdfium2 (Apache-2.0/BSD), not PyMuPDF (AGPL).

Files in this repository

FileWhat it isOriginLicense
rec.onnx, rec_charset.jsonThai + English text-line recognizer (ours, model card)fine-tuned from PaddlePaddle PP-OCRv6_tiny_recApache-2.0
layout.onnxlayout blocks + reading orderPaddlePaddle/PP-DocLayoutV3_onnx, unmodified copyApache-2.0
det.onnxtext-line detectionPaddlePaddle/PP-OCRv6_medium_det_onnx, unmodified copyApache-2.0
doc_ori.onnx, textline_ori.onnxpage / text-line orientationPP-LCNet_x1_0_doc_ori_onnx, PP-LCNet_x1_0_textline_ori_onnx, unmodified copiesApache-2.0
tatr.onnxtable structure (rows, columns, headers, spans)microsoft/table-transformer-structure-recognition-v1.1-all, convertedMIT
dewarp_mask.onnx, dewarp_grid.onnxpage segmentation + dewarping grid (optional)MonkeyOCRv2 document preprocessor, convertedApache-2.0
config.jsonpipeline manifest (components, source revisions)oursApache-2.0

The aksonocr-lite package downloads these on first use. The four PaddlePaddle files are byte-identical copies of the official inference.onnx exports, kept here so the whole pipeline loads from one repository.

Development

pip install -e .[dev]
pytest -m "not e2e"          # unit tests, no weights needed
pytest                       # + end-to-end test (downloads weights)

tools/ holds the scripts that produced the ONNX files (they need Paddle/PyTorch and are not part of the package): export_tatr.py, export_dewarp.py.

Acknowledgements

AksonOCR-Lite stands on open work from many teams:

Citation

@software{aksonocr_lite,
  author = {Jaknamon, Teetouch},
  title  = {AksonOCR-Lite: Thai Document OCR with Grapheme-Cluster CTC Recognition},
  version = {1.0.0},
  year   = {2026},
  url    = {https://github.com/Remtir/AksonOCR-Lite}
}

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

Modelsentence-similarity
sentence-transformers/all-MiniLM-L6-v2

all-MiniLM-L6-v2 This is a sentence-transformers(https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search. Usage (Sentence-Transformers) Using t...

♥0
164.7M
Jun 1, 2026
Modelsentence-similarity
sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2

sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 This is a sentence-transformers(https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic se...

♥0
24.9M
Jan 28, 2026
Modelimage-to-text
datalab-to/indra-ocr

Datalab State of the Art models for Document Intelligence Indra OCR Indra OCR is a 1M-parameter OCR model that reads up to 49 pages per second on CPU. It turns PDFs and images into markdown, plain text, or JSON with boxes, and it has these features:...

♥0
6.0k
Oct 19, 2026
Modeltext-ranking
cross-encoder/ms-marco-MiniLM-L6-v2

Cross-Encoder for MS Marco This model was trained on the MS Marco Passage Ranking(https://github.com/microsoft/MSMARCO-Passage-Ranking) task. The model can be used for Information Retrieval: Given a query, encode the query will all possible passages...

♥0
55.4M
Aug 9, 2026
Modelfill-mask
google-bert/bert-base-uncased

BERT base model (uncased) Pretrained model on English language using a masked language modeling (MLM) objective. It was introduced in this paper(https://arxiv.org/abs/1810.04805) and first released in this repository(https://github.com/google-resear...

♥0
33.5M
Feb 19, 2024
Modelimage-to-text
zai-org/GLM-OCR

GLM-OCR 👋 Join our WeChat and Discord community 📍 Use GLM-OCR's API 👉 GLM-OCR SDK Recommended 📖 Technical Report Introduction GLM-OCR is a multimodal OCR model for complex document understanding, built on the GLM-V encoder–decoder architecture....

♥0
2.1M
Sep 11, 2026
Modelimage-to-text
Salesforce/blip-image-captioning-large

BLIP: Bootstrapping Language-Image Pre-training for Unified Vision-Language Understanding and Generation Model card for image captioning pretrained on COCO dataset - base architecture (with ViT large backbone). | !BLIP.gif(https://cdn-uploads.huggin...

♥0
390.2k
Feb 3, 2025
Modelimage-to-text
Salesforce/blip-image-captioning-base

BLIP: Bootstrapping Language-Image Pre-training for Unified Vision-Language Understanding and Generation Model card for image captioning pretrained on COCO dataset - base architecture (with ViT base backbone). | !BLIP.gif(https://cdn-uploads.hugging...

♥0
1.2M
Feb 3, 2025
Modelimage-to-text
nlpconnect/vit-gpt2-image-captioning

nlpconnect/vit-gpt2-image-captioning This is an image captioning model trained by @ydshieh in flax (https://github.com/huggingface/transformers/tree/main/examples/flax/image-captioning) this is pytorch version of this(https://huggingface.co/ydshieh/...

♥0
98.5k
Feb 27, 2023