IlhaOCR: Edge-First Taiwanese Document & Healthcare OCR Engine
Release Summary: IlhaOCR is an edge-optimized, in-process optical character recognition (OCR) engine engineered for Taiwanese Traditional Chinese identity documents (ROC National ID, National Health Insurance Card) and clinical healthcare paperwork. Distributed as lightweight, self-contained ONNX models, IlhaOCR runs 100% on-premise on resource-constrained edge kiosks, Raspberry Pi, and local clinical workstations without GPU acceleration or cloud API dependencies.
Key Highlights
- 🇹🇼 Taiwanese Typography & Terminology: Covers standard Traditional Chinese, rare personal names, official administrative divisions (縣市、鄉鎮市區、村里、鄰、街路巷弄號樓), clinical terms, and full alphanumeric character sets.
- 🔒 On-Premise Privacy: 100% local in-process inference designed to keep Protected Health Information (PHI) and identity data strictly within the local security perimeter.
- ⚡ Ultra-Low Edge Footprint:
- 34.05 MB INT8 ONNX footprint for embedded hardware constraints.
- < 30 ms single-vCPU thread inference latency.
- Low peak RSS memory consumption (< 800 MB), suitable for fanless terminals and low-cost healthcare stations.
- 🏥 Healthcare & Identity Specialization:
- National ID Card (國民身分證): Front & back extraction (Name, National ID checksum verification, ROC birthdate, issuance category
初發/換發/補發, address lines, and blank card serial number). - National Health Insurance Card (健保卡): 12-digit card number (
0000 xxxx xxxx), National ID, and birthdate. - Clinical Documents: Triage records, clinic receipts, and laboratory forms.
- National ID Card (國民身分證): Front & back extraction (Name, National ID checksum verification, ROC birthdate, issuance category
Technical Specifications & Edge Benchmark
| Metric / Specification | IlhaOCR (INT8 ONNX) | IlhaOCR (FP32 Baseline) | Embedded Budget |
|---|---|---|---|
| Architecture | MobileNetV3 + BiLSTM + CTC | MobileNetV3 + BiLSTM + CTC | Edge CRNN |
| Vocabulary | 5,569 Tokens | 5,569 Tokens | Traditional Chinese + Alphanumeric |
| Input Shape | [1, 1, 32, 320] (Grayscale) | [1, 1, 32, 320] (Grayscale) | Dynamic Width Supported |
| Model Size | 34.05 MB (model_int8.onnx) | 42.20 MB (model.onnx) | $\le 40$ MB |
| Single vCPU Latency | 28.57 ms | 41.20 ms | $\le 50$ ms |
| Peak Memory (RSS) | 766 MB | 820 MB | $\le 2$ GB |
| Runtime Dependency | onnxruntime (Zero PyTorch / CUDA) | onnxruntime | Pure CPU Inference |
Quickstart
1. Installation
pip install onnxruntime numpy pillow huggingface_hub
2. Standalone Inference
import json
import numpy as np
import onnxruntime as ort
from PIL import Image
from huggingface_hub import hf_hub_download
# Download model and vocab from Hugging Face Hub
model_path = hf_hub_download(repo_id="weemed/IlhaOCR", filename="model_int8.onnx")
vocab_path = hf_hub_download(repo_id="weemed/IlhaOCR", filename="vocab.json")
with open(vocab_path, "r", encoding="utf-8") as f:
vocab = json.load(f)["vocab"]
idx2char = {i: ch for i, ch in enumerate(vocab)}
# Initialize single-threaded edge session
opts = ort.SessionOptions()
opts.intra_op_num_threads = 1
opts.inter_op_num_threads = 1
session = ort.InferenceSession(model_path, opts, providers=["CPUExecutionProvider"])
def predict_crop(crop_img: Image.Image) -> str:
# Resize and normalize to [1, 1, 32, 320]
gray = np.array(crop_img.convert("L"))
h, w = gray.shape
scale = min(32 / max(h, 1), 320 / max(w, 1))
new_w, new_h = max(1, int(w * scale)), max(1, int(h * scale))
resized = np.array(Image.fromarray(gray).resize((new_w, new_h), Image.Resampling.BILINEAR))
canvas = np.ones((32, 320), dtype=np.float32) * 255.0
y_off = (32 - new_h) // 2
canvas[y_off:y_off + new_h, 0:new_w] = resized
norm = ((canvas / 255.0) - 0.5) / 0.5
inp = norm[np.newaxis, np.newaxis, :, :].astype(np.float32)
# Run inference
logits = session.run(None, {"input": inp})[0]
preds = np.argmax(logits[0], axis=-1)
# CTC greedy decoding
chars, prev = [], 0
for p in preds:
if p != 0 and p != prev:
chars.append(idx2char.get(p, ""))
prev = p
return "".join(chars)
繁體中文說明
IlhaOCR 是專為台灣公衛醫療體系、基層診所長照機構與健康量測站(如 The Mirror)所研發之輕量化光學文字辨識(OCR)引擎。
核心特點
- 地端隱私與個資保護(Zero PHI Leakage):
- 採用純 CPU-first ONNX 格式,推論全流程於本機記憶體完成,無需連網或上傳外部雲端,符合公衛與醫療隱私合規要求。
- 極致邊緣端運算效能:
- 經動態 INT8 量化後模型僅 34.05 MB。
- 單核心 CPU(1 vCPU)辨識僅需約 28 毫秒。
- 記憶體峰值控制於 766 MB,能無縫部署於樹莓派、嵌入式 Kiosk、無 GPU 之低成本邊緣主機。
- 台灣官方證件精密適配:
- 深入適配台灣身分證字體排版幾何特徵,精準捕捉發證字樣(初發、換發、補發)與背面雷射流水號(如
007871 6215)。 - 內建台灣行政區劃辭彙(含鄉鎮市區、村里、鄰弄巷道門牌),提供高精確度的字元辨識。
- 深入適配台灣身分證字體排版幾何特徵,精準捕捉發證字樣(初發、換發、補發)與背面雷射流水號(如
醫療與身分資料安全邊界
- 預期用途(Intended Use):身分證件登記輔助、臨床病歷攝取與健康量測站自動填單(Suggest-with-Review Assistant)。
- 人工覆核機制:辨識結果涉及身分證號校驗碼(Checksum)驗證與生日邏輯比對,建議於臨床登錄或正式掛號前保留操作人員確認界面。
- 資料保護:模型本體不儲存任何推論圖片或辨識文字,所有運算皆於臨時記憶體緩衝區執行完畢即釋放。
Citation & Governance
IlhaOCR is developed by WeeMed AI under the Apache 2.0 license.
@software{ilhaocr2026,
author = {WeeMed AI Team},
title = {IlhaOCR: Edge-First Taiwanese Document and Healthcare OCR Engine},
url = {https://huggingface.co/weemed/IlhaOCR},
year = {2026}
}