Metadata-Version: 2.4
Name: rapid-doc
Version: 0.9.12
Summary: A practical tool for converting PDF to Markdown
License: Apache-2.0
Project-URL: homepage, https://github.com/RapidAI
Project-URL: repository, https://github.com/RapidAI/RapidOCR
Project-URL: issues, https://github.com/RapidAI/RapidOCR/issues
Keywords: rapid-doc, rapid_doc, onnx, convert, pdf, markdown
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: <3.15,>=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: onnx<2,>=1.17.0
Requires-Dist: loguru>=0.6.0
Requires-Dist: numpy>=1.21.6
Requires-Dist: packaging>=23.0
Requires-Dist: tqdm>=4.67.1
Requires-Dist: requests
Requires-Dist: pypdfium2<6.0.0,>=5.10.1
Requires-Dist: pypdf>=5.6.0
Requires-Dist: reportlab
Requires-Dist: pdftext<0.8.0,>=0.6.2
Requires-Dist: json-repair>=0.46.2
Requires-Dist: robust-downloader>=0.0.2
Requires-Dist: beautifulsoup4<5,>=4.13.5
Requires-Dist: ftfy<7,>=6.3.1
Requires-Dist: shapely<3,>=2.0.7
Requires-Dist: tokenizers>=0.13.2
Requires-Dist: rapidocr<=3.10.0,>=3.4.0
Requires-Dist: openai>=1.63
Requires-Dist: python-docx<2,>=1.2.0
Requires-Dist: pypptx-with-oxml<2,>=1.0.3
Requires-Dist: mammoth<2,>=1.11.0
Requires-Dist: pylatexenc<3,>=2.10
Requires-Dist: lxml<7.0.0,>=4.0.0
Requires-Dist: openpyxl<4,>=3.1.5
Requires-Dist: pydantic<3,>=2.12.5
Requires-Dist: pillow<13,>=11
Requires-Dist: olefile<1,>=0.47
Requires-Dist: metafile-render<1,>=0.3.0
Requires-Dist: resvg_py<0.6,>=0.5.0
Provides-Extra: test
Requires-Dist: rapid-doc[cpu]; extra == "test"
Requires-Dist: pytest; extra == "test"
Requires-Dist: tomli; python_version < "3.11" and extra == "test"
Requires-Dist: fuzzywuzzy; extra == "test"
Provides-Extra: cpu
Requires-Dist: onnxruntime>=1.18.0; extra == "cpu"
Provides-Extra: gpu
Requires-Dist: onnxruntime-gpu<=1.23.0; extra == "gpu"
Provides-Extra: api
Requires-Dist: fastapi>=0.104.0; extra == "api"
Requires-Dist: uvicorn[standard]>=0.24.0; extra == "api"
Requires-Dist: python-multipart>=0.0.6; extra == "api"
Provides-Extra: s3
Requires-Dist: boto3>=1.28.43; extra == "s3"
Provides-Extra: word
Requires-Dist: pypandoc-binary; extra == "word"
Provides-Extra: html
Requires-Dist: markdown-it-py; extra == "html"
Requires-Dist: mdit-py-plugins; extra == "html"
Requires-Dist: pygments; extra == "html"
Provides-Extra: gradio
Requires-Dist: gradio!=6.0.0,!=6.0.1,!=6.0.2,!=6.1.0,!=6.2.0,!=6.3.0,!=6.4.0,!=6.5.0,!=6.5.1,!=6.6.0,!=6.7.0,<6.9.0,>=5.49.1; extra == "gradio"
Requires-Dist: gradio-pdf>=0.0.22; extra == "gradio"
Provides-Extra: core
Requires-Dist: openvino>=2024.6.0; extra == "core"
Requires-Dist: onnxruntime-gpu<=1.23.0; extra == "core"
Requires-Dist: torch<3,>=2.6.0; extra == "core"
Requires-Dist: torchvision; extra == "core"
Provides-Extra: npu
Requires-Dist: numpy<2,>=1.21.6; extra == "npu"
Requires-Dist: decorator; extra == "npu"
Requires-Dist: attrs; extra == "npu"
Requires-Dist: psutil; extra == "npu"
Requires-Dist: onnxruntime-cann==1.22.0; extra == "npu"
Dynamic: license-file

