HxH OCR: models
To our knowledge, the first OCR for the Hunter × Hunter alphabet (ハンター文字), the
invented script of the manga and anime, which is a one-to-one cipher for Japanese kana. This
repository holds a small model family: five sets, each a text-line detector and two CTC line
readers (horizontal lines and vertical columns). The readers' classes are hiragana (the apps
show the reading in katakana); katakana and small kana come out as full-size kana, because the
glyphs do not tell them apart. The newer readers
also read digits and ! ? : / . - written inline, and the v7 readers, which the demo runs, also
read the cross × that separates the words of the anime's episode titles ("A×ト×B"). Two more
folders each hold a single, much smaller reader made for the Nintendo DSi: dsi_v1, and
dsi_v2, which also reads the cross and which the DSi app runs since version 0.3.0.
- Demo (runs these int8 files in the browser, nothing is uploaded): https://hxh-ocr.kokkakniphon.workers.dev
- Code, training and the full lab notebook: https://github.com/KokkakNiphon/hxh-ocr
- How it works: https://hxh-ocr.kokkakniphon.workers.dev/blog/ and the research deep dive,
https://hxh-ocr.kokkakniphon.workers.dev/blog/deep-dive (both describe the first,
v4set; the deep dive's appendices E and F cover the v6 and v7 readers) - Training data:
KokkakNiphon/hxh-ocr-lines,KokkakNiphon/hxh-ocr-pages
Every model uses an ImageNet-pretrained MobileNetV4-small backbone from timm (stem summed to one input channel), restricted to convolutions and ReLU, and was trained only on generated images.
The sets, and what the demo runs
| set | detector | readers | classes | int8 size | made for |
|---|---|---|---|---|---|
v4 |
det_v2: DBNet-lite on MobileNetV4-small 0.5, 640 × 640, 350k params, 1.57 G MACs |
qat_v4_mnv4s_h48, _vert: MobileNetV4-small 0.5, 48 × 768, 323k params, 154 M MACs per line |
75 | 0.37 + 0.34 + 0.34 MB | the first models: the blog, the deep dive and the parked ESP32-S3 work describe these |
tiny |
det_tiny_v3_qat: det_v2's architecture, fine-tuned with photo-style pages |
qat_fam_tiny_h48, _vert: the v4 architecture, retrained |
91 | 0.37 + 0.34 + 0.34 MB | phones, the live camera, microcontroller-class targets |
base |
det_base_v1_qat: MobileNetV4-small 1.0 (32/64/96/128 ch), FPN 64, depthwise-separable head, 960 × 960, 1.18M params, 4.44 G MACs |
qat_fam_base_h48, _vert: MobileNetV4-small 1.0, 48 × 768, 1.18M params, 555 M MACs per line |
91 | 1.21 + 1.21 + 1.21 MB | still images in the browser |
tiny_v7 |
det_v2 (the v4 detector) |
qat_v7dh_tiny_h48: the tiny reader retrained to read numbers in display lettering and the cross; vertical: qat_fam_tiny_h48_vert |
92 (vertical 91) | 0.37 + 0.34 + 0.34 MB | the demo's Fast set |
base_v7 |
det_base_v1_qat (the base detector) |
qat_v7bs_base_h48: the base reader, likewise; vertical: qat_fam_base_h48_vert |
92 (vertical 91) | 1.21 + 1.21 + 1.21 MB | the demo's Accurate set |
dsi_v1 |
none (a reader only) | qat_dsi_v1: the first three stages of MobileNetV4-small 0.5, 32 × 512, 96,923 params, 30.6 M MACs per line; horizontal lines only |
91 | 0.10 MB | the Nintendo DSi port of HxH Translator, until its version 0.2.0 (see below) |
dsi_v2 |
none (a reader only) | qat_dsi_v2h: the same model trained again on the v7 lines, so it reads the cross; 96,972 params, 30.6 M MACs per line |
92 | 0.10 MB | the Nintendo DSi port, since its version 0.3.0 |
The demo runs two presets (presets.json lists the exact files):
- Fast =
int8/tiny_v7/*:det_v2, the v7 tiny reader and the family tiny vertical reader, in the demo'sweb/models/. The live camera always uses it; for still images it adds overlapping tiles and a second look at the region of the text, so small text in a big photo is still found. Of the 640 px detectors,det_v2kept more recall on manga and frame pages thandet_tiny_v3, so Fast pairs it with the new readers. - Accurate =
int8/base_v7/*: the base detector, the v7 base reader and the family base vertical reader, inweb/models/accurate/, for still images: one full-page pass at 960 px and no tiles (the bigger letterbox already sees the small text, and tiles would cost about 2.5 times the time). 3.6 MB in all.
Until November 26, 2026 the demo ran the family readers (int8/tiny's readers with det_v2, and
int8/base); the v7 sets replace only the horizontal reader. det_tiny_v3 belongs to the family
but is not used by the demo: it shows half the false lines
of det_v2 on photo-style pages but loses 3.6 and 2.8 points of F1 on the older manga and
frame pages.
Files
| path | what |
|---|---|
int8/<set>/det.hxhm, det.json |
the detector in the .hxhm format of the project's Rust engine, and the demo's post-processing settings |
int8/<set>/model.hxhm, model.json |
the horizontal line reader; the json holds the input rules and vocab |
int8/<set>/model_v.hxhm, model_v.json |
the vertical column reader |
presets.json |
which of those files the demo runs as Fast and Accurate |
espdl/<set>/<model>.espdl |
the same int8 models as ESP-PPQ wrote them (ESP-DL format, target esp32s3) |
onnx/<set>/<model>_<H>x<W>.onnx |
fp32, BatchNorm folded, static input, opset 18: the graphs ESP-PPQ quantised |
pytorch/<set>/<run>.pt |
fp32 checkpoints before QAT (BatchNorm unfolded) and the QAT checkpoints (BN folded; the int8 models' weights) |
vocab/v4.json, v4.txt |
the 75 classes of the v4 readers |
vocab/family.json, family.txt |
the 91 classes of the tiny and base readers (and of every vertical reader after v4) |
vocab/v7.json, v7.txt |
the 92 classes of the v7 horizontal readers (tiny_v7, base_v7) and of dsi_v2 |
int8/dsi_v1/model.hxhm, model.json |
the first DSi reader (no detector, no vertical reader); its vocab is vocab/family.json |
int8/dsi_v2/model.hxhm, model.json |
the DSi reader with the cross (likewise a reader only); its vocab is vocab/v7.json |
Model names: readers qat_v4_mnv4s_h48[_vert] (from v4_mnv4s_h48[_vert]),
qat_fam_tiny_h48[_vert] (from fam_tiny_h48b[_vert]), qat_fam_base_h48[_vert] (from
fam_base_h48[_vert]); detectors det_v2, det_tiny_v3_qat (from det_tiny_v3) and
det_base_v1_qat (from det_base_v1); v7 readers qat_v7dh_tiny_h48 (from v7d_tiny_h48) and
qat_v7bs_base_h48 (from v7b_base_h48), fine-tuned from the v6 readers (published in the GitHub
repository, not here); DSi readers qat_dsi_v1 (from dsi_v1_s2) and qat_dsi_v2h (from
dsi_v2_s3, fine-tuned from dsi_v1_s2).
- Classes. Class 0 is the CTC blank, class i is
tokens[i - 1]in the vocab file. The first 74 tokens are the same in both vocabularies: 72 hiragana (46 base kana, 21 with dakuten including ゔ, 5 with handakuten), the long-vowel mark ー and the space. The family readers add0 1 2 3 4 5 6 7 8 9 ! ? : / . -as classes 75 to 90, and the v7 horizontal readers anddsi_v2add the cross×(U+00D7) as class 91; every earlier id is unchanged. Decoding is greedy: argmax per step, merge repeats, drop blanks. The ESP-DL classifier pads 91 outputs to 96 (64 × 96 MACs per step instead of 64 × 80, under 0.1% of a line; 92 for the v7 readers, also padded to 96). - Detector maps. Channel 0 is the text-kernel logit, channel 1 the vertical-orientation
logit, at stride 2 of the letterbox (long side scaled to 640, or 960 for
base, page at the top-left, padding 255).det.jsonholds the post-processing the demo uses (binary threshold 0.3, minimum score 0.5, unclip ratio 1.5, crop margins 0.3 / 0.2 line heights) and two display filters: a line is shown when its mean character confidence is at least 0.8 (min_conf) and its detector score at least 0.55 (min_show_score). - ONNX preprocessing. Grayscale,
(x / 255 - 0.5) / 0.5. Readers: resize to height 48 keeping the aspect ratio (OpenCVINTER_AREA), then pad on the right with the last column up to 768, or squeeze to 768 if longer (about 16 glyphs fit unsqueezed); outputlogits[1, classes, 1, 192]. The int8.hxhmfiles take the u8 strip directly: an input table folds in the normalisation (input exponent −7). - Checkpoints keep the weights and the training config only (no optimizer state, no raw
non-EMA weights). They load with
torch.load(path, weights_only=True), readers with the repository'shxh_ocr.engine.load_checkpoint(QAT ones included), fp32 detectors withhxh_ocr.det_model.load_det_checkpoint; the QAT detectors hold the BN-folded graph (seeload_det_foldedinscripts/hf_package_models.py). The v7 QAT readers were exported with the cross's logit lowered (a prior shift, 0.5 for tiny anddsi_v2, 1.0 for base: the training lines carry crosses far more often than real text does); their checkpoints here carry the same shift in the classifier bias (config["logit_shift"]), so they match the ONNX and int8 files. Each was checked to give outputs identical to the original checkpoint, and the QAT models anddet_v2to match the ONNX files within 2e-4.
Results
Every number is measured on generated images the models did not train on. There is no published real-image benchmark (see Limits).
Pages, end to end (the browser pipeline web/ocr.js readPage in node, int8, WASM SIMD,
with the demo's filters: reading confidence 0.8 and detector score 0.55; a detected line
matches at quadrilateral IoU ≥ 0.5; CER counts missed lines in full, "CER found" is the CER of
the matched lines; raw output in experiments/family/eval/ of the GitHub repository):
| test pages | models | precision | recall | F1 | CER h | CER v | CER found | false lines per page (on text, icons, other) |
|---|---|---|---|---|---|---|---|---|
v5 validation [900:1000], photo-style (100 pages, 669 lines) |
v4 | 87.9% | 66.2% | 75.5% | 29.8% | 67.2% | 5.2% | 0.14, 0.13, 0.34 |
| Fast | 89.2% | 66.7% | 76.3% | 28.8% | 66.7% | 4.7% | 0.09, 0.10, 0.34 | |
| tiny | 95.5% | 63.4% | 76.2% | 30.1% | 68.6% | 4.0% | 0.04, 0.01, 0.15 | |
| Accurate (base) | 94.0% | 74.6% | 83.2% | 20.9% | 57.8% | 3.4% | 0.06, 0.03, 0.23 | |
| Fast v7 (tiny_v7) | 89.6% | 67.1% | 76.8% | 28.6% | 66.7% | 4.6% | 0.09, 0.10, 0.32 | |
| Accurate v7 (base_v7) | 95.2% | 74.4% | 83.6% | 19.9% | 57.8% | 2.4% | 0.01, 0.01, 0.23 | |
v3o validation [900:1000], mixed pages (100 pages, 1,063 lines) |
v4 | 92.6% | 79.9% | 85.8% | 19.0% | 21.9% | 3.8% | 0.38, 0.02, 0.28 |
| Fast | 93.7% | 80.6% | 86.7% | 17.9% | 22.4% | 3.9% | 0.26, 0.01, 0.31 | |
| tiny | 94.7% | 74.9% | 83.6% | 22.4% | 28.1% | 3.7% | 0.10, 0.00, 0.35 | |
| Accurate (base) | 96.4% | 86.8% | 91.3% | 10.9% | 14.8% | 2.9% | 0.05, 0.00, 0.30 | |
| Fast v7 (tiny_v7) | 94.4% | 80.1% | 86.6% | 18.1% | 22.4% | 3.5% | 0.18, 0.03, 0.30 | |
| Accurate v7 (base_v7) | 96.7% | 87.3% | 91.7% | 10.4% | 14.8% | 2.9% | 0.04, 0.01, 0.27 | |
foreign_open, mostly not Hunter script (150 pages, 697 lines) |
v4 | 94.1% | 91.0% | 92.5% | 10.7% | 15.5% | 2.9% | 0.10, 0.11, 0.06 |
| Fast | 96.1% | 91.5% | 93.8% | 10.1% | 16.1% | 3.1% | 0.07, 0.05, 0.05 | |
| tiny | 96.7% | 88.0% | 92.1% | 13.1% | 21.8% | 2.5% | 0.05, 0.02, 0.07 | |
| Accurate (base) | 96.5% | 95.6% | 96.0% | 4.7% | 7.5% | 1.9% | 0.09, 0.05, 0.03 | |
| Fast v7 (tiny_v7) | 96.4% | 90.8% | 93.5% | 9.9% | 16.1% | 2.3% | 0.05, 0.06, 0.05 | |
| Accurate v7 (base_v7) | 97.8% | 95.6% | 96.7% | 4.2% | 7.5% | 1.3% | 0.04, 0.03, 0.03 | |
v2 validation [900:1000], Hunter script only (100 pages, 1,657 lines) |
v4 | 95.4% | 84.2% | 89.5% | 12.7% | 22.8% | 3.0% | 0.00, 0.00, 0.67 |
| Fast | 95.4% | 84.2% | 89.5% | 12.4% | 22.6% | 2.7% | 0.00, 0.00, 0.67 | |
| tiny | 94.8% | 78.5% | 85.9% | 16.6% | 35.8% | 3.0% | 0.00, 0.00, 0.71 | |
| Accurate (base) | 96.3% | 87.5% | 91.7% | 8.3% | 16.7% | 2.3% | 0.00, 0.00, 0.56 | |
| Fast v7 (tiny_v7) | 95.6% | 84.3% | 89.6% | 12.0% | 22.6% | 2.7% | 0.00, 0.00, 0.65 | |
| Accurate v7 (base_v7) | 96.5% | 87.3% | 91.6% | 8.2% | 16.7% | 2.1% | 0.00, 0.00, 0.53 |
On the v5 test pages, 13 labelled lines that are blurred past reading (almost no grey spread
in their box) are left out, as web/test/make_pages.py --drop-illegible does. Vertical text in
photo-style frames stays weak for every set: most of the vertical CER there is missed columns.
The same tables for pages_v3 and pages_foreign, the earlier sets rendered with system fonts
that are not published, are in the GitHub repository; F1 there is within about a point.
Readers, fp32, on lines (scripts/eval.py; v5 validation of hxh-ocr-lines: 7,444 crops
cut from v5 pages, of which 205 are non-Hunter negatives; "negatives read" is the
share of those read as text; synth_v4: the first 3,000 validation lines, no digits):
| reader | v5 CER |
negatives read | synth_v4 CER |
|---|---|---|---|
| v4 horizontal | 18.2% | 92% | 0.90% |
| tiny horizontal | 9.6% | 27% | 1.38% |
| base horizontal | 8.3% | 20% | 1.11% |
| v4 vertical | 12.2% | 8 of 8 | 0.56% |
| tiny vertical | 8.5% | 1 of 8 | 0.75% |
| base vertical | 8.1% | 2 of 8 | 0.76% |
The v4 readers cannot write digits or punctuation, which is part of their v5 error. On 3,000
synth_v4 lines without digits or punctuation, the family readers wrote at most one such
character.
In these tables "Fast" and "Accurate (base)" are the sets the demo ran before v7 (det_v2 with
the family tiny readers, and int8/base).
The v7 readers on lines, int8 (the demo's own line reader, readCrop in web/ocr.js, WASM
SIMD; horizontal lines; the configs are those of hxh-ocr-lines):
| test lines | Fast (family tiny) | Fast v7 | Accurate (family base) | Accurate v7 |
|---|---|---|---|---|
v7_cross validation: CER (7,018 lines, 3,499 crosses) |
24.33% | 10.54% | 23.66% | 8.30% |
v7_cross: crosses read as crosses (precision) |
0% | 81.9% (98.8%) | 0% | 88.5% (99.0%) |
v6_digits validation: CER (numbers in the lettering) |
24.84% | 9.87% | 23.41% | 7.33% |
v5 validation: CER |
9.22% | 7.58% | 8.85% | 6.43% |
synth_v4 validation (3,000 lines): CER |
1.50% | 1.49% | 1.16% | 1.01% |
The family readers read the cross as the long-vowel mark ー (a stretched X in this alphabet)
or as め; the v7 readers read 2-3% of the ー on blurry photo-style lines as × (none on clean
lines), and put a stray digit, mark or cross on about 0.8% of plain photo-style lines.
Readers, int8 (ESP-PPQ, CER on 512 held-out synth_v4 validation lines; every model is
bit-exact against ESP-PPQ's integer simulation on all 512 lines in the Rust engine and in
WebAssembly, SIMD and scalar):
| reader | int8 CER | greedy output identical to fp32 | .espdl |
|---|---|---|---|
qat_v4_mnv4s_h48 |
0.84% | 93.9% | 402 KB |
qat_v4_mnv4s_h48_vert |
0.71% | 90.4% | 401 KB |
qat_fam_tiny_h48 |
1.61% | 91.8% | 404 KB |
qat_fam_tiny_h48_vert |
1.64% | 87.3% | 404 KB |
qat_fam_base_h48 |
1.11% | 93.4% | 1.27 MB |
qat_fam_base_h48_vert |
0.82% | 95.3% | 1.27 MB |
qat_v7dh_tiny_h48 |
1.56% | 89.1% | 402 KB |
qat_v7bs_base_h48 |
1.06% | 93.9% | 1.27 MB |
The DSi reader (dsi_v1). The Nintendo DSi has a 134 MHz ARM9 and 16 MB of RAM, where the
Fast reader (154 M MACs a line) would take seconds per line. qat_dsi_v1 keeps the first three
stages of MobileNetV4-small 0.5 and reads 32 × 512 strips (it was the reader of HxH Translator for DSi until version 0.2.0, see Apps below): 5 times fewer MACs, a 104 KB .hxhm
and a 160 KB arena. It runs on the same int8 engine and is bit-exact with ESP-PPQ on all 512
hold-out lines, like every reader here. In an emulator's DS mode (67 MHz) it took 2.4 s a line
against the Fast reader's 11.0 s. Only the model is published: the DSi app's code is not.
int8, through the demo's own line reader at its own input size (CER / lines read exactly):
| test lines | Fast (family tiny) | dsi_v1 |
|---|---|---|
v6_digits validation (numbers in the lettering) |
24.84% / 50.3% | 13.35% / 65.5% |
v6 validation |
20.10% / 62.4% | 12.01% / 72.2% |
v5 validation (photo-style) |
9.22% / 80.1% | 9.89% / 78.0% |
synth_v4 validation (3,000 lines) |
1.50% / 91.6% | 2.43% / 87.6% |
non-Hunter crops read as text (v6_digits; v6; v5) |
37%; 40%; 48% | 19%; 17%; 30% |
It was trained on the v6 lines, so it reads numbers drawn in the lettering, which the family tiny
reader does not; on plain lines it trails it (1.6 times the error on clean synth_v4 lines),
mostly in word spaces and in dakuten, which are a few pixels at 32 px. It does not know the cross
(dsi_v2, below, does). int8 CER on the 512 held-out synth_v4 lines: 2.59% (.espdl 143 KB).
The DSi reader with the cross (dsi_v2), the reader of HxH Translator for DSi since version
0.3.0. The same model, trained again from dsi_v1 on the v7 lines with the v7 tiny reader's
recipe, so it reads the cross of the episode titles; only the classifier grows by one class. It
costs the DS the same: a 104 KB .hxhm, a 160 KB arena, the same 42 operations, and 6,144 more
MACs a line (one classifier row, +0.02%). It is bit-exact with ESP-PPQ on all 512 hold-out lines,
on the host and in WebAssembly, and in the host build of the DS's ARMv5TE kernels. int8, through
the demo's own line reader at its own input size (CER / lines read exactly):
| test lines | dsi_v1 | dsi_v2 |
|---|---|---|
v7_cross validation (7,018 lines, 3,499 crosses) |
20.01% / 48.6% | 13.27% / 63.7% |
v7_cross: crosses read as crosses (precision) |
0% | 76.3% (98.7%) |
v7 validation |
15.29% / 63.5% | 12.13% / 69.5% |
v6_digits validation (numbers in the lettering) |
13.35% / 65.5% | 12.93% / 65.9% |
v6 validation |
12.01% / 72.2% | 11.76% / 72.1% |
v5 validation (photo-style) |
9.89% / 78.0% | 9.70% / 78.3% |
synth_v4 validation (3,000 lines) |
2.43% / 87.6% | 2.41% / 88.2% |
512 held-out synth_v4 lines, int8 CER (ESP-PPQ) |
2.59% | 2.31% |
dsi_v1 read the crosses as ー, as nothing or as め. dsi_v2 reads about 2% of the ー as
×, like the v7 readers, and on the number lines of the v5 set it is 0.4 points behind
dsi_v1. It stays 2.5 to 3 points of CER behind the Fast v7 reader, the cost of 32 px and three
stages. .espdl 143 KB.
Detectors, int8 alone (Python reference post-processing, 100 held-out v5 pages):
det_tiny_v3_qat F1 0.743 (fp32 0.770), det_base_v1_qat 0.802 (fp32 0.845).
Speed (node 24, one thread of a Ryzen 7 3700X, WASM SIMD, machine idle): detector pass
60 ms for det_v2 and det_tiny_v3 (640), 190 ms for det_base_v1 (960); reader 6.0 ms per
line for the v4 and tiny readers, 19.7 ms for the base readers.
How to use
In the browser or node with the project's engine: web/ocr.js and web/hxh_infer.wasm
in the GitHub repository load the int8/ files unchanged. Put a preset's files where
presets.json says (web/models/ for Fast, web/models/accurate/ for Accurate). The
README there has a node example that reads a whole page.
Python with ONNX Runtime (one cropped horizontal line, the v7 tiny reader):
import json
import cv2, numpy as np, onnxruntime as ort
from huggingface_hub import snapshot_download
M = snapshot_download("KokkakNiphon/hxh-ocr")
vocab = json.load(open(f"{M}/vocab/v7.json", encoding="utf-8"))["tokens"]
sess = ort.InferenceSession(f"{M}/onnx/tiny_v7/qat_v7dh_tiny_h48_48x768.onnx")
def read_line(path, H=48, W=768):
g = cv2.imread(path, cv2.IMREAD_GRAYSCALE)
w = max(1, round(g.shape[1] * H / g.shape[0]))
g = cv2.resize(g, (min(w, W), H), interpolation=cv2.INTER_AREA)
g = cv2.copyMakeBorder(g, 0, 0, 0, W - g.shape[1], cv2.BORDER_REPLICATE)
x = ((g.astype(np.float32) / 255 - 0.5) / 0.5)[None, None]
ids = sess.run(None, {"image": x})[0][0, :, 0].argmax(0)
out, prev = [], 0
for i in ids:
if i != prev and i != 0:
out.append(vocab[i - 1])
prev = i
return "".join(out) # hiragana: the model's classes are hiragana
def to_katakana(text): # what the apps show; ー, spaces, digits and × pass through
return "".join(chr(ord(c) + 0x60) if "ぁ" <= c <= "ゖ" else c for c in text)
# print(to_katakana(read_line("line.png"))) # e.g. ハンター
For the DSi reader use onnx/dsi_v2/qat_dsi_v2h_32x512.onnx with the same vocab/v7.json (or
onnx/dsi_v1/qat_dsi_v1_32x512.onnx with vocab/family.json) and read_line(path, H=32, W=512). Use onnx/base_v7/qat_v7bs_base_h48_48x768.onnx for the v7 base reader (same vocab),
onnx/tiny/qat_fam_tiny_h48_48x768.onnx or onnx/base/qat_fam_base_h48_48x768.onnx with
vocab/family.json, or onnx/v4/qat_v4_mnv4s_h48_48x768.onnx with vocab/v4.json. For a
vertical column, turn the crop 90° counter-clockwise first and use a _vert model
(vocab/family.json). For whole pages, the repository's
hxh_ocr/det_data.py (letterbox) and hxh_ocr/det_post.py (decode, reading order)
post-process the detector's output; set HXH_LETTERBOX=960 for the base detector.
PyTorch (from a clone of the GitHub repository):
from hxh_ocr.engine import load_checkpoint
model, cfg = load_checkpoint("pytorch/base_v7/qat_v7bs_base_h48.pt") # logits [B, 92, 1, W / 4]
Apps built on these models
- HxH Translator, a fan web app for phones and computers, in 13 languages. Read points the camera at Hunter script, or takes a picture, and reads it with this repository's Fast and Accurate sets (the v7 readers since November 26, 2026); Write types kana as Hunter script; Learn teaches the alphabet. The models run on the device, in the browser.
- HxH Translator for DSi, a free homebrew port for the Nintendo DSi on itch.io
(version 0.3.0): the same three modes on a handheld from 2008. Read takes a picture with the
DSi's camera and reads a line with
dsi_v2(above;dsi_v1until version 0.2.0) on the console's own ARM9, in the same int8 engine, bit-exact with ESP-PPQ. How it was made: https://hxh-ocr.kokkakniphon.workers.dev/blog/dsi.
Both are unofficial fan apps by KokkakNiphon. Their source code is not published; the models and the OCR's code are (see the GitHub repository).
Training
- Data, all synthetic, all published except where noted:
v4readers:synth_v4(500k lines, 30% vertical).det_v1onpages_v2, thendet_v2fine-tuned onpages_v3+pages_v2.- family readers:
v5lines (about 100k lines cut from 14,000 photo-style pages exactly the way the browser cuts them, 2.7% negatives, digits and punctuation inline) plussynth_v4. tiny: from the v4 readers, 6k steps, classifier grown from 75 to 91 classes (old rows kept). base: ImageNet, thensynth_v4(14k steps), then 9k steps on the mix; the vertical base reader starts from the horizontal pre-training. - family detectors:
pages_v2/pages_v3o/pages_v5sampled 25 / 25 / 50%. tiny:det_v2fine-tuned 8k steps. base: ImageNet, thenpages_v2+pages_v3at 960 (24k steps, best at 22k), then 7k steps on the mix. - v7 readers: from the v6 readers (numbers in the lettering:
v6andv6mlines plusv5andsynth_v4), the classifier grown from 91 to 92 classes; 5,000 steps onv7(twice) +v6+v6m+v5+synth_v4(twice, 63% of the lines), then 3,000 steps with the cross-heavyv7xadded; the tiny reader then 2,000 steps withsynth_v4at about 70%. From v7 on, the padding after a short line counts in the CTC loss (it must read as blank), which ended the int8 readers' runs of!there. - DSi reader: from the 75-class 3-stage reader trained on
synth_v4(v4_mnv4s3_h32), the classifier grown to 91 classes; 12,000 steps onv6(twice) +v5+synth_v4, then 3,000 on that mix withv6mandsynth_v4twice; QAT 4,250 steps, at 32 × 512 throughout.dsi_v2: fromdsi_v1's fp32 checkpoint, the classifier grown to 92 classes, then the v7 tiny reader's three stages (5,000, 3,000 and 2,000 steps, the padding counted as blank from the second) and QAT 4,250 steps, exported with the cross's logit lowered by 0.5. pages_v3(used bydet_v2and the base detector's first stage) drew its distractor text from Windows system fonts and is not published;pages_v3ois the same recipe rendered with openly licensed fonts, and the published sets contain only such data.
- Readers: CTC, AdamW, warm-up and cosine decay, EMA weights with BatchNorm statistics re-estimated before every evaluation.
- int8: QAT with fake quantisation that reproduces ESP-DL (per-tensor power-of-two scales,
half-up rounding, KL calibration): readers 4,250 steps (the base horizontal reader's run
stopped at step 2,700 and its best checkpoint, step 2,000, was used), detectors 2k steps;
the width-1.0 base readers were cross-layer equalized first. Then ESP-PPQ 1.3.15 plain PTQ
for
esp32s3(TQT fordet_v2), then conversion to.hxhm. - Compute: one RTX 4080 SUPER.
The exact arguments of each run are in the checkpoints' config; the full story, including
what went wrong, is in docs/research/JOURNAL.md in the GitHub repository
(scripts/launch_family.sh runs the family stage by stage, scripts/launch_v7.sh the v7
readers).
Intended use and limits
Reading Hunter × Hunter script in fan contexts: translating signs, title cards and screens, studying the alphabet, and as a worked example of training an OCR without real data and of exact int8 inference in the browser.
- No published real-image evaluation. Every number above is on generated images. Real scans, photos and anime frames can be harder by an unknown amount.
- Vertical columns in photo-style frames are often missed (the int8 detectors find 31%
(tiny) and 43% (base) of the 61 columns in the
v5test pages). - Readers are weaker on lines cut from pages than on their own line sets; small text is missed more often by the 640 px detectors.
- On the older line distribution the family readers trail the v4 readers in int8 (
synth_v4hold-out: 1.6% tiny and 1.1% base against 0.84%), the cost of sharing capacity with the photo-style lines. - Other writing is not read; the detectors were trained to ignore it and the demo hides readings with low confidence, but captions and icons next to Hunter text can still come out as kana.
- The cross: the v7 readers (and
dsi_v2) read about 2-3% of the long-vowel marksーon blurry lines as×, and a lone×such as an app's close button can come out as a line of its own. The vertical readers have no cross (episode titles are horizontal). - The script maps to kana sounds, so the output is phonetic kana, not the original Japanese spelling (no kanji). The classes are hiragana, so a reading does not say whether the original used katakana; the apps show it in katakana, and small kana come out full size.
Credit
If you use these models, please credit HxH OCR by KokkakNiphon
(https://github.com/KokkakNiphon/hxh-ocr). When you redistribute the weights, or anything made
from them (a fine-tuned, quantised or converted model, or an app, service or device that bundles
one), the credit is required, not just requested: keep NOTICE with it, as
section 4(d) of the Apache License 2.0 asks, and show it wherever your work shows third-party
notices. A visible line such as "Uses HxH OCR by KokkakNiphon" in your app or page is welcome
too. For papers, cite the entry below.
Licence and notice
Apache-2.0 for the model weights and code; see LICENSE and NOTICE. The backbones start from timm's ImageNet-1k
weights (Apache-2.0). Hunter × Hunter and its alphabet are © Yoshihiro Togashi / Shueisha.
This is an unofficial fan project, not affiliated with or endorsed by them; no images from the
manga or anime were used for training. Built by KokkakNiphon with Claude Code (Anthropic).
Citation
@software{hxh_ocr_2026,
author = {KokkakNiphon},
title = {{HxH OCR}: an optical character recogniser for the Hunter x Hunter alphabet},
year = {2026},
url = {https://github.com/KokkakNiphon/hxh-ocr}
}
Model tree for KokkakNiphon/hxh-ocr
Base model
timm/mobilenetv4_conv_small.e2400_r224_in1kDatasets used to train KokkakNiphon/hxh-ocr
KokkakNiphon/hxh-ocr-pages
Evaluation results
- line F1 (%), quad IoU >= 0.5 on pages_v5 validation [900:1000] (photo-style pages)validation set self-reported83.560
- line F1 (%), quad IoU >= 0.5 on pages_v5 validation [900:1000] (photo-style pages)validation set self-reported76.750
- line F1 (%), quad IoU >= 0.5 on pages_v3o validation [900:1000]validation set self-reported91.740
- CER (%) on synth_v4 validation, 512 held-out linesvalidation set self-reported1.110
- CER (%) on v7_cross validation (held-out lines, crosses in 2,185 of 7,018 horizontal lines)validation set self-reported8.300
- CER (%) on v6_digits validation (held-out lines with numbers in the lettering)validation set self-reported13.350
- CER (%) on v7_cross validation (held-out lines, crosses in 2,185 of 7,018 horizontal lines)validation set self-reported13.270
- CER (%) on synth_v4 validation, 512 held-out linesvalidation set self-reported0.840