/ Модель

Характеристики

Лицензия
CC BY-NC 4.0
Библиотека
pytorch
Опубликована
28 окт 2026

khmer-handwritten-ocr

Описание изображенийИзображение → текст6 профессий

Набор моделей распознаёт кхмерские рукописные и печатные строки и обнаруживает строки текста на страницах и фотографиях.

120скачиваний за 30 дней0лайковвеса обновлены5 ноя 2026

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

Khmer Handwritten OCR — набор из двух моделей для распознавания кхмерского текста, разработанный Oun MengHeang для выпускной работы по науке о данных и инженерии в Королевском университете Пномпеня. Распознаватель на базе CRNN с CTC-декодированием читает отдельную строку или слово с изображения; свёрточный детектор на ResNet-18 находит строки на странице, после чего их можно распознать. Для распознавателя указано 9,5 млн параметров, для детектора — 11,6 млн. Модель работает с рукописным, печатным и уличным текстом на кхмерском языке; распознаватель может работать на CPU, примерно за 0,15 секунды на строку.

Модель предназначена для оцифровки рукописей и документов, распознавания строк на фотографиях и извлечения текста с целой страницы. В приведённых тестах качество заметно различается по наборам данных: CER распознавателя составляет 3,9–11,6% для отдельных рукописных строк, а детектор хуже справляется с фотографиями документов и уличными снимками, чем с тестовыми рукописными страницами. Ограничения включают разнообразие почерков, поддержку только примерно горизонтального текста и ошибки на похожих согласных и небольших гласных знаках. Модель выпущена по лицензии CC BY-NC 4.0, которая ограничивает коммерческое использование.

Сценарии применения

  • оцифровка кхмерских рукописных записей
  • распознавание кхмерского текста на отсканированной строке или слове
  • поиск и чтение строк на странице документа
  • извлечение кхмерских надписей из уличных фотографий

Ограничения

Модель обучена на ограниченном числе авторов и поддерживает только примерно горизонтальный текст; качество детектора снижается на реальных фотографиях страниц и улиц. Возможны ошибки на похожих кхмерских согласных и мелких гласных знаках.

Для каких профессий подходит6

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Также подходит для

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

Khmer Handwritten OCR: text-line detection + recognition

Two small models that read Khmer text (handwritten, printed, or scene text) and return Unicode Khmer text:

  • a text recognizer (CRNN + CTC, 9.5M parameters) that reads one cropped line or word (read);
  • a Khmer text-line detector (ResNet-18 segmentation network, 11.6M parameters) that finds every text line on a page or photo (read_page).

Both read on their own, without a language model (an optional character language model is included). The recognizer runs on CPU in about 0.15 s per line.

Built for a Year 4 thesis in Data Science and Engineering, Royal University of Phnom Penh (Oun MengHeang).

Results

All results without a language model (greedy decoding). Character error rate (CER) and word error rate (WER), lower is better. Words are segmented with khmercut.

Text lines (read)

Test setCERWERLines fully correct
SoyVitou handwritten (211 Khmer samples)11.6%38.6%36.0%
CADT handwritten (444 samples, unseen pages)3.9%16.3%57.4%
WildKhmerST scene text (1,499 lines)9.5%24.9%59.5%
SoyVitou printed (1,000 samples)0.9%3.7%90.6%

For comparison, Tesseract (khm, single-line mode) on the same images: 61.4% / 88.0% / 49.2% / 46.6% CER.

Full pages (read_page: line detection + recognition)

Test imagesLines found (IoU ≥ 0.5)ErrorWith docTR FAST detector instead
Handwritten pages (40 pages, 461 lines; real handwritten test crops laid out on blank pages)97.6%6.0% page CER93.3% found, 17.3% page CER
Street photos (WildKhmerST test photos, 1,504 Khmer lines)69.3%36.2% line CER52.2% found, 51.1% line CER
Document photos (KHOB benchmark level 2, 607 annotated lines)69.2%23.9% line CER78.1% found, 25.2% line CER
Scanned Khmer documents (KHOB benchmark level 1, 53 pages)67.9%11.6% page CER75.0% found, 10.5% page CER

Page CER compares all annotated text with all recognized text, each joined in reading order (handwritten pages: spaces ignored). Line CER: each annotated line against the text of the detected line matched to it (empty if missed). On the handwritten pages the recognizer reaches 5.4% CER when given the exact line boxes, so line detection now adds less than one point. "Lines found" counts a line as missed when it is split or merged differently from the annotation; the photo test sets only annotate Khmer text.

Versions

