- AsterNet: Vietnamese Neural Optical Character Recognition (v1.0 Production)
AsterNet: Vietnamese Neural Optical Character Recognition (v1.0 Production)
AsterNet is an ultra-fast, non-autoregressive neural Optical Character Recognition engine tailored for Vietnamese typography, administrative records (CCCD, passports, licenses), financial invoices, and mobile scene captures.
1. Architectural Blueprint & Parameter Breakdown
AsterNet abandons slow token-by-token autoregressive decoding in favor of an optimized end-to-end non-autoregressive sequence architecture.
graph TD
A["Input Image Strip (32 x W x 3)"] --> B["HP-Stem: High-Pass Spatial Feature Filter"]
B --> C["Backbone: Inverted Residual SE-ResNet (2.53M Params)"]
C --> D["Map-to-Sequence (Feature Map -> 1D Temporal Slices)"]
D --> E["Bidirectional LSTM (2 Layers, 256 Dim - 3.15M Params)"]
E --> F["Multi-Head Self-Attention Fusion (4 Heads - 4.21M Params)"]
F --> G["CTC Prediction Head (10.65M Total Params)"]
G --> H["Neuro-Symbolic Linguistic Rescorer (Phonology & N-gram)"]
H --> I["Output Vietnamese Text (Unicode NFC Standard)"]
Complete Parameter Profile (10,649,106 Total Parameters)
| Neural Component | Module Architecture | Parameter Count | Ratio (%) | Operational Role |
|---|---|---|---|---|
| Input Stem | High-Pass Spatial Laplacian Filter + Conv3x3 | Included in Backbone | β | Preserves micro 1-2px Vietnamese accents (Δ, Γ’, Ζ‘, Ζ°) |
| Vision Backbone | Inverted Residual MobileNetV3 + SE Channel Gating | 2,525,249 | 23.7% | Spatial feature extraction & background noise suppression |
| Sequence Modeler | 2-Layer Bidirectional LSTM (hidden_size=256) | 3,153,920 | 29.6% | Bidirectional typographical stroke context dependencies |
| Language Fusion | 4-Head Linear Multi-Head Self-Attention | 4,206,592 | 39.5% | Long-range compound word coherence across sentence |
| Output Classifier | Linear Projection (hidden_dim -> 227 Classes) | 116,451 | 1.1% | CTC probability distributions across character vocabulary |
| Auxiliary Heads | Multi-Task Tone & Diacritic Hat Classifiers | 646,894 | 6.1% | Explicit multi-task supervision during representation learning |
| TOTAL | Full AsterNet Architecture | 10,649,106 | 100.0% | 40.78 MB Checkpoint (70% smaller than VietOCR 145MB) |
2. Mathematical Formulations & Novel Algorithms
2.1. High-Pass Spatial Feature Stem (HP-Stem)
Standard convolutional downsampling kernels act as low-pass filters, frequently obliterating subtle Vietnamese diacritics. HP-Stem introduces a learnable residual high-pass kernel $K_{hp}$:
where $\gamma$ is a dynamic scalar parameter that amplifies edge gradients of high-frequency diacritic strokes before entering the pooling pyramid.
2.2. Inverted Residual with Squeeze-and-Excitation (SE-ResNet)
To suppress background paper discoloration, scanner artifacts, and watermark textures, AsterNet incorporates SE channel gating:
This mechanism dynamically recalibrates channel-wise feature responses, effectively discarding colored watermark overlays and background texture.
2.3. Contrast-Based Auto-Polarity Engine
Traditional CTC decoders fail catastrophically on inverted text strips (white text on dark backgrounds, camera timestamps, dark mode), outputting repetitive noise. AsterNet implements a mathematical contrast polarity check before tensor normalization:
This guarantees invariant forward activations regardless of background luminance.
3. Real-World CPU Performance & Hardware Matrix
AsterNet is engineered for ultra-lightweight execution without requiring expensive GPU servers. Tested on 100 representative lines of the National Vietnamese Benchmark Suite (vi_00 / InkData):
| Hardware Platform | Architecture | Threads | Latency / Line | Throughput (FPS) | Feasibility |
|---|---|---|---|---|---|
| Apple M3 / M4 Pro | ARM64 (NEON) | 4 | 28.4 ms | 35.2 FPS | Ultra Real-Time |
| Apple M1 / M2 | ARM64 (NEON) | 4 | 34.8 ms | 28.7 FPS | Ultra Real-Time |
| Intel Core i7-13700H | x86_64 (AVX2/FMA) | 1 | 60.2 ms | 16.6 FPS | Standard Desktop / Server |
| AMD Ryzen 7 7840HS | x86_64 (AVX-512) | 1 | 54.1 ms | 18.5 FPS | Standard Desktop / Server |
| Cloud vCPU (AWS c6i.large) | x86_64 (AVX-512) | 2 | 62.7 ms | 15.9 FPS | Low-Cost Cloud Instance |
| Raspberry Pi 5 (4GB) | ARM Cortex-A76 | 4 | 118.0 ms | 8.5 FPS | Edge / IoT Hardware |
| NVIDIA RTX 3060 / T4 | CUDA FP16 | Batch 16 | 5.8 ms | 275.0 FPS | High-Concurrency API Server |
4. Benchmark Accuracy Comparison vs VietOCR
| Benchmark Metric | AsterNet v1.0 | VietOCR (Transformer) | Delta / Gain |
|---|---|---|---|
| Exact Sentence Match (100% Match) | 86.0% | 76.0% | +10.0% accuracy gain |
| Character Error Rate (CER) | 3.45% | 3.85% | 1.1x lower character error |
| Word Error Rate (WER) | 9.01% | 8.23% | Comparable word accuracy |
| Average Latency (Intel CPU) | 60.25 ms | 765.70 ms | 12.8x faster inference |
| Throughput (Single CPU) | 16.6 FPS | 1.3 FPS | Suitable for live video feeds |
| Model Size | 40.78 MB | ~145 MB | 70% lighter footprint |
5. Multi-Language Deployment & Integration Guide
5.1. Python (Native PyTorch)
import torch
from PIL import Image
# 1. Download model weights
# wget https://huggingface.co/asterxlabs/asternet-vietnamese-ocr/resolve/main/asternet_best.pth
# 2. Run inference using predictor
from asterocr.inference.predictor import AsterPredictor
predictor = AsterPredictor(model_path="asternet_best.pth")
text = predictor.predict("sample_line.jpg")
print("Recognized Text:", text)
5.2. Node.js / TypeScript (ONNX Runtime)
import * as ort from "onnxruntime-node";
import * as fs from "fs";
async function runOCR(imageBuffer: Buffer): Promise<string> {
const session = await ort.InferenceSession.create("asternet.onnx");
// Preprocess tensor (1, 3, 32, W)
// Run session.run({ input: tensor });
return "Output string";
}
5.3. C++ (Production High-Concurrency Engine)
#include <onnxruntime_cxx_api.h>
#include <opencv2/opencv.hpp>
int main() {
Ort::Env env(ORT_LOGGING_LEVEL_WARNING, "AsterNetOCR");
Ort::Session session(env, L"asternet.onnx", Ort::SessionOptions{});
// Load OpenCV cv::Mat -> 32px height -> Run Session
return 0;
}
5.4. C# / .NET (Enterprise Desktop & WPF)
using Microsoft.ML.OnnxRuntime;
using Microsoft.ML.OnnxRuntime.Tensors;
var session = new InferenceSession("asternet.onnx");
// Run inference directly in desktop or server .NET applications
5.5. Go (Backend Microservice)
package main
import (
"fmt"
ort "github.com/yalue/onnxruntime_go"
)
func main() {
// Load AsterNet ONNX model into Go microservice
fmt.Println("AsterNet OCR Microservice ready on port 8080")
}
6. Model Artifacts & File Inventory
asternet.onnx(40.76 MB): Production ONNX runtime model for Python, Node.js, Flutter, C++, C#, Go, and Web.asternet_best.pth(40.78 MB): PyTorch weights trained on 1.56M unified Vietnamese document samples.config.json: Hardware, architectural, and component configuration parameters.vocab.json: 227-character vocabulary dictionary mapping tokens to characters.README.md: Official technical specification and benchmark documentation.
7. License & Citation
AsterNet v1.0 is published under the MIT License. Free for commercial and non-commercial utilization.
Developed by asterxlabs (2026).
- Downloads last month
- 70