ThaOCR font β€” font family, weight, slant and size per text line (ONNX)

Stage 4 of 5 of the ThaOCR pipeline. FontNet (training/font/model.py): 8 conv layers, about 0.45 M parameters. Input is a 32x256 grey line crop. Heads: family (29 classes), weight (regular / bold), slant (upright / italic) and a log em-size ratio (regression, converted to a CSS font size).

Models

id version file size description
font_cnn_v1 v1 font/font_cnn_v1.onnx 1.9 MB Font CNN v1 (29 Khmer/Latin families)
font_cnn_v2 (default) v2 font/font_cnn_v2.onnx 1.9 MB Font CNN v2 (family, weight, slant + learned em size)

font_cnn_v2 adds the em-size head; font_cnn_v1 predicts family, weight and slant only.

Families (29)

Khmer OS, Khmer OS System, Khmer OS Battambang, Khmer OS Content, Khmer OS Siemreap, Khmer OS Muol, Khmer OS Muol Light, Khmer OS Muol Pali, Khmer OS Bokor, Khmer OS Metal Chrieng, Khmer OS Fasthand, Khmer OS Freehand, Noto Sans Khmer, Noto Serif Khmer, Khmer Digital, Hanuman, Kantumruy Pro, Nokora, Odor Mean Chey, Chenla, Preahvihear, Suwannaphum, Koulen, Dangrek, Bayon, Angkor, Taprom, Latin serif, Latin sans.

How it was trained

  • Data: 100 % synthetic, rendered on the fly (training/font/gen.py): Khmer news corpus + English sentences, PIL + HarfBuzz shaping, random size and colour, synthetic bold by dilation and italic by shear, neighbouring lines intruding, underlines, resolution loss, blur, noise, JPEG, paper tint and a lighting gradient. Validation: 8,000 fixed crops from the held-out news split.
  • v1: 40 epochs x 400 steps x batch 256 (family 92.0 %, weight 97.9 %, slant 99.95 %).
  • v2: 24 epochs from v1 with the new size head, lr 1.5e-3.
  • Result (val, v2): family 92.0 %, weight 98.0 %, slant 99.9 %, size error median 1.7 %, 97.9 % of lines within 10 %.

Training data and licences

Synthetic only. Text: Khmer news corpus (5,601 articles scraped by the owner for research use; source URLs not recorded) and English sentences. Fonts are open-licence (OFL 1.1; Khmer OS is LGPL 2.1). Because part of the text is research-use only, the licence field is other: check that your use fits those terms. The owner's private exam photos were never used for training.

Part of ThaOCR

ThaOCR is a five-stage Khmer + English document OCR pipeline (layout, text-line detection, line recognition, font classification, page structure). Every model is plain ONNX (opset 17) and runs with onnxruntime on CPU. There is one repo per stage:

The index repo Thareah/ThaOCR-models holds the full models.json manifest for all five stages. models.font.json in this repo lists only this stage. The file and vocab paths in both are relative to a folder into which all stage repos are downloaded together, for example hf download Thareah/ThaOCR-font --local-dir ThaOCR. The pre/post-processing (letterbox + NMS, DB unclip, width bucketing + CTC, ...) is small numpy/OpenCV code in the ThaOCR backend (backend/app/services/stages/).

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support