ThakiOCR-KOEN-V1-Dense
A small (2.13 M parameters) Korean/English text-line recognizer trained from scratch with CTC. It reads one cropped text line and returns its transcription. It does not detect text on a page; pair it with a line detector or layout model.
Korean card: MODEL_CARD.ko.md carries the same facts in Korean.
This is a research release. All scores below come from a single training run (one seed). Most are measured on held-out synthetic data drawn from the same source as the training data, so they say little about real scanned documents. The one real-document number (an AI Hub validation subset, used for evaluation only) shows clear weaknesses, listed under Known failure modes. We make no claim of state-of-the-art accuracy.
Quick start
pip install torch numpy pillow safetensors
python inference.py line.png # one or more line images
python inference.py --demo # renders an English line and reads it back
from inference import ThakiOCR
ocr = ThakiOCR(".", device="cpu")
print(ocr.recognize(["line1.png", "line2.png"]))
inference.py is self-contained (torch, numpy, Pillow, safetensors). It holds a vendored copy of the network, the preprocessing and the greedy CTC decoder.
Files
| File | Content |
|---|---|
model.safetensors | fp32 weights (state_dict only, no optimizer state) |
config.json | architecture, preprocessing and decoding settings, provenance hashes |
vocab.json | 14,152 characters; CTC index i maps to chars[i-1], index 0 is blank |
inference.py | standalone model code, preprocessing, greedy CTC decoding, CLI |
LICENSE | Apache-2.0 (code and weights) |
NOTICE | CC BY 4.0 attribution for the training data, what is not included |
Model
- Input: one grayscale text-line image.
- Preprocessing: EXIF transpose, grayscale, resize to height 48 keeping the aspect ratio (bilinear), width
max(8, round(w*48/h)); lines wider than 2048 px after resizing are rejected rather than squeezed. Pixels are scaled to [-1, 1] (x/127.5 - 1). A batch is right-padded with white to a multiple of 16. - Encoder: convolutional stem (three stride stages: 2, 2, then 2 in height only), mean pooling over height, linear projection to 128 dims, two blocks of depthwise 1-D convolution (kernel 5) with a gated feed-forward, LayerNorm.
- Head: dense linear layer to 14,153 classes (14,152 characters + blank), syllable-level tokenization (one Hangul syllable = one class).
- Output stride: 4 pixels of resized width per CTC frame.
- Decoding: greedy CTC (argmax, merge repeats, drop blanks). No language model.
- Parameters: 2,130,249 (head 1,825,737, encoder 304,512).
Training
- Data: text-line crops from NVIDIA OCR-Synthetic-Multilingual-v1 (CC BY 4.0), files
ko/train/train_000.h5anden/train/train_000.h5only. Crops were split into train and held-out sets by source document group. The training manifest has 879,645 lines (Korean 435,510, English 444,135). - Vocabulary: printable ASCII, all 11,172 modern Hangul syllables, Hangul Jamo blocks, a short symbol list, plus every character in the training labels. Built from training labels only.
- Recipe: 20,000 optimizer steps, batch 64, AdamW (lr 3e-4, weight decay 0.02), 1,000 warmup steps then cosine decay, gradient clipping 5, bf16 autocast with fp32 CTC loss, seed 42, no augmentation. One B200 GPU, 1,407 s of training.
- Checkpoint: the fixed final step (
last.pt). No early stopping and no checkpoint selection on any evaluation set. - No AI Hub data was used for training or for the vocabulary.
Evaluation
Greedy decoding, batch 128, exact-string metrics after Unicode NFC (no case or punctuation normalization). 5,000 lines per set. Single run.
| Set | What it is | CER | WER | Exact line |
|---|---|---|---|---|
| Synthetic KO held-out | NVIDIA synthetic Korean lines, document groups not seen in training | 16.70% | 38.65% | 39.90% |
| Synthetic EN held-out | NVIDIA synthetic English lines, document groups not seen in training | 11.08% | 28.18% | 51.96% |
| Real KO development set | word crops from an AI Hub (dataset 71299) validation subset; evaluation only | 37.14% | 128.67% | 40.18% |
On the real development set, CER drops to 17.81% if spaces are ignored. Most of the error there is spurious space insertion (see below). The held-out synthetic sets share the generator and source file with training, so they overstate accuracy on real documents. The real development set is a development measurement, not an independent test set.
Latency (batch 1, 512 px wide input, fp32): 1.29 ms median on one B200 GPU; 5.61 ms median on 4 threads of a data-center server CPU. Laptop and mobile CPUs were not measured.
Known failure modes
- Space insertion on real documents. On 38% of real Korean word crops the model inserts spaces between syllables (for example
평면도read as평 면 도). The synthetic training lines have different spacing statistics from scanned word crops. - Domain gap. Trained only on synthetic renderings. Scanned, photographed, low-contrast, handwritten or stylized text was not in the training data.
- Line input only. Feeding a whole page or a multi-line block produces garbage.
- Long lines. Lines wider than 2048 px after resizing to height 48 are rejected; split them first.
- Batch effects. The depthwise convolution sees the white padding at line ends, so a line's output can change slightly with the other lines in its batch.
- Single seed. Run-to-run variance was not measured.
Intended use
Research and prototyping of Korean/English line recognition inside a larger document pipeline, as a small CPU-friendly baseline. It should not be used as the only reader for financial, legal or identity documents without human review.
Blog posts
Write-ups of this model on the ThakiCloud tech blog:
- ThakiOCR A: a 2.13M-parameter Korean-English OCR
- ThakiOCR A2: independent 43,751-line evaluation
- Four open Korean OCR models, from 2M to 27B parameters
- ThakiOCR model hub: all four public OCR models
License and attribution
Code and weights: Apache-2.0 (see LICENSE). Training data: NVIDIA OCR-Synthetic-Multilingual-v1, CC BY 4.0. Attribution and the list of what is not included are in NOTICE. No training data is distributed in this repository.