PP-OCRv5 Vietnamese/Latin Recognition v4
A research/non-commercial fine-tune of PaddlePaddle/latin_PP-OCRv5_mobile_rec for Vietnamese and Latin text recognition. Its 903-character dictionary includes Vietnamese, Latin, document punctuation, and math symbols such as ∀ ∃ ∈ ℝ ≤ ≥ ≠ ² ³.
Quick start
pip install -r requirements.txt
python infer.py --input page.png
pip install pymupdf # optional, for PDF input
python infer.py --input document.pdf --out document.json
Minimal PaddleOCR 3.x API usage:
from paddleocr import PaddleOCR
ocr = PaddleOCR(
text_detection_model_name="PP-OCRv5_server_det",
text_recognition_model_name="latin_PP-OCRv5_mobile_rec",
text_recognition_model_dir="inference",
text_det_unclip_ratio=2.0,
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False,
)
results = list(ocr.predict("page.png"))
The bundled infer.py is recommended because it implements the measured crop-margin and polarity pipeline. The detector downloads automatically on first use.
Input guide for best accuracy
- Use PP-OCRv5_server_det with unclip ratio
2.0, and add 64 px of background-coloured page padding before detection. - Add horizontal margin of about
0.3 × line heightto every rectified crop, filled with the crop's estimated background colour. - Invert light-on-dark crops so recognition always receives dark text on a light background.
- Do not apply page-level enhancement, upscaling, denoising, illumination correction, or binarisation.
- Render PDFs at 200 DPI and aim for a text line height of roughly 24–48 px.
- Run a layout model first for multi-column pages, tables, callouts, or contents pages, then OCR each block separately.
Results
| Evaluation set | v4 result |
|---|---|
| Scan validation | 2.10% CER; 97.2% VN-char accuracy |
| ducto VietOCR validation | 6.87% CER |
| UniMER math validation | 4.92% CER |
22-image infer.py benchmark | 10.65% CER |
Textbook page CER is dominated by detection, layout, and reading-order errors; clean prose recognition is substantially better than tables, diagrams, and callouts.
Limitations
- Handwriting and vertical text are not supported.
∀,∃, bold textbookℝ, and literal LaTeX remain difficult.- Dark-mode tone marks on circumflex vowels can be missed.
- Complex layouts and tables require a separate layout model.
Training data and license
- Synthetic Vietnamese/English lines using Wikipedia text and OFL/Apache-licensed fonts; ademax OCR printed/scanned sets and VinText scene text.
- UniMER-1M printed math converted from LaTeX to Unicode, plus
ducto489/ocr_datasetsVietOCR lines; source-specific and mixed upstream licences apply. - This release contains model weights only, no dataset content. The weights are CC BY-NC 4.0 and must not be used commercially.
- Built on PaddleOCR and its Apache-2.0 base model; see PaddleOCR for attribution.
Fine-tuning
Use train_checkpoint/ with tools/train.py from a compatible PaddleOCR source checkout, overriding the config's training and validation data paths for your dataset.