|
|
@@ -2,14 +2,19 @@
|
|
|
comments: true
|
|
|
---
|
|
|
|
|
|
-# 通用表格识别产线v2使用教程
|
|
|
+# 通用表格识别v2产线使用教程
|
|
|
|
|
|
-## 1. 通用表格识别产线v2介绍
|
|
|
+## 1. 通用表格识别v2产线介绍
|
|
|
表格识别是一种自动从文档或图像中识别和提取表格内容及其结构的技术,广泛应用于数据录入、信息检索和文档分析等领域。通过使用计算机视觉和机器学习算法,表格识别能够将复杂的表格信息转换为可编辑的格式,方便用户进一步处理和分析数据。
|
|
|
|
|
|
-通用表格识别产线v2用于解决表格识别任务,对图片中的表格进行识别,并以HTML格式输出。与通用表格识别产线不同,本产线引入了表格分类和表格单元格检测两个模块,并将其与表格结构识别模块串联以完成表格识别任务。基于本产线,可实现对表格的精准预测,使用场景覆盖通用、制造、金融、交通等各个领域。本产线同时提供了灵活的服务化部署方式,支持在多种硬件上使用多种编程语言调用。不仅如此,本产线也提供了二次开发的能力,您可以基于本产线在您自己的数据集上训练调优,训练后的模型也可以无缝集成。
|
|
|
+通用表格识别v2产线用于解决表格识别任务,对图片中的表格进行识别,并以HTML格式输出。与通用表格识别产线不同,本产线新引入了表格分类和表格单元格检测两个模块,通过采用“表格分类+表格结构识别+单元格检测”多模型串联组网方案,实现了相比通用表格识别产线更好的端到端表格识别性能。除此之外,通用表格识别v2产线原生支持针对性地模型微调,各类开发者均能对通用表格识别v2产线进行不同程度的自定义微调,使其在不同应用场景下都能得到令人满意的性能。
|
|
|
+
|
|
|
+本产线的使用场景覆盖通用、制造、金融、交通等各个领域。本产线同时提供了灵活的服务化部署方式,支持在多种硬件上使用多种编程语言调用。不仅如此,本产线也提供了二次开发的能力,您可以基于本产线在您自己的数据集上训练调优,训练后的模型也可以无缝集成。
|
|
|
+
|
|
|
+<b>❗ 通用表格识别v2产线仍在持续优化中,将在 PaddleX 下一版本发布最终版。为保持使用的稳定性,您可以先使用通用表格识别产线进行表格处理,v2最终版开源后我们将发布通知,敬请期待!</b>
|
|
|
+
|
|
|
+<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/pipelines/table_recognition_v2/01.png"/>
|
|
|
|
|
|
-<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/pipelines/table_recognition/01.png"/>
|
|
|
<b>通用</b><b>表格识别</b><b>产线v2中包含必选的表格结构识别模块、表格分类模块、表格单元格定位模块、文本检测模块和文本识别模块,以及可选的版面区域检测模块、文档图像方向分类模块和文本图像矫正模块</b>。
|
|
|
|
|
|
<b>如果您更注重模型的精度,请选择精度较高的模型;如果您更在意模型的推理速度,请选择推理速度较快的模型;如果您关注模型的存储大小,请选择存储体积较小的模型。</b>
|
|
|
@@ -426,19 +431,21 @@ SVTRv2 是一种由复旦大学视觉与学习实验室(FVL)的OpenOCR团队
|
|
|
</details>
|
|
|
|
|
|
## 2. 快速开始
|
|
|
-PaddleX 所提供的模型产线均可以快速体验效果,你可以在本地使用命令行或 Python 体验通用表格识别产线v2的效果。
|
|
|
+PaddleX 所提供的模型产线均可以快速体验效果,你可以在本地使用命令行或 Python 体验通用表格识别v2产线的效果。
|
|
|
|
|
|
### 2.1 在线体验
|
|
|
暂不支持在线体验。
|
|
|
|
|
|
### 2.2 本地体验
|
|
|
-在本地使用通用表格识别产线v2前,请确保您已经按照[PaddleX本地安装教程](../../../installation/installation.md)完成了PaddleX的wheel包安装。
|
|
|
+在本地使用通用表格识别v2产线前,请确保您已经按照[PaddleX本地安装教程](../../../installation/installation.md)完成了PaddleX的wheel包安装。
|
|
|
|
|
|
### 2.1 命令行方式体验
|
|
|
一行命令即可快速体验表格识别产线效果,使用 [测试文件](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/table_recognition.jpg),并将 `--input` 替换为本地路径,进行预测
|
|
|
|
|
|
```bash
|
|
|
paddlex --pipeline table_recognition_v2 \
|
|
|
+ --use_doc_orientation_classify=False \
|
|
|
+ --use_doc_unwarping=False \
|
|
|
--input table_recognition.jpg \
|
|
|
--save_path ./output \
|
|
|
--device gpu:0
|
|
|
@@ -449,141 +456,40 @@ paddlex --pipeline table_recognition_v2 \
|
|
|
<details><summary>👉 <b>运行后,得到的结果为:(点击展开)</b></summary>
|
|
|
|
|
|
```bash
|
|
|
-{'res': {'input_path': 'table_recognition.jpg', 'model_settings': {'use_doc_preprocessor': False, 'use_layout_detection': True, 'use_ocr_model': True}, 'layout_det_res': {'input_path': None, 'page_index': None, 'boxes': [{'cls_id': 0, 'label': 'Table', 'score': 0.9922188520431519, 'coordinate': [3.0127392, 0.14648987, 547.5102, 127.72023]}]}, 'overall_ocr_res': {'input_path': None, 'page_index': None, 'model_settings': {'use_doc_preprocessor': False, 'use_textline_orientation': False}, 'dt_polys': [array([[234, 6],
|
|
|
- [316, 6],
|
|
|
- [316, 25],
|
|
|
- [234, 25]], dtype=int16), array([[38, 39],
|
|
|
- [73, 39],
|
|
|
- [73, 57],
|
|
|
- [38, 57]], dtype=int16), array([[122, 32],
|
|
|
- [201, 32],
|
|
|
- [201, 58],
|
|
|
- [122, 58]], dtype=int16), array([[227, 34],
|
|
|
- [346, 34],
|
|
|
- [346, 57],
|
|
|
- [227, 57]], dtype=int16), array([[351, 34],
|
|
|
- [391, 34],
|
|
|
- [391, 58],
|
|
|
- [351, 58]], dtype=int16), array([[417, 35],
|
|
|
- [534, 35],
|
|
|
- [534, 58],
|
|
|
- [417, 58]], dtype=int16), array([[34, 70],
|
|
|
- [78, 70],
|
|
|
- [78, 90],
|
|
|
- [34, 90]], dtype=int16), array([[287, 70],
|
|
|
- [328, 70],
|
|
|
- [328, 90],
|
|
|
- [287, 90]], dtype=int16), array([[454, 69],
|
|
|
- [496, 69],
|
|
|
- [496, 90],
|
|
|
- [454, 90]], dtype=int16), array([[ 17, 101],
|
|
|
- [ 95, 101],
|
|
|
- [ 95, 124],
|
|
|
- [ 17, 124]], dtype=int16), array([[144, 101],
|
|
|
- [178, 101],
|
|
|
- [178, 122],
|
|
|
- [144, 122]], dtype=int16), array([[278, 101],
|
|
|
- [338, 101],
|
|
|
- [338, 124],
|
|
|
- [278, 124]], dtype=int16), array([[448, 101],
|
|
|
- [503, 101],
|
|
|
- [503, 121],
|
|
|
- [448, 121]], dtype=int16)], 'text_det_params': {'limit_side_len': 960, 'limit_type': 'max', 'thresh': 0.3, 'box_thresh': 0.6, 'unclip_ratio': 2.0}, 'text_type': 'general', 'textline_orientation_angles': [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], 'text_rec_score_thresh': 0, 'rec_texts': ['CRuncover', 'Dres', '连续工作3', '取出来放在网上', '没想', '江、整江等八大', 'Abstr', 'rSrivi', '$709.', 'cludingGiv', '2.72', 'Ingcubic', '$744.78'], 'rec_scores': [0.9951260685920715, 0.9943379759788513, 0.9968608021736145, 0.9978817105293274, 0.9985721111297607, 0.9616036415100098, 0.9977153539657593, 0.987593948841095, 0.9906861186027527, 0.9959743618965149, 0.9970152378082275, 0.9977849721908569, 0.9984450936317444], 'rec_polys': [array([[234, 6],
|
|
|
- [316, 6],
|
|
|
- [316, 25],
|
|
|
- [234, 25]], dtype=int16), array([[38, 39],
|
|
|
- [73, 39],
|
|
|
- [73, 57],
|
|
|
- [38, 57]], dtype=int16), array([[122, 32],
|
|
|
- [201, 32],
|
|
|
- [201, 58],
|
|
|
- [122, 58]], dtype=int16), array([[227, 34],
|
|
|
- [346, 34],
|
|
|
- [346, 57],
|
|
|
- [227, 57]], dtype=int16), array([[351, 34],
|
|
|
- [391, 34],
|
|
|
- [391, 58],
|
|
|
- [351, 58]], dtype=int16), array([[417, 35],
|
|
|
- [534, 35],
|
|
|
- [534, 58],
|
|
|
- [417, 58]], dtype=int16), array([[34, 70],
|
|
|
- [78, 70],
|
|
|
- [78, 90],
|
|
|
- [34, 90]], dtype=int16), array([[287, 70],
|
|
|
- [328, 70],
|
|
|
- [328, 90],
|
|
|
- [287, 90]], dtype=int16), array([[454, 69],
|
|
|
- [496, 69],
|
|
|
- [496, 90],
|
|
|
- [454, 90]], dtype=int16), array([[ 17, 101],
|
|
|
- [ 95, 101],
|
|
|
- [ 95, 124],
|
|
|
- [ 17, 124]], dtype=int16), array([[144, 101],
|
|
|
- [178, 101],
|
|
|
- [178, 122],
|
|
|
- [144, 122]], dtype=int16), array([[278, 101],
|
|
|
- [338, 101],
|
|
|
- [338, 124],
|
|
|
- [278, 124]], dtype=int16), array([[448, 101],
|
|
|
- [503, 101],
|
|
|
- [503, 121],
|
|
|
- [448, 121]], dtype=int16)], 'rec_boxes': array([[234, 6, 316, 25],
|
|
|
- [ 38, 39, 73, 57],
|
|
|
- [122, 32, 201, 58],
|
|
|
- [227, 34, 346, 57],
|
|
|
- [351, 34, 391, 58],
|
|
|
- [417, 35, 534, 58],
|
|
|
- [ 34, 70, 78, 90],
|
|
|
- [287, 70, 328, 90],
|
|
|
- [454, 69, 496, 90],
|
|
|
- [ 17, 101, 95, 124],
|
|
|
- [144, 101, 178, 122],
|
|
|
- [278, 101, 338, 124],
|
|
|
- [448, 101, 503, 121]], dtype=int16)}, 'table_res_list': [{'cell_box_list': [array([3.18822289e+00, 1.46489874e-01, 5.46996138e+02, 3.08782365e+01]), array([ 3.21032453, 31.1510637 , 110.20750237, 65.14108063]), array([110.18174553, 31.13076188, 213.00813103, 65.02860047]), array([212.96108818, 31.09959008, 404.19618034, 64.99535157]), array([404.08112907, 31.18304802, 547.00864983, 65.0847223 ]), array([ 3.21772957, 65.0738733 , 110.33685875, 96.07921387]), array([110.23703575, 65.02486207, 213.08839226, 96.01378419]), array([213.06095695, 64.96230103, 404.28425407, 95.97141816]), array([404.23704338, 65.04879548, 547.01273918, 96.03654267]), array([ 3.22793937, 96.08334137, 110.38572502, 127.08698823]), array([110.40586662, 96.10539795, 213.19943047, 127.07002045]), array([213.12627983, 96.0539148 , 404.42686272, 127.02842499]), array([404.33042717, 96.07251526, 547.01273918, 126.45088746])], 'pred_html': '<html><body><table><tr><td colspan="4">CRuncover</td></tr><tr><td>Dres</td><td>连续工作3</td><td>取出来放在网上 没想</td><td>江、整江等八大</td></tr><tr><td>Abstr</td><td></td><td>rSrivi</td><td>$709.</td></tr><tr><td>cludingGiv</td><td>2.72</td><td>Ingcubic</td><td>$744.78</td></tr></table></body></html>', 'table_ocr_pred': {'rec_polys': [array([[234, 6],
|
|
|
- [316, 6],
|
|
|
- [316, 25],
|
|
|
- [234, 25]], dtype=int16), array([[38, 39],
|
|
|
- [73, 39],
|
|
|
- [73, 57],
|
|
|
- [38, 57]], dtype=int16), array([[122, 32],
|
|
|
- [201, 32],
|
|
|
- [201, 58],
|
|
|
- [122, 58]], dtype=int16), array([[227, 34],
|
|
|
- [346, 34],
|
|
|
- [346, 57],
|
|
|
- [227, 57]], dtype=int16), array([[351, 34],
|
|
|
- [391, 34],
|
|
|
- [391, 58],
|
|
|
- [351, 58]], dtype=int16), array([[417, 35],
|
|
|
- [534, 35],
|
|
|
- [534, 58],
|
|
|
- [417, 58]], dtype=int16), array([[34, 70],
|
|
|
- [78, 70],
|
|
|
- [78, 90],
|
|
|
- [34, 90]], dtype=int16), array([[287, 70],
|
|
|
- [328, 70],
|
|
|
- [328, 90],
|
|
|
- [287, 90]], dtype=int16), array([[454, 69],
|
|
|
- [496, 69],
|
|
|
- [496, 90],
|
|
|
- [454, 90]], dtype=int16), array([[ 17, 101],
|
|
|
- [ 95, 101],
|
|
|
- [ 95, 124],
|
|
|
- [ 17, 124]], dtype=int16), array([[144, 101],
|
|
|
- [178, 101],
|
|
|
- [178, 122],
|
|
|
- [144, 122]], dtype=int16), array([[278, 101],
|
|
|
- [338, 101],
|
|
|
- [338, 124],
|
|
|
- [278, 124]], dtype=int16), array([[448, 101],
|
|
|
- [503, 101],
|
|
|
- [503, 121],
|
|
|
- [448, 121]], dtype=int16)], 'rec_texts': ['CRuncover', 'Dres', '连续工作3', '取出来放在网上', '没想', '江、整江等八大', 'Abstr', 'rSrivi', '$709.', 'cludingGiv', '2.72', 'Ingcubic', '$744.78'], 'rec_scores': [0.9951260685920715, 0.9943379759788513, 0.9968608021736145, 0.9978817105293274, 0.9985721111297607, 0.9616036415100098, 0.9977153539657593, 0.987593948841095, 0.9906861186027527, 0.9959743618965149, 0.9970152378082275, 0.9977849721908569, 0.9984450936317444], 'rec_boxes': [array([234, 6, 316, 25], dtype=int16), array([38, 39, 73, 57], dtype=int16), array([122, 32, 201, 58], dtype=int16), array([227, 34, 346, 57], dtype=int16), array([351, 34, 391, 58], dtype=int16), array([417, 35, 534, 58], dtype=int16), array([34, 70, 78, 90], dtype=int16), array([287, 70, 328, 90], dtype=int16), array([454, 69, 496, 90], dtype=int16), array([ 17, 101, 95, 124], dtype=int16), array([144, 101, 178, 122], dtype=int16), array([278, 101, 338, 124], dtype=int16), array([448, 101, 503, 121], dtype=int16)]}}]}}
|
|
|
+{'res': {'input_path': 'table_recognition.jpg', 'page_index': None, 'model_settings': {'use_doc_preprocessor': False, 'use_layout_detection': True, 'use_ocr_model': True}, 'layout_det_res': {'input_path': None, 'page_index': None, 'boxes': [{'cls_id': 0, 'label': 'Table', 'score': 0.9922188520431519, 'coordinate': [3.0127392, 0.14648987, 547.5102, 127.72023]}]}, 'overall_ocr_res': {'input_path': None, 'page_index': None, 'model_settings': {'use_doc_preprocessor': False, 'use_textline_orientation': False}, 'dt_polys': array([[[234, 6],
|
|
|
+ ...,
|
|
|
+ [234, 25]],
|
|
|
+
|
|
|
+ ...,
|
|
|
+
|
|
|
+ [[448, 101],
|
|
|
+ ...,
|
|
|
+ [448, 121]]], dtype=int16), 'text_det_params': {'limit_side_len': 960, 'limit_type': 'max', 'thresh': 0.3, 'box_thresh': 0.6, 'unclip_ratio': 2.0}, 'text_type': 'general', 'textline_orientation_angles': array([-1, ..., -1]), 'text_rec_score_thresh': 0, 'rec_texts': ['CRuncover', 'Dres', '连续工作3', '取出来放在网上', '没想', '江、整江等八大', 'Abstr', 'rSrivi', '$709.', 'cludingGiv', '2.72', 'Ingcubic', '$744.78'], 'rec_scores': array([0.99512607, ..., 0.99844509]), 'rec_polys': array([[[234, 6],
|
|
|
+ ...,
|
|
|
+ [234, 25]],
|
|
|
+
|
|
|
+ ...,
|
|
|
+
|
|
|
+ [[448, 101],
|
|
|
+ ...,
|
|
|
+ [448, 121]]], dtype=int16), 'rec_boxes': array([[234, ..., 25],
|
|
|
+ ...,
|
|
|
+ [448, ..., 121]], dtype=int16)}, 'table_res_list': [{'cell_box_list': [array([ 3.18822289, ..., 30.87823655]), array([ 3.21032453, ..., 65.14108063]), array([110.18174553, ..., 65.02860047]), array([212.96108818, ..., 64.99535157]), array([404.08112907, ..., 65.0847223 ]), array([ 3.21772957, ..., 96.07921387]), array([110.23703575, ..., 96.01378419]), array([213.06095695, ..., 95.97141816]), array([404.23704338, ..., 96.03654267]), array([ 3.22793937, ..., 127.08698823]), array([110.40586662, ..., 127.07002045]), array([213.12627983, ..., 127.02842499]), array([404.33042717, ..., 126.45088746])], 'pred_html': '<html><body><table><tr><td colspan="4">CRuncover</td></tr><tr><td>Dres</td><td>连续工作3</td><td>取出来放在网上 没想</td><td>江、整江等八大</td></tr><tr><td>Abstr</td><td></td><td>rSrivi</td><td>$709.</td></tr><tr><td>cludingGiv</td><td>2.72</td><td>Ingcubic</td><td>$744.78</td></tr></table></body></html>', 'table_ocr_pred': {'rec_polys': array([[[234, 6],
|
|
|
+ ...,
|
|
|
+ [234, 25]],
|
|
|
+
|
|
|
+ ...,
|
|
|
+
|
|
|
+ [[448, 101],
|
|
|
+ ...,
|
|
|
+ [448, 121]]], dtype=int16), 'rec_texts': ['CRuncover', 'Dres', '连续工作3', '取出来放在网上', '没想', '江、整江等八大', 'Abstr', 'rSrivi', '$709.', 'cludingGiv', '2.72', 'Ingcubic', '$744.78'], 'rec_scores': array([0.99512607, ..., 0.99844509]), 'rec_boxes': array([[234, ..., 25],
|
|
|
+ ...,
|
|
|
+ [448, ..., 121]], dtype=int16)}}]}}
|
|
|
```
|
|
|
运行结果参数说明可以参考[2.2 Python脚本方式集成](#22-python脚本方式集成)中的结果解释。
|
|
|
|
|
|
可视化结果保存在`save_path`下,其中表格识别的可视化结果如下:
|
|
|
-<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/pipelines/table_recognition_v2/01.jpg">
|
|
|
+<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/pipelines/table_recognition_v2/02.jpg">
|
|
|
|
|
|
</details>
|
|
|
|
|
|
@@ -612,7 +518,7 @@ for res in output:
|
|
|
|
|
|
在上述 Python 脚本中,执行了如下几个步骤:
|
|
|
|
|
|
-(1)通过 `create_pipeline()` 实例化通用表格识别产线v2对象,具体参数说明如下:
|
|
|
+(1)通过 `create_pipeline()` 实例化通用表格识别v2产线对象,具体参数说明如下:
|
|
|
|
|
|
<table>
|
|
|
<thead>
|
|
|
@@ -651,7 +557,7 @@ for res in output:
|
|
|
</tbody>
|
|
|
</table>
|
|
|
|
|
|
-(2)调用通用表格识别产线v2对象的 `predict()` 方法进行推理预测。该方法将返回一个 `generator`。以下是 `predict()` 方法的参数及其说明:
|
|
|
+(2)调用通用表格识别v2产线对象的 `predict()` 方法进行推理预测。该方法将返回一个 `generator`。以下是 `predict()` 方法的参数及其说明:
|
|
|
|
|
|
<table>
|
|
|
<thead>
|
|
|
@@ -717,6 +623,19 @@ for res in output:
|
|
|
</td>
|
|
|
<td><code>None</code></td>
|
|
|
</tr>
|
|
|
+<tr>
|
|
|
+<td><code>use_layout_detection</code></td>
|
|
|
+<td>是否使用版面检测模块</td>
|
|
|
+<td><code>bool|None</code></td>
|
|
|
+<td>
|
|
|
+<ul>
|
|
|
+<li><b>bool</b>:<code>True</code> 或者 <code>False</code>;</li>
|
|
|
+<li><b>None</b>:如果设置为<code>None</code>, 将默认使用产线初始化的该参数值,初始化为<code>True</code>;</li>
|
|
|
+</ul>
|
|
|
+</td>
|
|
|
+<td><code>None</code></td>
|
|
|
+</tr>
|
|
|
+
|
|
|
<td><code>text_det_limit_side_len</code></td>
|
|
|
<td>文本检测的图像边长限制</td>
|
|
|
<td><code>int|None</code></td>
|
|
|
@@ -727,6 +646,7 @@ for res in output:
|
|
|
</ul>
|
|
|
</td>
|
|
|
<td><code>None</code></td>
|
|
|
+</tr>
|
|
|
<td><code>text_det_limit_type</code></td>
|
|
|
<td>文本检测的图像边长限制类型</td>
|
|
|
<td><code>str|None</code></td>
|
|
|
@@ -737,6 +657,7 @@ for res in output:
|
|
|
</ul>
|
|
|
</td>
|
|
|
<td><code>None</code></td>
|
|
|
+</tr>
|
|
|
<td><code>text_det_thresh</code></td>
|
|
|
<td>检测像素阈值,输出的概率图中,得分大于该阈值的像素点才会被认为是文字像素点</td>
|
|
|
<td><code>float|None</code></td>
|
|
|
@@ -745,6 +666,7 @@ for res in output:
|
|
|
<li><b>float</b>:大于 <code>0</code> 的任意浮点数
|
|
|
<li><b>None</b>:如果设置为 <code>None</code>, 将默认使用产线初始化的该参数值 <code>0.3</code></li></li></ul></td>
|
|
|
<td><code>None</code></td>
|
|
|
+</tr>
|
|
|
<td><code>text_det_box_thresh</code></td>
|
|
|
<td>检测框阈值,检测结果边框内,所有像素点的平均得分大于该阈值时,该结果会被认为是文字区域</td>
|
|
|
<td><code>float|None</code></td>
|
|
|
@@ -753,6 +675,7 @@ for res in output:
|
|
|
<li><b>float</b>:大于 <code>0</code> 的任意浮点数
|
|
|
<li><b>None</b>:如果设置为 <code>None</code>, 将默认使用产线初始化的该参数值 <code>0.6</code></li></li></ul></td>
|
|
|
<td><code>None</code></td>
|
|
|
+</tr>
|
|
|
<td><code>text_det_unclip_ratio</code></td>
|
|
|
<td>文本检测扩张系数,使用该方法对文字区域进行扩张,该值越大,扩张的面积越大</td>
|
|
|
<td><code>float|None</code></td>
|
|
|
@@ -761,6 +684,7 @@ for res in output:
|
|
|
<li><b>float</b>:大于 <code>0</code> 的任意浮点数
|
|
|
<li><b>None</b>:如果设置为 <code>None</code>, 将默认使用产线初始化的该参数值 <code>2.0</code></li></li></ul></td>
|
|
|
<td><code>None</code></td>
|
|
|
+</tr>
|
|
|
<td><code>text_rec_score_thresh</code></td>
|
|
|
<td>文本识别阈值,得分大于该阈值的文本结果会被保留</td>
|
|
|
<td><code>float|None</code></td>
|
|
|
@@ -769,66 +693,7 @@ for res in output:
|
|
|
<li><b>float</b>:大于 <code>0</code> 的任意浮点数
|
|
|
<li><b>None</b>:如果设置为 <code>None</code>, 将默认使用产线初始化的该参数值 <code>0.0</code>。即不设阈值</li></li></ul></td>
|
|
|
<td><code>None</code></td>
|
|
|
-<tr>
|
|
|
-<td><code>use_layout_detection</code></td>
|
|
|
-<td>是否使用版面检测模块</td>
|
|
|
-<td><code>bool|None</code></td>
|
|
|
-<td>
|
|
|
-<ul>
|
|
|
-<li><b>bool</b>:<code>True</code> 或者 <code>False</code>;</li>
|
|
|
-<li><b>None</b>:如果设置为<code>None</code>, 将默认使用产线初始化的该参数值,初始化为<code>True</code>;</li>
|
|
|
-</ul>
|
|
|
-</td>
|
|
|
-<td><code>None</code></td>
|
|
|
-</tr>
|
|
|
-<tr>
|
|
|
-<td><code>layout_threshold</code></td>
|
|
|
-<td>版面检测置信度阈值,得分大于该阈值才会被输出</td>
|
|
|
-<td><code>float|dict|None</code></td>
|
|
|
-<td>
|
|
|
-<ul>
|
|
|
-<li><b>float</b>:大于 <code>0</code> 的任意浮点数
|
|
|
- <li><b>dict</b>:key是int类别id, value是大于 <code>0</code> 的任意浮点数
|
|
|
- <li><b>None</b>:如果设置为 <code>None</code>, 将默认使用产线初始化的该参数值 <code>0.5</code></li></li></li></ul></td>
|
|
|
-<td><code>None</code></td>
|
|
|
-</tr>
|
|
|
-<tr>
|
|
|
-<td><code>layout_nms</code></td>
|
|
|
-<td>是否使用版面检测后处理NMS</td>
|
|
|
-<td><code>bool|None</code></td>
|
|
|
-<td>
|
|
|
-<ul>
|
|
|
-<li><b>bool</b>:<code>True</code> 或者 <code>False</code>;</li>
|
|
|
-<li><b>None</b>:如果设置为<code>None</code>, 将默认使用产线初始化的该参数值,初始化为<code>True</code>;</li>
|
|
|
-</ul>
|
|
|
-</td>
|
|
|
-<td><code>None</code></td>
|
|
|
-</tr>
|
|
|
-<tr>
|
|
|
-<td><code>layout_unclip_ratio</code></td>
|
|
|
-<td>检测框的边长缩放倍数;如果不指定,将默认使用PaddleX官方模型配置</td>
|
|
|
-<td><code>float|list|None</code></td>
|
|
|
-<td>
|
|
|
-<ul>
|
|
|
-<li><b>float</b>, 大于0的浮点数,如 1.1 , 表示将模型输出的检测框中心不变,宽和高都扩张1.1倍</li>
|
|
|
-<li><b>列表</b>, 如 [1.2, 1.5] , 表示将模型输出的检测框中心不变,宽度扩张1.2倍,高度扩张1.5倍</li>
|
|
|
-<li><b>None</b>:如果设置为<code>None</code>, 将默认使用产线初始化的该参数值,初始化为1.0</li>
|
|
|
-</ul>
|
|
|
-</td>
|
|
|
-<tr>
|
|
|
-<td><code>layout_merge_bboxes_mode</code></td>
|
|
|
-<td>模型输出的检测框的合并处理模式;如果不指定,将默认使用PaddleX官方模型配置</td>
|
|
|
-<td><code>string|None</code></td>
|
|
|
-<td>
|
|
|
-<ul>
|
|
|
-<li><b>large</b>, 设置为large时,表示在模型输出的检测框中,对于互相重叠包含的检测框,只保留外部最大的框,删除重叠的内部框。</li>
|
|
|
-<li><b>small</b>, 设置为small,表示在模型输出的检测框中,对于互相重叠包含的检测框,只保留内部被包含的小框,删除重叠的外部框。</li>
|
|
|
-<li><b>union</b>, 不进行框的过滤处理,内外框都保留</li>
|
|
|
-<li><b>None</b>:如果设置为<code>None</code>, 将默认使用产线初始化的该参数值,初始化为<code>large</code></li>
|
|
|
-</ul>
|
|
|
-</td>
|
|
|
-<td>None</td>
|
|
|
-</tr>
|
|
|
+
|
|
|
</tr></table>
|
|
|
|
|
|
(3)对预测结果进行处理,每个样本的预测结果均为对应的Result对象,且支持打印、保存为图片、保存为`xlsx`文件、保存为`HTML`文件、保存为`json`文件的操作:
|
|
|
@@ -958,10 +823,10 @@ for res in output:
|
|
|
- `rec_boxes`: `(numpy.ndarray)` 检测框的矩形边界框数组,shape为(n, 4),dtype为int16。每一行表示一个矩形框的[x_min, y_min, x_max, y_max]坐标
|
|
|
,其中(x_min, y_min)为左上角坐标,(x_max, y_max)为右下角坐标
|
|
|
|
|
|
-- 调用`save_to_json()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}.json`,如果指定为文件,则直接保存到该文件中。由于json文件不支持保存numpy数组,因此会将其中的`numpy.array`类型转换为列表形式。
|
|
|
+- 调用`save_to_json()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}_res.json`,如果指定为文件,则直接保存到该文件中。由于json文件不支持保存numpy数组,因此会将其中的`numpy.array`类型转换为列表形式。
|
|
|
- 调用`save_to_img()` 方法会将可视化结果保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}_ocr_res_img.{your_img_extension}`,如果指定为文件,则直接保存到该文件中。(产线通常包含较多结果图片,不建议直接指定为具体的文件路径,否则多张图会被覆盖,仅保留最后一张图)
|
|
|
-- 调用`save_to_html()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}.html`,如果指定为文件,则直接保存到该文件中。在通用表格识别产线v2中,将会把图像中表格的HTML形式写入到指定的html文件中。
|
|
|
-- 调用`save_to_xlsx()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}.xlsx`,如果指定为文件,则直接保存到该文件中。在通用表格识别产线v2中,将会把图像中表格的Excel表格形式写入到指定的xlsx文件中。
|
|
|
+- 调用`save_to_html()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}_table_1.html`,如果指定为文件,则直接保存到该文件中。在通用表格识别v2产线中,将会把图像中表格的HTML形式写入到指定的html文件中。
|
|
|
+- 调用`save_to_xlsx()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}_res.xlsx`,如果指定为文件,则直接保存到该文件中。在通用表格识别v2产线中,将会把图像中表格的Excel表格形式写入到指定的xlsx文件中。
|
|
|
|
|
|
* 此外,也支持通过属性获取带结果的可视化图像和预测结果,具体如下:
|
|
|
|
|
|
@@ -985,13 +850,13 @@ for res in output:
|
|
|
- `json` 属性获取的预测结果为dict类型的数据,相关内容与调用 `save_to_json()` 方法保存的内容一致。
|
|
|
- `img` 属性返回的预测结果是一个字典类型的数据。其中,键分别为 `table_res_img`、`ocr_res_img` 、`layout_res_img` 和 `preprocessed_img`,对应的值是四个 `Image.Image` 对象,按顺序分别为:表格识别结果的可视化图像、OCR 结果的可视化图像、版面区域检测结果的可视化图像、图像预处理的可视化图像。如果没有使用某个子模块,则字典中不包含对应的结果图像。
|
|
|
|
|
|
-此外,您可以获取通用表格识别产线v2配置文件,并加载配置文件进行预测。可执行如下命令将结果保存在 `my_path` 中:
|
|
|
+此外,您可以获取通用表格识别v2产线配置文件,并加载配置文件进行预测。可执行如下命令将结果保存在 `my_path` 中:
|
|
|
|
|
|
```
|
|
|
paddlex --get_pipeline_config table_recognition_v2 --save_path ./my_path
|
|
|
```
|
|
|
|
|
|
-若您获取了配置文件,即可对通用表格识别产线v2各项配置进行自定义,只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为产线配置文件路径即可。示例如下:
|
|
|
+若您获取了配置文件,即可对通用表格识别v2产线各项配置进行自定义,只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为产线配置文件路径即可。示例如下:
|
|
|
|
|
|
```python
|
|
|
from paddlex import create_pipeline
|
|
|
@@ -1013,7 +878,7 @@ for res in output:
|
|
|
|
|
|
```
|
|
|
|
|
|
-<b>注:</b> 配置文件中的参数为产线初始化参数,如果希望更改通用通用表格识别产线v2初始化参数,可以直接修改配置文件中的参数,并加载配置文件进行预测。同时,CLI 预测也支持传入配置文件,`--pipeline` 指定配置文件的路径即可。
|
|
|
+<b>注:</b> 配置文件中的参数为产线初始化参数,如果希望更改通用通用表格识别v2产线初始化参数,可以直接修改配置文件中的参数,并加载配置文件进行预测。同时,CLI 预测也支持传入配置文件,`--pipeline` 指定配置文件的路径即可。
|
|
|
|
|
|
|
|
|
## 3. 开发集成/部署
|
|
|
@@ -1278,10 +1143,10 @@ for i, res in enumerate(result["tableRecResults"]):
|
|
|
您可以根据需要选择合适的方式部署模型产线,进而进行后续的 AI 应用集成。
|
|
|
|
|
|
## 4. 二次开发
|
|
|
-如果通用表格识别产线v2提供的默认模型权重在您的场景中,精度或速度不满意,您可以尝试利用<b>您自己拥有的特定领域或应用场景的数据</b>对现有模型进行进一步的<b>微调</b>,以提升通用表格识别产线v2的在您的场景中的识别效果。
|
|
|
+如果通用表格识别v2产线提供的默认模型权重在您的场景中,精度或速度不满意,您可以尝试利用<b>您自己拥有的特定领域或应用场景的数据</b>对现有模型进行进一步的<b>微调</b>,以提升通用表格识别v2产线的在您的场景中的识别效果。
|
|
|
|
|
|
### 4.1 模型微调
|
|
|
-由于通用表格识别产线v2包含若干模块,模型产线的效果如果不及预期,可能来自于其中任何一个模块。您可以对识别效果差的图片进行分析,进而确定是哪个模块存在问题,并参考以下表格中对应的微调教程链接进行模型微调。
|
|
|
+由于通用表格识别v2产线包含若干模块,模型产线的效果如果不及预期,可能来自于其中任何一个模块。您可以对识别效果差的图片进行分析,进而确定是哪个模块存在问题,并参考以下表格中对应的微调教程链接进行模型微调。
|
|
|
|
|
|
<table>
|
|
|
<thead>
|
|
|
@@ -1416,10 +1281,12 @@ SubPipelines:
|
|
|
## 5. 多硬件支持
|
|
|
PaddleX 支持英伟达 GPU、昆仑芯 XPU、昇腾 NPU和寒武纪 MLU 等多种主流硬件设备,<b>仅需修改 `--device` 参数</b>即可完成不同硬件之间的无缝切换。
|
|
|
|
|
|
-例如,您使用昇腾 NPU 进行 OCR 产线的推理,使用的 CLI 命令为:
|
|
|
+例如,您使用昇腾 NPU 进行通用表格识别v2产线的推理,使用的 CLI 命令为:
|
|
|
|
|
|
```bash
|
|
|
paddlex --pipeline table_recognition_v2 \
|
|
|
+ --use_doc_orientation_classify=False \
|
|
|
+ --use_doc_unwarping=False \
|
|
|
--input table_recognition.jpg \
|
|
|
--save_path ./output \
|
|
|
--device npu:0
|
|
|
@@ -1427,4 +1294,4 @@ paddlex --pipeline table_recognition_v2 \
|
|
|
|
|
|
当然,您也可以在 Python 脚本中 `create_pipeline()` 时或者 `predict()` 时指定硬件设备。
|
|
|
|
|
|
-若您想在更多种类的硬件上使用通用表格识别产线v2,请参考[PaddleX多硬件使用指南](../../../other_devices_support/multi_devices_use_guide.md)。
|
|
|
+若您想在更多种类的硬件上使用通用表格识别v2产线,请参考[PaddleX多硬件使用指南](../../../other_devices_support/multi_devices_use_guide.md)。
|