Downloads · 30 days
0
vudang449/vietocr-vietnamese-handwriting
vietocr-vietnamese-handwriting is a image-to-text model from vudang449. Use it when you need a caption or text from an image. The card lists the license as apache-2.0.
VietOCR vggtransformer (vgg19bn + Transformer, dmodel 256, vocab 233) tinh chỉnh cho chữ VIẾT TAY tiếng Việt trên 56.669 dòng train của 5CD-AI/Viet-Handwriting-OCR-v2, khởi từ trọng số chữ in doanhm/vggtransformer. Kè…
Downloads · 30 days
0
Access
Public
Updated Sep 4, 2026
Repo size
229 MB
Likes
0
Public
Click a slice to open those files.
.pth152 MB · 66%
From the Hugging Face model README
VietOCR vgg_transformer (vgg19_bn + Transformer, d_model 256, vocab 233) tinh chỉnh cho chữ
VIẾT TAY tiếng Việt trên 56.669 dòng train của 5CD-AI/Viet-Handwriting-OCR-v2, khởi từ trọng
số chữ in doanhm/vgg_transformer. Kèm bản ONNX fp16 (encoder + decoder, đồ thị động theo
khuôn dzngo/vietocr-models) chạy CPU bằng onnxruntime — không cần torch khi suy luận.
| model | CER trung vị | CER trọng số | đúng nguyên văn | giây/dòng (CPU M4) |
|---|---|---|---|---|
| vietocr gốc (chữ in) | 28,4% | 27,7% | — | 0,37 |
| Vintern-1B (VLM, predict_line) | 10,0% | 17,6% | 17% | 4,34 |
| bản này (ONNX, epoch 11) | 3,2% | 5,1% | 29,9% | 0,31 |
Parity torch ↔ ONNX: 20/20 dòng khớp nguyên văn.
| tệp | vai trò |
|---|---|
encoder_fp16.onnx | ảnh dòng [B,3,32,W] → memory [S,B,256] |
decoder_fp16.onnx | tokens [T,B] + memory → logits [B,233] (tự hồi quy, sos=1 eos=2) |
vocab.txt | 233 mục, 4 mục đầu <pad> <sos> <eos> <mask> |
best_ep11.pth | checkpoint torch (state_dict) — để tinh chỉnh tiếp |
train_ep1-12.log | log 12 epoch (loss + val CER từng epoch) |
import numpy as np, onnxruntime as ort
from PIL import Image
enc = ort.InferenceSession("encoder_fp16.onnx"); dec = ort.InferenceSession("decoder_fp16.onnx")
vocab = open("vocab.txt", encoding="utf-8").read().splitlines()
img = Image.open("dong_viet_tay.png").convert("RGB")
w = max(32, int(round(32 * img.width / img.height)))
x = (np.asarray(img.resize((w, 32)), np.float32) / 255.0).transpose(2, 0, 1)[None]
memory = enc.run(None, {enc.get_inputs()[0].name: x})[0]
ids = [1] # <sos>
for _ in range(128):
logits = dec.run(None, {dec.get_inputs()[0].name: np.array([ids], np.int64).T,
dec.get_inputs()[1].name: memory})[0]
t = int(logits[0].argmax())
if t == 2: break # <eos>
ids.append(t)
print("".join(vocab[i] for i in ids[1:]))
12 epoch CPU (AdamW + OneCycle 3e-4, batch 32, label smoothing 0.1, 5% mask token; ảnh cao 32px,
bề rộng lượng tử về bội 40 đệm trắng) — best epoch 11, val CER trọng số 5,6%. ONNX xuất bằng
tráo trọng số vào đồ thị động dzngo/vietocr-models (exporter torch trực tiếp không dựng được
đồ thị động cho decoder tự hồi quy này); Linear nặc danh map theo node-path, Conv gộp BatchNorm.
Nguồn gốc: kiến trúc & nghi thức huấn luyện vietocr
(Apache-2.0) · trọng số khởi tạo doanhm/vgg_transformer · khuôn đồ thị ONNX
dzngo/vietocr-models · dữ liệu 5CD-AI/Viet-Handwriting-OCR-v2.