rapidocr-spanish
Two text-recognition checkpoints for Spanish documents, fine-tuned for
RapidOCR from PP-OCRv5_latin_mobile_rec
with a reduced Spanish vocabulary.
Everyday Spanish paperwork is not just clean paragraphs: identity cards, payslips, certificates, receipts, family records and engineering drawings each bring their own fonts, layouts and symbol sets. These checkpoints target that mix.
Files
| file | size | use |
|---|---|---|
spanish_rec_v18.onnx |
7.7 MB | default checkpoint |
spanish_rec_v19.onnx |
7.7 MB | alternative for receipts and records |
ppocr_keys_es.txt |
116 lines | vocabulary for both; required |
Load each model with ppocr_keys_es.txt. Pairing a model with a different
dictionary corrupts the CTC decoding: indices no longer match characters.
Vocabulary
116 characters: lowercase and uppercase Spanish letters including ñ and the
accented vowels, digits, common punctuation, € £ º ª, and the symbols the
multilingual Latin vocabulary had but naive pruning drops:
< > _ Ø | · □ Φ ≠. The < matters in practice — machine-readable zones on ID
cards are full of it, and without it those lines cannot be transcribed at all.
Metrics
Held-out gold of 3,079 crops (44,947 reference characters) from 14 Spanish document types, compared against the stock Latin checkpoint on the same crops:
| model | CER micro | CER macro |
|---|---|---|
PP-OCRv5_latin_mobile_rec (stock) |
0.1745 | 0.1412 |
spanish_rec_v18 |
0.1476 | 0.1238 |
micro is the standard character-error rate (edit distance over reference
characters); macro is the mean of per-crop error rates and flatters a model on
short fields. The checkpoints win on 10 of the 14 document types; blueprints
−19%, CVs −18%, health-insurance slips −25%.
Per-type routing between the two checkpoints adds a further ~0.8% relative with no regression, because an unknown document type falls back to the default model.
Training data
- Real crops mined from 48 worker files covering 17 document types (identity cards, CVs, certificates, receipts, health-insurance slips, driving licences, family records, transfer deeds, experience records), rendered at 300 DPI.
- Synthetic Spanish lines composed over real scanned-paper backgrounds.
- Labels produced by a three-model vision consensus and refined by repeated passes; a fraction was reviewed by hand. This is the main limitation, see below.
- Fine-tuned from the Latin checkpoint with the head pruned to the 116-character
vocabulary, low learning rate (
5e-5) and 8 epochs. Reusing a from-scratch schedule on a converged model wrecks it, which is worth knowing if you retrain.
No client documents, names or identifiers are part of this release.
Usage
from rapidocr import RapidOCR, LangRec
ocr = RapidOCR(params={
"Rec.lang_type": LangRec.ES,
"Rec.model_path": "spanish_rec_v18.onnx",
"Rec.rec_keys_path": "ppocr_keys_es.txt",
})
result = ocr("document.png")
print(result.txts)
Consumers
These checkpoints are consumed by rapidocr-worker, a Rust daemon on ONNX Runtime that serves the full PP-OCR pipeline over a UNIX socket with bounded memory (about 74 MB per worker after load, no Python GIL contention).
It needs no code change to use them: the checkpoint goes in --rec-model and the
vocabulary in --keys.
rapidocr-worker \
--rec-model spanish_rec_v18.onnx \
--keys ppocr_keys_es.txt
--keys is mandatory here because the checkpoint carries no embedded character
metadata, and pairing it with a different vocabulary corrupts the CTC decoding
silently.
Limitations
- Label noise. Part of the gold set was labelled by vision models without human review, so the measured error includes some reference error. Treat the numbers as a comparison between checkpoints, not as an absolute quality claim.
- Small text. On drawings rendered at 300 DPI the error is much higher (CER ≈ 0.30 micro) because the detector also finds dimension marks and tiny labels. This is the weakest area.
- Tables and formulas are not covered by these checkpoints; use PPStructureV3 for table HTML and LaTeX.
- No paragraph model. The recognizer reads one line at a time; merged multi-line regions are recognized poorly.
- Mobile-size architecture (7.7 MB). A larger model fine-tuned on the same data measured worse, so capacity was not the bottleneck here.
License
Apache-2.0, inherited from PaddleOCR's released weights.