Skip to main content

A practical tool for converting PDF to Markdown

Project description

RapidDoc – 高速文档解析产线

😺 项目介绍

RapidDoc 是一个轻量级、专注于文档解析的开源框架,支持 OCR、版面分析、公式识别、表格识别和阅读顺序恢复 等多种功能。

框架基于 Mineru 二次开发,移除 VLM,专注于 Pipeline 产线下的高效文档解析,在 CPU 上也能保持不错的解析速度。

本项目所使用的核心模型主要来源于 PaddleOCRPP-StructureV3 系列(OCR、版面分析、公式识别、阅读顺序恢复,以及部分表格识别模型),并已全部转换为 ONNX 格式,支持在 CPU/GPU 上高效推理。

KittyDoc 已经成为 RapidAI开源家族成员


✨如果该项目对您有帮助,您的star是我不断优化的动力!!!

👏 项目特点

  • OCR 识别

    • 使用 RapidOCR 支持多种推理引擎
    • CPU 下默认使用 OpenVINO,GPU 下默认使用 torch
  • 版面识别

    • 模型使用 PP-DocLayout 系列 ONNX 模型(plus-L、L、M、S)
      • PP-DocLayout_plus-L:效果最好,速度稍慢
      • PP-DocLayout-L:速度快,效果也不错,默认使用
      • PP-DocLayout-S:速度极快,可能存在部分漏检
  • 公式识别

    • 使用 PP-FormulaNet_plus 系列 ONNX 模型(L、M、S)
      • PP-FormulaNet_plus-L:速度慢
      • PP-FormulaNet_plus-S:速度最快,默认使用
    • 支持配置只识别行间公式
    • cuda环境默认不使用gpu,公式模型onnx gpu推理会报错,暂时无人解决 PaddleOCR/issues/15125, PaddleX/issues/4238, Paddle2ONNX/issues/1593
  • 表格识别

    • 基于 rapid_table_self 增强,在原有基础上增强为多模型串联方案:
      • 表格分类(区分有线/无线表格)
      • SLANeXt 系列 表结构识别 + 单元格检测
      • 有线表格识别UNET + SLANET_plus/UNITABLE(作为无线表格识别)
  • 阅读顺序恢复

    • 使用 PP-StructureV3 阅读顺序 xycut++ 算法简化
    • 速度快且阅读顺序恢复效果不错
  • 推理方式

    • 所有模型通过 ONNXRuntime 推理,OCR可配置其他推理引擎
    • 除了 OCR 和 PP-DocLayout-M/S 模型,OpenVINO推理会报错,暂时难以解决。PaddleOCR/issues/16277

🛠️ 安装RapidDoc

使用pip安装

pip install rapid-doc -i https://mirrors.aliyun.com/pypi/simple

通过源码安装

# 克隆仓库
git clone https://github.com/RapidAI/RapidDoc.git
cd RapidDoc

# 安装依赖
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple

使用gpu推理

# 在安装完 rapid_doc 之后,卸载 cpu 版的 onnxruntime
pip uninstall onnxruntime
# 这里一定要确定onnxruntime-gpu与GPU对应
# 可参见https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements
pip install onnxruntime-gpu
# 在 Python 中指定 GPU(必须在导入 rapid_doc 之前设置)
import os
# 使用默认 GPU(cuda:0)
os.environ['MINERU_DEVICE_MODE'] = "cuda"
# 或指定 GPU 编号,例如使用第二块 GPU(cuda:1)
os.environ['MINERU_DEVICE_MODE'] = "cuda:1"

📋 使用示例


模型下载

不指定模型路径,初次运行时,会自动下载


📌 TODO

  • 表格非OCR文本提取
  • 跨页表格合并
  • 复选框识别,使用opencv(默认关闭、opencv识别存在误检)
  • 复选框识别,使用模型
  • 四方向分类旋转表格解析 rapid_orientation
  • 表格内公式提取
  • 表格内图片提取
  • 公式识别支持gpu
  • 版面、表格、公式支持openvino
  • RapidDoc4j(Java版本)

🙏 致谢

⚖️ 开源许可

基于 MinerU 改造而来,已移除原项目中的 YOLO 模型,并替换为 PP-StructureV3 系列 ONNX 模型
由于已移除 AGPL 授权的 YOLO 模型部分,本项目整体不再受 AGPL 约束。

该项目采用 Apache 2.0 license 开源许可证。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rapid_doc-0.1.0.tar.gz (973.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rapid_doc-0.1.0-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

Details for the file rapid_doc-0.1.0.tar.gz.

File metadata

  • Download URL: rapid_doc-0.1.0.tar.gz
  • Upload date:
  • Size: 973.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for rapid_doc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c51dab2a881e378ac5959f2f505b115e7021187ad1301ab971226d23351ab111
MD5 38ec8187e196f591fbd27d9cee7b273f
BLAKE2b-256 03279f8b4f9283e6828e926b6f34c9cdaaed4469cbd2ce48616883d69b66de16

See more details on using hashes here.

File details

Details for the file rapid_doc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rapid_doc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for rapid_doc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 53b880fe91d57153a80c0726e96bcae6ac2c1b624e1d2afe5ea2a2a4f5ad96da
MD5 43d4616838f08a31c6678931d1bd6cfc
BLAKE2b-256 86ba55a84a12907c8c077373296178a06a55c026960b91378d7a1e015356c843

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page