How bmd1905/vietnamese-ocr works
Project Type and Purpose
• This is an end-to-end OCR pipeline tool (not a web app) combining two major subsystems:
a. PaddleOCR – handles text detection.
b. VietOCR – handles Vietnamese text recognition using a Transformer OCR model.
• Users interact via CLI scripts (predict.py) or Jupyter notebooks (predict.ipynb).
High-Level Components
A. User Interface Layer
• CLI / Notebook
– predict.py, predict.ipynb
– Accepts image path & output path parameters
B. Orchestration Layer (Controller)
• predict.py main() function
• Loads configurations & dispatches to detection & recognition subsystems
C. Text Detection Subsystem (PaddleOCR)
• Config Loader (YAML configs under PaddleOCR/configs/det)
• Pre-processing
– Image normalization, resizing
• Detection Model
– DB algorithm implemented in ppocr/modeling/backbones + heads + necks
• Post-processing
• Crop & Pad Module
– Crops detected regions and pads them for recognition
D. Text Recognition Subsystem (VietOCR)
• Config Loader (vietocr/config/*.yml)
• Pre-processing
– Resize & normalize cropped image
• CNN + Transformer Model
– CNN backbone extracts visual features
– Transformer decoder generates character sequences
• Post-processing
– Beam search or greedy decoding
– Vocabulary mapping (vietocr/model/vocab.py)
E. Utility & Shared Modules
• Logging, profiling (ppocr/utils/loggers)
• Configuration management (vietocr/tool/config.py)
• Image I/O, augmentation (ppocr/data & vietocr/loader)
F. Output Layer
• JSON/Text file or image overlay with recognized text
• save_to_file / display results
Relationships & Data Flow
1. User → CLI/Notebook
– CLI parses arguments, loads configs
2. CLI → Detection Subsystem
– Pass raw image
5. Recognition → Text Strings
6. Orchestrator → Aggregates & saves final result
Architectural Patterns & Principles
• Pipeline pattern: clearly separated stages (detect → crop → recognize)
• Strategy for model choice via external YAML configs
• Modular code: detection and recognition are loosely coupled
• Single responsibility per module: ppocr handles all detection concerns; vietocr handles recognition
Technologies & Frameworks
• PaddleOCR core (PaddlePaddle) for detection
• PyTorch-based VietOCR for recognition
• YAML config files to switch models
• Python scripts for orchestration and utilities
Details to Capture
• Config loading: show that both subsystems read separate YAML trees.
• Cropping and padding step as a bridge between detection & recognition.
• Orchestrator script (predict.py) as the central controller.