Khmer OCR - Siemreap/Arial CRNN Models

This repository contains Khmer OCR text-line recognition checkpoints trained on the 200k synthetic Siemreap/Arial OCR dataset.

The models recognize rendered Khmer text-line images using a CRNN pipeline:

Input image -> Modified ResNet CNN -> vertical mean pooling -> 2-layer BiGRU -> linear classifier -> CTC decoding

Available Checkpoints

File Architecture Validation Loss Validation CER Exact Match Accuracy Test CER
siemreap_arial_ocr_bs256_epoch_25.safetensors ResNet34 + BiGRU + CTC 0.0085 0.1635% 95.695% ~0.18%
resnet18_bigru_epoch_25.safetensors ResNet18 + BiGRU + CTC 0.0189 0.4325% 90.245% 0.4509%

Dataset

The models were trained on a generated 200,000-image Khmer OCR text-line dataset using:

  • Khmer font: Siemreap
  • Latin fallback font: Arial
  • Image height: 64 px
  • Image width: dynamic
  • Train/validation/test split: 160k / 20k / 20k

Text sources:

  • Approximately 100,000 Hanuman-derived Khmer lines from seanghay/khmer-hanuman-100k. Credit to the original uploader/owner seanghay.
  • Approximately 100,000 contextual Khmer Wikipedia / word-Markov generated lines.

Dataset repo:

KimkosalYon/khmer-ocr-200k-siemreap-arial

Architecture Details

Both models use the same OCR head and training pipeline. The only main difference is the ResNet backbone depth.

Shared Pipeline

Input Image: (B, 1, H, W)
        ↓
Modified ResNet18/34 backbone
        ↓
Feature Map: (B, 512, H', W')
        ↓
Vertical Mean Pooling: (B, 512, W')
        ↓
Sequence Formatting: (T, B, 512)
        ↓
2-layer BiGRU, hidden size 256, dropout 0.2
        ↓
Linear classifier: 193 logits
        ↓
CTC decoding / loss

OCR ResNet Modification

The ResNet backbone is adapted for OCR by:

  • changing the first convolution to grayscale input: Conv2d(1, 64, 7, 2, 3)
  • changing later ResNet strides from (2,2) to (2,1) in layers 3 and 4
  • preserving horizontal resolution so CTC has enough time steps for Khmer text

Training

  • Epochs: 25
  • Batch size: 256
  • Image height: 64
  • Optimizer: AdamW
  • Loss: CTC loss, blank index 0
  • Augmentation: random rotation, brightness/contrast jitter, Gaussian blur, random erasing

Loading

The checkpoint metadata contains the character vocabulary mapping c2i. The vocab.json file is also uploaded for convenience.

For ResNet34, use the KhmerCRNN_BiGRU model class from the project source.

For ResNet18, use the same architecture pattern but initialize the CNN backbone with torchvision.models.resnet18(weights=None) instead of ResNet34.

Limitations

These models were trained on synthetic rendered text-line images. Real scanned documents, photographed text, handwriting, unusual fonts, heavy blur, and severe perspective distortion may require additional fine-tuning.

Credits

Dataset construction uses text derived partly from seanghay/khmer-hanuman-100k. Please credit the original owner/uploader seanghay when referencing the Hanuman-derived source text.

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