jsaksrisuwan commited on
Commit
38678a9
·
1 Parent(s): 2378948

Add best.pt model weights (LFS)

Browse files
Files changed (5) hide show
  1. .gitattributes +0 -35
  2. .gitignore +3 -0
  3. README.md +63 -1
  4. best.pt +3 -0
  5. classes.json +1 -0
.gitattributes DELETED
@@ -1,35 +0,0 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #unstaged files for environment
2
+
3
+ .gitattributes
README.md CHANGED
@@ -1,3 +1,65 @@
1
  ---
2
- license: mit
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: apache-2.0
3
+ language:
4
+ - th
5
+ - en
6
+ tags:
7
+ - ocr
8
+ - thai
9
+ - crnn
10
+ - ctc
11
+ - document-ocr
12
+ pipeline_tag: image-to-text
13
+ library_name: pytorch
14
  ---
15
+
16
+ # larngear-antocr-crnn-th (v40)
17
+
18
+ Compact **CRNN + CTC line recognizer** for printed/typed **Thai** documents with
19
+ Latin (English / European-accent) co-script. ~33 MB, 254-character charset.
20
+ Reads one text-line crop → string. Tuned for clean documents (forms, government
21
+ reports, financial statements, academic calendars/timetables).
22
+
23
+ This repo is **artifacts only** — no inference code. It pairs with the
24
+ recognizer in
25
+ [`larngear_AntOCR`](https://github.com/jakksaksrisuwan-tech/larngear_AntOCR)
26
+ (the `_CRNN` architecture + input normalization + CTC decode that these weights
27
+ are shape-locked to), used in production by `larngear-docling`.
28
+
29
+ ## Files
30
+
31
+ | File | What |
32
+ |------|------|
33
+ | `best.pt` | CRNN weights — plain `state_dict`, load with `torch.load(weights_only=True)` |
34
+ | `classes.json` | charset, `{"chars": [...]}` — **254 chars** (Thai + Latin + accents + digits + punctuation) |
35
+
36
+ The two are a **versioned pair**: `len(chars) + 1` (the +1 is the CTC blank) is
37
+ the model's output dimension. A mismatched pair decodes to garbage — always pull
38
+ both from the same revision.
39
+
40
+ ## Accuracy
41
+
42
+ | Benchmark | CER |
43
+ |-----------|-----|
44
+ | AntOCR real-PDF line bench (3502 lines) | ~4.3% |
45
+ | `larngear-docling` control corpus — region-aligned text CER (~20 pages, born-digital Thai PDFs) | 2.34% |
46
+
47
+ Out of scope (not trained for it): scene text, handwriting.
48
+
49
+ ## Usage
50
+
51
+ ```python
52
+ from huggingface_hub import hf_hub_download
53
+ from antocr.core import CRNNLineRecognizer # from larngear_AntOCR
54
+
55
+ repo = "jakksaksrisuwan-tech/larngear-antocr-crnn-th" # set to this repo
56
+ weights = hf_hub_download(repo, "best.pt", revision="v40")
57
+ classes = hf_hub_download(repo, "classes.json", revision="v40")
58
+
59
+ rec = CRNNLineRecognizer(weights=weights, classes=classes)
60
+ texts = rec.recognize_batch([line_crop0, line_crop1, ...]) # grayscale np.uint8 crops
61
+ ```
62
+
63
+ Line segmentation (finding the line crops) is the consumer's job —
64
+ `larngear-docling` does layout detection + line-crop before calling this.
65
+ Pin `revision` to a tag or commit SHA for reproducible deploys.
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:372a542ed956f71efb51db307697470048059e71ea0fe04b0c0898293bc42a84
3
+ size 33286873
classes.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"chars": " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~£§©«°¶»½ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿกขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรฤลฦวศษสหฬอฮฯะัาำิีึืฺุู฿เแโใไๅๆ็่้๊๋์ํ๐๑๒๓๔๕๖๗๘๙–—†‡•…›€∞"}