科学工具
科学工具让世界更美好
让世界更美好

PaddleOCR 文字识别和文档解析工具PaddleOCR 文字识别和文档解析工具

PaddleOCR全面适配飞桨框架3.0正式版,在文字识别精度、多文字类型支持、手写体识别等方面实现突破,新增对昆仑芯、昇腾等国产硬件的支持,为开发者带来更强大的OCR工具。

• 单模型支持简体中文、繁体中文、中文拼音、英文、日文五种文字类型识别。

• 强化复杂手写体识别能力,针对连笔、非规范字迹优化,识别性能显著提升。

• 整体识别精度较上一代PP-OCRv4提升13个百分点,多种场景识别能力达到SOTA( state-of-the-art)水平。

通用文档解析方案 PP-StructureV3

• 支持多场景、多版式PDF高精度解析,在OmniDocBench基准测试中表现领先。

• 具备印章识别、图表转表格、嵌套公式/图片的表格识别、竖排文本解析和复杂表格结构分析等专精能力。

智能文档理解方案 PP-ChatOCRv4

• 关键信息提取精度较上一代提升15个百分点。

• 原生支持文心大模型4.5 Turbo,兼容PaddleNLP、Ollama、vLLM等工具部署的大模型。

• 集成PP-DocBee2,支持印刷文字、手写体、印章、表格、图表等复杂文档信息的抽取与理解。

PaddleOCR安装和使用首恶

本地安装

先完成PaddlePaddle 3.0安装,再通过以下命令安装paddleocr:

pip install paddleocr==3.0.0
命令行推理

PP-OCRv5推理

paddleocr ocr -i https://示例图片地址 --use_doc_orientation_classify False --use_doc_unwarping False --use_textline_orientation False

PP-StructureV3推理

paddleocr pp_structurev3 -i https://示例图片地址 --use_doc_orientation_classify False --use_doc_unwarping False

PP-ChatOCRv4推理(需先获取千帆API Key)

paddleocr pp_chatocrv4_doc -i https://示例图片地址 -k 目标关键词 --qianfan_api_key your_api_key --use_doc_orientation_classify False --use_doc_unwarping False
API方式推理

PP-OCRv5示例

from paddleocr import PaddleOCR

ocr = PaddleOCR(
    use_doc_orientation_classify=False,
    use_doc_unwarping=False,
    use_textline_orientation=False)
result = ocr.predict(input="https://示例图片地址")
for res in result:
    res.print()
    res.save_to_img("output")
    res.save_to_json("output")

PP-StructureV3示例

from pathlib import Path
from paddleocr import PPStructureV3

pipeline = PPStructureV3(
    use_doc_orientation_classify=False,
    use_doc_unwarping=False
)
output = pipeline.predict(input="https://示例图片地址")
for res in output:
    res.print() 
    res.save_to_json(save_path="output") 
    res.save_to_markdown(save_path="output") 

PP-ChatOCRv4示例

from paddleocr import PPChatOCRv4Doc

chat_bot_config = {
    "module_name": "chat_bot",
    "model_name": "ernie-3.5-8k",
    "base_url": "https://qianfan.baidubce.com/v2",
    "api_type": "openai",
    "api_key": "your_api_key",  # 替换为实际API Key
}

retriever_config = {
    "module_name": "retriever",
    "model_name": "embedding-v1",
    "base_url": "https://qianfan.baidubce.com/v2",
    "api_type": "qianfan",
    "api_key": "your_api_key",  # 替换为实际API Key
}

pipeline = PPChatOCRv4Doc(
    use_doc_orientation_classify=False,
    use_doc_unwarping=False
)

visual_predict_res = pipeline.visual_predict(
    input="https://示例图片地址",
    use_common_ocr=True,
    use_seal_recognition=True,
    use_table_recognition=True,
)

# 如需使用多模态大模型,需按文档部署本地服务并配置
if use_mllm:
    mllm_chat_bot_config = {
        "module_name": "chat_bot",
        "model_name": "PP-DocBee",
        "base_url": "http://127.0.0.1:8080/",  # 本地服务地址
        "api_type": "openai",
        "api_key": "api_key",  # 替换为实际API Key
    }
    mllm_predict_res = pipeline.mllm_pred(
        input="https://示例图片地址",
        key_list=["目标关键词"],
        mllm_chat_bot_config=mllm_chat_bot_config,
    )
    mllm_predict_info = mllm_predict_res["mllm_res"]

visual_info_list = [res["visual_info"] for res in visual_predict_res]
vector_info = pipeline.build_vector(
    visual_info_list, flag_save_bytes_vector=True, retriever_config=retriever_config
)
chat_result = pipeline.chat(
    key_list=["目标关键词"],
    visual_info=visual_info_list,
    vector_info=vector_info,
    mllm_predict_info=mllm_predict_info,
    chat_bot_config=chat_bot_config,
    retriever_config=retriever_config,
)
print(chat_result)

应用场景

PaddleOCR 3.0已在多个领域落地,包括:

• 票据合同审查、企业财报分析

• 海关单据处理、智能试卷批改

• 证照信息提取、通用文档解析

生态与社区

PaddleOCR被广泛应用于多个知名开源项目,如:

项目名称 简介
RAGFlow 基于RAG的AI工作流引擎
MinerU 多类型文档转换Markdown工具
Umi-OCR 开源批量离线OCR软件
OmniParser 基于纯视觉的GUI智能体屏幕解析工具
QAnything 基于任意内容的问答系统
PDF-Extract-Kit 高效复杂PDF文档提取工具包
Dango-Translator 屏幕实时翻译工具