TrorYongOCR
This repository contains model weights and configuration files for the pre-trained model compatible with
tror-yong-ocrversion 0.2.7 onwards
TrorYongOCR is a tiny encoder-decoder model for Scene Text Recognition task.
It prepends the encoding of image patches to the "begin of sequence" token to condition next character token generation.
Using LLM analogy, patch encodings can be simply seen as a prefill prompt.
The single text decoder block of TrorYongOCR generates character tokens based on the prefill prompt in an autoregressive manner without cross-attention mechanism.
TrorYongOCR can process input images of arbitrary aspect ratio.
Current pre-trained weight supports 2 languages: Khmer and English.
Testing on challenging WildKhmerST dataset, TrorYongOCR (5.5M parameters) achieves cer of 42.97% while fine-tuned DeepSeek-OCR (3B parameters) achieves cer of 67.66%.
So, TrorYongOCR has less parameters, performs relatively better for Khmer text and faster for inference.
It is suitable for local or edge-device usage such as License Plate Recognition application.
TrorYongOCR is deployed on Huggingface Space here for demonstration.
Model Details
- Developed by: KHUN Kimang (Ph.D.)
- Shared by: KrorngAI
- Model type: OCR (Optical Character Recognition)
- Language(s) (NLP): Khmer and English
Model Architecture
Model Sources
This model has been pushed to the Hub using the PytorchModelHubMixin integration:
- Code: https://pypi.org/project/tror-yong-ocr/
- Blog Post: https://kimang18.github.io/krorngai-blog/TrorYongOCR/
- Demo:: https://krorngai-troryongocr-demo.hf.space
Model Configuration
The choice of model configuration can be found as the following. While preserving aspect ratio, the input image is resized to $min(W, H) = 32$ where $W$ and $H$ are width and height of the image respectively. This is to reduce computation cost in the training as images with high resolution and big aspect ratio incur very long sequence of patches. The image patch size is $(8, 4)$ where $8$ is along the width of input image. The context length for character sequence is up to $1024$. Transformer configuration is the following: there are $4$ blocks, each has embedding dimension $d_{model}=384$ and $h=6$ heads. In particular, encoding blocks (block $1$ to $3$) have MLP dimension $d_{MLP}=\frac{4d_{model}}{3}=512$ and the decoding block has $d_{MLP}=\frac{8d_{model}}{3}=1024$.
| Layer | $d_{model}$ | $h$ | $d_{MLP}$ | Role |
|---|---|---|---|---|
| 1 | 384 | 6 | 512 | Encoder |
| 2 | 384 | 6 | 512 | Encoder |
| 3 | 384 | 6 | 512 | Encoder |
| 4 | 384 | 6 | 1024 | Decoder |
Training Detail
TrorYongOCR is implemented as a PyPI package and can be installed via
pip install tror-yong-ocr
The pre-trained weight of TrorYongOCR can be found here.
It is obtained by pre-training on seanghay/khmer-hanuman-100k and SoyVitou/KhmerSynthetic1M datasets and fine-tuning on Wild Khmer Scene Text dataset.
KhmerSynthetic1M
KhmerSynthetic1M is a dataset by Mr. Soy Vitou.
This dataset contains images in gray monochromatic color palette (black, white, gray, etc.,).
The distribution of the number of tokens, i.e. frequency of each number of tokens, is fairly uniform.
In particular, the maximum number of tokens is around $120$.
This implies that there are images with aspect ratio largely higher than $4$.
khmer-hanuman-100k
This dataset by Mr. Yat Seanghay contains images with a variety of background colors and character colors.
WildKhmerST: A Dataset for Khmer Scene Text Detection and Recognition in the Wild
This dataset of Khmer scene text comprises 29,601 annotated text lines from 10,000 unique images. It is highly diverse and challenging, encompassing artistic text, blurred text, low-light conditions, curved text, text in complex backgrounds, and occluded text. Each text line is annotated with polygonal bounding box coordinates and line-level transcriptions, alongside attributes describing background complexity, character appearance, and text style.
To fine-tune TrorYongOCR, I cropped the quadrilateral bounding boxes to get only text images. Then, warp operation is used to transform quadrilateral image into rectangle one.
For the sake of benchmarking, WildKhmerST is processed and split into 3 parts: train, validate, and test.
It can be found here
Evaluation
I fine-tuned DeepSeek-OCR, one of the most well-known Vision Language model, on WildKhmerST and compare its performance with TrorYongOCR.
DeepSeek-OCR has 3 billions parameters and be can be used for text recognition task.
Following the notebooks from Unsloth, the fine-tuned model can be found here.
Despite the fine-tuning, it still hallucinates on some images of test split.
Ignoring the hallucination instances, the fine-tuned model achieves cer of 67.66%.
This is relatively worst compared to TrorYongOCR who achieves cer of 42.97%.
Moreover, due to its size, DeepSeek-OCR needs a lot of compute which can slow down its inference speed.
TrorYongOCR has only 5.5 millions parameters.
So, it enjoys faster inference and is suitable for local or edge-device usage.
For instance, TrorYongOCR can be further fine-tuned for License Plate Recognition dataset and integrated into traffic system to enhance traffic security.
Citation
BibTeX:
@online{khun2026,
author = {KHUN, Kimang},
title = {TrorYongOCR: A {Novel} {Encoder-Decoder} {Model} for {Scene}
{Text} {Recognition}},
date = {2026-02-19},
url = {https://kimang18.github.io/krorngai-blog/TrorYongOCR/},
langid = {en}
}
Model Card Author
- ឈ្មោះ: បណ្ឌិត ឃុន គីមអាង
- Name: KHUN Kimang (Ph.D.)
Acknowledgement
LightningAI and Google Colab did not specifically sponsor this project.
But, both models are be trained thanks to their free credits.
So, huge thanks to LightningAI and Google Colab.
Thanks to all the authors of publicly available datasets.
Model Card Contact
If you have any questions, please reach out at Facebook Page.
- Downloads last month
- 221
