项目简介
PaddleOCR 是一个强大的 OCR 工具包,能将任何 PDF 或图像转化为 LLM 可用的结构化数据(JSON/Markdown)。支持 100+ 种语言,具备 PP-StructureV3 和 PaddleOCR-VL 模型的最先进文档解析能力,并与 RAG 和智能代理应用无缝集成。
README 预览
\n\n \n \n \n\n\n\nGlobal Leading OCR Toolkit & Document AI Engine\n\nEnglish | [简体中文](./readme/README_cn.md) | [繁體中文](./readme/README_tcn.md) | [日本語](./readme/README_ja.md) | [한국어](./readme/README_ko.md) | [Français](./readme/README_fr.md) | [Русский](./readme/README_ru.md) | [Español](./readme/README_es.md) | [العربية](./readme/README_ar.md)\n\n\n\n[](https://pepy.tech/projects/paddleocr)\n[](https://github.com/PaddlePaddle/PaddleOCR/network/dependents)\n\n\n\n\n[](https://www.paddleocr.com)\n[](https://deepwiki.com/PaddlePaddle/PaddleOCR)\n[](../LICENSE)\n\n\n\n\n\n\n\n\n**PaddleOCR converts PDF documents and images into structured, LLM-ready data (JSON/Markdown) with industry-leading accuracy. With 70k+ Stars and trusted by top-tier projects like Dify, RAGFlow, and Cherry Studio, PaddleOCR is the bedrock for building intelligent RAG and Agentic applications.**\n\n\n## 🚀 Key Features\n\n### 📄 Intelligent Document Parsing (LLM-Ready)\n> *Transforming messy visuals into structured data for the LLM era.*\n\n* **SOTA Document VLM**: Featuring **PaddleOCR-VL-1.6 (0.9B)**, the industry's leading lightweight vision-language model for document parsing. It achieves 96.3% accuracy on OmniDocBench v1.6, leads in text, formula, and table recognition, and shows significantly enhanced capabilities in ancient documents, rare characters, seals, and charts, with structured outputs in **Markdown** and **JSON** formats.\n* **Structure-Aware Conversion**: Powered by **PP-StructureV3**, seamlessly convert complex PDFs and images into **Markdown** or **JSON**. Unlike the PaddleOCR-VL series models, it provides more fine-grained coordinate information, including table cell coordinates, text coordinates, and more.\n* **Production-Ready Efficiency**: Achieve commercial-grade accuracy with an ultra-small footprint. Outperforms numerous closed-source solutions in public benchmarks while remaining resource-efficient for edge/cloud deployment.\n\n### 🔍 Universal Text Recognition (S
常见问题 (3)
故障排除为什么 PaddleOCR SealRecognition 返回空的印章识别结果(seal_res_list: []),该如何解决?
根本原因:SealRecognition 默认启用版面检测(use_layout_detection=True),内置的 PP-DocLayout-L 版面模型会将红色圆形印章归类为无效区域,从而导致下游的印章检测 pipeline 被截断。修复方法:在初始化 pipeline 时禁用版面检测:
from paddleocr import SealRecognition
ocr = SealRecognition(device="gpu", use_layout_detection=False)
result = ocr.predict(input="testpic.png")
这样即可恢复印章检测。注意:官方 pipeline 仍未完全支持环形印章上的圆形/弧形文字(矩形裁剪无法处理弯曲文字,且检测框可能存在偏移)。截至 PaddleOCR 3.7.0,官方尚未提供修复方案;社区建议的方法是提取印章多边形,并应用极坐标展开将弧形文字拉直后再进行识别,或者微调一个自定义的印章检测模型。
故障排除如何修复 PaddleOCRVL llama-cpp-server 在处理包含智能引号的图像时出现的 HTTP 500 "Failed to parse input" 错误?
当 PaddleOCR-VL 输出中包含弯引号/智能引号(U+201C/U+201D)的内容被解码为无效的 UTF-8 或 U+FFFD 字节时,llama.cpp b9637 会出现此问题,导致 llama-server 的 chat-template 解析器返回 HTTP 500。随后 PaddleOCR 3.7.0 会取消所有待处理的 VLM 块,并使整个 predict() 调用失败。
首选修复方案:将 llama-server 更新或重新构建为包含上游修复(标题为 "chat: sanitize invalid UTF-8 before peg-native parsing")的版本,然后重启服务器并重新运行 predict()。
PaddleOCR 临时解决方案:修改 paddlex/inference/models/doc_vlm/predictor.py 中的 DocVLMGenAIClientPredictor._genai_client_process(),使单个失败的块返回空内容,而不是取消所有 future 并重新抛出异常:
import logging
contents = [""] * len(futures)
for idx, future in enumerate(futures):
try:
contents[idx] = future.result().choices[0].message.content or ""
except Exception as exc:
logging.warning("Skipping failed VLM block %s: %s", idx, exc)
contents[idx] = ""
移除或替换那个取消待处理 future 并调用 raise 的全局处理器。失败的段落将为空白,但其余块和页面输出仍会正常生成。使用以下命令定位已安装的文件:
python -c "import paddlex, os; print(os.path.dirname(paddlex.__file__))"
打补丁后重启 Python。更新 llama.cpp 更为可取,因为它能从源头防止解析器故障本身。
故障排除如何修复 PaddleOCR PP-OCRv3 检测验证时显存持续增长并抛出 BadAlloc/ResourceExhaustedError 的 GPU OOM 问题?
这通常是因为验证图像在经过 DetResizeForTest 后 H/W 尺寸不固定,因此 PaddlePaddle 的缓存分配器会为新的形状保留内存块;同时训练/优化器的内存也会一直驻留在 T4 上。请在 PP-OCRv3 det 配置中减小或固定评估输入尺寸:
Eval:
loader:
batch_size_per_card: 1
dataset:
transforms:
- DetResizeForTest:
limit_type: max
limit_side_len: 736 # 如果仍然 OOM,可以尝试 640
默认值通常是 960。为了使内存复用具有确定性,可以将其替换为固定的、可被 32 整除的形状,例如:
- DetResizeForTest:
image_shape: [3, 640, 960]
如果你修改了评估循环,请确保推理在不启用 autograd 的情况下运行:
model.eval()
with paddle.no_grad():
for batch in eval_loader:
preds = model(images)
作为临时解决方案,可以在训练前启用 CUDA managed memory——使用 true,而不是旧错误信息中显示的 false:
export FLAGS_use_cuda_managed_memory=true
python tools/train.py -c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_distill_train.yml
如果训练过程中的验证仍然失败,请单独运行评估,这样优化器状态和训练缓存就不会驻留在显存中:
python tools/eval.py \
-c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_distill_train.yml \
-o Global.checkpoints=<output_dir>/best_accuracy
此外,还可以将 Train.loader.batch_size_per_card 减小到 1,或使用更大的 GPU。