mirror of
https://github.com/PaddlePaddle/PaddleOCR.git
synced 2026-08-30 17:23:03 +08:00
Add chart parsing module (#16111)
This commit is contained in:
@@ -0,0 +1,225 @@
|
||||
---
|
||||
comments: true
|
||||
---
|
||||
|
||||
# Chart Parsing Module Tutorial
|
||||
|
||||
## 1. Overview
|
||||
|
||||
Multimodal chart parsing is a cutting-edge OCR technology that focuses on automatically converting various types of visual charts (such as bar charts, line charts, pie charts, etc.) into structured data tables with formatted output. Traditional methods rely on complex pipeline designs with chart keypoint detection models, which involve many prior assumptions and tend to lack robustness. The models in this module leverage the latest VLM (Vision-Language Model) techniques and are data-driven, learning robust features from vast real-world datasets. Application scenarios include financial analysis, academic research, business reporting, and more—for instance, quickly extracting growth trend data from financial reports, experimental comparison figures from research papers, or user distribution statistics from market surveys—empowering users to transition from “viewing charts” to “using data”.
|
||||
|
||||
## 2. Supported Model List
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Model</th><th>Download Link</th>
|
||||
<th>Model Size (B)</th>
|
||||
<th>Storage Size (GB)</th>
|
||||
<th>Score</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PP-Chart2Table</td>
|
||||
<td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-Chart2Table_infer.tar">Inference Model</a></td>
|
||||
<td>0.58</td>
|
||||
<td>1.4</td>
|
||||
<th>80.60</th>
|
||||
<td>PP-Chart2Table is a multimodal chart parsing model developed by the PaddlePaddle team. It demonstrates exceptional performance on both Chinese and English chart parsing tasks. The team designed a specialized “Shuffled Chart Data Retrieval” training task and adopted a carefully designed token masking strategy, significantly improving performance on chart-to-table conversion. Additionally, the team enhanced the model with a high-quality data synthesis process using seed data, RAG, and LLM persona-driven generation to diversify training data. To handle large amounts of out-of-distribution (OOD) unlabeled data, a two-stage large model distillation process was used to ensure excellent adaptability and generalization to diverse real-world data. In internal Chinese-English use case evaluations, PP-Chart2Table achieved state-of-the-art performance among models of similar size and reached accuracy comparable to 7B-parameter VLMs in key scenarios.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
**Note:** The scores above are based on internal evaluation on a test set of 1801 samples, covering various chart types (bar, line, pie, etc.) across scenarios such as financial reports, regulations, and contracts. There is currently no plan for public release.
|
||||
|
||||
> ❗ **Note:** The PP-Chart2Table model was upgraded on June 27, 2025. To use the previous version, please download it [here](https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-Chart2Table_infer.bak.tar)
|
||||
|
||||
## 3. Quick Start
|
||||
|
||||
> ❗ Before getting started, please install the PaddleOCR wheel package. Refer to the [Installation Guide](../installation.md) for details.
|
||||
|
||||
Run the following command to get started instantly:
|
||||
|
||||
```bash
|
||||
paddleocr chart_parsing -i "{'image': 'https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/chart_parsing_02.png'}"
|
||||
````
|
||||
|
||||
**Note:** By default, PaddleOCR retrieves models from HuggingFace. If HuggingFace access is restricted in your environment, you can switch the model source to BOS by setting the environment variable: `PADDLE_PDX_MODEL_SOURCE="BOS"`. Support for more mainstream sources is planned.
|
||||
|
||||
You can also integrate the inference of the vision-language model into your own project. Please download the [example image](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/chart_parsing_02.png) locally before running the following code:
|
||||
|
||||
```python
|
||||
from paddleocr import ChartParsing
|
||||
model = ChartParsing(model_name="PP-Chart2Table")
|
||||
results = model.predict(
|
||||
input={"image": "chart_parsing_02.png"},
|
||||
batch_size=1
|
||||
)
|
||||
for res in results:
|
||||
res.print()
|
||||
res.save_to_json(f"./output/res.json")
|
||||
```
|
||||
|
||||
The output result will be:
|
||||
|
||||
```bash
|
||||
{'res': {'image': 'chart_parsing_02.png', 'result': 'Year | Avg Revenue per 5-star Hotel (Million CNY) | Avg Profit per 5-star Hotel (Million CNY)\n2018 | 104.22 | 9.87\n2019 | 99.11 | 7.47\n2020 | 57.87 | -3.87\n2021 | 68.99 | -2.9\n2022 | 56.29 | -9.48\n2023 | 87.99 | 5.96'}}
|
||||
```
|
||||
|
||||
Explanation of output parameters:
|
||||
|
||||
* `image`: The path to the input image
|
||||
* `result`: The model's prediction output
|
||||
|
||||
The visualized result is:
|
||||
|
||||
```bash
|
||||
Year | Avg Revenue per 5-star Hotel (Million CNY) | Avg Profit per 5-star Hotel (Million CNY)
|
||||
2018 | 104.22 | 9.87
|
||||
2019 | 99.11 | 7.47
|
||||
2020 | 57.87 | -3.87
|
||||
2021 | 68.99 | -2.9
|
||||
2022 | 56.29 | -9.48
|
||||
2023 | 87.99 | 5.96
|
||||
```
|
||||
|
||||
Detailed explanation of related methods and parameters:
|
||||
|
||||
* Instantiate a vision-language model with `ChartParsing`. Parameters:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Parameter</th>
|
||||
<th>Description</th>
|
||||
<th>Type</th>
|
||||
<th>Default</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>model_name</code></td>
|
||||
<td>Model name. If set to <code>None</code>, defaults to <code>PP-Chart2Table</code>.</td>
|
||||
<td><code>str | None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>model_dir</code></td>
|
||||
<td>Model storage path.</td>
|
||||
<td><code>str | None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>device</code></td>
|
||||
<td>Inference device.<br/>
|
||||
<b>Examples:</b> <code>"cpu"</code>, <code>"gpu"</code>, <code>"npu"</code>, <code>"gpu:0"</code><br/>
|
||||
Defaults to GPU 0 if available; otherwise falls back to CPU.
|
||||
</td>
|
||||
<td><code>str | None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
* Use the model's `predict()` method for inference. This returns a list of results. The module also offers a `predict_iter()` method, which behaves identically in terms of inputs and outputs but returns a generator—ideal for large datasets or memory-sensitive scenarios. Choose based on your needs.
|
||||
|
||||
`predict()` method parameters:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Parameter</th>
|
||||
<th>Description</th>
|
||||
<th>Type</th>
|
||||
<th>Default</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td><code>input</code></td>
|
||||
<td>Input data (required). Input formats vary by model.<br/>
|
||||
For PP-Chart2Table: <code>{'image': image_path}</code>
|
||||
</td>
|
||||
<td><code>dict</code></td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>batch_size</code></td>
|
||||
<td>Batch size. Any positive integer.</td>
|
||||
<td><code>int</code></td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
* Prediction results are returned as `Result` objects for each sample, with support for printing and saving to JSON:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Method</th>
|
||||
<th>Description</th>
|
||||
<th>Parameter</th>
|
||||
<th>Type</th>
|
||||
<th>Explanation</th>
|
||||
<th>Default</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td rowspan = "3"><code>print()</code></td>
|
||||
<td rowspan = "3">Print results to terminal</td>
|
||||
<td><code>format_json</code></td>
|
||||
<td><code>bool</code></td>
|
||||
<td>Format output using JSON indentation</td>
|
||||
<td><code>True</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>indent</code></td>
|
||||
<td><code>int</code></td>
|
||||
<td>Indentation level for pretty-printed JSON. Only works when <code>format_json=True</code></td>
|
||||
<td>4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>ensure_ascii</code></td>
|
||||
<td><code>bool</code></td>
|
||||
<td>Whether to escape non-ASCII characters to Unicode. If <code>False</code>, keeps characters as-is.</td>
|
||||
<td><code>False</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan = "3"><code>save_to_json()</code></td>
|
||||
<td rowspan = "3">Save results to JSON file</td>
|
||||
<td><code>save_path</code></td>
|
||||
<td><code>str</code></td>
|
||||
<td>File path to save. If a directory, file will use input name as filename.</td>
|
||||
<td>N/A</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>indent</code></td>
|
||||
<td><code>int</code></td>
|
||||
<td>Same as in `print()`</td>
|
||||
<td>4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>ensure_ascii</code></td>
|
||||
<td><code>bool</code></td>
|
||||
<td>Same as in `print()`</td>
|
||||
<td><code>False</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
* You can also access the result via properties:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Property</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td><code>json</code></td>
|
||||
<td>Returns the result in JSON format</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## 4. Custom Development
|
||||
|
||||
Currently, this module supports inference only and does not yet support fine-tuning. Fine-tuning capabilities are planned for future releases.
|
||||
|
||||
## 5. FAQ
|
||||
@@ -0,0 +1,222 @@
|
||||
---
|
||||
comments: true
|
||||
---
|
||||
|
||||
# 图表解析模块使用教程
|
||||
|
||||
## 一、概述
|
||||
|
||||
多模态图表解析是一项OCR领域的前沿技术,专注于将各类可视化图表(如柱状图、折线图、饼图等)自动转化为底层数据表,并进行格式化输出。传统方法依赖于图表关键点检测等模型进行复杂串联编排,先验假设较多,鲁棒性较差,该模块中的模型使用最新的VLM技术,数据驱动,从海量的现实数据中学习鲁棒的特征。其应用场景覆盖金融分析、学术研究、商业报告等场景——例如快速提取财报中的增长趋势数据、科研论文中的实验对比数值,或市场调研中的用户分布统计,助力用户从“看图”转向“用数”。
|
||||
|
||||
## 二、支持模型列表
|
||||
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>模型</th><th>模型下载链接</th>
|
||||
<th>模型参数规模(B)</th>
|
||||
<th>模型存储大小(GB)</th>
|
||||
<th>模型分数 </th>
|
||||
<th>介绍</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PP-Chart2Table</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-Chart2Table_infer.tar">推理模型</a></td>
|
||||
<td>0.58</td>
|
||||
<td>1.4</td>
|
||||
<th>80.60</th>
|
||||
<td>PP-Chart2Table是飞桨团队自研的一款专注于图表解析的多模态模型,在中英文图表解析任务中展现出卓越性能。团队专为图表解析设计了Shuffled Chart Data Retrieval训练任务,并结合精心设计的令牌掩码策略,显著提升其在图表转数据表任务上的性能。此外,团队通过精心设计的数据合成流程增强了PP-Chart2Table的能力,该流程利用高质量的种子数据,并结合RAG和大语言模型人格设计,以生成更丰富多样化的数据。为了处理大量未标记的分布外 (OOD) 数据,团队采用了两阶段大模型蒸馏训练过程,确保模型在广泛的真实世界数据集中具有出色的适应性和泛化能力。在内部业务的中英文场景测试中,PP-Chart2Table不仅达到同参数量级模型中的SOTA水平,更在关键场景中实现了与7B参数量级VLM模型相当的精度。</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<b>注:以上模型分数为内部评估集模型测试结果,共1801条数据,包括了各个场景(财报、法律法规、合同等)下的各种图表类型(柱状图、折线图、饼图等)的测试样本,暂时未有计划公开。</b>
|
||||
|
||||
> ❗ <b>注</b>:PP-Chart2Table模型于 2025.6.27 升级,如需使用升级前的模型权重,请点击<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0.0/PP-Chart2Table_infer.bak.tar">下载链接</a>
|
||||
|
||||
## 三、快速开始
|
||||
|
||||
> ❗ 在快速开始前,请先安装 PaddleOCR 的 wheel 包,详细请参考 [安装教程](../installation.md)。
|
||||
|
||||
使用一行命令即可快速体验:
|
||||
|
||||
```bash
|
||||
paddleocr chart_parsing -i "{'image': 'https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/chart_parsing_02.png'}"
|
||||
```
|
||||
|
||||
<b>注:</b>PaddleOCR 官方模型默认从 HuggingFace 获取,如运行环境访问 HuggingFace 不便,可通过环境变量修改模型源为 BOS:`PADDLE_PDX_MODEL_SOURCE="BOS"`,未来将支持更多主流模型源;
|
||||
|
||||
您也可以将开放文档类视觉语言模型模块中的模型推理集成到您的项目中。运行以下代码前,请您下载[示例图片](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/chart_parsing_02.png)到本地。
|
||||
|
||||
```python
|
||||
from paddleocr import ChartParsing
|
||||
model = ChartParsing(model_name="PP-Chart2Table")
|
||||
results = model.predict(
|
||||
input={"image": "chart_parsing_02.png"},
|
||||
batch_size=1
|
||||
)
|
||||
for res in results:
|
||||
res.print()
|
||||
res.save_to_json(f"./output/res.json")
|
||||
```
|
||||
|
||||
运行后,得到的结果为:
|
||||
|
||||
```bash
|
||||
{'res': {'image': 'chart_parsing_02.png', 'result': '年份 | 单家五星级旅游饭店年平均营收 (百万元) | 单家五星级旅游饭店年平均利润 (百万元)\n2018 | 104.22 | 9.87\n2019 | 99.11 | 7.47\n2020 | 57.87 | -3.87\n2021 | 68.99 | -2.9\n2022 | 56.29 | -9.48\n2023 | 87.99 | 5.96'}}
|
||||
```
|
||||
|
||||
运行结果参数含义如下:
|
||||
|
||||
- `image`: 表示输入待预测图像的路径
|
||||
- `result`: 模型预测的结果信息
|
||||
|
||||
预测结果打印可视化如下:
|
||||
|
||||
```bash
|
||||
年份 | 单家五星级旅游饭店年平均营收 (百万元) | 单家五星级旅游饭店年平均利润 (百万元)
|
||||
2018 | 104.22 | 9.87
|
||||
2019 | 99.11 | 7.47
|
||||
2020 | 57.87 | -3.87
|
||||
2021 | 68.99 | -2.9
|
||||
2022 | 56.29 | -9.48
|
||||
2023 | 87.99 | 5.96
|
||||
```
|
||||
|
||||
相关方法、参数等说明如下:
|
||||
|
||||
* `ChartParsing`实例化文档类视觉语言模型,具体说明如下:
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
<th>参数说明</th>
|
||||
<th>参数类型</th>
|
||||
<th>默认值</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>model_name</code></td>
|
||||
<td>>模型名称。如果设置为<code>None</code>,则使用<code>PP-Chart2Table</code>。</td>
|
||||
<td><code>str|None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>model_dir</code></td>
|
||||
<td>模型存储路径。</td>
|
||||
<td><code>str|None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>device</code></td>
|
||||
<td>用于推理的设备。<br/>
|
||||
<b>例如:</b><code>"cpu"</code>、<code>"gpu"</code>、<code>"npu"</code>、<code>"gpu:0"</code></code>。
|
||||
默认情况下,优先使用 GPU 0;若不可用则使用 CPU。
|
||||
</td>
|
||||
<td><code>str|None</code></td>
|
||||
<td><code>None</code></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
* 调用图表解析模型的 `predict()` 方法进行推理预测,该方法会返回一个结果列表。另外,本模块还提供了 `predict_iter()` 方法。两者在参数接受和结果返回方面是完全一致的,区别在于 `predict_iter()` 返回的是一个 `generator`,能够逐步处理和获取预测结果,适合处理大型数据集或希望节省内存的场景。可以根据实际需求选择使用这两种方法中的任意一种。`predict()` 方法参数有 `input` 、 `batch_size`,具体说明如下:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
<th>参数说明</th>
|
||||
<th>参数类型</th>
|
||||
<th>默认值</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td><code>input</code></td>
|
||||
<td>待预测数据,必填。由于多模态模型对输入要求不同,请根据具体模型设定输入格式。<br/>
|
||||
<li>PP-Chart2Table的输入形式为<code>{'image': image_path}</code></li>
|
||||
</td>
|
||||
<td><code>dict</code></td>
|
||||
<td>无</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>batch_size</code></td>
|
||||
<td>批大小,可设置为任意正整数。</td>
|
||||
<td><code>int</code></td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
* 对预测结果进行处理,每个样本的预测结果均为对应的Result对象,且支持打印、保存为`json`文件的操作:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>方法</th>
|
||||
<th>方法说明</th>
|
||||
<th>参数</th>
|
||||
<th>参数类型</th>
|
||||
<th>参数说明</th>
|
||||
<th>默认值</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td rowspan = "3"><code>print()</code></td>
|
||||
<td rowspan = "3">打印结果到终端</td>
|
||||
<td><code>format_json</code></td>
|
||||
<td><code>bool</code></td>
|
||||
<td>是否对输出内容进行使用 <code>JSON</code> 缩进格式化</td>
|
||||
<td><code>True</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>indent</code></td>
|
||||
<td><code>int</code></td>
|
||||
<td>指定缩进级别,以美化输出的 <code>JSON</code> 数据,使其更具可读性,仅当 <code>format_json</code> 为 <code>True</code> 时有效</td>
|
||||
<td>4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>ensure_ascii</code></td>
|
||||
<td><code>bool</code></td>
|
||||
<td>控制是否将非 <code>ASCII</code> 字符转义为 <code>Unicode</code>。设置为 <code>True</code> 时,所有非 <code>ASCII</code> 字符将被转义;<code>False</code> 则保留原始字符,仅当<code>format_json</code>为<code>True</code>时有效</td>
|
||||
<td><code>False</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td rowspan = "3"><code>save_to_json()</code></td>
|
||||
<td rowspan = "3">将结果保存为json格式的文件</td>
|
||||
<td><code>save_path</code></td>
|
||||
<td><code>str</code></td>
|
||||
<td>保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致</td>
|
||||
<td>无</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>indent</code></td>
|
||||
<td><code>int</code></td>
|
||||
<td>指定缩进级别,以美化输出的 <code>JSON</code> 数据,使其更具可读性,仅当 <code>format_json</code> 为 <code>True</code> 时有效</td>
|
||||
<td>4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>ensure_ascii</code></td>
|
||||
<td><code>bool</code></td>
|
||||
<td>控制是否将非 <code>ASCII</code> 字符转义为 <code>Unicode</code>。设置为 <code>True</code> 时,所有非 <code>ASCII</code> 字符将被转义;<code>False</code> 则保留原始字符,仅当<code>format_json</code>为<code>True</code>时有效</td>
|
||||
<td><code>False</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
* 此外,也支持通过属性获取预测结果,具体如下:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>属性</th>
|
||||
<th>属性说明</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<td rowspan = "1"><code>json</code></td>
|
||||
<td rowspan = "1">获取预测的<code>json</code>格式的结果</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## 四、二次开发
|
||||
|
||||
当前模块暂时不支持微调训练,仅支持推理集成。关于该模块的微调训练,计划在未来支持。
|
||||
|
||||
## 五、FAQ
|
||||
@@ -8,7 +8,7 @@ comments: true
|
||||
|
||||
Layout analysis is a technique used to extract structured information from document images. It is primarily used to convert complex document layouts into machine-readable data formats. This technology has broad applications in document management, information extraction, and data digitization. Layout analysis combines Optical Character Recognition (OCR), image processing, and machine learning algorithms to identify and extract text blocks, titles, paragraphs, images, tables, and other layout elements from documents. This process generally includes three main steps: layout analysis, element analysis, and data formatting. The final result is structured document data, which enhances the efficiency and accuracy of data processing. <b>PP-StructureV3 improves upon the general layout analysis v1 pipeline by enhancing layout region detection, table recognition, and formula recognition. It also adds capabilities such as multi-column reading order recovery, chart understanding, and result conversion to Markdown files. It performs excellently across various document types and can handle complex document data.</b> This pipeline also provides flexible service deployment options, supporting invocation using multiple programming languages on various hardware. In addition, it offers secondary development capabilities, allowing you to train and fine-tune models on your own dataset and integrate the trained models seamlessly.
|
||||
|
||||
<b>The PP-StructureV3 pipeline consists of the following six modules or sub-pipelines. Each module or sub-pipeline can be trained and inferred independently and contains multiple models. For more details, please click the corresponding links to view the documentation.</b>
|
||||
<b>The PP-StructureV3 pipeline consists of the following seven modules or sub-pipelines. Each module or sub-pipeline can be trained and inferred independently and contains multiple models. For more details, please click the corresponding links to view the documentation.</b>
|
||||
|
||||
- [Layout Detection Module](../module_usage/layout_detection.en.md)
|
||||
- [General OCR Subline](./OCR.en.md)
|
||||
@@ -16,6 +16,7 @@ Layout analysis is a technique used to extract structured information from docum
|
||||
- [Table Recognition Subline ](./table_recognition_v2.en.md) (Optional)
|
||||
- [Seal Text Recognition Subline](./seal_recognition.en.md) (Optional)
|
||||
- [Formula Recognition Subline](./formula_recognition.en.md) (Optional)
|
||||
- [Chart Parsing Module](../module_usage/chart_parsing.en.md) (Optional)
|
||||
|
||||
In this pipeline, you can choose the model to use based on the benchmark data below.
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ comments: true
|
||||
|
||||
版面解析是一种从文档图像中提取结构化信息的技术,主要用于将复杂的文档版面转换为机器可读的数据格式。这项技术在文档管理、信息提取和数据数字化等领域具有广泛的应用。版面解析通过结合光学字符识别(OCR)、图像处理和机器学习算法,能够识别和提取文档中的文本块、标题、段落、图片、表格以及其他版面元素。此过程通常包括版面分析、元素分析和数据格式化三个主要步骤,最终生成结构化的文档数据,提升数据处理的效率和准确性。<b>PP-StructureV3 产线在通用版面解析v1产线的基础上,强化了版面区域检测、表格识别、公式识别的能力,增加了图表理解能力和多栏阅读顺序的恢复能力、结果转换 Markdown 文件的能力,在多种文档数据中,表现优异,可以处理较复杂的文档数据。</b>本产线同时提供了灵活的服务化部署方式,支持在多种硬件上使用多种编程语言调用。不仅如此,本产线也提供了二次开发的能力,您可以基于本产线在您自己的数据集上训练调优,训练后的模型也可以无缝集成。
|
||||
|
||||
<b>PP-StructureV3 产线中包含以下6个模块或子产线。每个模块或子产线均可独立进行训练和推理,并包含多个模型。有关详细信息,请点击相应链接以查看文档。</b>
|
||||
<b>PP-StructureV3 产线中包含以下7个模块或子产线。每个模块或子产线均可独立进行训练和推理,并包含多个模型。有关详细信息,请点击相应链接以查看文档。</b>
|
||||
|
||||
- [版面区域检测模块](../module_usage/layout_detection.md)
|
||||
- [通用OCR子产线](./OCR.md)
|
||||
@@ -16,6 +16,7 @@ comments: true
|
||||
- [表格识别子产线](./table_recognition_v2.md) (可选)
|
||||
- [印章文本识别子产线](./seal_recognition.md) (可选)
|
||||
- [公式识别子产线](./formula_recognition.md) (可选)
|
||||
- [图表解析模块](../module_usage/chart_parsing.md) (可选)
|
||||
|
||||
在本产线中,您可以根据下方的基准测试数据选择使用的模型。
|
||||
|
||||
|
||||
@@ -133,6 +133,7 @@ plugins:
|
||||
文档理解产线: Document Understanding Pipeline
|
||||
印章文本识别产线: Seal Text Recognition Pipeline
|
||||
通用表格识别v2产线: General Table Recognition v2 Pipeline
|
||||
图表解析模块: Chart Parsing Module
|
||||
多硬件使用: Multi-Devices Usage
|
||||
PaddleOCR 多硬件使用指南: PaddleOCR Multi-Devices Usage Guide
|
||||
昇腾 NPU 飞桨安装教程: Ascend NPU PaddlePaddle Installation Tutorial
|
||||
@@ -301,6 +302,7 @@ nav:
|
||||
- 文本图像矫正模块: version3.x/module_usage/text_image_unwarping.md
|
||||
- 文本行方向分类模块: version3.x/module_usage/textline_orientation_classification.md
|
||||
- 文本识别模块: version3.x/module_usage/text_recognition.md
|
||||
- 图表解析模块: version3.x/module_usage/chart_parsing.md
|
||||
- 产线列表:
|
||||
- 产线概述: version3.x/pipeline_usage/pipeline_overview.md
|
||||
- 公式识别产线: version3.x/pipeline_usage/formula_recognition.md
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
from ._models import (
|
||||
ChartParsing,
|
||||
DocImgOrientationClassification,
|
||||
DocVLM,
|
||||
FormulaRecognition,
|
||||
@@ -41,6 +42,7 @@ from ._utils.logging import logger
|
||||
from ._version import version as __version__
|
||||
|
||||
__all__ = [
|
||||
"ChartParsing",
|
||||
"DocImgOrientationClassification",
|
||||
"DocVLM",
|
||||
"FormulaRecognition",
|
||||
|
||||
@@ -19,6 +19,7 @@ import sys
|
||||
import warnings
|
||||
|
||||
from ._models import (
|
||||
ChartParsing,
|
||||
DocImgOrientationClassification,
|
||||
DocVLM,
|
||||
FormulaRecognition,
|
||||
@@ -67,6 +68,7 @@ def _register_pipelines(subparsers):
|
||||
|
||||
def _register_models(subparsers):
|
||||
for cls in [
|
||||
ChartParsing,
|
||||
DocImgOrientationClassification,
|
||||
DocVLM,
|
||||
FormulaRecognition,
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from .chart_parsing import ChartParsing
|
||||
from .doc_img_orientation_classification import DocImgOrientationClassification
|
||||
from .doc_vlm import DocVLM
|
||||
from .formula_recognition import FormulaRecognition
|
||||
@@ -26,6 +27,7 @@ from .textline_orientation_classification import TextLineOrientationClassificati
|
||||
from .text_recognition import TextRecognition
|
||||
|
||||
__all__ = [
|
||||
"ChartParsing",
|
||||
"DocImgOrientationClassification",
|
||||
"DocVLM",
|
||||
"FormulaRecognition",
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import abc
|
||||
|
||||
from .._utils.cli import (
|
||||
get_subcommand_args,
|
||||
perform_simple_inference,
|
||||
)
|
||||
from .base import PaddleXPredictorWrapper, PredictorCLISubcommandExecutor
|
||||
from paddlex.utils.pipeline_arguments import custom_type
|
||||
|
||||
|
||||
class BaseDocVLM(PaddleXPredictorWrapper):
|
||||
def __init__(
|
||||
self,
|
||||
*args,
|
||||
**kwargs,
|
||||
):
|
||||
self._extra_init_args = {}
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def _get_extra_paddlex_predictor_init_args(self):
|
||||
return self._extra_init_args
|
||||
|
||||
|
||||
class BaseDocVLMSubcommandExecutor(PredictorCLISubcommandExecutor):
|
||||
input_validator = staticmethod(custom_type(dict))
|
||||
|
||||
@property
|
||||
@abc.abstractmethod
|
||||
def wrapper_cls(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def execute_with_args(self, args):
|
||||
params = get_subcommand_args(args)
|
||||
params["input"] = self.input_validator(params["input"])
|
||||
perform_simple_inference(self.wrapper_cls, params)
|
||||
@@ -0,0 +1,45 @@
|
||||
# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from .._utils.cli import add_simple_inference_args
|
||||
from ._doc_vlm import (
|
||||
BaseDocVLM,
|
||||
BaseDocVLMSubcommandExecutor,
|
||||
)
|
||||
|
||||
|
||||
class ChartParsing(BaseDocVLM):
|
||||
@property
|
||||
def default_model_name(self):
|
||||
return "PP-Chart2Table"
|
||||
|
||||
@classmethod
|
||||
def get_cli_subcommand_executor(cls):
|
||||
return ChartParsingSubcommandExecutor()
|
||||
|
||||
|
||||
class ChartParsingSubcommandExecutor(BaseDocVLMSubcommandExecutor):
|
||||
@property
|
||||
def subparser_name(self):
|
||||
return "chart_parsing"
|
||||
|
||||
@property
|
||||
def wrapper_cls(self):
|
||||
return ChartParsing
|
||||
|
||||
def _update_subparser(self, subparser):
|
||||
add_simple_inference_args(
|
||||
subparser,
|
||||
input_help='Input dict, e.g. `{"image": "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/chart_parsing_02.png"}`.',
|
||||
)
|
||||
@@ -12,26 +12,14 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from paddlex.utils.pipeline_arguments import custom_type
|
||||
|
||||
from .._utils.cli import (
|
||||
add_simple_inference_args,
|
||||
get_subcommand_args,
|
||||
perform_simple_inference,
|
||||
from .._utils.cli import add_simple_inference_args
|
||||
from ._doc_vlm import (
|
||||
BaseDocVLM,
|
||||
BaseDocVLMSubcommandExecutor,
|
||||
)
|
||||
from .base import PaddleXPredictorWrapper, PredictorCLISubcommandExecutor
|
||||
from paddlex.utils.pipeline_arguments import custom_type
|
||||
|
||||
|
||||
class DocVLM(PaddleXPredictorWrapper):
|
||||
def __init__(
|
||||
self,
|
||||
*args,
|
||||
**kwargs,
|
||||
):
|
||||
self._extra_init_args = {}
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
class DocVLM(BaseDocVLM):
|
||||
@property
|
||||
def default_model_name(self):
|
||||
return "PP-DocBee2-3B"
|
||||
@@ -40,24 +28,18 @@ class DocVLM(PaddleXPredictorWrapper):
|
||||
def get_cli_subcommand_executor(cls):
|
||||
return DocVLMSubcommandExecutor()
|
||||
|
||||
def _get_extra_paddlex_predictor_init_args(self):
|
||||
return self._extra_init_args
|
||||
|
||||
|
||||
class DocVLMSubcommandExecutor(PredictorCLISubcommandExecutor):
|
||||
input_validator = staticmethod(custom_type(dict))
|
||||
|
||||
class DocVLMSubcommandExecutor(BaseDocVLMSubcommandExecutor):
|
||||
@property
|
||||
def subparser_name(self):
|
||||
return "doc_vlm"
|
||||
|
||||
@property
|
||||
def wrapper_cls(self):
|
||||
return DocVLM
|
||||
|
||||
def _update_subparser(self, subparser):
|
||||
add_simple_inference_args(
|
||||
subparser,
|
||||
input_help='Input dict, e.g. `{"image": "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/medal_table.png", "query": "Recognize this table"}`.',
|
||||
)
|
||||
|
||||
def execute_with_args(self, args):
|
||||
params = get_subcommand_args(args)
|
||||
params["input"] = self.input_validator(params["input"])
|
||||
perform_simple_inference(DocVLM, params)
|
||||
|
||||
Reference in New Issue
Block a user