# RapidDoc - 高速文档解析系统

[English](README_EN.md) | [中文](README.md)

## 😺 项目介绍

**RapidDoc 是一个轻量级、专注于文档解析的开源框架，支持 **OCR、版面分析、公式识别、表格识别和阅读顺序恢复** 等多种功能，支持将复杂 PDF 文档转换为 Markdown、JSON、WORD、HTML 格式。**

**支持docx/doc、pptx/ppt、xlsx/xls的原生解析（不使用模型）。**

**框架基于 [Mineru](https://github.com/opendatalab/MinerU) 二次开发，移除 VLM，专注于 Pipeline 产线下的高效文档解析，在 CPU 上也能保持不错的解析速度。**

**本项目所使用的默认模型主要来源于 [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR) 的 [PP-StructureV3](https://www.paddleocr.ai/main/version3.x/pipeline_usage/PP-StructureV3.html) 系列（OCR、版面分析、公式识别、阅读顺序恢复，以及部分表格识别模型），并已全部转换为 ONNX 格式，支持在 CPU/GPU 上高效推理。**

**同时支持自定义OCR、公式、表格模型，需实现 CustomBaseModel 的 batch_predict 方法，目前内置 [PaddleOCRVL](https://www.paddleocr.ai/main/version3.x/pipeline_usage/PaddleOCR-VL.html) 系列模型的集成。**

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

## 选择解析引擎与语言 SDK

RapidDoc 提供原 Python 实现和共享 Rust 引擎。原 Python 包继续使用 `rapid-doc`；新的 Python、Java、Go、Node.js 绑定调用同一套 Rust 解析核心，不需要安装原 Python 包。Rust、Java、Go 和 Node.js 应用运行时不需要 Python 环境。

| 使用方式 | 包名 / 引入名 | 使用文档 |
| --- | --- | --- |
| 原 Python | `rapid-doc` / `rapid_doc` | [安装与使用](#安装与使用原-python-实现) |
| Rust 引擎的 Python 绑定 | `rapid-doc-rust` / `rapid_doc_rust` | [Python SDK](bindings/python/README.md) |
| Rust | `rapiddoc` | [Rust SDK](rust/rapiddoc/README.md) |
| Java | `io.github.rapidai:rapid-doc` | [Java SDK](bindings/java/README.md) |
| Go | `github.com/RapidAI/RapidDoc/bindings/go` | [Go SDK](bindings/go/README.md) |
| Node.js / TypeScript | `rapid-doc`（npm） | [Node.js SDK](bindings/node/README.md) |

**发布状态：新 Rust SDK 及各语言绑定当前为 `0.1.0` 发布候选，尚未发布到公共包仓库。** 版本变更记录见 [CHANGELOG.md](CHANGELOG.md)，发布构建与验证流程见[发布说明](docs/publishing.md)。

Rust 引擎支持 PDF、DOC、DOCX、XLS、XLSX、PPT、PPTX，Office 格式直接原生解析；PDF 模型推理使用 ONNX Runtime。PDFium、ORT、GEOS 及 CUDA 算子等运行库的提供方式随语言和平台包而异，不能只复制一个动态库部署。模型缺失时按配置自动下载，也可使用已有模型目录，详见[模型配置](docs/rust-models.md)。

原 Python 与 Rust 的配置和扩展能力尚未完全一致：Rust 完整 PDF 流程支持 V2/V3 版面、公式 S/M/L、UNET/SLANet 和 Table Transformer；Plus-L 完整 PDF 阅读顺序、增强阅读顺序及 `use_word_box=True` 字符框拆分仍未接入。原 Python 的 Torch、其他 OCR 推理引擎及 `CustomBaseModel` 扩展不代表 Rust 绑定也支持。完整支持范围与默认值以各 SDK 文档为准。

现有 [Docker / FastAPI 部署](docker/README.md)仍使用原 Python 实现，尚未切换为 Rust 镜像。两套引擎的输出、耗时和内存应在相同模型、参数及文档下比较，不保证仅更换语言即可获得固定倍数的性能提升。

---

> ✨如果该项目对您有帮助，您的star是我不断优化的动力！！！
>
> - [github点击前往](https://github.com/RapidAI/RapidDoc)
> - [gitee点击前往](https://gitee.com/hzkitty/KittyDoc)

## 👏 项目特点

本节介绍原 Python 实现；Rust SDK 的模型和参数支持范围见上方导航。

- **OCR 识别**
  - 使用 [RapidOCR](https://github.com/RapidAI/RapidOCR) 支持多种推理引擎
  - CPU/CUDA 下默认使用 ONNX Runtime：CPU 安装 `rapid-doc[cpu]`，CUDA GPU 安装 `rapid-doc[gpu]`
  
- **版面识别**
  - 模型使用 `PP-DocLayout` 系列 ONNX 模型（v2、plus-L、L、M、S）
    - **PP-DocLayoutV3**：自带阅读顺序，支持异形框，默认使用
    - **PP-DocLayoutV2**：自带阅读顺序
    - **PP-DocLayout_plus-L**：效果好运行稳定
    - **PP-DocLayout-L**：速度快，效果也不错
    - **PP-DocLayout-S**：速度极快，存在部分漏检

- **公式识别**
  - 使用 `PP-FormulaNet_plus` 系列 ONNX 模型（L、M、S）
    - **PP-FormulaNet_plus-L**：速度慢，支持onnx  
    - **PP-FormulaNet_plus-M**：默认使用，支持onnx和torch    
    - **PP-FormulaNet_plus-S**：速度最快，支持onnx，复杂公式精度不够
  - 支持配置只识别行间公式
  - CPU/CUDA 下默认使用 ONNX Runtime；GPU 路径已接入内置 CUDA 算子库，详见 [算子库说明](native/onnx_ops/README.md)
  - 显式选择 Torch 引擎时，需自行安装对应的 Torch 依赖

- **表格识别**
  - 基于 [rapid_table_self](rapid_doc/model/table/rapid_table_self) 增强，在原有基础上增强为多模型串联方案：  
    - **表格分类**（区分有线/无线表格）
    - **[有线表格识别UNET](https://github.com/RapidAI/TableStructureRec)** + SLANET_plus/UNITABLE（作为无线表格识别）

### 内置的 DocVortex 原生 PDF 解析

非扫描 PDF 可使用内置 DocVortex 核心的规则版面识别和原生表格结构恢复，六种 Office 格式直接原生解析，无需 LibreOffice 转换。核心采用 Python 后端，已移除 fasttext 依赖。

按运行环境安装一种 Runtime：

```bash
pip install "rapid-doc[cpu]"
# CUDA 环境选择：pip install "rapid-doc[gpu]"
```

源码来源、变更和验收记录见 [迁移记录](docs/migrations/docvortex-baseline.md)。

```python
from rapid_doc import RapidDoc

parser = RapidDoc(
    layout_config={
        "model_type": "pp_doclayoutv2",  # 扫描页和原生解析失败时的兜底模型
        "docvortex_mode": "rule",  # 电子版快速模式
        # "docvortex_mode": "rule_plus_s",  # PP-DocLayout-S 补公式、公式编号和印章
    },
    table_config={"rule_table_engine": "docvortex"},
)
result = parser("document.pdf")
```

`docvortex_mode` 默认为 `off`，此时直接使用 `model_type`。`rule` 优先用 DocVortex 解析电子版 PDF；`rule_plus_s` 额外用 PP-DocLayout-S 定位公式、公式编号和印章。配置 PP 版面模型作为 `model_type` 时，扫描页或 DocVortex 异常页逐页回退到该模型。只配置 `model_type="docvortex_rule"` 时保留原始 DocVortex 结果，不执行 PP 版面兜底，便于对比效果；没有原生版面结果的页面会为空。若同时设置 `docvortex_mode="rule_plus_s"`，仍会运行 PP-DocLayout-S 补充识别。表格优先使用 DocVortex 已生成的 HTML，或按表格区域恢复原生结构；未命中时使用现有表格模型。

- **阅读顺序恢复**
  - PP-DocLayoutV2和PP-DocLayoutV3使用版面模型自带的阅读顺序
  - 其余版面模型，使用 PP-StructureV3 阅读顺序恢复算法，基于xycut算法和版面的结果

- **推理方式**
  - 默认 Pipeline 模型（OCR、版面、公式、表格）使用 ONNX Runtime，CPU/CUDA 按安装的 Runtime 和设备配置运行
  - OCR、公式等模块可显式配置其支持的其他引擎；原生 Office 和 DocVortex 规则解析不使用模型推理
---

## 基准测试结果

### 1. OmniDocBench

以下是RapidDoc在 OmniDocBench v1.6 上的评估结果。

Pipeline 模型使用 PP-DocLayoutV3、PP-OCRv6-small、PP-FormulaNet_plus-M、UNET_SLANET_PLUS。
<table style="width:100%; border-collapse: collapse;">
    <caption>Comprehensive evaluation of document parsing on OmniDocBench (v1.6_full)</caption>
    <thead>
        <tr>
            <th>Model Type</th>
            <th>Methods</th>
            <th>Size</th>
            <th>Overall&#x2191;</th>
            <th>Text<sup>Edit</sup>&#x2193;</th>
            <th>Formula<sup>CDM</sup>&#x2191;</th>
            <th>Table<sup>TEDS</sup>&#x2191;</th>
            <th>Table<sup>TEDS-S</sup>&#x2191;</th>
            <th>Read Order<sup>Edit</sup>&#x2193;</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>MinerU2.5-Pro</td>
            <td>Specialized VLMs</td>
            <td>1.2B</td>
            <td><strong>95.75</strong></td>
            <td><ins>0.036<ins></td>
            <td><strong>97.45</strong></td>
            <td><strong>93.42</strong></td>
            <td><strong>95.92</strong></td>
            <td><ins>0.120<ins></td>
        </tr>
        <tr>    
            <td>GLM-OCR</td>
            <td>Specialized VLMs</td>
            <td>0.9B</td>
            <td><ins>95.22<ins></td>
            <td>0.044</td>
            <td><ins>97.18<ins></td>
            <td><ins>92.83<ins></td>
            <td><ins>95.39<ins></td>
            <td>0.133</td>
        </tr>
        <tr>    
            <td>PaddleOCR-VL-1.5</td>
            <td>Specialized VLMs</td>
            <td>0.9B</td>
            <td>94.93</td>
            <td>0.038</td>
            <td>96.89</td>
            <td>91.67</td>
            <td>94.37</td>
            <td>0.130</td>
        </tr>
        <tr>    
            <td>PaddleOCR-VL</td>
            <td>Specialized VLMs</td>
            <td>0.9B</td>
            <td>94.18</td>
            <td>0.040</td>
            <td>95.91</td>
            <td>90.65</td>
            <td>93.74</td>
            <td>0.135</td>
        </tr>
        <tr>
            <td>Youtu-Parsing</td>
            <td>Specialized VLMs</td>
            <td>2.5B</td>
            <td>93.74</td>
            <td>0.044</td>
            <td>93.63</td>
            <td>92.02</td>
            <td>95.00</td>
            <td><strong>0.116<strong></td>
        </tr>
        <tr>
            <td>Qianfan-OCR</td>
            <td>Specialized VLMs</td>
            <td>4B</td>
            <td>93.90</td>
            <td>0.04</td>
            <td>95.08</td>
            <td>90.53</td>
            <td>93.31</td>
            <td>0.13</td>
        </tr>
        <tr>
            <td>Ovis2.6-30B-A3B</td>
            <td>General VLMs</td>
            <td>30B</td>
            <td>93.70</td>
            <td><strong>0.035<strong></td>
            <td>95.17</td>
            <td>89.44</td>
            <td>92.40</td>
            <td>0.135</td>
        </tr>
        <tr>
            <td>Logics-Parsing-v2</td>
            <td>Specialized VLMs</td>
            <td>4B</td>
            <td>93.33</td>
            <td>0.041</td>
            <td>95.65</td>
            <td>88.42</td>
            <td>91.98</td>
            <td>0.137</td>
        </tr>
         <tr>
            <td>ABot-OCR</td>
            <td>Specialized VLMs</td>
            <td>2B</td>
            <td>93.30</td>
            <td>0.037</td>
            <td>94.86</td>
            <td>88.69</td>
            <td>91.87</td>
            <td>0.137</td>
        </tr>
        <tr>
            <td>FireRed-OCR</td>
            <td>Specialized VLMs</td>
            <td>2B</td>
            <td>93.26</td>
            <td>0.037</td>
            <td>95.44</td>
            <td>88.04</td>
            <td>91.06</td>
            <td>0.131</td>
        </tr>
        <tr>
            <td>MinerU-2.5</td>
            <td>Specialized VLMs</td>
            <td>1.2B</td>
            <td>93.04</td>
            <td>0.045</td>
            <td>95.77</td>
            <td>87.88</td>
            <td>91.47</td>
            <td>0.130</td>
        </tr>
        <tr>
            <td>Gemini 3 Pro</td>
            <td>General VLMs</td>
            <td>-</td>
            <td>92.91</td>
            <td>0.064</td>
            <td>95.99</td>
            <td>89.15</td>
            <td>92.96</td>
            <td>0.165</td>
        </tr>
        <tr>
            <td>Gemini 3 Flash</td>
            <td>General VLMs</td>
            <td>-</td>
            <td>92.62</td>
            <td>0.066</td>
            <td>95.16</td>
            <td>89.29</td>
            <td>93.51</td>
            <td>0.172</td>
        </tr>
        <tr>
            <td>dots.ocr</td>
            <td>Specialized VLMs</td>
            <td>3B</td>
            <td>90.77</td>
            <td>0.048</td>
            <td>89.95</td>
            <td>87.18</td>
            <td>90.58</td>
            <td>0.138</td>
        </tr>
        <tr>
            <td>OpenDoc-0.1B</td>
            <td>Specialized VLMs</td>
            <td>0.1B</td>
            <td>90.67</td>
            <td>0.049</td>
            <td>93.02</td>
            <td>83.88</td>
            <td>87.45</td>
            <td>0.140</td>
        </tr>
        <tr>
            <td><strong>RapidDoc</strong></td>
            <td><strong>Pipeline Tools</strong></td>
            <td><strong>-</strong></td>
            <td><strong>90.479</strong></td>
            <td><strong>0.047</strong></td>
            <td><strong>94.342</strong></td>
            <td><strong>81.797</strong></td>
            <td><strong>88.433</strong></td>
            <td><strong>0.135</strong></td>
        </tr>
        <tr>
            <td>DeepSeek-OCR 2</td>
            <td>Specialized VLMs</td>
            <td>3B</td>
            <td>90.25</td>
            <td>0.050</td>
            <td>91.84</td>
            <td>83.89</td>
            <td>87.75</td>
            <td>0.144</td>
        </tr>
        <tr>
            <td>HunyuanOCR</td>
            <td>Specialized VLMs</td>
            <td>1B</td>
            <td>89.95</td>
            <td>0.088</td>
            <td>87.68</td>
            <td>91.01</td>
            <td>93.23</td>
            <td>0.171</td>
        </tr>
        <tr>
            <td>Qwen3-VL-235B</td>
            <td>General VLMs</td>
            <td>235B</td>
            <td>89.78</td>
            <td>0.063</td>
            <td>92.55</td>
            <td>83.07</td>
            <td>86.75</td>
            <td>0.166</td>
        </tr>
        <tr>
            <td>Dolphin-v2</td>
            <td>Specialized VLMs</td>
            <td>3B</td>
            <td>89.50</td>
            <td>0.069</td>
            <td>91.01</td>
            <td>84.40</td>
            <td>87.44</td>
            <td>0.150</td>
        </tr>
        <tr>
            <td>OCRVerse</td>
            <td>Specialized VLMs</td>
            <td>4B</td>
            <td>88.60</td>
            <td>0.063</td>
            <td>89.61</td>
            <td>82.44</td>
            <td>86.27</td>
            <td>0.163</td>
        </tr>
        <tr>
            <td>MonkeyOCR-pro-3B</td>
            <td>Specialized VLMs</td>
            <td>3B</td>
            <td>88.57</td>
            <td>0.074</td>
            <td>88.74</td>
            <td>84.35</td>
            <td>88.62</td>
            <td>0.189</td>
        </tr>
        <tr>
            <td>GPT-5.2</td>
            <td>General VLMs</td>
            <td>-</td>
            <td>86.59</td>
            <td>0.114</td>
            <td>88.21</td>
            <td>82.95</td>
            <td>87.93</td>
            <td>0.193</td>
        </tr>
        <tr>
            <td>Dolphin-1.5</td>
            <td>Specialized VLMs</td>
            <td>0.3B</td>
            <td>86.52</td>
            <td>0.094</td>
            <td>87.49</td>
            <td>81.43</td>
            <td>84.82</td>
            <td>0.167</td>
        </tr>
        <tr>
            <td>MinerU-Pipeline</td>
            <td>Pipeline Tools</td>
            <td>-</td>
            <td>86.47</td>
            <td>0.055</td>
            <td>83.07</td>
            <td>81.88</td>
            <td>88.68</td>
            <td>0.153</td>
        </tr>
        <tr>
            <td>olmOCR</td>
            <td>Specialized VLMs</td>
            <td>7B</td>
            <td>85.74</td>
            <td>0.139</td>
            <td>88.10</td>
            <td>83.00</td>
            <td>87.17</td>
            <td>0.216</td>
        </tr>
        <tr>
            <td>Mistral OCR</td>
            <td>Specialized VLMs</td>
            <td>-</td>
            <td>85.66</td>
            <td>0.097</td>
            <td>89.91</td>
            <td>76.78</td>
            <td>80.93</td>
            <td>0.171</td>
        </tr>
        <tr>
            <td>Kimi K2.5</td>
            <td>General VLMs</td>
            <td>1T</td>
            <td>84.53</td>
            <td>0.107</td>
            <td>83.50</td>
            <td>80.76</td>
            <td>84.00</td>
            <td>0.211</td>
        </tr>
        <tr>
            <td>InternVL3.5-241B</td>
            <td>General VLMs</td>
            <td>241B</td>
            <td>83.76</td>
            <td>0.130</td>
            <td>89.95</td>
            <td>74.35</td>
            <td>79.78</td>
            <td>0.215</td>
        </tr>
        <tr>
            <td>Nanonets-OCR-s</td>
            <td>Specialized VLMs</td>
            <td>3B</td>
            <td>83.61</td>
            <td>0.108</td>
            <td>81.46</td>
            <td>80.18</td>
            <td>84.51</td>
            <td>0.213</td>
        </tr>
        <tr>
            <td>POINTS-Reader</td>
            <td>Specialized VLMs</td>
            <td>3B</td>
            <td>83.37</td>
            <td>0.096</td>
            <td>85.72</td>
            <td>73.98</td>
            <td>77.40</td>
            <td>0.198</td>
        </tr>
        <tr>
            <td>Marker</td>
            <td>Pipeline Tools</td>
            <td>-</td>
            <td>78.44</td>
            <td>0.157</td>
            <td>85.24</td>
            <td>65.77</td>
            <td>73.24</td>
            <td>0.243</td>
        </tr>
    </tbody>
</table>

## 🛠️ 安装RapidDoc

### 安装与使用原 Python 实现

以下安装命令使用 `rapid-doc`，不会安装新的 Rust 引擎；Rust 引擎的 Python 绑定请参阅 [Python SDK 文档](bindings/python/README.md)。

#### 使用pip安装
```bash
# CPU 环境
pip install "rapid-doc[cpu]" -i https://mirrors.aliyun.com/pypi/simple
# 或 CUDA GPU 环境
pip install "rapid-doc[gpu]" -i https://mirrors.aliyun.com/pypi/simple
```

CPU extra 安装 `onnxruntime`，GPU extra 安装 `onnxruntime-gpu`，用于默认模型的推理，包括 OCR 和公式模型。按运行环境选择一种；GPU extra 不会额外安装 CPU 版 Runtime，也不默认安装 Torch。两个 Runtime 发行包使用同一个 `onnxruntime` 导入名，不要同时安装。

#### 通过源码安装
```bash
# 克隆仓库
git clone https://github.com/RapidAI/RapidDoc.git
cd RapidDoc

# 安装依赖
pip install -e ".[cpu]" -i https://mirrors.aliyun.com/pypi/simple
# 或 CUDA GPU 环境
pip install -e ".[gpu]" -i https://mirrors.aliyun.com/pypi/simple
```
#### 使用gpu推理

`rapid-doc[gpu]` 按项目依赖约束安装 `onnxruntime-gpu`（当前为 `<=1.23.0`）。CUDA/cuDNN 需满足 [CUDA Execution Provider 要求](https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements)。默认 OCR 和公式模型使用 ONNX Runtime，无需切换到 Torch。

OCR 默认启用 `onnx_ops`，公式 ONNX 路径也已接入内置算子库，用于 CUDA 算子支持与优化。原生库及其 CUDA/cuDNN 要求、构建方法和平台验证范围见 [算子库说明](native/onnx_ops/README.md)。这些原生库与 `onnxruntime-gpu` 是不同组件，安装 Runtime 不代表原生库及其系统依赖都已就绪。

```python
# 在 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"
```
#### 使用PaddleOCRVL系列推理
vl模型的部署，参考[官方文档](https://www.paddleocr.ai/main/version3.x/pipeline_usage/PaddleOCR-VL.html#31-vlm) 
```python
import os
os.environ['PADDLEOCRVL_VERSION'] = "v1.6"
os.environ['PADDLEOCRVL_VL_REC_BACKEND'] = "vllm-server"
os.environ['PADDLEOCRVL_VL_VL_REC_SERVER_URL'] = "http://localhost:8118/v1"

from rapid_doc.model.layout.rapid_layout_self import ModelType as LayoutModelType
from rapid_doc.model.custom.paddleocr_vl.paddleocr_vl import PaddleOCRVLTableModel, PaddleOCRVLOCRModel, PaddleOCRVLFormulaModel
layout_config = {
    "model_type": LayoutModelType.PP_DOCLAYOUTV3,
}
ocr_config = {
    "custom_model": PaddleOCRVLOCRModel()
}
formula_config = {
    "custom_model": PaddleOCRVLFormulaModel()
}
table_config = {
    "custom_model": PaddleOCRVLTableModel()
}
```

#### 使用docker部署RapidDoc
RapidDoc提供了便捷的docker部署方式，这有助于快速搭建环境并解决一些棘手的环境兼容问题。

您可以在文档中获取 [Docker部署说明](docker/README.md)，镜像已推送至 [Docker Hub](https://hub.docker.com/r/hzkitty/rapid-doc)。

---
### 📋 使用

```python
import os
from pathlib import Path
from rapid_doc import RapidDoc
__dir__ = Path(__file__).resolve().parent.parent
output_dir = os.path.join(__dir__, "output")

doc_path_list = [
    __dir__ / "demo/pdfs/示例1-论文模板.pdf",
    __dir__ / "demo/docx/test.docx",
]
engine = RapidDoc()
outputs = engine(doc_path_list, output_dir=output_dir)
for output in outputs:
    print(output.markdown)
```
---

## 在线体验

### 基于Gradio的在线demo
基于gradio开发的webui，界面简洁，仅包含核心解析功能，免登录

- [![ModelScope](https://img.shields.io/badge/Demo_on_ModelScope-purple?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIzIiBoZWlnaHQ9IjIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KCiA8Zz4KICA8dGl0bGU+TGF5ZXIgMTwvdGl0bGU+CiAgPHBhdGggaWQ9InN2Z18xNCIgZmlsbD0iIzYyNGFmZiIgZD0ibTAsODkuODRsMjUuNjUsMGwwLDI1LjY0OTk5bC0yNS42NSwwbDAsLTI1LjY0OTk5eiIvPgogIDxwYXRoIGlkPSJzdmdfMTUiIGZpbGw9IiM2MjRhZmYiIGQ9Im05OS4xNCwxMTUuNDlsMjUuNjUsMGwwLDI1LjY1bC0yNS42NSwwbDAsLTI1LjY1eiIvPgogIDxwYXRoIGlkPSJzdmdfMTYiIGZpbGw9IiM2MjRhZmYiIGQ9Im0xNzYuMDksMTQxLjE0bC0yNS42NDk5OSwwbDAsMjIuMTlsNDcuODQsMGwwLC00Ny44NGwtMjIuMTksMGwwLDI1LjY1eiIvPgogIDxwYXRoIGlkPSJzdmdfMTciIGZpbGw9IiMzNmNmZDEiIGQ9Im0xMjQuNzksODkuODRsMjUuNjUsMGwwLDI1LjY0OTk5bC0yNS42NSwwbDAsLTI1LjY0OTk5eiIvPgogIDxwYXRoIGlkPSJzdmdfMTgiIGZpbGw9IiMzNmNmZDEiIGQ9Im0wLDY0LjE5bDI1LjY1LDBsMCwyNS42NWwtMjUuNjUsMGwwLC0yNS42NXoiLz4KICA8cGF0aCBpZD0ic3ZnXzE5IiBmaWxsPSIjNjI0YWZmIiBkPSJtMTk4LjI4LDg5Ljg0bDI1LjY0OTk5LDBsMCwyNS42NDk5OWwtMjUuNjQ5OTksMGwwLC0yNS42NDk5OXoiLz4KICA8cGF0aCBpZD0ic3ZnXzIwIiBmaWxsPSIjMzZjZmQxIiBkPSJtMTk4LjI4LDY0LjE5bDI1LjY0OTk5LDBsMCwyNS42NWwtMjUuNjQ5OTksMGwwLC0yNS42NXoiLz4KICA8cGF0aCBpZD0ic3ZnXzIxIiBmaWxsPSIjNjI0YWZmIiBkPSJtMTUwLjQ0LDQybDAsMjIuMTlsMjUuNjQ5OTksMGwwLDI1LjY1bDIyLjE5LDBsMCwtNDcuODRsLTQ3Ljg0LDB6Ii8+CiAgPHBhdGggaWQ9InN2Z18yMiIgZmlsbD0iIzM2Y2ZkMSIgZD0ibTczLjQ5LDg5Ljg0bDI1LjY1LDBsMCwyNS42NDk5OWwtMjUuNjUsMGwwLC0yNS42NDk5OXoiLz4KICA8cGF0aCBpZD0ic3ZnXzIzIiBmaWxsPSIjNjI0YWZmIiBkPSJtNDcuODQsNjQuMTlsMjUuNjUsMGwwLC0yMi4xOWwtNDcuODQsMGwwLDQ3Ljg0bDIyLjE5LDBsMCwtMjUuNjV6Ii8+CiAgPHBhdGggaWQ9InN2Z18yNCIgZmlsbD0iIzYyNGFmZiIgZD0ibTQ3Ljg0LDExNS40OWwtMjIuMTksMGwwLDQ3Ljg0bDQ3Ljg0LDBsMCwtMjIuMTlsLTI1LjY1LDBsMCwtMjUuNjV6Ii8+CiA8L2c+Cjwvc3ZnPg==&labelColor=white)](https://www.modelscope.cn/studios/RapidAI/RapidDoc)

---

## 📋 使用示例

- [代码示例](./demo/demo.py)

- [参数介绍](./docs/analyze_param.md)

- [FastAPI 示例](./docker/README_API.md)
---

## 模型下载
不指定模型路径，初次运行时，会自动下载
- [RapidDoc 模型集（版面/公式/表格）](https://www.modelscope.cn/models/RapidAI/RapidDoc)  
- [RapidOCR 模型](https://www.modelscope.cn/models/RapidAI/RapidOCR)  
- [部分表格模型RapidTable](https://www.modelscope.cn/models/RapidAI/RapidTable) 

---

## 🙏 致谢

- [MinerU](https://github.com/opendatalab/MinerU)
- [PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR)
- [RapidOCR](https://github.com/RapidAI/RapidOCR)

## Star History

<a href="https://www.star-history.com/?repos=RapidAI%2FRapidDoc&type=date&legend=top-left">
 <picture>
   <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/image?repos=RapidAI/RapidDoc&type=date&theme=dark&legend=top-left" />
   <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/image?repos=RapidAI/RapidDoc&type=date&legend=top-left" />
   <img alt="Star History Chart" src="https://api.star-history.com/image?repos=RapidAI/RapidDoc&type=date&legend=top-left" />
 </picture>
</a>

## ⚖️ 开源许可

该项目采用 [Apache 2.0 license](LICENSE) 开源许可证。
