How hoainv99/ocr-vietnamese works
Project type and purpose
• This is an open-source OCR system specialized for Vietnamese text. It implements a two-stage pipeline:
a. Text detection using the CRAFT model (craft.py, detection.py, craft_utils.py)
b. Text recognition using a Transformer-based OCR model (model_recognition.py, modules/transformerocr.py, modules/*)
File structure
Top-level:
• OCR.py – CLI entry point
• recognition.py / detection.py – high-level functions for each pipeline stage
• imgproc.py / utils.py – image pre-processing, helper routines
• model_recognition.py – orchestrates recognition stage
• craft_utils.py / craft.py – CRAFT-based detector
• config/ – YAML configs for different network backbones (resnet, vgg, transformer)
• modules/ – PyTorch model definitions (cnn, resnet, vgg, transformer, vocabulary)
• tools/ – auxiliary scripts (config generation, translation)
• test/ – sample images and expected outputs
Patterns / architecture hints:
• Pipeline pattern: image → pre-process → detect → crop & reorder → recognize → post-process → output
• Config-driven model instantiation (config/*.yml + tools/config.py)
• Modular network design (each backbone in modules/)
README for additional insights
• Describes two core components: CRAFT text detector + Transformer text recognizer
• Requires downloading pretrained models and placing them under a specific directory for “End-to-End-OCR”
• CLI usage example python3 OCR.py --image_path test/test2.png
Be detailed but not over-engineered
• Cover every folder and its role.
• Both code modules and data/configuration files.
• Keep the high-level flow clear; avoid diagramming every class or function—focus on logical components.