| name | paddleocr |
| description | Comprehensive PaddleOCR document intelligence skill covering OCR text extraction, table detection and QA, layout analysis, document-level reasoning, structured extraction (forms, invoices, IDs, receipts), seal/stamp recognition, handwriting, formulas, multilingual OCR, and PaddleOCR-VL multimodal tasks. Use when extracting text from images or PDFs, parsing tables, understanding document structure, extracting key-value pairs, running document QA, processing financial documents, or doing any image-to-structured-data task. |
PaddleOCR Skill
Installed: PaddleOCR 3.5.0 · PaddlePaddle 3.3.1 · Python 3.12 · macOS ARM64
Model cache: ~/.paddlex/official_models/
Official docs: https://www.paddleocr.ai/v3.5.0/en/quick_start.html
Task → Tool Matrix
Quick Start
Python
from paddleocr import PaddleOCR
ocr = PaddleOCR(
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False,
lang='en'
)
result = ocr.predict('document.jpg')
for res in result:
data = res.json['res']
texts = data['rec_texts']
scores = data['rec_scores']
polys = data['rec_polys']
boxes = data['rec_boxes']
print(texts)
res.save_to_img("output")
res.save_to_json("output")
CLI
paddleocr ocr -i ./document.png \
--use_doc_orientation_classify False \
--use_doc_unwarping False \
--use_textline_orientation False \
--save_path ./output \
--device cpu
paddleocr pp_structurev3 -i ./report.png \
--use_doc_orientation_classify False \
--use_doc_unwarping False
paddleocr text_detection -i ./image.png
paddleocr text_recognition -i ./cropped_text.png
paddleocr layout_detection -i ./document.png
paddleocr seal_recognition -i ./stamp.png
paddleocr table_recognition_v2 -i ./table.png
paddleocr formula_recognition_pipeline -i ./equation.png
paddleocr chart_parsing -i ./chart.png
paddleocr doc2md -i ./document.docx
paddleocr doc_vlm -i ./complex_doc.png
Core Patterns
1. Full OCR Pipeline (Detection → Recognition)
from paddleocr import PaddleOCR
ocr = PaddleOCR(
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False,
lang='en',
)
result = ocr.predict('document.jpg')
for res in result:
data = res.json['res']
texts = data['rec_texts']
scores = data['rec_scores']
polys = data['rec_polys']
boxes = data['rec_boxes']
for text, score in zip(texts, scores):
if score > 0.8:
print(f"{text} ({score:.2f})")
res.save_to_img("output")
res.save_to_json("output")
2. Document Structure Analysis (Layout + Tables + Text + Formulas)
from paddleocr import PPStructureV3
pipeline = PPStructureV3(
use_doc_orientation_classify=False,
use_doc_unwarping=False,
)
output = pipeline.predict(input='./report.png')
for res in output:
data = res.json['res']
layout = data['layout_det_res']
for box in layout['boxes']:
print(f" {box['label']} (score={box['score']:.2f}) at {box['coordinate']}")
ocr_data = data['overall_ocr_res']
texts = ocr_data['rec_texts']
res.save_to_markdown("output")
res.save_to_json("output")
Note: PPStructureV3 requires extra dependencies. Install with:
pip install "paddleocr[all]"
pip install "paddlex[ocr]"
3. Individual Module Usage
from paddleocr import TextDetection
det = TextDetection()
output = det.predict("document.png")
for res in output:
polys = res.json['res']['dt_polys']
scores = res.json['res']['dt_scores']
res.save_to_img("./output/")
res.save_to_json("./output/res.json")
from paddleocr import TextRecognition
rec = TextRecognition()
output = rec.predict(input="cropped_line.png")
for res in output:
text = res.json['res']['rec_text']
score = res.json['res']['rec_score']
from paddleocr import LayoutDetection
layout = LayoutDetection()
output = layout.predict("document.png")
4. Structured KV Extraction
import re
from paddleocr import PaddleOCR
ocr = PaddleOCR(
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False,
lang='en'
)
def extract_kv(ocr_lines, patterns: dict) -> dict:
full_text = '\n'.join(ocr_lines)
return {k: re.search(p, full_text, re.I).group(1)
for k, p in patterns.items()
if re.search(p, full_text, re.I)}
result = ocr.predict('invoice.jpg')
for res in result:
texts = res.json['res']['rec_texts']
fields = extract_kv(texts, {
'invoice_no': r'Invoice\s*No[.:\s]+([A-Z0-9\-]+)',
'date': r'Date[:\s]+([\d]{1,2}[\/\-][\d]{1,2}[\/\-][\d]{2,4})',
'total': r'Total\s*[\$₦€£]?\s*([\d,]+\.?\d*)',
})
print(fields)
5. Batch PDF Processing
import pypdfium2 as pdfium
from paddleocr import PaddleOCR
ocr = PaddleOCR(
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=False,
lang='en'
)
def pdf_to_images(pdf_path, dpi=200):
doc = pdfium.PdfDocument(pdf_path)
for i in range(len(doc)):
page = doc[i]
bitmap = page.render(scale=dpi/72)
yield bitmap.to_pil()
for page_num, page_img in enumerate(pdf_to_images('report.pdf')):
result = ocr.predict(page_img)
for res in result:
texts = res.json['res']['rec_texts']
print(f"Page {page_num+1}: {len(texts)} lines")
6. Streaming Large Datasets with predict_iter()
ocr = PaddleOCR(use_doc_orientation_classify=False, use_doc_unwarping=False,
use_textline_orientation=False, lang='en')
for res in ocr.predict_iter(large_image_list):
texts = res.json['res']['rec_texts']
process(texts)
Result Object API (OCRResult)
The predict() method returns an iterator of OCRResult objects. Each has:
| Method / Attribute | Description |
|---|
res.json | Dict with key 'res' containing all results |
res.json['res']['rec_texts'] | list[str] — recognized text lines |
res.json['res']['rec_scores'] | list[float] — confidence per line |
res.json['res']['rec_polys'] | list[list] — 4-corner polygons [[x,y],...] |
res.json['res']['rec_boxes'] | list[list] — bounding boxes [x, y, w, h] |
res.json['res']['dt_polys'] | list[list] — raw detection polygons |
res.json['res']['input_path'] | Source file path |
res.json['res']['page_index'] | Page number (for PDFs) |
res.json['res']['model_settings'] | Dict of pipeline config used |
res.print() | Print results to stdout |
res.save_to_img(path) | Save annotated image |
res.save_to_json(path) | Save JSON results |
For PPStructureV3, additional keys:
| Key | Description |
|---|
res.json['res']['layout_det_res']['boxes'] | Layout regions with label, score, coordinate |
res.json['res']['overall_ocr_res']['rec_texts'] | Full-page OCR text |
res.save_to_markdown(path) | Save reconstructed Markdown document |
CLI Subcommands (v3.5.0)
paddleocr <subcommand> -i <input> [options]
ocr
text_detection
text_recognition
pp_structurev3
layout_detection
seal_recognition
table_recognition_v2
formula_recognition_pipeline
chart_parsing
doc_preprocessor
doc_understanding
doc_vlm
pp_chatocrv4_doc
pp_doctranslation
doc2md
doc_img_orientation_classification
doc_parser
seal_text_detection
text_image_unwarping
textline_orientation_classification
table_cells_detection
table_classification
table_structure_recognition
formula_recognition
Common CLI options:
-i, --input PATH
--save_path PATH
--device DEVICE
--lang LANG
--use_doc_orientation_classify BOOL
--use_doc_unwarping BOOL
--use_textline_orientation BOOL
--ocr_version VERSION
--engine ENGINE
--cpu_threads INT
--enable_mkldnn BOOL
Model Selection Guide
| Use Case | Detection Model | Recognition Model | Speed | Accuracy |
|---|
| Standard printed text | PP-OCRv5_server_det (default) | en_PP-OCRv5_mobile_rec (default) | Medium | High |
| Fast/mobile use | PP-OCRv5_mobile_det | en_PP-OCRv5_mobile_rec | Fast | Good |
| Highest accuracy | PP-OCRv5_server_det | en_PP-OCRv5_server_rec | Slow | Highest |
| Chinese documents | PP-OCRv5_server_det | ch_PP-OCRv4_rec | Medium | High |
| Scene text (photos) | PP-OCRv5_server_det | en_PP-OCRv5_server_rec | Slow | Highest |
Switch models at init:
ocr = PaddleOCR(
text_detection_model_name="PP-OCRv5_mobile_det",
text_recognition_model_name="en_PP-OCRv5_server_rec",
lang='en'
)
Installation Notes
Base install (OCR only)
pip install paddlepaddle paddleocr
Full install (all pipelines including PPStructureV3)
pip install "paddleocr[all]"
Specific extras
pip install "paddleocr[doc-parser]"
pip install "paddleocr[ie]"
pip install "paddleocr[doc2md]"
pip install "paddleocr[all]"
Important Notes
- API changed in v3.5.0:
.ocr() → .predict(). The old .ocr(img, cls=True) method is deprecated and cls kwarg is removed. Use .predict(img) instead.
show_log removed: Not a valid parameter in v3.5.0. Remove all show_log=False calls.
use_angle_cls removed: Use use_textline_orientation=True at init time.
use_gpu renamed: Use device="cpu" or device="gpu" parameter.
- CLI restructured: Now requires subcommand (
paddleocr ocr -i file.png instead of paddleocr --image_dir file.png).
--image_dir → -i: CLI input flag changed.
- Result format changed: Returns
OCRResult objects (use .json['res']) instead of nested lists.
PPStructure → PPStructureV3: The old class is replaced. Import from paddleocr import PPStructureV3.
- First run downloads models to
~/.paddlex/official_models/ (~200MB total for defaults)
- GPU disabled by default on this host — CPU inference only. Use
device="gpu" if GPU available.
PaddleOCR-VL-1.5 is a separate large model (not installed); needed only for multimodal document QA — see vl-model.md
- For high-accuracy table extraction, prefer
PPStructureV3 over plain PaddleOCR
- Not suitable for network diagrams or visual layouts — PaddleOCR extracts text labels only, not shapes/connections/topology. Use a vision/multimodal LLM for diagram analysis.
- CPU inference can be slow on large images. Downsample to ~150 DPI for faster results when full resolution isn't needed.
Migration from v2.x / early v3.x
| Old (v2.x / early v3.x) | New (v3.5.0) | Notes |
|---|
ocr.ocr(img, cls=True) | ocr.predict(img) | .ocr() deprecated, cls removed |
result[0][i][1][0] (text) | res.json['res']['rec_texts'][i] | List access instead of nested tuples |
result[0][i][1][1] (score) | res.json['res']['rec_scores'][i] | Direct list access |
result[0][i][0] (bbox) | res.json['res']['rec_polys'][i] | Polygon as list of [x,y] points |
PaddleOCR(show_log=False) | PaddleOCR(...) | show_log removed entirely |
PaddleOCR(use_gpu=False) | PaddleOCR(device="cpu") | Renamed parameter |
PaddleOCR(use_angle_cls=True) | PaddleOCR(use_textline_orientation=True) | Renamed parameter |
PPStructure(show_log=False) | PPStructureV3(...) | Class renamed, show_log removed |
PPStructure(table=True, ocr=True) | PPStructureV3(use_table_recognition=True) | Param names changed |
paddleocr --image_dir ./dir --use_gpu False | paddleocr ocr -i ./dir --device cpu | CLI restructured |
region['res']['html'] (table) | res.save_to_json() / res.save_to_markdown() | Use save methods |
Scripts
Ready-to-run scripts in scripts/:
python3 scripts/ocr_quick.py document.jpg
python3 scripts/table_extract.py report.pdf --out ./tables/
python3 scripts/structured_extract.py invoice.jpg --type invoice
python3 scripts/doc_pipeline.py contract.pdf --out result.json
References
- references/quick-start.md — Installation, first run, common errors
- references/ocr-pipeline.md — Text detection, recognition, orientation, PDF batch
- references/table-qa.md — Table detection, HTML export, CSV, pandas QA
- references/document-reasoning.md — Layout analysis, reading order, LLM reasoning chains
- references/structured-extraction.md — Forms, invoices, receipts, ID cards, KV pairs
- references/vl-model.md — PaddleOCR-VL multimodal QA (installation + usage)
- references/advanced-tasks.md — Seals, handwriting, formulas, multilingual, scene text