VersionChangeHandwritten CER (SoyVitou / CADT, no LM)
1Pre-training on printed text, fine-tuning on all real data13.4% / 4.7%
2+ handwriting augmentation (elastic distortion, ink blots)12.2% / 3.9%
3 (current)+ first trained on 60k synthetic handwriting-style lines, then on real data; new Khmer line detector11.6% / 3.9%

Mixing the synthetic lines into the real data in one run gave no gain (12.2% → 11.8% SoyVitou, 3.9% → 4.1% CADT); training on them first and finishing on real data did. Older versions are in this repository's commit history.

Usage

# pip install torch torchvision numpy pillow safetensors opencv-python-headless huggingface_hub
from huggingface_hub import snapshot_download
import sys
folder = snapshot_download("mengheang/khmer-handwritten-ocr")
sys.path.insert(0, folder)
from khmer_ocr import KhmerOCR

ocr = KhmerOCR(folder)
print(ocr.read("line.png"))                 # one text line or word, the model on its own
print(ocr.read("line.png", use_lm=True))    # + character language model (beam search)

# Full page or photo: our line detector + recognition, in reading order
for line in ocr.read_page("page.jpg"):
    print(line["box"], line["text"])

# Optional: docTR's FAST word detector instead (pip install python-doctr)
ocr.read_page("page.jpg", photo=True)

read expects an image of one text line or word. read_page finds the text lines itself.

Models

Recognizer

PartDetails
InputGrayscale, height 64 px, width scaled with aspect ratio (max 1,800 px)
CNNResNet-style, 4 stages, reduces width by 4 (one output frame per 4 pixels)
Sequence model2-layer bidirectional LSTM, hidden size 256
Output241 symbols (Khmer block, Khmer symbols, digits, ASCII) + CTC blank
DecodingGreedy (default), or CTC prefix beam search (beam 16) + character 6-gram language model

Line detector

PartDetails
InputRGB page, long side resized to at most 1,536 px
NetworkResNet-18 encoder (ImageNet initialisation) + feature pyramid, output at 1/2 resolution
TargetThe middle half (vertically) of every text line, so neighbouring lines stay apart even when tall vowels and subscripts touch
Post-processingThreshold 0.6 → connected components → rotated rectangle → grown back to the line height (0.75 × 2) → line box

Training

Recognizer:

  1. Pre-training (3 epochs) on 386k synthetic and printed images: KimkosalYon 200k synthetic lines, emhengly 136k printed words, SoyVitou 62k printed.
  2. Synthetic handwriting (6 epochs) on 60k generated lines: 17 Khmer fonts (handwriting-style Fasthand and Freehand 60% of the time), half real text and half random valid Khmer syllables, with heavy distortion (slant, wavy baseline, elastic warping, stroke width, pen pressure, paper texture, ruled lines, blur, JPEG).
  3. Fine-tuning (20 epochs) on real data only: SoyVitou handwritten (2,894 Khmer samples) and CADT handwritten (3,152), each repeated 4x, plus WildKhmerST scene text (26,348 lines) and SoyVitou printed.

Line detector: 15 epochs on generated pages (training-split crops of real handwriting, synthetic handwriting and printed lines, with random layouts, ruled paper, perspective, shadows and camera noise), then 8 epochs with 35% real WildKhmerST training photos. Selected on handwritten validation pages and validation photos.

AdamW, one-cycle learning rate, mixed precision. One RTX 5070 Ti laptop GPU.

Training data and credits

DatasetLicense
SoyVitou Khmer handwritten 4.2kMIT
LaySopanha Khmer Handwritten Dataset (CADT capstone: Ly Leab, Lay Sopanha, Narith Sopheakleap, Hinge Sothida, Sok Sothika)CC BY 4.0
WildKhmerSTCC BY-NC 4.0
KimkosalYon Khmer OCR 200kMIT
SoyVitou 62k printedMIT
emhengly Khmer text recognitionApache 2.0
Khmer fonts from Google Fonts (synthetic handwriting)SIL Open Font License

Because WildKhmerST is non-commercial, this model is released under CC BY-NC 4.0 (non-commercial use only).

Limitations

  • Trained on a few thousand handwritten samples from a limited number of writers; unusual handwriting styles will have more errors.
  • No public dataset has full Khmer handwritten pages, so the handwritten page test uses real handwritten lines laid out on blank pages; real notebook photos are harder.
  • Only roughly horizontal text is supported. On clean scanned documents the line detector is slightly behind docTR (photo=True).
  • Common errors: similar-looking consonants (រ/ន, ម/ជ) and small vowel signs.
  • Test splits are our own (SoyVitou Khmer-only test samples; CADT split by page), so numbers are not directly comparable to other papers.

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · pytorch

Нельзя запустить

Архитектура ? неизвестна transformers в образе рантайма.

Ревизия весов
45d33d8

0 моделей