[Feat] Add PP-DocTranslate and update docs (#15890)

* Add PP-DocTranslate and update docs

* Fix docs

* Add English doc

* Fix ut
This commit is contained in:
Lin Manhui
2025-06-28 23:13:32 +08:00
committed by GitHub
parent 8ab5edf0b7
commit de0ecd466f
47 changed files with 7459 additions and 560 deletions
+1 -1
View File
@@ -167,7 +167,7 @@ See [2.1 Quick Start](#21-quick-start).
1. Install `paddleocr-mcp`.
2. Set up AI Studio community service.
- Visit [PaddlePaddle AI Studio Community](https://aistudio.baidu.com/pipeline/mine) and log in. **Note: A China mainland phone number is required to use this service.** If unavailable, consider other modes.
- In the left panel under "More Content" → "PaddleX Pipelines", [Create Pipeline] - [OCR] - [General OCR] - [Deploy Directly] - [Start Deployment].
- Under "PaddleX Pipeline" in the "More" section on the left, click in sequence: [Create Pipeline] - [OCR] - [General OCR] - [Deploy Directly] - [Start Deployment].
- After deployment, obtain your **service base URL** (e.g., `https://xxxxxx.aistudio-hub.baidu.com`).
- Get your **access token** from [this page](https://aistudio.baidu.com/index/accessToken).
3. Refer to the configuration example below to modify the contents of the `claude_desktop_config.json` file.
+4 -4
View File
@@ -67,7 +67,7 @@ ImportError: failed to find libmagic. Check your installation
### 2.1 快速开始
接下来以 **星河社区服务** 工作模式为例,引导您完成快速配置。此模式无需在本地安装复杂的依赖,因此比较适合用于快速体验。
接下来以 **星河社区服务** 工作模式为例,引导您快速上手。此模式无需在本地安装复杂的依赖,因此比较适合用于快速体验。
1. **安装 `paddleocr-mcp`**
@@ -76,7 +76,7 @@ ImportError: failed to find libmagic. Check your installation
2. **准备星河社区服务**
- 访问 [飞桨星河社区](https://aistudio.baidu.com/pipeline/mine) 并登录。**请注意,目前星河社区要求用户绑定中国大陆手机号。** 如果您不具备此条件,请考虑使用其他工作模式。
- 在左侧"更多内容"下的 "PaddleX 产线" 部分,[创建产线] - [OCR] - [通用 OCR] - [直接部署] - [开始部署]
- 在左侧"更多内容"下的 "PaddleX 产线" 部分,依次点击:【创建产线 - OCR- 通用OCR】-【直接部署】-【开始部署
- 部署成功后,获取您的 **服务基础 URL**(示例:`https://xxxxxx.aistudio-hub.baidu.com`)。
- 在 [此页面](https://aistudio.baidu.com/index/accessToken) 获取您的 **访问令牌**
@@ -109,8 +109,8 @@ ImportError: failed to find libmagic. Check your installation
**说明**
- 将 `<your-server-url>` 替换为您的星河社区服务的 **服务基础 URL**,例如 `https://xxxxx.aistudio-hub.baidu.com`,注意不要带有端点路径(如 `/ocr`)。
- 将 `<your-access-token>` 替换为您的 **访问令牌**
- 将 `<your-server-url>` 替换为您的星河社区服务的基础 URL,例如 `https://xxxxx.aistudio-hub.baidu.com`,注意不要带有端点路径(如 `/ocr`)。
- 将 `<your-access-token>` 替换为您的访问令牌。
**注意**
+5 -3
View File
@@ -26,19 +26,21 @@ The version correspondence between PaddleOCR, PaddleX, and the PaddlePaddle fram
| `3.0.1` | `3.0.1` | `>= 3.0.0` |
| `3.0.2` | `3.0.2` | `>= 3.0.0` |
| `3.0.3` | `>= 3.0.3` | `>= 3.0.0` |
| `3.1.0` | `>= 3.1.0` | `>= 3.0.0` |
## 2. Correspondence Between PaddleOCR Pipelines and PaddleX Pipeline Registration Names
| PaddleOCR Pipeline | PaddleX Pipeline Registration Name |
| --- | --- |
| General OCR | `OCR` |
| General Layout Analysis v3 | `PP-StructureV3` |
| Document Scenario Information Extraction v4 | `PP-ChatOCRv4-doc` |
| General Table Recognition v2 | `table_recognition_v2` |
| PP-StructureV3 | `PP-StructureV3` |
| PP-ChatOCRv4 | `PP-ChatOCRv4-doc` |
| General Table Recognition V2 | `table_recognition_v2` |
| Formula Recognition | `formula_recognition` |
| Seal Text Recognition | `seal_recognition` |
| Document Image Preprocessing | `doc_preprocessor` |
| Document Understanding | `doc_understanding` |
| PP-DocTranslation | `PP-DocTranslation` |
## 3. Using PaddleX Pipeline Configuration Files
+4 -2
View File
@@ -26,19 +26,21 @@ PaddleOCR、PaddleX 和飞桨框架的版本存在如下对应关系:
| `3.0.1` | `3.0.1` | `>= 3.0.0` |
| `3.0.2` | `3.0.2` | `>= 3.0.0` |
| `3.0.3` | `>= 3.0.3` | `>= 3.0.0` |
| `3.1.0` | `>= 3.1.0` | `>= 3.0.0` |
## 2. PaddleOCR 产线与 PaddleX 产线注册名的对应关系
| PaddleOCR 产线 | PaddleX 产线注册名 |
| --- | --- |
| 通用 OCR | `OCR` |
| 通用版面解析 v3 | `PP-StructureV3` |
| 文档场景信息抽取 v4 | `PP-ChatOCRv4-doc` |
| PP-StructureV3 | `PP-StructureV3` |
| PP-ChatOCRv4 | `PP-ChatOCRv4-doc` |
| 通用表格识别 v2 | `table_recognition_v2` |
| 公式识别 | `formula_recognition` |
| 印章文本识别 | `seal_recognition` |
| 文档图像预处理 | `doc_preprocessor` |
| 文档理解 | `doc_understanding` |
| PP-DocTranslation | `PP-DocTranslation` |
## 3. 使用 PaddleX 产线配置文件
+38 -38
View File
@@ -733,26 +733,26 @@ paddleocr ocr -i ./general_ocr_002.png --ocr_version PP-OCRv4
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>Whether to load and use the document orientation classification module. If not set, the pipeline's initialized value for this parameter (initialized to <code>True</code>) will be used.</td>
<td>Whether to load and use the document orientation classification module. If not set, the pipeline's initialized value for this parameter (defaults to <code>True</code>) will be used.</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>Whether to load and use the text image unwarping module. If not set, the pipeline's initialized value for this parameter (initialized to <code>True</code>) will be used.</td>
<td>Whether to load and use the text image unwarping module. If not set, the pipeline's initialized value for this parameter (defaults to <code>True</code>) will be used.</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_textline_orientation</code></td>
<td>Whether to load and use the text line orientation module. If not set, the pipeline's initialized value for this parameter (initialized to <code>True</code>) will be used.</td>
<td>Whether to load and use the text line orientation module. If not set, the pipeline's initialized value for this parameter (defaults to <code>True</code>) will be used.</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>text_det_limit_side_len</code></td>
<td>Image side length limitation for text detection.
Any integer greater than <code>0</code>. If not set, the pipeline's initialized value for this parameter (initialized to <code>64</code>) will be used.
Any integer greater than <code>0</code>. If not set, the pipeline's initialized value for this parameter (defaults to <code>64</code>) will be used.
</td>
<td><code>int</code></td>
<td></td>
@@ -760,14 +760,14 @@ Any integer greater than <code>0</code>. If not set, the pipeline's initialized
<tr>
<td><code>text_det_limit_type</code></td>
<td>Type of side length limit for text detection.
Supports <code>min</code> and <code>max</code>. <code>min</code> means ensuring the shortest side of the image is not smaller than <code>det_limit_side_len</code>, and <code>max</code> means ensuring the longest side of the image is not larger than <code>limit_side_len</code>. If not set, the pipeline's initialized value for this parameter (initialized to <code>min</code>) will be used.
Supports <code>min</code> and <code>max</code>. <code>min</code> means ensuring the shortest side of the image is not smaller than <code>det_limit_side_len</code>, and <code>max</code> means ensuring the longest side of the image is not larger than <code>limit_side_len</code>. If not set, the pipeline's initialized value for this parameter (defaults to <code>min</code>) will be used.
</td>
<td><code>str</code></td>
<td></td>
</tr>
<tr>
<td><code>text_det_thresh</code></td>
<td>Pixel threshold for text detection. In the output probability map, pixels with scores higher than this threshold will be considered text pixels.Any floating-point number greater than <code>0</code>. If not set, the pipeline's initialized value for this parameter (<code>0.3</code>) will be used.
<td>Pixel threshold for text detection. In the output probability map, pixels with scores higher than this threshold will be considered text pixels.Any floating-point number greater than <code>0</code>. If not set, the pipeline's initialized value for this parameter (defaults to <code>0.3</code>) will be used.
</td>
<td><code>float</code></td>
<td></td>
@@ -775,7 +775,7 @@ Supports <code>min</code> and <code>max</code>. <code>min</code> means ensuring
<tr>
<td><code>text_det_box_thresh</code></td>
<td>Text detection box threshold. If the average score of all pixels within the detected result boundary is higher than this threshold, the result will be considered a text region.
Any floating-point number greater than <code>0</code>. If not set, the pipeline's initialized value for this parameter (<code>0.6</code>) will be used.
Any floating-point number greater than <code>0</code>. If not set, the pipeline's initialized value for this parameter (defaults to <code>0.6</code>) will be used.
</td>
<td><code>float</code></td>
<td></td>
@@ -783,7 +783,7 @@ Any floating-point number greater than <code>0</code>. If not set, the pipeline'
<tr>
<td><code>text_det_unclip_ratio</code></td>
<td>Text detection expansion coefficient. This method is used to expand the text region—the larger the value, the larger the expanded area.
Any floating-point number greater than <code>0</code>. If not set, the pipeline's initialized value for this parameter (<code>2.0</code>) will be used.
Any floating-point number greater than <code>0</code>. If not set, the pipeline's initialized value for this parameter (defaults to <code>2.0</code>) will be used.
</td>
<td><code>float</code></td>
<td></td>
@@ -797,7 +797,7 @@ Any floating-point number greater than <code>0</code>. If not set, the pipeline'
<tr>
<td><code>text_rec_score_thresh</code></td>
<td>Text recognition threshold. Text results with scores higher than this threshold will be retained.Any floating-point number greater than <code>0</code>
. If not set, the pipeline's initialized value for this parameter (<code>0.0</code>, i.e., no threshold) will be used.
. If not set, the pipeline's initialized value for this parameter (defaults to <code>0.0</code>, i.e., no threshold) will be used.
</td>
<td><code>float</code></td>
<td></td>
@@ -1112,19 +1112,19 @@ In the above Python script, the following steps are performed:
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>Whether to load and use the document orientation classification module. If set to <code>None</code>, the pipeline's initialized value for this parameter (initialized to <code>True</code>) will be used.</td>
<td>Whether to load and use the document orientation classification module. If set to <code>None</code>, the pipeline's initialized value for this parameter (defaults to <code>True</code>) will be used.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>Whether to load and use the text image unwarping module. If set to <code>None</code>, the pipeline's initialized value for this parameter (initialized to <code>True</code>) will be used.</td>
<td>Whether to load and use the text image unwarping module. If set to <code>None</code>, the pipeline's initialized value for this parameter (defaults to <code>True</code>) will be used.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_textline_orientation</code></td>
<td>Whether to load and use the text line orientation module. If set to <code>None</code>, the pipeline's initialized value for this parameter (initialized to <code>True</code>) will be used.</td>
<td>Whether to load and use the text line orientation module. If set to <code>None</code>, the pipeline's initialized value for this parameter (defaults to <code>True</code>) will be used.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -1133,7 +1133,7 @@ In the above Python script, the following steps are performed:
<td>Image side length limitation for text detection.
<ul>
<li><b>int</b>: Any integer greater than <code>0</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the pipeline's initialized value for this parameter (initialized to <code>64</code>) will be used.</li>
<li><b>None</b>: If set to <code>None</code>, the pipeline's initialized value for this parameter (defaults to <code>64</code>) will be used.</li>
</ul>
</td>
<td><code>int|None</code></td>
@@ -1144,7 +1144,7 @@ In the above Python script, the following steps are performed:
<td>Type of side length limit for text detection.
<ul>
<li><b>str</b>: Supports <code>min</code> and <code>max</code>, where <code>min</code> means ensuring the shortest side of the image is not smaller than <code>det_limit_side_len</code>, and <code>max</code> means ensuring the longest side of the image is not larger than <code>limit_side_len</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the pipeline's initialized value for this parameter (initialized to <code>min</code>) will be used.</li>
<li><b>None</b>: If set to <code>None</code>, the pipeline's initialized value for this parameter (defaults to <code>min</code>) will be used.</li>
</ul>
</td>
<td><code>str|None</code></td>
@@ -1155,7 +1155,7 @@ In the above Python script, the following steps are performed:
<td>Pixel threshold for text detection. Pixels with scores higher than this threshold in the output probability map will be considered text pixels.
<ul>
<li><b>float</b>: Any floating-point number greater than <code>0</code>;
<li><b>None</b>: If set to <code>None</code>, the pipeline's initialized value for this parameter (<code>0.3</code>) will be used.</li></li></ul>
<li><b>None</b>: If set to <code>None</code>, the pipeline's initialized value for this parameter (defaults to <code>0.3</code>) will be used.</li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1165,7 +1165,7 @@ In the above Python script, the following steps are performed:
<td>Box threshold for text detection. A detection result will be considered a text region if the average score of all pixels within the bounding box is higher than this threshold.
<ul>
<li><b>float</b>: Any floating-point number greater than <code>0</code>;
<li><b>None</b>: If set to <code>None</code>, the pipeline's initialized value for this parameter (<code>0.6</code>) will be used.</li></li></ul>
<li><b>None</b>: If set to <code>None</code>, the pipeline's initialized value for this parameter (defaults to <code>0.6</code>) will be used.</li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1175,7 +1175,7 @@ In the above Python script, the following steps are performed:
<td>Dilation coefficient for text detection. This method is used to dilate the text region, and the larger this value, the larger the dilated area.
<ul>
<li><b>float</b>: Any floating-point number greater than <code>0</code>;
<li><b>None</b>: If set to <code>None</code>, the pipeline's initialized value for this parameter (<code>2.0</code>) will be used.</li></li></ul>
<li><b>None</b>: If set to <code>None</code>, the pipeline's initialized value for this parameter (defaults to <code>2.0</code>) will be used.</li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1191,7 +1191,7 @@ In the above Python script, the following steps are performed:
<td>Recognition score threshold for text. Text results with scores higher than this threshold will be retained.
<ul>
<li><b>float</b>: Any floating-point number greater than <code>0</code>;
<li><b>None</b>: If set to <code>None</code>, the pipeline's initialized value for this parameter (<code>0.0</code>, i.e., no threshold) will be used.</li></li></ul>
<li><b>None</b>: If set to <code>None</code>, the pipeline's initialized value for this parameter (defaults to <code>0.0</code>, i.e., no threshold) will be used.</li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1616,26 +1616,6 @@ Below are the API reference for basic service deployment and examples of multi-l
<td>No</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>
Whether to return the final visualization image and intermediate images during the processing.<br/>
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>If <code>true</code> is provided: return images.</li>
<li>If <code>false</code> is provided: do not return any images.</li>
<li>If this parameter is omitted from the request body, or if <code>null</code> is explicitly passed, the behavior will follow the value of <code>Serving.visualize</code> in the pipeline configuration.</li>
</ul>
<br/>
For example, adding the following setting to the pipeline config file:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
will disable image return by default. This behavior can be overridden by explicitly setting the <code>visualize</code> parameter in the request.<br/>
If neither the request body nor the configuration file is set (If <code>visualize</code> is set to <code>null</code> in the request and not defined in the configuration file), the image is returned by default.
</td>
<td>No</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>Refer to the <code>use_doc_orientation_classify</code> parameter in the pipeline object's <code>predict</code> method.</td>
@@ -1690,6 +1670,26 @@ If neither the request body nor the configuration file is set (If <code>visualiz
<td>Refer to the <code>text_rec_score_thresh</code> parameter in the pipeline object's <code>predict</code> method.</td>
<td>No</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>
Whether to return the final visualization image and intermediate images during the processing.<br/>
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>If <code>true</code> is provided: return images.</li>
<li>If <code>false</code> is provided: do not return any images.</li>
<li>If this parameter is omitted from the request body, or if <code>null</code> is explicitly passed, the behavior will follow the value of <code>Serving.visualize</code> in the pipeline configuration.</li>
</ul>
<br/>
For example, adding the following setting to the pipeline config file:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
will disable image return by default. This behavior can be overridden by explicitly setting the <code>visualize</code> parameter in the request.<br/>
If neither the request body nor the configuration file is set (If <code>visualize</code> is set to <code>null</code> in the request and not defined in the configuration file), the image is returned by default.
</td>
<td>No</td>
</tr>
</tbody>
</table>
<ul>
+38 -38
View File
@@ -734,33 +734,33 @@ paddleocr ocr -i ./general_ocr_002.png --ocr_version PP-OCRv4
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>是否加载并使用文档方向分类模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文档方向分类模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>是否加载并使用文本图像矫正模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本图像矫正模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_textline_orientation</code></td>
<td>是否加载并使用文本行方向模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本行方向模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>text_det_limit_side_len</code></td>
<td>文本检测的图像边长限制。
大于 <code>0</code> 的任意整数。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>64</code>。
大于 <code>0</code> 的任意整数。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>64</code>。
</td>
<td><code>int</code></td>
<td></td>
</tr>
<tr>
<td><code>text_det_limit_type</code></td>
<td>文本检测的边长度限制类型。支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code>。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>min</code>。
<td>文本检测的边长度限制类型。支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code>。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>min</code>。
</td>
<td><code>str</code></td>
<td></td>
@@ -768,7 +768,7 @@ paddleocr ocr -i ./general_ocr_002.png --ocr_version PP-OCRv4
<tr>
<td><code>text_det_thresh</code></td>
<td>文本检测像素阈值,输出的概率图中,得分大于该阈值的像素点才会被认为是文字像素点。
大于<code>0</code>的任意浮点数。如果不设置,将默认使用产线初始化的该参数值 <code>0.3</code>。
大于<code>0</code>的任意浮点数。如果不设置,将使用产线初始化的该参数值(默认为 <code>0.3</code>
</td>
<td><code>float</code></td>
<td></td>
@@ -776,14 +776,14 @@ paddleocr ocr -i ./general_ocr_002.png --ocr_version PP-OCRv4
<tr>
<td><code>text_det_box_thresh</code></td>
<td>文本检测框阈值,检测结果边框内,所有像素点的平均得分大于该阈值时,该结果会被认为是文字区域。
大于 <code>0</code> 的任意浮点数。如果不设置,将默认使用产线初始化的该参数值 <code>0.6</code>。
大于 <code>0</code> 的任意浮点数。如果不设置,将使用产线初始化的该参数值(默认为 <code>0.6</code>
</td>
<td><code>float</code></td>
<td></td>
</tr>
<tr>
<td><code>text_det_unclip_ratio</code></td>
<td>文本检测扩张系数,使用该方法对文字区域进行扩张,该值越大,扩张的面积越大。大于<code>0</code>的任意浮点数。如果不设置,将默认使用产线初始化的该参数值 <code>2.0</code>。
<td>文本检测扩张系数,使用该方法对文字区域进行扩张,该值越大,扩张的面积越大。大于 <code>0</code> 的任意浮点数。如果不设置,将使用产线初始化的该参数值(默认为 <code>2.0</code>
</td>
<td><code>float</code></td>
<td></td>
@@ -797,7 +797,7 @@ paddleocr ocr -i ./general_ocr_002.png --ocr_version PP-OCRv4
<tr>
<td><code>text_rec_score_thresh</code></td>
<td>文本识别阈值,得分大于该阈值的文本结果会被保留。
大于<code>0</code>的任意浮点数。如果不设置,将默认使用产线初始化的该参数值 <code>0.0</code>即不设阈值。
大于<code>0</code>的任意浮点数。如果不设置,将使用产线初始化的该参数值(默认为 <code>0.0</code>即不设阈值
</td>
<td><code>float</code></td>
<td></td>
@@ -1113,19 +1113,19 @@ for res in result:
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>是否加载并使用文档方向分类模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文档方向分类模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>是否加载并使用文本图像矫正模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本图像矫正模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_textline_orientation</code></td>
<td>是否加载并使用文本行方向模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本行方向模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -1134,7 +1134,7 @@ for res in result:
<td>文本检测的图像边长限制。
<ul>
<li><b>int</b>:大于 <code>0</code> 的任意整数;</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>64</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>64</code>。</li>
</ur>
</td>
<td><code>int|None</code></td>
@@ -1145,7 +1145,7 @@ for res in result:
<td>文本检测的边长度限制类型。
<ul>
<li><b>str</b>:支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code></li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>min</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>min</code>。</li>
</ur>
</td>
<td><code>str|None</code></td>
@@ -1156,7 +1156,7 @@ for res in result:
<td>文本检测像素阈值,输出的概率图中,得分大于该阈值的像素点才会被认为是文字像素点。
<ul>
<li><b>float</b>:大于<code>0</code>的任意浮点数;
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值 <code>0.3</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值(默认为<code>0.3</code>。</li>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1166,7 +1166,7 @@ for res in result:
<td>文本检测框阈值,检测结果边框内,所有像素点的平均得分大于该阈值时,该结果会被认为是文字区域。
<ul>
<li><b>float</b>:大于<code>0</code>的任意浮点数;
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值 <code>0.6</code>。
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值(默认为<code>0.6</code>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1176,7 +1176,7 @@ for res in result:
<td>文本检测扩张系数,使用该方法对文字区域进行扩张,该值越大,扩张的面积越大。
<ul>
<li><b>float</b>:大于<code>0</code>的任意浮点数;
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值 <code>2.0</code>。
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值(默认为<code>2.0</code>
</ur>
</td>
<td><code>float|None</code></td>
@@ -1193,7 +1193,7 @@ for res in result:
<td>文本识别阈值,得分大于该阈值的文本结果会被保留。
<ul>
<li><b>float</b>:大于<code>0</code>的任意浮点数;
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值 <code>0.0</code>,即不设阈值。
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值(默认为<code>0.0</code>,即不设阈值
</ur>
</td>
<td><code>float|None</code></td>
@@ -1619,23 +1619,6 @@ MKL-DNN 缓存容量。
<td>否</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>是否返回可视化结果图以及处理过程中的中间图像等。
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>传入 <code>true</code>:返回图像。</li>
<li>传入 <code>false</code>:不返回图像。</li>
<li>若请求体中未提供该参数或传入 <code>null</code>:遵循产线配置文件<code>Serving.visualize</code> 的设置。</li>
</ul>
<br/>例如,在产线配置文件中添加如下字段:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
将默认不返回图像,通过请求体中的<code>visualize</code>参数可以覆盖默认行为。如果请求体和配置文件中均未设置(或请求体传入<code>null</code>、配置文件中未设置),则默认返回图像。
</td>
<td>否</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>请参阅产线对象中 <code>predict</code> 方法的 <code>use_doc_orientation_classify</code> 参数相关说明。</td>
@@ -1690,6 +1673,23 @@ MKL-DNN 缓存容量。
<td>请参阅产线对象中 <code>predict</code> 方法的 <code>text_rec_score_thresh</code> 参数相关说明。</td>
<td>否</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>是否返回可视化结果图以及处理过程中的中间图像等。
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>传入 <code>true</code>:返回图像。</li>
<li>传入 <code>false</code>:不返回图像。</li>
<li>若请求体中未提供该参数或传入 <code>null</code>:遵循产线配置文件<code>Serving.visualize</code> 的设置。</li>
</ul>
<br/>例如,在产线配置文件中添加如下字段:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
将默认不返回图像,通过请求体中的<code>visualize</code>参数可以覆盖默认行为。如果请求体和配置文件中均未设置(或请求体传入<code>null</code>、配置文件中未设置),则默认返回图像。
</td>
<td>否</td>
</tr>
</tbody>
</table>
<ul>
@@ -2240,7 +2240,7 @@ pipeline = PaddleOCR(text_detection_model_dir="./your_det_model_path")
1.获取产线配置文件
可调用 PaddleOCR 中 通用OCR 产线对象的 `export_paddlex_config_to_yaml` 方法,将当前产线配置导出为 YAML 文件:
可调用 PaddleOCR 中 通用 OCR 产线对象的 `export_paddlex_config_to_yaml` 方法,将当前产线配置导出为 YAML 文件:
```Python
from paddleocr import PaddleOCR
@@ -2284,7 +2284,7 @@ SubModules:
3.在 CLI 中加载产线配置文件
在修改完成配置文件后,通过命令行的 --paddlex_config 参数指定修改后的产线配置文件的路径,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
在修改完成配置文件后,通过命令行的 `--paddlex_config` 参数指定修改后的产线配置文件的路径,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
```bash
paddleocr ocr --paddlex_config PaddleOCR.yaml ...
@@ -2292,7 +2292,7 @@ paddleocr ocr --paddlex_config PaddleOCR.yaml ...
4.在 Python API 中加载产线配置文件
初始化产线对象时,可通过 paddlex_config 参数传入 PaddleX 产线配置文件路径或配置dict,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
初始化产线对象时,可通过 `paddlex_config` 参数传入 PaddleX 产线配置文件路径或配置dict,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
```python
from paddleocr import PaddleOCR
@@ -1133,19 +1133,19 @@ The name of the document orientation classification model. If not set, the defau
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>Whether to load and use the document orientation classification module. If not set, the parameter value initialized by the pipeline will be used by default, initialized as <code>True</code>.</td>
<td>Whether to load and use the document orientation classification module. If not set, the parameter value initialized by the pipeline will be used, which defaults to <code>True</code>.</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>Whether to load and use the text image unwarping module. If not set, the parameter value initialized by the pipeline will be used by default, initialized as <code>True</code>.</td>
<td>Whether to load and use the text image unwarping module. If not set, the parameter value initialized by the pipeline will be used, which defaults to <code>True</code>.</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_textline_orientation</code></td>
<td>Whether to load and use the text line orientation classification module. If not set, the parameter value initialized by the pipeline will be used by default, initialized as <code>True</code>.</td>
<td>Whether to load and use the text line orientation classification module. If not set, the parameter value initialized by the pipeline will be used, which defaults to <code>True</code>.</td>
<td><code>bool</code></td>
<td></td>
</tr>
@@ -1171,7 +1171,7 @@ The name of the document orientation classification model. If not set, the defau
<tr>
<td><code>layout_nms</code></td>
<td>
Whether to use Non-Maximum Suppression (NMS) as post-processing for layout detection. If not set, the parameter will default to the value initialized in the pipeline, which is set to <code>True</code> by default.
Whether to use Non-Maximum Suppression (NMS) as post-processing for layout detection. If not set, the parameter will be set to the value initialized in the pipeline, which defaults to <code>True</code> by default.
</td>
<td><code>bool</code></td>
<td></td>
@@ -1458,7 +1458,7 @@ After running, the output is as follows:
The prediction process, API description, and output description for PP-ChatOCRv4 are as follows:
<details><summary>(1) Call the <code>PPChatOCRv4Doc</code> method to instantiate the PP-ChatOCRv4 pipeline object.</summary>
<details><summary>(1) Call <code>PPChatOCRv4Doc</code> to instantiate the PP-ChatOCRv4 pipeline object.</summary>
The relevant parameter descriptions are as follows:
@@ -1582,31 +1582,31 @@ The relevant parameter descriptions are as follows:
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>Whether to load and use the document orientation classification module. If set to<code>None</code>, the value initialized by the pipeline for this parameter will be used by default (initialized to <code>True</code>).</td>
<td>Whether to load and use the document orientation classification module. If set to<code>None</code>, the value initialized by the pipeline for this parameter will be used (defaults to <code>True</code>).</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>Whether to load and use the document unwarping module. If set to<code>None</code>, the value initialized by the pipeline for this parameter will be used by default (initialized to <code>True</code>).</td>
<td>Whether to load and use the document unwarping module. If set to<code>None</code>, the value initialized by the pipeline for this parameter will be used (defaults to <code>True</code>).</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_textline_orientation</code></td>
<td>Whether to load and use the text line orientation classification function. If set to<code>None</code>, the value initialized by the pipeline for this parameter will be used by default (initialized to <code>True</code>).</td>
<td>Whether to load and use the text line orientation classification function. If set to<code>None</code>, the value initialized by the pipeline for this parameter will be used (defaults to <code>True</code>).</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_seal_recognition</code></td>
<td>Whether to load and use the seal text recognition sub-pipeline. If set to<code>None</code>, the value initialized by the pipeline for this parameter will be used by default (initialized to <code>True</code>).</td>
<td>Whether to load and use the seal text recognition sub-pipeline. If set to<code>None</code>, the value initialized by the pipeline for this parameter will be used (defaults to <code>True</code>).</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_table_recognition</code></td>
<td>Whether to load and use the table recognition sub-pipeline. If set to<code>None</code>, the value initialized by the pipeline for this parameter will be used by default (initialized to <code>True</code>).</td>
<td>Whether to load and use the table recognition sub-pipeline. If set to<code>None</code>, the value initialized by the pipeline for this parameter will be used (defaults to <code>True</code>).</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -1624,7 +1624,7 @@ The relevant parameter descriptions are as follows:
</tr>
<tr>
<td><code>layout_nms</code></td>
<td>Whether to use Non-Maximum Suppression (NMS) as post-processing for layout detection. If set to <code>None</code>, the parameter will default to the value initialized in the pipeline, which is set to <code>True</code> by default.</td>
<td>Whether to use Non-Maximum Suppression (NMS) as post-processing for layout detection. If set to <code>None</code>, the parameter will be set to the value initialized in the pipeline, which is set to <code>True</code> by default.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -1647,7 +1647,7 @@ The relevant parameter descriptions are as follows:
<ul>
<li><b>str</b>: <code>large</code>,<code>small</code>, <code>union</code>, representing whether to keep the large box, small box, or both when filtering overlapping boxes;</li>
<li><b>dict</b>, where the key is of <b>int</b> type, representing <code>cls_id</code>, and the value is of <b>str</b> type, e.g.,<code>{0: "large", 2: "small"}</code>, meaning use "large" mode for class 0 detection boxes and "small" mode for class 2 detection boxes;</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter will be used by default (initialized to <code>large</code>).</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter will be used (defaults to <code>large</code>).</li>
</ul>
</td>
<td><code>str|dict|None</code></td>
@@ -1658,7 +1658,7 @@ The relevant parameter descriptions are as follows:
<td>Image side length limitation for text detection.
<ul>
<li><b>int</b>: Any integer greater than <code>0</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter will be used by default (initialized to <code>960</code>).</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter will be used (defaults to <code>960</code>).</li>
</ul>
</td>
<td><code>int|None</code></td>
@@ -1669,7 +1669,7 @@ The relevant parameter descriptions are as follows:
<td>Type of side length limit for text detection.
<ul>
<li><b>str</b>: Supports <code>min</code> and <code>max</code>. <code>min</code> ensures the shortest side of the image is not less than <code>det_limit_side_len</code>. <code>max</code> ensures the longest side of the image is not greater than <code>limit_side_len</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter will be used by default (initialized to <code>max</code>).</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter will be used (defaults to <code>max</code>).</li>
</ul>
</td>
<td><code>str|None</code></td>
@@ -1680,7 +1680,7 @@ The relevant parameter descriptions are as follows:
<td>Detection pixel threshold. In the output probability map, pixels with scores greater than this threshold are considered text pixels.
<ul>
<li><b>float</b>: Any float greater than <code>0</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (<code>0.3</code>) will be used by default.</li></ul>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (defaults to <code>0.3</code>) will be used.</li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1690,7 +1690,7 @@ The relevant parameter descriptions are as follows:
<td>Detection box threshold. If the average score of all pixels within a detection result's bounding box is greater than this threshold, the result is considered a text region.
<ul>
<li><b>float</b>: Any float greater than <code>0</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (<code>0.6</code>) will be used by default.</li></ul>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (defaults to <code>0.6</code>) will be used.</li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1700,7 +1700,7 @@ The relevant parameter descriptions are as follows:
<td>Text detection expansion factor. This method is used to expand text regions; the larger the value, the larger the expanded area.
<ul>
<li><b>float</b>: Any float greater than <code>0</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (<code>2.0</code>) will be used by default.</li></ul>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (defaults to <code>2.0</code>) will be used.</li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1710,7 +1710,7 @@ The relevant parameter descriptions are as follows:
<td>Text recognition threshold. Text results with scores greater than this threshold will be kept.
<ul>
<li><b>float</b>: Any float greater than <code>0</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (<code>0.0</code>, i.e., no threshold) will be used by default.</li></ul>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (defaults to <code>0.0</code>, i.e., no threshold) will be used.</li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1720,7 +1720,7 @@ The relevant parameter descriptions are as follows:
<td>Image side length limit for seal text detection.
<ul>
<li><b>int</b>: Any integer greater than <code>0</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter will be used by default (initialized to <code>736</code>).</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter will be used (defaults to <code>736</code>).</li>
</ul>
</td>
<td><code>int|None</code></td>
@@ -1731,7 +1731,7 @@ The relevant parameter descriptions are as follows:
<td>Type of image side length limit for seal text detection.
<ul>
<li><b>str</b>: Supports <code>min</code> and <code>max</code>. <code>min</code> ensures the shortest side of the image is not less than <code>det_limit_side_len</code>. <code>max</code> ensures the longest side of the image is not greater than <code>limit_side_len</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter will be used by default (initialized to <code>min</code>).</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter will be used (defaults to <code>min</code>).</li>
</ul>
</td>
<td><code>str|None</code></td>
@@ -1742,7 +1742,7 @@ The relevant parameter descriptions are as follows:
<td>Detection pixel threshold. In the output probability map, pixels with scores greater than this threshold are considered text pixels.
<ul>
<li><b>float</b>: Any float greater than <code>0</code>;
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (<code>0.2</code>) will be used by default.</li></li></ul>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (defaults to <code>0.2</code>) will be used.</li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1752,7 +1752,7 @@ The relevant parameter descriptions are as follows:
<td>Detection box threshold. If the average score of all pixels within a detection result's bounding box is greater than this threshold, the result is considered a text region.
<ul>
<li><b>float</b>: Any float greater than <code>0</code>;
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (<code>0.6</code>) will be used by default.</li></li></ul>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (defaults to <code>0.6</code>) will be used.</li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1762,7 +1762,7 @@ The relevant parameter descriptions are as follows:
<td>Seal text detection expansion factor. This method is used to expand text regions; the larger the value, the larger the expanded area.
<ul>
<li><b>float</b>: Any float greater than <code>0</code>;
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (<code>0.5</code>) will be used by default.</li></li></ul>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (defaults to <code>0.5</code>) will be used.</li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1772,7 +1772,7 @@ The relevant parameter descriptions are as follows:
<td>Seal text recognition threshold. Text results with scores greater than this threshold will be kept.
<ul>
<li><b>float</b>: Any float greater than <code>0</code>;
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (<code>0.0</code>, i.e., no threshold) will be used by default.</li></li></ul>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline for this parameter (defaults to <code>0.0</code>, i.e., no threshold) will be used.</li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -2563,26 +2563,6 @@ To remove the page limit, please add the following configuration to the pipeline
<td>No</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>
Whether to return the final visualization image and intermediate images during the processing.<br/>
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>If <code>true</code> is provided: return images.</li>
<li>If <code>false</code> is provided: do not return any images.</li>
<li>If this parameter is omitted from the request body, or if <code>null</code> is explicitly passed, the behavior will follow the value of <code>Serving.visualize</code> in the pipeline configuration.</li>
</ul>
<br/>
For example, adding the following setting to the pipeline config file:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
will disable image return by default. This behavior can be overridden by explicitly setting the <code>visualize</code> parameter in the request.<br/>
If neither the request body nor the configuration file is set (If <code>visualize</code> is set to <code>null</code> in the request and not defined in the configuration file), the image is returned by default.
</td>
<td>No</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>Please refer to the description of the <code>use_doc_orientation_classify</code> parameter of the pipeline object's <code>visual_predict</code> method.</td>
@@ -2702,6 +2682,26 @@ If neither the request body nor the configuration file is set (If <code>visualiz
<td>Please refer to the description of the <code>seal_rec_score_thresh</code> parameter of the pipeline object's <code>visual_predict</code> method.</td>
<td>No</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>
Whether to return the final visualization image and intermediate images during the processing.<br/>
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>If <code>true</code> is provided: return images.</li>
<li>If <code>false</code> is provided: do not return any images.</li>
<li>If this parameter is omitted from the request body, or if <code>null</code> is explicitly passed, the behavior will follow the value of <code>Serving.visualize</code> in the pipeline configuration.</li>
</ul>
<br/>
For example, adding the following setting to the pipeline config file:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
will disable image return by default. This behavior can be overridden by explicitly setting the <code>visualize</code> parameter in the request.<br/>
If neither the request body nor the configuration file is set (If <code>visualize</code> is set to <code>null</code> in the request and not defined in the configuration file), the image is returned by default.
</td>
<td>No</td>
</tr>
</tbody>
</table>
<ul>
@@ -2746,7 +2746,7 @@ If neither the request body nor the configuration file is set (If <code>visualiz
<tr>
<td><code>prunedResult</code></td>
<td><code>object</code></td>
<td>A simplified version of the <code>res</code> field in the JSON representation of the results generated by the pipeline's <code>visual_predict</code> method, with the <code>input_path</code> and the <code>page_index</code> fields removed.</td>
<td>A simplified version of the <code>res</code> field in the JSON representation of the <code>layout_parsing_result</code> generated by the pipeline object's <code>visual_predict</code> method, with the <code>input_path</code> and <code>page_index</code> fields removed.</td>
</tr>
<tr>
<td><code>outputImages</code></td>
@@ -2786,13 +2786,13 @@ If neither the request body nor the configuration file is set (If <code>visualiz
</tr>
<tr>
<td><code>minCharacters</code></td>
<td><code>integer</code> | <code>null</code></td>
<td>Minimum data length to enable the vector database.</td>
<td><code>integer</code></td>
<td>Please refer to the description of the <code>min_characters</code> parameter of the pipeline object's <code>build_vector</code> method.</td>
<td>No</td>
</tr>
<tr>
<td><code>blockSize</code></td>
<td><code>int</code> | <code>null</code></td>
<td><code>integer</code></td>
<td>Please refer to the description of the <code>block_size</code> parameter of the pipeline object's <code>build_vector</code> method.</td>
<td>No</td>
</tr>
@@ -2911,7 +2911,7 @@ If neither the request body nor the configuration file is set (If <code>visualiz
</tr>
<tr>
<td><code>useVectorRetrieval</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td><code>boolean</code></td>
<td>Please refer to the description of the <code>use_vector_retrieval</code> parameter of the pipeline object's <code>chat</code> method.</td>
<td>No</td>
</tr>
@@ -2924,12 +2924,12 @@ If neither the request body nor the configuration file is set (If <code>visualiz
<tr>
<td><code>minCharacters</code></td>
<td><code>integer</code></td>
<td>Minimum data length to enable the vector database.</td>
<td>Please refer to the description of the <code>min_characters</code> parameter of the pipeline object's <code>chat</code> method.</td>
<td>No</td>
</tr>
<tr>
<td><code>textTaskDescription</code></td>
<td><code>string</code> | <code>null</code></td>
<td><code>string</code></td>
<td>Please refer to the description of the <code>text_task_description</code> parameter of the pipeline object's <code>chat</code> method.</td>
<td>No</td>
</tr>
@@ -2995,7 +2995,7 @@ If neither the request body nor the configuration file is set (If <code>visualiz
</tr>
<tr>
<td><code>mllmIntegrationStrategy</code></td>
<td><code>string</code> | <code>null</code></td>
<td><code>string</code></td>
<td>Please refer to the description of the <code>mllm_integration_strategy</code> parameter of the pipeline object's <code>chat</code> method.</td>
<td>No</td>
</tr>
@@ -3051,7 +3051,7 @@ import sys
import requests
API_BASE_URL = "http://0.0.0.0:8080"
API_BASE_URL = "http://127.0.0.1:8080"
image_path = "./demo.jpg"
keys = ["name"]
@@ -3813,10 +3813,10 @@ If you need to use the fine-tuned model weights, simply modify the production co
You can call the `export_paddlex_config_to_yaml` method of the pipeline object to export the current pipeline configuration to a YAML file. Here is an example:
```Python
from paddleocr import PPChatOCRv4
from paddleocr import PPChatOCRv4Doc
pipeline = PPChatOCRv4()
pipeline.export_paddlex_config_to_yaml("PP-ChatOCRv4.yaml")
pipeline = PPChatOCRv4Doc()
pipeline.export_paddlex_config_to_yaml("PP-ChatOCRv4-doc.yaml")
```
2. Editing Pipeline Configuration Files
@@ -3854,7 +3854,7 @@ The exported PaddleX pipeline configuration file not only includes parameters su
By specifying the path to the PaddleX pipeline configuration file using the `--paddlex_config` parameter, PaddleOCR will read its contents as the configuration for inference. Here is an example:
```bash
paddleocr pp_chatocrv4_doc --paddlex_config PP-ChatOCRv4.yaml ...
paddleocr pp_chatocrv4_doc --paddlex_config PP-ChatOCRv4-doc.yaml ...
```
4. Loading Pipeline Configuration Files in Python API
@@ -3862,7 +3862,7 @@ paddleocr pp_chatocrv4_doc --paddlex_config PP-ChatOCRv4.yaml ...
When initializing the pipeline object, you can pass the path to the PaddleX pipeline configuration file or a configuration dictionary through the `paddlex_config` parameter, and PaddleOCR will use it as the configuration for inference. Here is an example:
```python
from paddleocr import PPChatOCRv4
from paddleocr import PPChatOCRv4Doc
pipeline = PPChatOCRv4(paddlex_config="PP-ChatOCRv4.yaml")
pipeline = PPChatOCRv4Doc(paddlex_config="PP-ChatOCRv4-doc.yaml")
```
+71 -71
View File
@@ -901,7 +901,7 @@ paddleocr pp_chatocrv4_doc -i vehicle_certificate-1.png -k 驾驶室准乘人数
</tr>
<tr>
<td><code>invoke_mllm</code></td>
<td>是否加载并使用多模态大模型。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>False</code>。</td>
<td>是否加载并使用多模态大模型。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>False</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
@@ -1015,13 +1015,13 @@ paddleocr pp_chatocrv4_doc -i vehicle_certificate-1.png -k 驾驶室准乘人数
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>是否加载并使用文档方向分类模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文档方向分类模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>是否加载并使用文本图像矫正模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本图像矫正模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
@@ -1033,33 +1033,33 @@ paddleocr pp_chatocrv4_doc -i vehicle_certificate-1.png -k 驾驶室准乘人数
</tr>
<tr>
<td><code>use_seal_recognition</code></td>
<td>是否加载并使用印章文本识别子产线。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用印章文本识别子产线。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_table_recognition</code></td>
<td>是否加载并使用表格识别子产线。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用表格识别子产线。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>layout_threshold</code></td>
<td>版面模型得分阈值。
<code>0-1</code> 之间的任意浮点数。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>0.5</code>。
<code>0-1</code> 之间的任意浮点数。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>0.5</code>。
</td>
<td><code>float</code></td>
<td></td>
</tr>
<tr>
<td><code>layout_nms</code></td>
<td>版面检测是否使用后处理NMS。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>版面检测是否使用后处理NMS。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>layout_unclip_ratio</code></td>
<td>版面区域检测模型检测框的扩张系数。任意大于 <code>0</code> 浮点数。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>1.0</code>。
<td>版面区域检测模型检测框的扩张系数。任意大于 <code>0</code> 浮点数。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>1.0</code>。
</td>
<td><code>float</code></td>
<td></td>
@@ -1071,14 +1071,14 @@ paddleocr pp_chatocrv4_doc -i vehicle_certificate-1.png -k 驾驶室准乘人数
<li><b>large</b>,设置为large时,表示在模型输出的检测框中,对于互相重叠包含的检测框,只保留外部最大的框,删除重叠的内部框;</li>
<li><b>small</b>,设置为small,表示在模型输出的检测框中,对于互相重叠包含的检测框,只保留内部被包含的小框,删除重叠的外部框;</li>
<li><b>union</b>,不进行框的过滤处理,内外框都保留;</li>
</ul>如果不设置,将默认使用产线初始化的该参数值,初始化为<code>large</code>。
</ul>如果不设置,将使用产线初始化的该参数值,默认初始化为<code>large</code>。
</td>
<td><code>str</code></td>
<td></td>
</tr>
<tr>
<td><code>text_det_limit_side_len</code></td>
<td>文本检测的图像边长限制。大于 <code>0</code> 的任意整数。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>960</code>。
<td>文本检测的图像边长限制。大于 <code>0</code> 的任意整数。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>960</code>。
</td>
<td><code>int</code></td>
<td></td>
@@ -1086,7 +1086,7 @@ paddleocr pp_chatocrv4_doc -i vehicle_certificate-1.png -k 驾驶室准乘人数
<tr>
<td><code>text_det_limit_type</code></td>
<td>文本检测的边长度限制类型。支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code></li>
</ul>如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>max</code>。
</ul>如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>max</code>。
</td>
<td><code>str</code></td>
<td></td>
@@ -1122,14 +1122,14 @@ paddleocr pp_chatocrv4_doc -i vehicle_certificate-1.png -k 驾驶室准乘人数
</tr>
<tr>
<td><code>seal_det_limit_side_len</code></td>
<td>印章文本检测的图像边长限制。大于 <code>0</code> 的任意整数。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>736</code>。
<td>印章文本检测的图像边长限制。大于 <code>0</code> 的任意整数。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>736</code>。
</td>
<td><code>int</code></td>
<td></td>
</tr>
<tr>
<td><code>seal_det_limit_type</code></td>
<td>印章文本检测的图像边长限制类型。支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code>。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>min</code>。
<td>印章文本检测的图像边长限制类型。支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code>。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>min</code>。
</td>
<td><code>str</code></td>
<td></td>
@@ -1151,7 +1151,7 @@ paddleocr pp_chatocrv4_doc -i vehicle_certificate-1.png -k 驾驶室准乘人数
<tr>
<td><code>seal_det_unclip_ratio</code></td>
<td>印章文本检测扩张系数,使用该方法对文字区域进行扩张,该值越大,扩张的面积越大。大于 <code>0</code> 的任意浮点数
。如果不设置,将默认使用产线初始化的该参数值 <code>0.5</code>。
。如果不设置,将使用产线初始化的该参数值,默认为 <code>0.5</code>。
</td>
<td><code>float</code></td>
<td></td>
@@ -1159,7 +1159,7 @@ paddleocr pp_chatocrv4_doc -i vehicle_certificate-1.png -k 驾驶室准乘人数
<tr>
<td><code>seal_rec_score_thresh</code></td>
<td>印章文本识别阈值,得分大于该阈值的文本结果会被保留。大于 <code>0</code> 的任意浮点数
。如果不设置,将默认使用产线初始化的该参数值 <code>0.0</code>即不设阈值。
。如果不设置,将使用产线初始化的该参数值,默认为<code>0.0</code>即不设阈值。
</td>
<td><code>float</code></td>
<td></td>
@@ -1326,7 +1326,7 @@ print(chat_result)
PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<details><summary>1)调用 <code>PPChatOCRv4Doc</code> 方法实例化PP-ChatOCRv4产线对象。</summary>
<details><summary>1)调用 <code>PPChatOCRv4Doc</code> 实例化PP-ChatOCRv4产线对象。</summary>
相关参数说明如下:
@@ -1450,31 +1450,31 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>是否加载并使用文档方向分类模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文档方向分类模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>是否加载并使用文本图像矫正模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本图像矫正模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_textline_orientation</code></td>
<td>是否加载并使用文本行方向分类模块. 如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本行方向分类模块. 如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_seal_recognition</code></td>
<td>是否加载并使用印章文本识别子产线。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用印章文本识别子产线。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_table_recognition</code></td>
<td>是否加载并使用表格识别子产线。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用表格识别子产线。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -1484,7 +1484,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<ul>
<li><b>float</b><code>0-1</code> 之间的任意浮点数;</li>
<li><b>dict</b> <code>{0:0.1}</code> key为类别IDvalue为该类别的阈值;</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>0.5</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>0.5</code>。</li>
</ul>
</td>
<td><code>float|dict|None</code></td>
@@ -1492,7 +1492,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
</tr>
<tr>
<td><code>layout_nms</code></td>
<td>版面检测是否使用后处理NMS。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>版面检测是否使用后处理NMS。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -1503,7 +1503,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<li><b>float</b>:任意大于 <code>0</code> 浮点数;</li>
<li><b>Tuple[float,float]</b>:在横纵两个方向各自的扩张系数;</li>
<li><b>dict</b>dict的key为<b>int</b>类型,代表<code>cls_id</code>value为<b>tuple</b>类型,如<code>{0: (1.12.0)}</code>,表示将模型输出的第0类别检测框中心不变,宽度扩张1.1倍,高度扩张2.0倍</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>1.0</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>1.0</code>。</li>
</ul>
</td>
<td><code>float|Tuple[float,float]|dict|None</code></td>
@@ -1515,7 +1515,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<ul>
<li><b>str</b><code>large</code><code>small</code><code>union</code>,分别表示重叠框过滤时选择保留大框,小框还是同时保留;</li>
<li><b>dict</b>dict的key为<b>int</b>类型,代表<code>cls_id</code>value为<b>str</b>类型,如<code>{0: "large"2: "small"}</code>,表示对第0类别检测框使用large模式,对第2类别检测框使用small模式;</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>large</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>large</code>。</li>
</ul>
</td>
<td><code>str|dict|None</code></td>
@@ -1526,7 +1526,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<td>文本检测的图像边长限制。
<ul>
<li><b>int</b>:大于 <code>0</code> 的任意整数;</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>960</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>960</code>。</li>
</ul>
</td>
<td><code>int|None</code></td>
@@ -1537,7 +1537,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<td>文本检测的边长度限制类型。
<ul>
<li><b>str</b>:支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code></li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>max</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>max</code>。</li>
</ul>
</td>
<td><code>str|None</code></td>
@@ -1548,7 +1548,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<td>检测像素阈值,输出的概率图中,得分大于该阈值的像素点才会被认为是文字像素点。
<ul>
<li><b>float</b>:大于<code>0</code>的任意浮点数;
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值 <code>0.3</code>。</li></li></ul>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认为<code>0.3</code>。</li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1558,7 +1558,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<td>检测框阈值,检测结果边框内,所有像素点的平均得分大于该阈值时,该结果会被认为是文字区域。
<ul>
<li><b>float</b>:大于<code>0</code>的任意浮点数;
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值 <code>0.6</code>。</li></li></ul>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认为<code>0.6</code>。</li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1568,7 +1568,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<td>文本检测扩张系数,使用该方法对文字区域进行扩张,该值越大,扩张的面积越大。
<ul>
<li><b>float</b>:大于<code>0</code>的任意浮点数;
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值 <code>2.0</code></li></li></ul>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认为<code>2.0</code></li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1578,7 +1578,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<td>文本识别阈值,得分大于该阈值的文本结果会被保留。
<ul>
<li><b>float</b>:大于<code>0</code>的任意浮点数;
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值 <code>0.0</code>,即不设阈值。</li></li></ul>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认为<code>0.0</code>,即不设阈值。</li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1588,7 +1588,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<td>印章文本检测的图像边长限制。
<ul>
<li><b>int</b>:大于<code>0</code>的任意整数;</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>736</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>736</code>。</li>
</ul>
</td>
<td><code>int|None</code></td>
@@ -1599,7 +1599,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<td>印章文本检测的图像边长限制类型。
<ul>
<li><b>str</b>:支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code></li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>min</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>min</code>。</li>
</ul>
</td>
<td><code>str|None</code></td>
@@ -1610,7 +1610,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<td>检测像素阈值,输出的概率图中,得分大于该阈值的像素点才会被认为是文字像素点。
<ul>
<li><b>float</b>:大于<code>0</code>的任意浮点数;
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值 <code>0.2</code>。</li></li></ul>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认为<code>0.2</code>。</li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1620,7 +1620,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<td>检测框阈值,检测结果边框内,所有像素点的平均得分大于该阈值时,该结果会被认为是文字区域。
<ul>
<li><b>float</b>:大于<code>0</code>的任意浮点数;
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值 <code>0.6</code>。</li></li></ul>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认为<code>0.6</code>。</li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1630,7 +1630,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<td>印章文本检测扩张系数,使用该方法对文字区域进行扩张,该值越大,扩张的面积越大。
<ul>
<li><b>float</b>:大于<code>0</code>的任意浮点数;
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值 <code>0.5</code>。</li></li></ul>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认为<code>0.5</code>。</li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -1640,7 +1640,7 @@ PP-ChatOCRv4 预测的流程、API说明、产出说明如下:
<td>印章文本识别阈值,得分大于该阈值的文本结果会被保留。
<ul>
<li><b>float</b>:大于<code>0</code>的任意浮点数;
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值 <code>0.0</code>,即不设阈值。</li></li></ul>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认为<code>0.0</code>,即不设阈值。</li></li></ul>
</td>
<td><code>float|None</code></td>
<td><code>None</code></td>
@@ -2441,23 +2441,6 @@ for res in visual_predict_res:
<td>否</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>是否返回可视化结果图以及处理过程中的中间图像等。
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>传入 <code>true</code>:返回图像。</li>
<li>传入 <code>false</code>:不返回图像。</li>
<li>若请求体中未提供该参数或传入 <code>null</code>:遵循产线配置文件<code>Serving.visualize</code> 的设置。</li>
</ul>
<br/>例如,在产线配置文件中添加如下字段:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
将默认不返回图像,通过请求体中的<code>visualize</code>参数可以覆盖默认行为。如果请求体和配置文件中均未设置(或请求体传入<code>null</code>、配置文件中未设置),则默认返回图像。
</td>
<td>否</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>请参阅产线对象中 <code>visual_predict</code> 方法的 <code>use_doc_orientation_classify</code> 参数相关说明。</td>
@@ -2577,6 +2560,23 @@ for res in visual_predict_res:
<td>请参阅产线对象中 <code>visual_predict</code> 方法的 <code>seal_rec_score_thresh</code> 参数相关说明。</td>
<td>否</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>是否返回可视化结果图以及处理过程中的中间图像等。
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>传入 <code>true</code>:返回图像。</li>
<li>传入 <code>false</code>:不返回图像。</li>
<li>若请求体中未提供该参数或传入 <code>null</code>:遵循产线配置文件<code>Serving.visualize</code> 的设置。</li>
</ul>
<br/>例如,在产线配置文件中添加如下字段:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
将默认不返回图像,通过请求体中的<code>visualize</code>参数可以覆盖默认行为。如果请求体和配置文件中均未设置(或请求体传入<code>null</code>、配置文件中未设置),则默认返回图像。
</td>
<td>否</td>
</tr>
</tbody>
</table>
<ul>
@@ -2621,7 +2621,7 @@ for res in visual_predict_res:
<tr>
<td><code>prunedResult</code></td>
<td><code>object</code></td>
<td>产线对象的 <code>visual_predict</code> 方法生成结果的 JSON 表示中 <code>res</code> 字段的简化版本,其中去除了 <code>input_path</code> 和 <code>page_index</code> 字段。</td>
<td>产线对象的 <code>visual_predict</code> 方法生成的 <code>layout_parsing_result</code> 的 JSON 表示中 <code>res</code> 字段的简化版本,其中去除了 <code>input_path</code> 和 <code>page_index</code> 字段。</td>
</tr>
<tr>
<td><code>outputImages</code></td>
@@ -2661,13 +2661,13 @@ for res in visual_predict_res:
</tr>
<tr>
<td><code>minCharacters</code></td>
<td><code>integer</code> | <code>null</code></td>
<td>启用向量数据库的最小数据长度。</td>
<td><code>integer</code></td>
<td>请参阅产线对象中 <code>build_vector</code> 方法的 <code>min_characters</code> 参数相关说明。</td>
<td>否</td>
</tr>
<tr>
<td><code>blockSize</code></td>
<td><code>int</code> | <code>null</code></td>
<td><code>integer</code></td>
<td>请参阅产线对象中 <code>build_vector</code> 方法的 <code>block_size</code> 参数相关说明。</td>
<td>否</td>
</tr>
@@ -2718,7 +2718,7 @@ for res in visual_predict_res:
<tbody>
<tr>
<td><code>image</code></td>
<td><code>string</code></code></td>
<td><code>string</code></td>
<td>服务器可访问的图像文件的URL或图像文件内容的Base64编码结果。</td>
<td>是</td>
</tr>
@@ -2787,7 +2787,7 @@ for res in visual_predict_res:
</tr>
<tr>
<td><code>useVectorRetrieval</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td><code>boolean</code></td>
<td>请参阅产线对象中 <code>chat</code> 方法的 <code>use_vector_retrieval</code> 参数相关说明。</td>
<td>否</td>
</tr>
@@ -2800,7 +2800,7 @@ for res in visual_predict_res:
<tr>
<td><code>minCharacters</code></td>
<td><code>integer</code></td>
<td>启用向量数据库的最小数据长度</td>
<td>请参阅产线对象中 <code>chat</code> 方法的 <code>min_characters</code> 参数相关说明。</td>
<td>否</td>
</tr>
<tr>
@@ -2871,7 +2871,7 @@ for res in visual_predict_res:
</tr>
<tr>
<td><code>mllmIntegrationStrategy</code></td>
<td><code>string</code> | <code>null</code></td>
<td><code>string</code></td>
<td>请参阅产线对象中 <code>chat</code> 方法的 <code>mllm_integration_strategy</code> 参数相关说明。</td>
<td>否</td>
</tr>
@@ -2928,7 +2928,7 @@ import sys
import requests
API_BASE_URL = "http://0.0.0.0:8080"
API_BASE_URL = "http://127.0.0.1:8080"
image_path = "./demo.jpg"
keys = ["姓名"]
@@ -3689,10 +3689,10 @@ function send_post_raw($url, $data) {
可调用 PaddleOCR 中 PPChatOCRv4 产线对象的 `export_paddlex_config_to_yaml` 方法,将当前产线配置导出为 YAML 文件:
```Python
from paddleocr import PPChatOCRv4
from paddleocr import PPChatOCRv4Doc
pipeline = PPChatOCRv4()
pipeline.export_paddlex_config_to_yaml("PP-ChatOCRv4.yaml")
pipeline = PPChatOCRv4Doc()
pipeline.export_paddlex_config_to_yaml("PP-ChatOCRv4-doc.yaml")
```
2. 修改配置文件
@@ -3725,18 +3725,18 @@ SubModules:
3. 在 CLI 中加载产线配置文件
在修改完成配置文件后,通过命令行的 --paddlex_config 参数指定修改后的产线配置文件的路径,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
在修改完成配置文件后,通过命令行的 `--paddlex_config` 参数指定修改后的产线配置文件的路径,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
```bash
paddleocr pp_chatocrv4_doc --paddlex_config PP-ChatOCRv4.yaml ...
paddleocr pp_chatocrv4_doc --paddlex_config PP-ChatOCRv4-doc.yaml ...
```
4. 在 Python API 中加载产线配置文件
初始化产线对象时,可通过 paddlex_config 参数传入 PaddleX 产线配置文件路径或配置dict,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
初始化产线对象时,可通过 `paddlex_config` 参数传入 PaddleX 产线配置文件路径或配置dict,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
```python
from paddleocr import PPChatOCRv4
from paddleocr import PPChatOCRv4Doc
pipeline = PPChatOCRv4(paddlex_config="PP-ChatOCRv4.yaml")
pipeline = PPChatOCRv4Doc(paddlex_config="PP-ChatOCRv4-doc.yaml")
```
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -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>PP-StructureV3</b> includes the following six modules. Each module can be independently trained and inferred, and contains multiple models. Click the corresponding module for more documentation.
<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>
- [Layout Detection Module](../module_usage/layout_detection.en.md)
- [General OCR Subline](./OCR.en.md)
@@ -1033,7 +1033,7 @@ paddleocr pp_structurev3 -i ./pp_structure_v3_demo.png --device gpu
</tr>
<tr>
<td><code>layout_merge_bboxes_mode</code></td>
<td>The merging mode for the detection boxes output by the model in layout region detection.
<td>The merging mode for the detection boxes output by the model in layout detection.
<ul>
<li><b>large</b>: When set to "large", only the largest outer bounding box will be retained for overlapping bounding boxes, and the inner overlapping boxes will be removed;</li>
<li><b>small</b>: When set to "small", only the smallest inner bounding boxes will be retained for overlapping bounding boxes, and the outer overlapping boxes will be removed;</li>
@@ -1362,13 +1362,13 @@ any float > <code>0</code>. If not set, the default is <code>0.6</code>.
<td><code>use_doc_orientation_classify</code></td>
<td>Whether to use document orientation classification module.</td>
<td><code>bool</code></td>
<td>False</td>
<td><code>False</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>Whether to use document unwarping module.</td>
<td><code>bool</code></td>
<td>False</td>
<td><code>False</code></td>
</tr>
<tr>
<td><code>use_textline_orientation</code></td>
@@ -1398,7 +1398,7 @@ any float > <code>0</code>. If not set, the default is <code>0.6</code>.
<td><code>use_chart_recognition</code></td>
<td>Whether to use the chart parsing module.</td>
<td><code>bool</code></td>
<td>False</td>
<td><code>False</code></td>
</tr>
<tr>
<td><code>use_region_detection</code></td>
@@ -2003,31 +2003,31 @@ The above Python script performs the following steps:
</tr>
<tr>
<td><code>use_textline_orientation</code></td>
<td>Whether to use the text line orientation classification. If not set, the default is <code>True</code>.</td>
<td><code>bool</code></td>
<td></td>
<td>Whether to use the text line orientation classification. If set to <code>None</code>, the default value is <code>True</code>.</td>
<td><code>bool|None</code></td>
<td>None</td>
</tr>
<tr>
<td><code>use_seal_recognition</code></td>
<td>Whether to enable seal text recognition subpipeline. If not set, the default is <code>True</code>.</td>
<td><code>bool</code></td>
<td></td>
<td>Whether to enable seal text recognition subpipeline. If set to <code>None</code>, the default value is <code>True</code>.</td>
<td><code>bool|None</code></td>
<td>None</td>
</tr>
<tr>
<td><code>use_table_recognition</code></td>
<td>Whether to enable table recognition subpipeline. If not set, the default is <code>True</code>.</td>
<td><code>bool</code></td>
<td></td>
<td>Whether to enable table recognition subpipeline. If set to <code>None</code>, the default value is <code>True</code>.</td>
<td><code>bool|None</code></td>
<td>None</td>
</tr>
<tr>
<td><code>use_formula_recognition</code></td>
<td>Whether to enable formula recognition subpipeline. If not set, the default is <code>True</code>.</td>
<td><code>bool</code></td>
<td></td>
<td>Whether to enable formula recognition subpipeline. If set to <code>None</code>, the default value is <code>True</code>.</td>
<td><code>bool|None</code></td>
<td>None</td>
</tr>
<tr>
<td><code>use_chart_recognition</code></td>
<td>Whether to use the chart parsing module. If set to <code>None</code>, the default value is <code>True</code>.</td>
<td>Whether to load and use the chart parsing module. If set to <code>None</code>, the default value is <code>True</code>.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -2130,49 +2130,49 @@ MKL-DNN cache capacity.
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>Whether to use document orientation classification during inference.</td>
<td>Whether to use document orientation classification during inference. If set to <code>None</code>, the instantiation value is used; otherwise, this parameter takes precedence.</td>
<td><code>bool|None</code></td>
<td><code>False</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>Whether to use document image unwarping during inference.</td>
<td>Whether to use document image unwarping during inference. If set to <code>None</code>, the instantiation value is used; otherwise, this parameter takes precedence.</td>
<td><code>bool|None</code></td>
<td><code>False</code></td>
</tr>
<tr>
<td><code>use_textline_orientation</code></td>
<td>Whether to use textline orientation classification during inference.</td>
<td>Whether to use textline orientation classification during inference. If set to <code>None</code>, the instantiation value is used; otherwise, this parameter takes precedence.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_seal_recognition</code></td>
<td>Whether to use the seal text recognition sub-pipeline during inference.</td>
<td>Whether to use the seal text recognition sub-pipeline during inference. If set to <code>None</code>, the instantiation value is used; otherwise, this parameter takes precedence.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_table_recognition</code></td>
<td>Whether to use the table recognition sub-pipeline during inference.</td>
<td>Whether to use the table recognition sub-pipeline during inference. If set to <code>None</code>, the instantiation value is used; otherwise, this parameter takes precedence.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_formula_recognition</code></td>
<td>Whether to use the formula recognition sub-pipeline during inference.</td>
<td>Whether to use the formula recognition sub-pipeline during inference. If set to <code>None</code>, the instantiation value is used; otherwise, this parameter takes precedence.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_chart_recognition</code></td>
<td>Whether to use the chart parsing module. If set to <code>None</code>, the default value is <code>True</code>.</td>
<td>Whether to use the chart parsing module. If set to <code>None</code>, the instantiation value is used; otherwise, this parameter takes precedence.</td>
<td><code>bool|None</code></td>
<td><code>False</code></td>
</tr>
<tr>
<td><code>use_region_detection</code></td>
<td>Whether to use the document region detection pipeline. If set to <code>None</code>, the default value is <code>True</code>.</td>
<td>Whether to use the document region detection pipeline. If set to <code>None</code>, the instantiation value is used; otherwise, this parameter takes precedence.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -2274,13 +2274,13 @@ MKL-DNN cache capacity.
</tr>
<tr>
<td><code>use_wired_table_cells_trans_to_html</code></td>
<td>Whether to enable direct conversion of wired table cell detection results to HTML. Default is False. If enabled, HTML will be constructed directly based on the geometric relationship of wired table cell detection results.</td>
<td>Whether to enable direct conversion of wired table cell detection results to HTML. If enabled, HTML will be constructed directly based on the geometric relationship of wired table cell detection results.</td>
<td><code>bool</code></td>
<td><code>False</code></td>
</tr>
<tr>
<td><code>use_wireless_table_cells_trans_to_html</code></td>
<td>Whether to enable direct conversion of wireless table cell detection results to HTML. Default is False. If enabled, HTML will be constructed directly based on the geometric relationship of wireless table cell detection results.</td>
<td>Whether to enable direct conversion of wireless table cell detection results to HTML. If enabled, HTML will be constructed directly based on the geometric relationship of wireless table cell detection results.</td>
<td><code>bool</code></td>
<td><code>False</code></td>
</tr>
@@ -2648,26 +2648,6 @@ Below is the API reference and multi-language service invocation examples for ba
<td>No</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>
Whether to return the final visualization image and intermediate images during the processing.<br/>
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>If <code>true</code> is provided: return images.</li>
<li>If <code>false</code> is provided: do not return any images.</li>
<li>If this parameter is omitted from the request body, or if <code>null</code> is explicitly passed, the behavior will follow the value of <code>Serving.visualize</code> in the pipeline configuration.</li>
</ul>
<br/>
For example, adding the following setting to the pipeline config file:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
will disable image return by default. This behavior can be overridden by explicitly setting the <code>visualize</code> parameter in the request.<br/>
If neither the request body nor the configuration file is set (If <code>visualize</code> is set to <code>null</code> in the request and not defined in the configuration file), the image is returned by default.
</td>
<td>No</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>Refer to the <code>use_doc_orientation_classify</code> parameter in the pipelines <code>predict</code> method.</td>
@@ -2818,6 +2798,26 @@ If neither the request body nor the configuration file is set (If <code>visualiz
<td>Refer to the <code>use_e2e_wireless_table_rec_model</code> parameter in the pipelines <code>predict</code> method.</td>
<td>No</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>
Whether to return the final visualization image and intermediate images during the processing.<br/>
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>If <code>true</code> is provided: return images.</li>
<li>If <code>false</code> is provided: do not return any images.</li>
<li>If this parameter is omitted from the request body, or if <code>null</code> is explicitly passed, the behavior will follow the value of <code>Serving.visualize</code> in the pipeline configuration.</li>
</ul>
<br/>
For example, adding the following setting to the pipeline config file:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
will disable image return by default. This behavior can be overridden by explicitly setting the <code>visualize</code> parameter in the request.<br/>
If neither the request body nor the configuration file is set (If <code>visualize</code> is set to <code>null</code> in the request and not defined in the configuration file), the image is returned by default.
</td>
<td>No</td>
</tr>
</tbody>
</table>
<ul>
@@ -2894,7 +2894,7 @@ If neither the request body nor the configuration file is set (If <code>visualiz
<tr>
<td><code>images</code></td>
<td><code>object</code></td>
<td>Key-value pairs of image relative paths and base64-encoded image content.</td>
<td>Key-value pairs of image relative paths and Base64-encoded image content.</td>
</tr>
<tr>
<td><code>isStart</code></td>
@@ -3512,7 +3512,7 @@ paddleocr pp_structurev3 --paddlex_config PP-StructureV3.yaml ...
```
4. Load the pipeline configuration file via Python API
When initializing the pipeline object, you can pass the PaddleX pipeline configuration file path or a configuration dictionary using the paddlex_config parameter. PaddleOCR will load its content as the pipeline configuration. Example:
When initializing the pipeline object, you can pass the PaddleX pipeline configuration file path or a configuration dictionary using the `paddlex_config` parameter. PaddleOCR will load its content as the pipeline configuration. Example:
```python
from paddleocr import PPStructureV3
@@ -8,7 +8,7 @@ comments: true
版面解析是一种从文档图像中提取结构化信息的技术,主要用于将复杂的文档版面转换为机器可读的数据格式。这项技术在文档管理、信息提取和数据数字化等领域具有广泛的应用。版面解析通过结合光学字符识别(OCR)、图像处理和机器学习算法,能够识别和提取文档中的文本块、标题、段落、图片、表格以及其他版面元素。此过程通常包括版面分析、元素分析和数据格式化三个主要步骤,最终生成结构化的文档数据,提升数据处理的效率和准确性。<b>PP-StructureV3 产线在通用版面解析v1产线的基础上,强化了版面区域检测、表格识别、公式识别的能力,增加了图表理解能力和多栏阅读顺序的恢复能力、结果转换 Markdown 文件的能力,在多种文档数据中,表现优异,可以处理较复杂的文档数据。</b>本产线同时提供了灵活的服务化部署方式,支持在多种硬件上使用多种编程语言调用。不仅如此,本产线也提供了二次开发的能力,您可以基于本产线在您自己的数据集上训练调优,训练后的模型也可以无缝集成。
<b>PP-StructureV3 产线中包含以下6个模块。每个模块均可独立进行训练和推理,并包含多个模型。有关详细信息,请点击相应模块以查看文档。</b>
<b>PP-StructureV3 产线中包含以下6个模块或子产线。每个模块或子产线均可独立进行训练和推理,并包含多个模型。有关详细信息,请点击相应链接以查看文档。</b>
- [版面区域检测模块](../module_usage/layout_detection.md)
- [通用OCR子产线](./OCR.md)
@@ -1094,21 +1094,21 @@ paddleocr pp_structurev3 -i ./pp_structure_v3_demo.png --device gpu
</tr>
<tr>
<td><code>layout_threshold</code></td>
<td>版面模型得分阈值。<code>0-1</code> 之间的任意浮点数。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>0.5</code>。
<td>版面模型得分阈值。<code>0-1</code> 之间的任意浮点数。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>0.5</code>。
</td>
<td><code>float</code></td>
<td></td>
</tr>
<tr>
<td><code>layout_nms</code></td>
<td>版面检测是否使用后处理NMS。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>版面检测是否使用后处理NMS。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>layout_unclip_ratio</code></td>
<td>版面区域检测模型检测框的扩张系数。
任意大于 <code>0</code> 浮点数。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>1.0</code>。
任意大于 <code>0</code> 浮点数。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>1.0</code>。
</td>
<td><code>float</code></td>
<td></td>
@@ -1120,7 +1120,7 @@ paddleocr pp_structurev3 -i ./pp_structure_v3_demo.png --device gpu
<li><b>large</b>,设置为large时,表示在模型输出的检测框中,对于互相重叠包含的检测框,只保留外部最大的框,删除重叠的内部框;</li>
<li><b>small</b>,设置为small,表示在模型输出的检测框中,对于互相重叠包含的检测框,只保留内部被包含的小框,删除重叠的外部框;</li>
<li><b>union</b>,不进行框的过滤处理,内外框都保留;</li>
</ul>如果不设置,将默认使用产线初始化的该参数值,初始化为<code>large</code>。
</ul>如果不设置,将使用产线初始化的该参数值,默认初始化为<code>large</code>。
</td>
<td><code>str</code></td>
<td></td>
@@ -1194,14 +1194,14 @@ paddleocr pp_structurev3 -i ./pp_structure_v3_demo.png --device gpu
<tr>
<td><code>text_det_limit_side_len</code></td>
<td>文本检测的图像边长限制。
大于 <code>0</code> 的任意整数。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>960</code>。
大于 <code>0</code> 的任意整数。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>960</code>。
</td>
<td><code>int</code></td>
<td></td>
</tr>
<tr>
<td><code>text_det_limit_type</code></td>
<td>文本检测的图像边长限制类型。支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code>。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>max</code>。
<td>文本检测的图像边长限制类型。支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code>。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>max</code>。
</td>
<td><code>str</code></td>
<td></td>
@@ -1363,14 +1363,14 @@ paddleocr pp_structurev3 -i ./pp_structure_v3_demo.png --device gpu
<tr>
<td><code>seal_det_limit_side_len</code></td>
<td>印章文本检测的图像边长限制。
大于 <code>0</code> 的任意整数。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>736</code>。
大于 <code>0</code> 的任意整数。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>736</code>。
</td>
<td><code>int</code></td>
<td></td>
</tr>
<tr>
<td><code>seal_det_limit_type</code></td>
<td>印章文本检测的图像边长限制类型。支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code>。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>min</code>。
<td>印章文本检测的图像边长限制类型。支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code>。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>min</code>。
</td>
<td><code>str</code></td>
<td></td>
@@ -1450,35 +1450,35 @@ paddleocr pp_structurev3 -i ./pp_structure_v3_demo.png --device gpu
<td><code>use_doc_orientation_classify</code></td>
<td>是否使用文档方向分类模块。</td>
<td><code>bool</code></td>
<td>False</td>
<td><code>False</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>是否使用文本图像矫正模块。</td>
<td><code>bool</code></td>
<td>False</td>
<td><code>False</code></td>
</tr>
<tr>
<td><code>use_textline_orientation</code></td>
<td>是否加载并使用文本行方向分类模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本行方向分类模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_seal_recognition</code></td>
<td>是否加载并使用印章文本识别子产线。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用印章文本识别子产线。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_table_recognition</code></td>
<td>是否加载并使用表格识别子产线。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用表格识别子产线。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_formula_recognition</code></td>
<td>是否加载并使用公式识别子产线。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用公式识别子产线。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
@@ -1486,11 +1486,11 @@ paddleocr pp_structurev3 -i ./pp_structure_v3_demo.png --device gpu
<td><code>use_chart_recognition</code></td>
<td>是否使用图表解析模块。</td>
<td><code>bool</code></td>
<td>False</td>
<td><code>False</code></td>
</tr>
<tr>
<td><code>use_region_detection</code></td>
<td>是否加载并使用文档区域检测子产线。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文档区域检测子产线。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
@@ -1655,7 +1655,7 @@ for item in markdown_images:
在上述 Python 脚本中,执行了如下几个步骤:
<details><summary>1)实例化 <code>PPStructureV3</code> 实例化产线对象,具体参数说明如下:</summary>
<details><summary>1)实例化产线对象,具体参数说明如下:</summary>
<table>
<thead>
@@ -1685,7 +1685,7 @@ for item in markdown_images:
<ul>
<li><b>float</b><code>0-1</code> 之间的任意浮点数;</li>
<li><b>dict</b> <code>{0:0.1}</code> key为类别IDvalue为该类别的阈值;</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>0.5</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>0.5</code>。</li>
</ul>
</td>
<td><code>float|dict|None</code></td>
@@ -1693,7 +1693,7 @@ for item in markdown_images:
</tr>
<tr>
<td><code>layout_nms</code></td>
<td>版面检测是否使用后处理NMS。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>版面检测是否使用后处理NMS。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -1704,7 +1704,7 @@ for item in markdown_images:
<li><b>float</b>:任意大于 <code>0</code> 浮点数;</li>
<li><b>Tuple[float,float]</b>:在横纵两个方向各自的扩张系数;</li>
<li><b>dict</b>dict的key为<b>int</b>类型,代表<code>cls_id</code>, value为<b>tuple</b>类型,如<code>{0: (1.1, 2.0)}</code>,表示将模型输出的第0类别检测框中心不变,宽度扩张1.1倍,高度扩张2.0倍;</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>1.0</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>1.0</code>。</li>
</ul>
</td>
<td><code>float|Tuple[float,float]|dict|None</code></td>
@@ -1716,7 +1716,7 @@ for item in markdown_images:
<ul>
<li><b>str</b><code>large</code><code>small</code><code>union</code>,分别表示重叠框过滤时选择保留大框,小框还是同时保留;</li>
<li><b>dict</b> dict的key为<b>int</b>类型,代表<code>cls_id</code>value为<b>str</b>类型,如<code>{0: "large", 2: "small"}</code>,表示对第0类别检测框使用large模式,对第2类别检测框使用small模式;</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>large</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>large</code>。</li>
</ul>
</td>
<td><code>str|dict|None</code></td>
@@ -1793,7 +1793,7 @@ for item in markdown_images:
<td>文本检测的图像边长限制。
<ul>
<li><b>int</b>:大于 <code>0</code> 的任意整数;</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>960</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>960</code>。</li>
</ul>
</td>
<td><code>int|None</code></td>
@@ -1804,7 +1804,7 @@ for item in markdown_images:
<td>文本检测的图像边长限制类型。
<ul>
<li><b>str</b>:支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code></li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>max</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>max</code>。</li>
</ul>
</td>
<td><code>str|None</code></td>
@@ -1975,7 +1975,7 @@ for item in markdown_images:
<td>印章文本检测的图像边长限制。
<ul>
<li><b>int</b>:大于 <code>0</code> 的任意整数;</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>736</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>736</code>。</li>
</ul>
</td>
<td><code>int|None</code></td>
@@ -1986,7 +1986,7 @@ for item in markdown_images:
<td>印章文本检测的图像边长限制类型。
<ul>
<li><b>str</b>:支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code></li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>min</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>min</code>。</li>
</ul>
</td>
<td><code>str|None</code></td>
@@ -2070,49 +2070,49 @@ for item in markdown_images:
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>是否加载文档方向分类模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文档方向分类模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>是否加载文本图像矫正模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本图像矫正模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_textline_orientation</code></td>
<td>是否加载并使用文本行方向分类模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本行方向分类模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_seal_recognition</code></td>
<td>是否加载并使用印章文本识别子产线。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用印章文本识别子产线。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_table_recognition</code></td>
<td>是否加载并使用表格识别子产线。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用表格识别子产线。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_formula_recognition</code></td>
<td>是否加载并使用公式识别子产线。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用公式识别子产线。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_chart_recognition</code></td>
<td>是否加载图表解析模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用图表解析模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_region_detection</code></td>
<td>是否加载并使用文档区域检测子产线。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文档区域检测子产线。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -2210,49 +2210,49 @@ MKL-DNN 缓存容量。
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>是否在推理时使用文档方向分类模块。</td>
<td>是否在推理时使用文档方向分类模块。设置为<code>None</code>表示使用实例化参数,否则该参数优先级更高。</td>
<td><code>bool|None</code></td>
<td><code>False</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>是否在推理时使用文本图像矫正模块。</td>
<td>是否在推理时使用文本图像矫正模块。设置为<code>None</code>表示使用实例化参数,否则该参数优先级更高。</td>
<td><code>bool|None</code></td>
<td><code>False</code></td>
</tr>
<tr>
<td><code>use_textline_orientation</code></td>
<td>是否在推理时使用文本行方向分类模块。</td>
<td>是否在推理时使用文本行方向分类模块。设置为<code>None</code>表示使用实例化参数,否则该参数优先级更高。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_seal_recognition</code></td>
<td>是否在推理时使用印章文本识别子产线。</td>
<td>是否在推理时使用印章文本识别子产线。设置为<code>None</code>表示使用实例化参数,否则该参数优先级更高。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_table_recognition</code></td>
<td>是否在推理时使用表格识别子产线。</td>
<td>是否在推理时使用表格识别子产线。设置为<code>None</code>表示使用实例化参数,否则该参数优先级更高。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_formula_recognition</code></td>
<td>是否在推理时使用公式识别子产线。</td>
<td>是否在推理时使用公式识别子产线。设置为<code>None</code>表示使用实例化参数,否则该参数优先级更高。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_chart_recognition</code></td>
<td>是否使用图表解析模块。</td>
<td>是否使用图表解析模块。设置为<code>None</code>表示使用实例化参数,否则该参数优先级更高。</td>
<td><code>bool|None</code></td>
<td><code>False</code></td>
</tr>
<tr>
<td><code>use_region_detection</code></td>
<td>是否使用文档区域检测子产线。</td>
<td>是否使用文档区域检测子产线。设置为<code>None</code>表示使用实例化参数,否则该参数优先级更高。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -2354,13 +2354,13 @@ MKL-DNN 缓存容量。
</tr>
<tr>
<td><code>use_wired_table_cells_trans_to_html</code></td>
<td>是否启用有线表单元格检测结果直转HTML,默认False启用则直接基于有线表单元格检测结果的几何关系构建HTML。</td>
<td>是否启用有线表单元格检测结果直转HTML,启用则直接基于有线表单元格检测结果的几何关系构建HTML。</td>
<td><code>bool</code></td>
<td><code>False</code></td>
</tr>
<tr>
<td><code>use_wireless_table_cells_trans_to_html</code></td>
<td>是否启用无线表单元格检测结果直转HTML,默认False启用则直接基于无线表单元格检测结果的几何关系构建HTML。</td>
<td>是否启用无线表单元格检测结果直转HTML,启用则直接基于无线表单元格检测结果的几何关系构建HTML。</td>
<td><code>bool</code></td>
<td><code>False</code></td>
</tr>
@@ -2728,23 +2728,6 @@ MKL-DNN 缓存容量。
<td>否</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>是否返回可视化结果图以及处理过程中的中间图像等。
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>传入 <code>true</code>:返回图像。</li>
<li>传入 <code>false</code>:不返回图像。</li>
<li>若请求体中未提供该参数或传入 <code>null</code>:遵循产线配置文件<code>Serving.visualize</code> 的设置。</li>
</ul>
<br/>例如,在产线配置文件中添加如下字段:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
将默认不返回图像,通过请求体中的<code>visualize</code>参数可以覆盖默认行为。如果请求体和配置文件中均未设置(或请求体传入<code>null</code>、配置文件中未设置),则默认返回图像。
</td>
<td>否</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>请参阅产线对象中 <code>predict</code> 方法的 <code>use_doc_orientation_classify</code> 参数相关说明。</td>
@@ -2894,6 +2877,23 @@ MKL-DNN 缓存容量。
<td>请参阅产线对象中 <code>predict</code> 方法的 <code>use_e2e_wireless_table_rec_model</code> 参数相关说明。</td>
<td>否</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>是否返回可视化结果图以及处理过程中的中间图像等。
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>传入 <code>true</code>:返回图像。</li>
<li>传入 <code>false</code>:不返回图像。</li>
<li>若请求体中未提供该参数或传入 <code>null</code>:遵循产线配置文件<code>Serving.visualize</code> 的设置。</li>
</ul>
<br/>例如,在产线配置文件中添加如下字段:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
将默认不返回图像,通过请求体中的<code>visualize</code>参数可以覆盖默认行为。如果请求体和配置文件中均未设置(或请求体传入<code>null</code>、配置文件中未设置),则默认返回图像。
</td>
<td>否</td>
</tr>
</tbody>
</table>
<ul>
@@ -2938,7 +2938,7 @@ MKL-DNN 缓存容量。
<tr>
<td><code>markdown</code></td>
<td><code>object</code></td>
<td>markdown结果。</td>
<td>Markdown结果。</td>
</tr>
<tr>
<td><code>outputImages</code></td>
@@ -2970,7 +2970,7 @@ MKL-DNN 缓存容量。
<tr>
<td><code>images</code></td>
<td><code>object</code></td>
<td>Markdown图片相对路径和base64编码图像的键值对。</td>
<td>Markdown图片相对路径和Base64编码图像的键值对。</td>
</tr>
<tr>
<td><code>isStart</code></td>
@@ -3581,7 +3581,7 @@ SubPipelines:
3. 在 CLI 中加载产线配置文件
在修改完成配置文件后,通过命令行的 --paddlex_config 参数指定修改后的产线配置文件的路径,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
在修改完成配置文件后,通过命令行的 `--paddlex_config` 参数指定修改后的产线配置文件的路径,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
```bash
paddleocr pp_structurev3 --paddlex_config PP-StructureV3.yaml ...
@@ -3589,7 +3589,7 @@ paddleocr pp_structurev3 --paddlex_config PP-StructureV3.yaml ...
4. 在 Python API 中加载产线配置文件
初始化产线对象时,可通过 paddlex_config 参数传入 PaddleX 产线配置文件路径或配置dict,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
初始化产线对象时,可通过 `paddlex_config` 参数传入 PaddleX 产线配置文件路径或配置dict,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
```python
from paddleocr import PPStructureV3
@@ -196,13 +196,13 @@ For example, the local path of an image file or PDF file: <code>/root/data/img.j
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>Whether to load and use the document orientation classification module. If not set, the parameter value initialized by the pipeline will be used by default, initialized as <code>True</code>.</td>
<td>Whether to load and use the document orientation classification module. If not set, the parameter value initialized by the pipeline will be used, which defaults to <code>True</code>.</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>Whether to load and use the text image unwarping module. If not set, the parameter value initialized by the pipeline will be used by default, initialized as <code>True</code>.</td>
<td>Whether to load and use the text image unwarping module. If not set, the parameter value initialized by the pipeline will be used, which defaults to <code>True</code>.</td>
<td><code>bool</code></td>
<td></td>
</tr>
@@ -342,13 +342,13 @@ In the above Python script, the following steps are executed:
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>Whether to load and use the document orientation classification module. If set to <code>None</code>, the parameter value initialized by the pipeline will be used by default, initialized as <code>True</code>.</td>
<td>Whether to load and use the document orientation classification module. If set to <code>None</code>, the parameter value initialized by the pipeline will be used, which defaults to <code>True</code>.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>Whether to load and use the text image unwarping module. If set to <code>None</code>, the parameter value initialized by the pipeline will be used by default, initialized as <code>True</code>.</td>
<td>Whether to load and use the text image unwarping module. If set to <code>None</code>, the parameter value initialized by the pipeline will be used, which defaults to <code>True</code>.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -680,6 +680,18 @@ Below are the API references for basic service-oriented deployment and examples
<td>No</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>Please refer to the description of the <code>use_doc_orientation_classify</code> parameter in the <code>predict</code> method of the pipeline object.</td>
<td>No</td>
</tr>
<tr>
<td><code>useDocUnwarping</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>Please refer to the description of the <code>use_doc_unwarping</code> parameter in the <code>predict</code> method of the pipeline object.</td>
<td>No</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>
@@ -699,18 +711,6 @@ If neither the request body nor the configuration file is set (If <code>visualiz
</td>
<td>No</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>Please refer to the description of the <code>use_doc_orientation_classify</code> parameter in the <code>predict</code> method of the pipeline object.</td>
<td>No</td>
</tr>
<tr>
<td><code>useDocUnwarping</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>Please refer to the description of the <code>use_doc_unwarping</code> parameter in the <code>predict</code> method of the pipeline object.</td>
<td>No</td>
</tr>
</tbody>
</table>
<ul>
@@ -198,14 +198,14 @@ paddleocr doc_preprocessor -i ./doc_test_rotated.jpg --device gpu
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>是否加载并使用文档方向分类模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。
<td>是否加载并使用文档方向分类模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。
</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>是否加载并使用文本图像矫正模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。
<td>是否加载并使用文本图像矫正模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。
</td>
<td><code>bool</code></td>
<td></td>
@@ -347,14 +347,14 @@ for res in output:
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>是否加载并使用文档方向分类模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。
<td>是否加载并使用文档方向分类模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。
</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>是否加载并使用文本图像矫正模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。
<td>是否加载并使用文本图像矫正模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。
</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
@@ -687,6 +687,18 @@ MKL-DNN 缓存容量。
<td>否</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>请参阅产线对象中 <code>predict</code> 方法的 <code>use_doc_orientation_classify</code> 参数相关说明。</td>
<td>否</td>
</tr>
<tr>
<td><code>useDocUnwarping</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>请参阅产线对象中 <code>predict</code> 方法的 <code>use_doc_unwarping</code> 参数相关说明。</td>
<td>否</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>是否返回可视化结果图以及处理过程中的中间图像等。
@@ -703,18 +715,6 @@ MKL-DNN 缓存容量。
</td>
<td>否</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>请参阅产线对象中 <code>predict</code> 方法的 <code>use_doc_orientation_classify</code> 参数相关说明。</td>
<td>否</td>
</tr>
<tr>
<td><code>useDocUnwarping</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>请参阅产线对象中 <code>predict</code> 方法的 <code>use_doc_unwarping</code> 参数相关说明。</td>
<td>否</td>
</tr>
</tbody>
</table>
<ul>
@@ -758,7 +758,7 @@ OpenAI interface invocation example
<pre><code class="language-python">import base64
from openai import OpenAI
API_BASE_URL = "http://0.0.0.0:8080"
API_BASE_URL = "http://127.0.0.1:8080"
# Initialize OpenAI client
client = OpenAI(
@@ -756,7 +756,7 @@ openai接口调用示例
<pre><code class="language-python">import base64
from openai import OpenAI
API_BASE_URL = "http://0.0.0.0:8080"
API_BASE_URL = "http://127.0.0.1:8080"
# 初始化OpenAI客户端
client = OpenAI(
@@ -495,14 +495,14 @@ The name of the document orientation classification model. If not set, the defau
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>Whether to load and use the document orientation classification module. If not set, the parameter will default to the value initialized in the pipeline, which is <code>True</code>.</td>
<td>Whether to load and use the document orientation classification module. If not set, the parameter will be set to the value initialized in the pipeline, which is <code>True</code> by default.</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>
Whether to load and use the text image unwarping module. If not set, the parameter will default to the value initialized in the pipeline, which is <code>True</code>.</td>
Whether to load and use the text image unwarping module. If not set, the parameter will be set to the value initialized in the pipeline, which is <code>True</code> by default.</td>
<td><code>bool</code></td>
<td></td>
</tr>
@@ -530,7 +530,7 @@ The name of the layout detection model. If not set, the default model in pipelin
<tr>
<td><code>layout_nms</code></td>
<td>
Whether to use Non-Maximum Suppression (NMS) as post-processing for layout detection. If not set, the parameter will default to the value initialized in the pipeline, which is set to <code>True</code> by default.
Whether to use Non-Maximum Suppression (NMS) as post-processing for layout detection. If not set, the parameter will be set to the value initialized in the pipeline, which is <code>True</code> by default.
</td>
<td><code>bool</code></td>
<td></td>
@@ -563,7 +563,7 @@ Whether to use Non-Maximum Suppression (NMS) as post-processing for layout detec
<tr>
<td><code>use_layout_detection</code></td>
<td>
Whether to load and use the layout detection module. If not set, the parameter will default to the value initialized in the pipeline, which is <code>True</code>.</td>
Whether to load and use the layout detection module. If not set, the parameter will be set to the value initialized in the pipeline, which is <code>True</code> by default.</td>
<td><code>bool</code></td>
<td></td>
</tr>
@@ -749,13 +749,13 @@ In the above Python script, the following steps are executed:
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>Whether to load and use the document orientation classification module. If set to <code>None</code>, the parameter will default to the value initialized in the pipeline, which is <code>True</code>.</td>
<td>Whether to load and use the document orientation classification module. If set to <code>None</code>, the parameter will be set to the value initialized in the pipeline, which is <code>True</code> by default.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>Whether to load and use the text image unwarping module. If set to <code>None</code>, the parameter will default to the value initialized in the pipeline, which is <code>True</code>.</td>
<td>Whether to load and use the text image unwarping module. If set to <code>None</code>, the parameter will be set to the value initialized in the pipeline, which is <code>True</code> by default.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -785,7 +785,7 @@ In the above Python script, the following steps are executed:
</tr>
<tr>
<td><code>layout_nms</code></td>
<td>Whether to use Non-Maximum Suppression (NMS) as post-processing for layout detection. If set to <code>None</code>, the parameter will default to the value initialized in the pipeline, which is set to <code>True</code> by default.</td>
<td>Whether to use Non-Maximum Suppression (NMS) as post-processing for layout detection. If set to <code>None</code>, the parameter will be set to the value initialized in the pipeline, which is set to <code>True</code> by default.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -822,7 +822,7 @@ In the above Python script, the following steps are executed:
</tr>
<tr>
<td><code>use_layout_detection</code></td>
<td>Whether to load and use the layout detection module. If set to <code>None</code>, the parameter will default to the value initialized in the pipeline, which is <code>True</code>.</td>
<td>Whether to load and use the layout detection module. If set to <code>None</code>, the parameter will be set to the value initialized in the pipeline, which is <code>True</code> by default.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -1225,26 +1225,6 @@ To remove the page limit, please add the following configuration to the pipeline
<td>No</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>
Whether to return the final visualization image and intermediate images during the processing.<br/>
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>If <code>true</code> is provided: return images.</li>
<li>If <code>false</code> is provided: do not return any images.</li>
<li>If this parameter is omitted from the request body, or if <code>null</code> is explicitly passed, the behavior will follow the value of <code>Serving.visualize</code> in the pipeline configuration.</li>
</ul>
<br/>
For example, adding the following setting to the pipeline config file:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
will disable image return by default. This behavior can be overridden by explicitly setting the <code>visualize</code> parameter in the request.<br/>
If neither the request body nor the configuration file is set (If <code>visualize</code> is set to <code>null</code> in the request and not defined in the configuration file), the image is returned by default.
</td>
<td>No</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>Please refer to the description of the <code>use_doc_orientation_classify</code> parameter of the pipeline object's <code>predict</code> method.</td>
@@ -1286,6 +1266,26 @@ If neither the request body nor the configuration file is set (If <code>visualiz
<td>Please refer to the description of the <code>layout_merge_bboxes_mode</code> parameter of the pipeline object's <code>predict</code> method.</td>
<td>No</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>
Whether to return the final visualization image and intermediate images during the processing.<br/>
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>If <code>true</code> is provided: return images.</li>
<li>If <code>false</code> is provided: do not return any images.</li>
<li>If this parameter is omitted from the request body, or if <code>null</code> is explicitly passed, the behavior will follow the value of <code>Serving.visualize</code> in the pipeline configuration.</li>
</ul>
<br/>
For example, adding the following setting to the pipeline config file:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
will disable image return by default. This behavior can be overridden by explicitly setting the <code>visualize</code> parameter in the request.<br/>
If neither the request body nor the configuration file is set (If <code>visualize</code> is set to <code>null</code> in the request and not defined in the configuration file), the image is returned by default.
</td>
<td>No</td>
</tr>
</tbody>
</table>
<ul>
@@ -492,13 +492,13 @@ paddleocr formula_recognition_pipeline -i ./general_formula_recognition_001.png
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>是否加载并使用文档方向分类模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文档方向分类模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>是否加载并使用文本图像矫正模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本图像矫正模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
@@ -525,7 +525,7 @@ paddleocr formula_recognition_pipeline -i ./general_formula_recognition_001.png
</tr>
<tr>
<td><code>layout_nms</code></td>
<td>版面检测是否使用后处理NMS。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>版面检测是否使用后处理NMS。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
@@ -556,7 +556,7 @@ paddleocr formula_recognition_pipeline -i ./general_formula_recognition_001.png
<td></td>
</tr>
<td><code>use_layout_detection</code></td>
<td>是否加载并使用版面区域检测模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用版面区域检测模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
@@ -738,13 +738,13 @@ for res in output:
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>是否加载并使用文档方向分类模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文档方向分类模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>是否加载并使用文本图像矫正模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本图像矫正模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -773,7 +773,7 @@ for res in output:
</tr>
<tr>
<td><code>layout_nms</code></td>
<td>版面检测是否使用后处理NMS。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>版面检测是否使用后处理NMS。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -784,7 +784,7 @@ for res in output:
<li><b>float</b>:任意大于 <code>0</code> 浮点数;</li>
<li><b>Tuple[float,float]</b>:在横纵两个方向各自的扩张系数;</li>
<li><b>dict</b>dict的key为<b>int</b>类型,代表<code>cls_id</code>value为<b>tuple</b>类型,如<code>{0: (1.12.0)}</code>,表示将模型输出的第0类别检测框中心不变,宽度扩张1.1倍,高度扩张2.0倍</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>1.0</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>1.0</code>。</li>
</ul>
</td>
<td><code>float|Tuple[float,float]|dict|None</code></td>
@@ -796,7 +796,7 @@ for res in output:
<ul>
<li><b>str</b><code>large</code><code>small</code><code>union</code>,分别表示重叠框过滤时选择保留大框,小框还是同时保留;</li>
<li><b>dict</b> dict的key为<b>int</b>类型,代表<code>cls_id</code>value为<b>str</b>类型,如<code>{0: "large", 2: "small"}</code>,表示对第0类别检测框使用large模式,对第2类别检测框使用small模式;</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>large</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>large</code>。</li>
</ul>
</td>
<td><code>str|dict|None</code></td>
@@ -810,7 +810,7 @@ for res in output:
</tr>
<tr>
<td><code>use_layout_detection</code></td>
<td>是否加载并使用版面区域检测模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用版面区域检测模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -1205,23 +1205,6 @@ MKL-DNN 缓存容量。
<td>否</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>是否返回可视化结果图以及处理过程中的中间图像等。
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>传入 <code>true</code>:返回图像。</li>
<li>传入 <code>false</code>:不返回图像。</li>
<li>若请求体中未提供该参数或传入 <code>null</code>:遵循产线配置文件<code>Serving.visualize</code> 的设置。</li>
</ul>
<br/>例如,在产线配置文件中添加如下字段:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
将默认不返回图像,通过请求体中的<code>visualize</code>参数可以覆盖默认行为。如果请求体和配置文件中均未设置(或请求体传入<code>null</code>、配置文件中未设置),则默认返回图像。
</td>
<td>否</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>请参阅产线对象中 <code>predict</code> 方法的 <code>use_doc_orientation_classify</code> 参数相关说明。</td>
@@ -1263,6 +1246,23 @@ MKL-DNN 缓存容量。
<td>请参阅产线对象中<code>predict</code>方法的 <code>layout_merge_bboxes_mode</code> 参数相关说明。</td>
<td>否</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>是否返回可视化结果图以及处理过程中的中间图像等。
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>传入 <code>true</code>:返回图像。</li>
<li>传入 <code>false</code>:不返回图像。</li>
<li>若请求体中未提供该参数或传入 <code>null</code>:遵循产线配置文件<code>Serving.visualize</code> 的设置。</li>
</ul>
<br/>例如,在产线配置文件中添加如下字段:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
将默认不返回图像,通过请求体中的<code>visualize</code>参数可以覆盖默认行为。如果请求体和配置文件中均未设置(或请求体传入<code>null</code>、配置文件中未设置),则默认返回图像。
</td>
<td>否</td>
</tr>
</tbody>
</table>
<ul>
@@ -1888,7 +1888,7 @@ use_layout_detection: true
3.在 CLI 中加载产线配置文件
在修改完成配置文件后,通过命令行的 --paddlex_config 参数指定修改后的产线配置文件的路径,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
在修改完成配置文件后,通过命令行的 `--paddlex_config` 参数指定修改后的产线配置文件的路径,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
```bash
paddleocr formula_recognition_pipeline -i ./general_formula_recognition_001.png --paddlex_config FormulaRecognitionPipeline.yaml
@@ -1896,7 +1896,7 @@ paddleocr formula_recognition_pipeline -i ./general_formula_recognition_001.png
4.在 Python API 中加载产线配置文件
初始化产线对象时,可通过 paddlex_config 参数传入 PaddleX 产线配置文件路径或配置dict,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
初始化产线对象时,可通过 `paddlex_config` 参数传入 PaddleX 产线配置文件路径或配置dict,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
```python
from paddleocr import FormulaRecognitionPipeline
@@ -823,7 +823,7 @@ The name of the layout detection model. If not set, the default model in pipelin
<tr>
<td><code>use_layout_detection</code></td>
<td>
Whether to load and use the layout detection module. If not set, the parameter will default to the value initialized in the pipeline, which is <code>True</code>.</td>
Whether to load and use the layout detection module. If not set, the parameter will be set to the value initialized in the pipeline, which is <code>True</code> by default.</td>
<td><code>bool</code></td>
<td></td>
</tr>
@@ -836,7 +836,7 @@ Whether to load and use the layout detection module. If not set, the parameter w
</tr>
<tr>
<td><code>layout_nms</code></td>
<td>Whether to use Non-Maximum Suppression (NMS) as post-processing for layout detection. If not set, the parameter will default to the value initialized in the pipeline, which is set to <code>True</code> by default.</td>
<td>Whether to use Non-Maximum Suppression (NMS) as post-processing for layout detection. If not set, the parameter will be set to the value initialized in the pipeline, which is set to <code>True</code> by default.</td>
<td><code>bool</code></td>
<td></td>
</tr>
@@ -1114,7 +1114,7 @@ In the above Python script, the following steps were executed:
</tr>
<tr>
<td><code>use_layout_detection</code></td>
<td>Whether to load and use the layout detection module. If set to <code>None</code>, the parameter will default to the value initialized in the pipeline, which is <code>True</code>.</td>
<td>Whether to load and use the layout detection module. If set to <code>None</code>, the parameter will be set to the value initialized in the pipeline, which is <code>True</code> by default.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -1132,7 +1132,7 @@ In the above Python script, the following steps were executed:
</tr>
<tr>
<td><code>layout_nms</code></td>
<td>Whether to use Non-Maximum Suppression (NMS) as post-processing for layout detection. If set to <code>None</code>, the parameter will default to the value initialized in the pipeline, which is set to <code>True</code> by default.</td>
<td>Whether to use Non-Maximum Suppression (NMS) as post-processing for layout detection. If set to <code>None</code>, the parameter will be set to the value initialized in the pipeline, which is set to <code>True</code> by default.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -1660,26 +1660,6 @@ To remove the page limit, please add the following configuration to the pipeline
<td>No</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>
Whether to return the final visualization image and intermediate images during the processing.<br/>
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>If <code>true</code> is provided: return images.</li>
<li>If <code>false</code> is provided: do not return any images.</li>
<li>If this parameter is omitted from the request body, or if <code>null</code> is explicitly passed, the behavior will follow the value of <code>Serving.visualize</code> in the pipeline configuration.</li>
</ul>
<br/>
For example, adding the following setting to the pipeline config file:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
will disable image return by default. This behavior can be overridden by explicitly setting the <code>visualize</code> parameter in the request.<br/>
If neither the request body nor the configuration file is set (If <code>visualize</code> is set to <code>null</code> in the request and not defined in the configuration file), the image is returned by default.
</td>
<td>No</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>Please refer to the description of the <code>use_doc_orientation_classify</code> parameter of the pipeline object's <code>predict</code> method.</td>
@@ -1757,6 +1737,26 @@ If neither the request body nor the configuration file is set (If <code>visualiz
<td>Please refer to the description of the <code>seal_rec_score_thresh</code> parameter of the pipeline object's <code>predict</code> method.</td>
<td>No</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>
Whether to return the final visualization image and intermediate images during the processing.<br/>
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>If <code>true</code> is provided: return images.</li>
<li>If <code>false</code> is provided: do not return any images.</li>
<li>If this parameter is omitted from the request body, or if <code>null</code> is explicitly passed, the behavior will follow the value of <code>Serving.visualize</code> in the pipeline configuration.</li>
</ul>
<br/>
For example, adding the following setting to the pipeline config file:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
will disable image return by default. This behavior can be overridden by explicitly setting the <code>visualize</code> parameter in the request.<br/>
If neither the request body nor the configuration file is set (If <code>visualize</code> is set to <code>null</code> in the request and not defined in the configuration file), the image is returned by default.
</td>
<td>No</td>
</tr>
</tbody>
</table>
<ul>
@@ -2360,7 +2360,7 @@ The pipeline configuration file not only contains the parameters supported by th
3. Load pipeline Configuration File in CLI
After modifying the configuration file, specify the path of the modified pipeline configuration file using the --paddlex_config parameter in the command line. PaddleOCR will read its contents as the pipeline configuration. Example:
After modifying the configuration file, specify the path of the modified pipeline configuration file using the `--paddlex_config` parameter in the command line. PaddleOCR will read its contents as the pipeline configuration. Example:
```bash
paddleocr seal_recognition --paddlex_config SealRecognition.yaml ...
@@ -2368,7 +2368,7 @@ paddleocr seal_recognition --paddlex_config SealRecognition.yaml ...
4. Load pipeline Configuration File in Python API
When initializing the pipeline object, you can pass the PaddleX pipeline configuration file path or configuration dictionary through the paddlex_config parameter. PaddleOCR will read its contents as the pipeline configuration. Example:
When initializing the pipeline object, you can pass the PaddleX pipeline configuration file path or configuration dictionary through the `paddlex_config` parameter. PaddleOCR will read its contents as the pipeline configuration. Example:
```python
from paddleocr import SealRecognition
@@ -807,39 +807,39 @@ paddleocr seal_recognition -i ./seal_text_det.png --device gpu
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>是否加载并使用文档方向分类模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文档方向分类模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>是否加载并使用文本图像矫正模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本图像矫正模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_layout_detection</code></td>
<td>是否加载并使用版面检测模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用版面检测模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>layout_threshold</code></td>
<td>版面模型得分阈值。<code>0-1</code> 之间的任意浮点数。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>0.5</code>。
<td>版面模型得分阈值。<code>0-1</code> 之间的任意浮点数。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>0.5</code>。
</td>
<td><code>float</code></td>
<td></td>
</tr>
<tr>
<td><code>layout_nms</code></td>
<td>版面检测是否使用后处理NMS。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>版面检测是否使用后处理NMS。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>layout_unclip_ratio</code></td>
<td>检测框的边长缩放倍数。
大于0的浮点数,如 1.1 ,表示将模型输出的检测框中心不变,宽和高都扩张1.1倍如果不设置,将默认使用产线初始化的该参数值,初始化为1.0。
大于0的浮点数,如 1.1 ,表示将模型输出的检测框中心不变,宽和高都扩张1.1倍如果不设置,将使用产线初始化的该参数值,默认初始化为1.0。
</td>
<td><code>float</code></td>
<td></td>
@@ -851,7 +851,7 @@ paddleocr seal_recognition -i ./seal_text_det.png --device gpu
<li><b>large</b>,设置为large时,表示在模型输出的检测框中,对于互相重叠包含的检测框,只保留外部最大的框,删除重叠的内部框;</li>
<li><b>small</b>,设置为small,表示在模型输出的检测框中,对于互相重叠包含的检测框,只保留内部被包含的小框,删除重叠的外部框;</li>
<li><b>union</b>,不进行框的过滤处理,内外框都保留;</li>
</ul>如果不设置,将默认使用产线初始化的该参数值,初始化为<code>large</code>。
</ul>如果不设置,将使用产线初始化的该参数值,默认初始化为<code>large</code>。
</td>
<td><code>str</code></td>
<td></td>
@@ -859,7 +859,7 @@ paddleocr seal_recognition -i ./seal_text_det.png --device gpu
<tr>
<td><code>seal_det_limit_side_len</code></td>
<td>印章文本检测的图像边长限制。
大于 <code>0</code> 的任意整数。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>736</code>。
大于 <code>0</code> 的任意整数。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>736</code>。
</td>
<td><code>int</code></td>
<td></td>
@@ -867,7 +867,7 @@ paddleocr seal_recognition -i ./seal_text_det.png --device gpu
<tr>
<td><code>seal_det_limit_type</code></td>
<td>印章文本检测的图像边长限制类型。
支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code>。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>min</code>。
支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code>。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>min</code>。
</td>
<td><code>str</code></td>
<td></td>
@@ -1101,19 +1101,19 @@ for res in output:
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>是否加载并使用文档方向分类模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文档方向分类模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>是否加载并使用文本图像矫正模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本图像矫正模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_layout_detection</code></td>
<td>是否加载并使用版面检测模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用版面检测模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -1130,7 +1130,7 @@ for res in output:
</tr>
<tr>
<td><code>layout_nms</code></td>
<td>版面检测是否使用后处理NMS。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>版面检测是否使用后处理NMS。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -1141,7 +1141,7 @@ for res in output:
<li><b>float</b>:任意大于 <code>0</code> 浮点数;</li>
<li><b>Tuple[float,float]</b>:在横纵两个方向各自的扩张系数;</li>
<li><b>dict</b>dict的key为<b>int</b>类型,代表<code>cls_id</code>, value为<b>tuple</b>类型,如<code>{0: (1.1, 2.0)}</code>,表示将模型输出的第0类别检测框中心不变,宽度扩张1.1倍,高度扩张2.0倍;</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>1.0</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>1.0</code>。</li>
</ul>
</td>
<td><code>float|Tuple[float,float]|dict|None</code></td>
@@ -1153,7 +1153,7 @@ for res in output:
<ul>
<li><b>str</b><code>large</code><code>small</code><code>union</code>,分别表示重叠框过滤时选择保留大框,小框还是同时保留;</li>
<li><b>dict</b> dict的key为<b>int</b>类型,代表<code>cls_id</code>value为<b>str</b>类型,如<code>{0: "large", 2: "small"}</code>,表示对第0类别检测框使用large模式,对第2类别检测框使用small模式;</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>large</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>large</code>。</li>
</ul>
</td>
<td><code>str|dict|None</code></td>
@@ -1164,7 +1164,7 @@ for res in output:
<td>印章文本检测的图像边长限制。
<ul>
<li><b>int</b>:大于 <code>0</code> 的任意整数;</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>736</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>736</code>。</li>
</ul>
</td>
<td><code>int|None</code></td>
@@ -1175,7 +1175,7 @@ for res in output:
<td>印章文本检测的图像边长限制类型。
<ul>
<li><b>str</b>:支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code></li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>min</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>min</code>。</li>
</ul>
</td>
<td><code>str|None</code></td>
@@ -1654,23 +1654,6 @@ MKL-DNN 缓存容量。
<td>否</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>是否返回可视化结果图以及处理过程中的中间图像等。
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>传入 <code>true</code>:返回图像。</li>
<li>传入 <code>false</code>:不返回图像。</li>
<li>若请求体中未提供该参数或传入 <code>null</code>:遵循产线配置文件<code>Serving.visualize</code> 的设置。</li>
</ul>
<br/>例如,在产线配置文件中添加如下字段:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
将默认不返回图像,通过请求体中的<code>visualize</code>参数可以覆盖默认行为。如果请求体和配置文件中均未设置(或请求体传入<code>null</code>、配置文件中未设置),则默认返回图像。
</td>
<td>否</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>请参阅产线对象中 <code>predict</code> 方法的 <code>use_doc_orientation_classify</code> 参数相关说明。</td>
@@ -1748,6 +1731,23 @@ MKL-DNN 缓存容量。
<td>请参阅产线对象中 <code>predict</code> 方法的 <code>seal_rec_score_thresh</code> 参数相关说明。</td>
<td>否</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>是否返回可视化结果图以及处理过程中的中间图像等。
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>传入 <code>true</code>:返回图像。</li>
<li>传入 <code>false</code>:不返回图像。</li>
<li>若请求体中未提供该参数或传入 <code>null</code>:遵循产线配置文件<code>Serving.visualize</code> 的设置。</li>
</ul>
<br/>例如,在产线配置文件中添加如下字段:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
将默认不返回图像,通过请求体中的<code>visualize</code>参数可以覆盖默认行为。如果请求体和配置文件中均未设置(或请求体传入<code>null</code>、配置文件中未设置),则默认返回图像。
</td>
<td>否</td>
</tr>
</tbody>
</table>
<ul>
@@ -2351,7 +2351,7 @@ SubPipelines:
3. 在 CLI 中加载产线配置文件
在修改完成配置文件后,通过命令行的 --paddlex_config 参数指定修改后的产线配置文件的路径,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
在修改完成配置文件后,通过命令行的 `--paddlex_config` 参数指定修改后的产线配置文件的路径,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
```bash
paddleocr seal_recognition --paddlex_config SealRecognition.yaml ...
@@ -2359,7 +2359,7 @@ paddleocr seal_recognition --paddlex_config SealRecognition.yaml ...
4. 在 Python API 中加载产线配置文件
初始化产线对象时,可通过 paddlex_config 参数传入 PaddleX 产线配置文件路径或配置dict,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
初始化产线对象时,可通过 `paddlex_config` 参数传入 PaddleX 产线配置文件路径或配置dict,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
```python
from paddleocr import SealRecognition
@@ -997,7 +997,7 @@ Local path to image files or PDF files: <code>/root/data/img.jpg</code>; <b>as U
<tr>
<td><code>text_det_limit_side_len</code></td>
<td>Image side length limit for text detection.
Any integer greater than <code>0</code>. If not set, the default value initialized by the pipeline will be used, initialized to <code>960</code>.
Any integer greater than <code>0</code>. If not set, the value initialized by the pipeline will be used, which defaults to <code>960</code>.
</td>
<td><code>int</code></td>
<td></td>
@@ -1005,7 +1005,7 @@ Any integer greater than <code>0</code>. If not set, the default value initializ
<tr>
<td><code>text_det_limit_type</code></td>
<td>Type of the image side length limit for text detection.
Supports <code>min</code> and <code>max</code>. <code>min</code> ensures that the shortest side of the image is not less than <code>det_limit_side_len</code>, while <code>max</code> ensures that the longest side of the image is not greater than <code>limit_side_len</code>. If not set, the default value initialized by the pipeline will be used, initialized to <code>max</code>.
Supports <code>min</code> and <code>max</code>. <code>min</code> ensures that the shortest side of the image is not less than <code>det_limit_side_len</code>, while <code>max</code> ensures that the longest side of the image is not greater than <code>limit_side_len</code>. If not set, the value initialized by the pipeline will be used, which defaults to <code>max</code>.
</td>
<td><code>str</code></td>
<td></td>
@@ -1013,7 +1013,7 @@ Supports <code>min</code> and <code>max</code>. <code>min</code> ensures that th
<tr>
<td><code>text_det_thresh</code></td>
<td>Detection pixel threshold. In the output probability map, only pixels with a score greater than this threshold will be considered text pixels.
Any floating-point number greater than <code>0</code>. If not set, the default value initialized by the pipeline will be used, which is <code>0.3</code>.
Any floating-point number greater than <code>0</code>. If not set, the value initialized by the pipeline will be used, which defaults to <code>0.3</code>.
</td>
<td><code>float</code></td>
<td></td>
@@ -1021,7 +1021,7 @@ Any floating-point number greater than <code>0</code>. If not set, the default v
<tr>
<td><code>text_det_box_thresh</code></td>
<td>Detection box threshold. When the average score of all pixels within the detection result box is greater than this threshold, the result is considered a text area.
Any floating-point number greater than <code>0</code>. If not set, the default value initialized by the pipeline will be used, which is <code>0.6</code>.
Any floating-point number greater than <code>0</code>. If not set, the value initialized by the pipeline will be used, which defaults to <code>0.6</code>.
</td>
<td><code>float</code></td>
<td></td>
@@ -1029,7 +1029,7 @@ Any floating-point number greater than <code>0</code>. If not set, the default v
<tr>
<td><code>text_det_unclip_ratio</code></td>
<td>Text detection expansion coefficient. This method expands the text area; the larger this value, the larger the expanded area.
Any floating-point number greater than <code>0</code>. If not set, the default value initialized by the pipeline will be used, which is <code>2.0</code>.
Any floating-point number greater than <code>0</code>. If not set, the value initialized by the pipeline will be used, which defaults to <code>2.0</code>.
</td>
<td><code>float</code></td>
<td></td>
@@ -1055,32 +1055,32 @@ Any floating-point number greater than <code>0</code>. If not set, the default v
<tr>
<td><code>text_rec_score_thresh</code></td>
<td>Text recognition threshold. Text results with a score greater than this threshold will be retained.
Any floating-point number greater than <code>0</code>. If not set, the default value initialized by the pipeline will be used, which is <code>0.0</code>. That is, no threshold is set.
Any floating-point number greater than <code>0</code>. If not set, the value initialized by the pipeline will be used, which defaults to <code>0.0</code>. That is, no threshold is set.
</td>
<td><code>float</code></td>
<td></td>
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>Whether to load and use the document orientation classification module. If not set, the default value initialized by the pipeline will be used, initialized to <code>True</code>.</td>
<td>Whether to load and use the document orientation classification module. If not set, the value initialized by the pipeline will be used, which defaults to <code>True</code>.</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>Whether to load and use the text image unwarping module. If not set, the default value initialized by the pipeline will be used, initialized to <code>True</code>.</td>
<td>Whether to load and use the text image unwarping module. If not set, the value initialized by the pipeline will be used, which defaults to <code>True</code>.</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_layout_detection</code></td>
<td>Whether to load and use the layout detection module. If not set, the default value initialized by the pipeline will be used, initialized to <code>True</code>.</td>
<td>Whether to load and use the layout detection module. If not set, the value initialized by the pipeline will be used, which defaults to <code>True</code>.</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_ocr_model</code></td>
<td>Whether to load and use the OCR module. If not set, the default value initialized by the pipeline will be used, initialized to <code>True</code>.</td>
<td>Whether to load and use the OCR module. If not set, the value initialized by the pipeline will be used, which defaults to <code>True</code>.</td>
<td><code>bool</code></td>
<td></td>
</tr>
@@ -1342,7 +1342,7 @@ In the above Python script, the following steps are performed:
<td>Image side length limit for text detection.
<ul>
<li><b>int</b>: Any integer greater than <code>0</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the default value initialized by the pipeline will be used, initialized to <code>960</code>.</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline will be used, which defaults to <code>960</code>.</li>
</ul>
</td>
<td><code>int|None</code></td>
@@ -1353,7 +1353,7 @@ In the above Python script, the following steps are performed:
<td>Type of the image side length limit for text detection.
<ul>
<li><b>str</b>: Supports <code>min</code> and <code>max</code>. <code>min</code> ensures that the shortest side of the image is not less than <code>det_limit_side_len</code>, while <code>max</code> ensures that the longest side of the image is not greater than <code>limit_side_len</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the default value initialized by the pipeline will be used, initialized to <code>max</code>.</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline will be used, which defaults to <code>max</code>.</li>
</ul>
</td>
<td><code>str|None</code></td>
@@ -1364,7 +1364,7 @@ In the above Python script, the following steps are performed:
<td>Detection pixel threshold. In the output probability map, only pixels with a score greater than this threshold will be considered text pixels.
<ul>
<li><b>float</b>: Any floating-point number greater than <code>0</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the default value initialized by the pipeline will be used, which is <code>0.3</code>.</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline will be used, which defaults to <code>0.3</code>.</li>
</ul>
</td>
<td><code>float|None</code></td>
@@ -1375,7 +1375,7 @@ In the above Python script, the following steps are performed:
<td>Detection box threshold. When the average score of all pixels within the detection result box is greater than this threshold, the result is considered a text area.
<ul>
<li><b>float</b>: Any floating-point number greater than <code>0</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the default value initialized by the pipeline will be used, which is <code>0.6</code>.</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline will be used, which defaults to <code>0.6</code>.</li>
</ul>
</td>
<td><code>float|None</code></td>
@@ -1386,7 +1386,7 @@ In the above Python script, the following steps are performed:
<td>Text detection expansion coefficient. This method expands the text area; the larger this value, the larger the expanded area.
<ul>
<li><b>float</b>: Any floating-point number greater than <code>0</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the default value initialized by the pipeline will be used, which is <code>2.0</code>.</li>
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline will be used, which defaults to <code>2.0</code>.</li>
</ul>
</td>
<td><code>float|None</code></td>
@@ -1415,7 +1415,7 @@ In the above Python script, the following steps are performed:
<td>Text recognition threshold. Text results with a score greater than this threshold will be retained.
<ul>
<li><b>float</b>: Any floating-point number greater than <code>0</code>;</li>
<li><b>None</b>: If set to <code>None</code>, the default value initialized by the pipeline will be used, which is <code>0.0</code>. That is, no threshold is set.
<li><b>None</b>: If set to <code>None</code>, the value initialized by the pipeline will be used, which defaults to <code>0.0</code>. That is, no threshold is set.
</ur>
</td>
<td><code>float|None</code></td>
@@ -1423,25 +1423,25 @@ In the above Python script, the following steps are performed:
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>Whether to load and use the document orientation classification module. If set to <code>None</code>, the default value initialized by the pipeline will be used, initialized to <code>True</code>.</td>
<td>Whether to load and use the document orientation classification module. If set to <code>None</code>, the value initialized by the pipeline will be used, which defaults to <code>True</code>.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>Whether to load and use the text image unwarping module. If set to <code>None</code>, the default value initialized by the pipeline will be used, initialized to <code>True</code>.</td>
<td>Whether to load and use the text image unwarping module. If set to <code>None</code>, the value initialized by the pipeline will be used, which defaults to <code>True</code>.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_layout_detection</code></td>
<td>Whether to load and use the layout detection module. If set to <code>None</code>, the default value initialized by the pipeline will be used, initialized to <code>True</code>.</td>
<td>Whether to load and use the layout detection module. If set to <code>None</code>, the value initialized by the pipeline will be used, which defaults to <code>True</code>.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_ocr_model</code></td>
<td>Whether to load and use the OCR module. If set to <code>None</code>, the default value initialized by the pipeline will be used, initialized to <code>True</code>.</td>
<td>Whether to load and use the OCR module. If set to <code>None</code>, the value initialized by the pipeline will be used, which defaults to <code>True</code>.</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -1911,26 +1911,6 @@ Below is the API reference for basic service-oriented deployment and examples of
<td>No</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>
Whether to return the final visualization image and intermediate images during the processing.<br/>
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>If <code>true</code> is provided: return images.</li>
<li>If <code>false</code> is provided: do not return any images.</li>
<li>If this parameter is omitted from the request body, or if <code>null</code> is explicitly passed, the behavior will follow the value of <code>Serving.visualize</code> in the pipeline configuration.</li>
</ul>
<br/>
For example, adding the following setting to the pipeline config file:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
will disable image return by default. This behavior can be overridden by explicitly setting the <code>visualize</code> parameter in the request.<br/>
If neither the request body nor the configuration file is set (If <code>visualize</code> is set to <code>null</code> in the request and not defined in the configuration file), the image is returned by default.
</td>
<td>No</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>Please refer to the <code>use_doc_orientation_classify</code> parameter description in the <code>predict</code> method of the model object.</td>
@@ -2008,6 +1988,26 @@ If neither the request body nor the configuration file is set (If <code>visualiz
<td>Please refer to the <code>use_e2e_wireless_table_rec_model</code> parameter description in the <code>predict</code> method of the model object.</td>
<td>No</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>
Whether to return the final visualization image and intermediate images during the processing.<br/>
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>If <code>true</code> is provided: return images.</li>
<li>If <code>false</code> is provided: do not return any images.</li>
<li>If this parameter is omitted from the request body, or if <code>null</code> is explicitly passed, the behavior will follow the value of <code>Serving.visualize</code> in the pipeline configuration.</li>
</ul>
<br/>
For example, adding the following setting to the pipeline config file:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
will disable image return by default. This behavior can be overridden by explicitly setting the <code>visualize</code> parameter in the request.<br/>
If neither the request body nor the configuration file is set (If <code>visualize</code> is set to <code>null</code> in the request and not defined in the configuration file), the image is returned by default.
</td>
<td>No</td>
</tr>
</tbody>
</table>
<ul>
@@ -2681,7 +2681,7 @@ The pipeline configuration file includes not only the parameters supported by Pa
3. Loading the pipeline configuration file in CLI
After completing the configuration file modifications, specify the path to the modified pipeline configuration file using the --paddlex_config parameter in the command line. PaddleOCR will read its contents as the pipeline configuration. For example:
After completing the configuration file modifications, specify the path to the modified pipeline configuration file using the `--paddlex_config` parameter in the command line. PaddleOCR will read its contents as the pipeline configuration. For example:
```bash
paddleocr table_recognition_v2_pipeline --paddlex_config PaddleOCR.yaml ...
@@ -2689,7 +2689,7 @@ paddleocr table_recognition_v2_pipeline --paddlex_config PaddleOCR.yaml ...
4. Loading the pipeline configuration file in Python API
When initializing the pipeline object, you can pass the PaddleX pipeline configuration file path or configuration dictionary through the paddlex_config parameter. PaddleOCR will read its contents as the pipeline configuration. For example:
When initializing the pipeline object, you can pass the PaddleX pipeline configuration file path or configuration dictionary through the `paddlex_config` parameter. PaddleOCR will read its contents as the pipeline configuration. For example:
```python
from paddleocr import TableRecognitionPipelineV2
@@ -999,7 +999,7 @@ paddleocr table_recognition_v2 -i ./table_recognition_v2.jpg --device gpu
<tr>
<td><code>text_det_limit_side_len</code></td>
<td>文本检测的图像边长限制。
大于 <code>0</code> 的任意整数。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>960</code>。
大于 <code>0</code> 的任意整数。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>960</code>。
</td>
<td><code>int</code></td>
<td></td>
@@ -1007,7 +1007,7 @@ paddleocr table_recognition_v2 -i ./table_recognition_v2.jpg --device gpu
<tr>
<td><code>text_det_limit_type</code></td>
<td>文本检测的图像边长限制类型。
支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code>。如果不设置,将默认使用产线初始化的该参数值,初始化为 <code>max</code>。
支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code>。如果不设置,将使用产线初始化的该参数值,默认初始化为 <code>max</code>。
</td>
<td><code>str</code></td>
<td></td>
@@ -1068,25 +1068,25 @@ paddleocr table_recognition_v2 -i ./table_recognition_v2.jpg --device gpu
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>是否加载并使用文档方向分类模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文档方向分类模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>是否加载并使用文本图像矫正模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本图像矫正模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_layout_detection</code></td>
<td>是否加载并使用版面检测模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用版面检测模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
<tr>
<td><code>use_ocr_model</code></td>
<td>是否加载并使用OCR模块。如果不设置,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用OCR模块。如果不设置,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool</code></td>
<td></td>
</tr>
@@ -1348,7 +1348,7 @@ for res in output:
<td>文本检测的图像边长限制。
<ul>
<li><b>int</b>:大于 <code>0</code> 的任意整数;</li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>960</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>960</code>。</li>
</ul>
</td>
<td><code>int|None</code></td>
@@ -1359,7 +1359,7 @@ for res in output:
<td>文本检测的图像边长限制类型。
<ul>
<li><b>str</b>:支持 <code>min</code> 和 <code>max</code><code>min</code> 表示保证图像最短边不小于 <code>det_limit_side_len</code><code>max</code> 表示保证图像最长边不大于 <code>limit_side_len</code></li>
<li><b>None</b>:如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为 <code>max</code>。</li>
<li><b>None</b>:如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为 <code>max</code>。</li>
</ul>
</td>
<td><code>str|None</code></td>
@@ -1425,25 +1425,25 @@ for res in output:
</tr>
<tr>
<td><code>use_doc_orientation_classify</code></td>
<td>是否加载并使用文档方向分类模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文档方向分类模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_doc_unwarping</code></td>
<td>是否加载并使用文本图像矫正模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用文本图像矫正模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_layout_detection</code></td>
<td>是否加载并使用版面检测模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用版面检测模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
<tr>
<td><code>use_ocr_model</code></td>
<td>是否加载并使用OCR模块。如果设置为<code>None</code>,将默认使用产线初始化的该参数值,初始化为<code>True</code>。</td>
<td>是否加载并使用OCR模块。如果设置为<code>None</code>,将使用产线初始化的该参数值,默认初始化为<code>True</code>。</td>
<td><code>bool|None</code></td>
<td><code>None</code></td>
</tr>
@@ -1912,23 +1912,6 @@ MKL-DNN 缓存容量。
<td>否</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>是否返回可视化结果图以及处理过程中的中间图像等。
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>传入 <code>true</code>:返回图像。</li>
<li>传入 <code>false</code>:不返回图像。</li>
<li>若请求体中未提供该参数或传入 <code>null</code>:遵循产线配置文件<code>Serving.visualize</code> 的设置。</li>
</ul>
<br/>例如,在产线配置文件中添加如下字段:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
将默认不返回图像,通过请求体中的<code>visualize</code>参数可以覆盖默认行为。如果请求体和配置文件中均未设置(或请求体传入<code>null</code>、配置文件中未设置),则默认返回图像。
</td>
<td>否</td>
</tr>
<tr>
<td><code>useDocOrientationClassify</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>请参阅产线对象中 <code>predict</code> 方法的 <code>use_doc_orientation_classify</code> 参数相关说明。</td>
@@ -2006,6 +1989,23 @@ MKL-DNN 缓存容量。
<td>请参阅产线对象中 <code>predict</code> 方法的 <code>use_e2e_wireless_table_rec_model</code> 参数相关说明。</td>
<td>否</td>
</tr>
<tr>
<td><code>visualize</code></td>
<td><code>boolean</code> | <code>null</code></td>
<td>是否返回可视化结果图以及处理过程中的中间图像等。
<ul style="margin: 0 0 0 1em; padding-left: 0em;">
<li>传入 <code>true</code>:返回图像。</li>
<li>传入 <code>false</code>:不返回图像。</li>
<li>若请求体中未提供该参数或传入 <code>null</code>:遵循产线配置文件<code>Serving.visualize</code> 的设置。</li>
</ul>
<br/>例如,在产线配置文件中添加如下字段:<br/>
<pre><code>Serving:
visualize: False
</code></pre>
将默认不返回图像,通过请求体中的<code>visualize</code>参数可以覆盖默认行为。如果请求体和配置文件中均未设置(或请求体传入<code>null</code>、配置文件中未设置),则默认返回图像。
</td>
<td>否</td>
</tr>
</tbody>
</table>
<ul>
@@ -2680,7 +2680,7 @@ SubPipelines:
3.在 CLI 中加载产线配置文件
在修改完成配置文件后,通过命令行的 --paddlex_config 参数指定修改后的产线配置文件的路径,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
在修改完成配置文件后,通过命令行的 `--paddlex_config` 参数指定修改后的产线配置文件的路径,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
```bash
paddleocr table_recognition_v2_pipeline --paddlex_config PaddleOCR.yaml ...
@@ -2688,7 +2688,7 @@ paddleocr table_recognition_v2_pipeline --paddlex_config PaddleOCR.yaml ...
4.在 Python API 中加载产线配置文件
初始化产线对象时,可通过 paddlex_config 参数传入 PaddleX 产线配置文件路径或配置dict,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
初始化产线对象时,可通过 `paddlex_config` 参数传入 PaddleX 产线配置文件路径或配置dict,PaddleOCR 会读取其中的内容作为产线配置。示例如下:
```python
from paddleocr import TableRecognitionPipelineV2
+1
View File
@@ -303,6 +303,7 @@ nav:
- 文档理解产线: version3.x/pipeline_usage/doc_understanding.md
- 印章文本识别产线: version3.x/pipeline_usage/seal_recognition.md
- 通用表格识别v2产线: version3.x/pipeline_usage/table_recognition_v2.md
- PP-DocTranslation产线: version3.x/pipeline_usage/PP-DocTranslation.md
- 多硬件使用:
- PaddleOCR 多硬件使用指南: version3.x/other_devices_support/multi_devices_use_guide.md
- 昇腾 NPU 飞桨安装教程: version3.x/other_devices_support/paddlepaddle_install_NPU.md
+2
View File
@@ -32,6 +32,7 @@ from ._pipelines import (
FormulaRecognitionPipeline,
PaddleOCR,
PPChatOCRv4Doc,
PPDocTranslation,
PPStructureV3,
SealRecognition,
TableRecognitionPipelineV2,
@@ -57,6 +58,7 @@ __all__ = [
"FormulaRecognitionPipeline",
"PaddleOCR",
"PPChatOCRv4Doc",
"PPDocTranslation",
"PPStructureV3",
"SealRecognition",
"TableRecognitionPipelineV2",
+2
View File
@@ -38,6 +38,7 @@ from ._pipelines import (
FormulaRecognitionPipeline,
PaddleOCR,
PPChatOCRv4Doc,
PPDocTranslation,
PPStructureV3,
SealRecognition,
TableRecognitionPipelineV2,
@@ -54,6 +55,7 @@ def _register_pipelines(subparsers):
FormulaRecognitionPipeline,
PaddleOCR,
PPChatOCRv4Doc,
PPDocTranslation,
PPStructureV3,
SealRecognition,
TableRecognitionPipelineV2,
+2
View File
@@ -17,6 +17,7 @@ from .doc_understanding import DocUnderstanding
from .formula_recognition import FormulaRecognitionPipeline
from .ocr import PaddleOCR
from .pp_chatocrv4_doc import PPChatOCRv4Doc
from .pp_doctranslation import PPDocTranslation
from .pp_structurev3 import PPStructureV3
from .seal_recognition import SealRecognition
from .table_recognition_v2 import TableRecognitionPipelineV2
@@ -27,6 +28,7 @@ __all__ = [
"FormulaRecognitionPipeline",
"PaddleOCR",
"PPChatOCRv4Doc",
"PPDocTranslation",
"PPStructureV3",
"SealRecognition",
"TableRecognitionPipelineV2",
+2 -2
View File
@@ -422,9 +422,9 @@ class PPChatOCRv4DocCLISubcommandExecutor(PipelineCLISubcommandExecutor):
subparser.add_argument(
"--save_path",
type=str,
default="output",
help="Path to the output directory.",
)
subparser.add_argument(
"--invoke_mllm",
type=str2bool,
@@ -693,7 +693,7 @@ class PPChatOCRv4DocCLISubcommandExecutor(PipelineCLISubcommandExecutor):
chatocr = PPChatOCRv4Doc(**params)
result_visual = chatocr.visual_predict(input)
result_visual = chatocr.visual_predict_iter(input)
visual_info_list = []
for res in result_visual:
+936
View File
@@ -0,0 +1,936 @@
# 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 (
get_subcommand_args,
str2bool,
)
from .._utils.logging import logger
from .base import PaddleXPipelineWrapper, PipelineCLISubcommandExecutor
from .utils import create_config_from_structure
class PPDocTranslation(PaddleXPipelineWrapper):
def __init__(
self,
layout_detection_model_name=None,
layout_detection_model_dir=None,
layout_threshold=None,
layout_nms=None,
layout_unclip_ratio=None,
layout_merge_bboxes_mode=None,
chart_recognition_model_name=None,
chart_recognition_model_dir=None,
chart_recognition_batch_size=None,
region_detection_model_name=None,
region_detection_model_dir=None,
doc_orientation_classify_model_name=None,
doc_orientation_classify_model_dir=None,
doc_unwarping_model_name=None,
doc_unwarping_model_dir=None,
text_detection_model_name=None,
text_detection_model_dir=None,
text_det_limit_side_len=None,
text_det_limit_type=None,
text_det_thresh=None,
text_det_box_thresh=None,
text_det_unclip_ratio=None,
textline_orientation_model_name=None,
textline_orientation_model_dir=None,
textline_orientation_batch_size=None,
text_recognition_model_name=None,
text_recognition_model_dir=None,
text_recognition_batch_size=None,
text_rec_score_thresh=None,
table_classification_model_name=None,
table_classification_model_dir=None,
wired_table_structure_recognition_model_name=None,
wired_table_structure_recognition_model_dir=None,
wireless_table_structure_recognition_model_name=None,
wireless_table_structure_recognition_model_dir=None,
wired_table_cells_detection_model_name=None,
wired_table_cells_detection_model_dir=None,
wireless_table_cells_detection_model_name=None,
wireless_table_cells_detection_model_dir=None,
table_orientation_classify_model_name=None,
table_orientation_classify_model_dir=None,
seal_text_detection_model_name=None,
seal_text_detection_model_dir=None,
seal_det_limit_side_len=None,
seal_det_limit_type=None,
seal_det_thresh=None,
seal_det_box_thresh=None,
seal_det_unclip_ratio=None,
seal_text_recognition_model_name=None,
seal_text_recognition_model_dir=None,
seal_text_recognition_batch_size=None,
seal_rec_score_thresh=None,
formula_recognition_model_name=None,
formula_recognition_model_dir=None,
formula_recognition_batch_size=None,
use_doc_orientation_classify=None,
use_doc_unwarping=None,
use_textline_orientation=None,
use_seal_recognition=None,
use_table_recognition=None,
use_formula_recognition=None,
use_chart_recognition=None,
use_region_detection=None,
chat_bot_config=None,
**kwargs,
):
params = locals().copy()
params.pop("self")
params.pop("kwargs")
self._params = params
super().__init__(**kwargs)
@property
def _paddlex_pipeline_name(self):
return "PP-DocTranslation"
def visual_predict_iter(
self,
input,
*,
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=None,
use_seal_recognition=None,
use_table_recognition=None,
use_formula_recognition=None,
use_chart_recognition=False,
use_region_detection=None,
layout_threshold=None,
layout_nms=None,
layout_unclip_ratio=None,
layout_merge_bboxes_mode=None,
text_det_limit_side_len=None,
text_det_limit_type=None,
text_det_thresh=None,
text_det_box_thresh=None,
text_det_unclip_ratio=None,
text_rec_score_thresh=None,
seal_det_limit_side_len=None,
seal_det_limit_type=None,
seal_det_thresh=None,
seal_det_box_thresh=None,
seal_det_unclip_ratio=None,
seal_rec_score_thresh=None,
use_wired_table_cells_trans_to_html=False,
use_wireless_table_cells_trans_to_html=False,
use_table_orientation_classify=True,
use_ocr_results_with_table_cells=True,
use_e2e_wired_table_rec_model=False,
use_e2e_wireless_table_rec_model=True,
**kwargs,
):
return self.paddlex_pipeline.visual_predict(
input,
use_doc_orientation_classify=use_doc_orientation_classify,
use_doc_unwarping=use_doc_unwarping,
use_textline_orientation=use_textline_orientation,
use_seal_recognition=use_seal_recognition,
use_table_recognition=use_table_recognition,
use_formula_recognition=use_formula_recognition,
use_chart_recognition=use_chart_recognition,
use_region_detection=use_region_detection,
layout_threshold=layout_threshold,
layout_nms=layout_nms,
layout_unclip_ratio=layout_unclip_ratio,
layout_merge_bboxes_mode=layout_merge_bboxes_mode,
text_det_limit_side_len=text_det_limit_side_len,
text_det_limit_type=text_det_limit_type,
text_det_thresh=text_det_thresh,
text_det_box_thresh=text_det_box_thresh,
text_det_unclip_ratio=text_det_unclip_ratio,
text_rec_score_thresh=text_rec_score_thresh,
seal_det_limit_side_len=seal_det_limit_side_len,
seal_det_limit_type=seal_det_limit_type,
seal_det_thresh=seal_det_thresh,
seal_det_box_thresh=seal_det_box_thresh,
seal_det_unclip_ratio=seal_det_unclip_ratio,
seal_rec_score_thresh=seal_rec_score_thresh,
use_wired_table_cells_trans_to_html=use_wired_table_cells_trans_to_html,
use_wireless_table_cells_trans_to_html=use_wireless_table_cells_trans_to_html,
use_table_orientation_classify=use_table_orientation_classify,
use_ocr_results_with_table_cells=use_ocr_results_with_table_cells,
use_e2e_wired_table_rec_model=use_e2e_wired_table_rec_model,
use_e2e_wireless_table_rec_model=use_e2e_wireless_table_rec_model,
**kwargs,
)
def visual_predict(
self,
input,
*,
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=None,
use_seal_recognition=None,
use_table_recognition=None,
use_formula_recognition=None,
use_chart_recognition=False,
use_region_detection=None,
layout_threshold=None,
layout_nms=None,
layout_unclip_ratio=None,
layout_merge_bboxes_mode=None,
text_det_limit_side_len=None,
text_det_limit_type=None,
text_det_thresh=None,
text_det_box_thresh=None,
text_det_unclip_ratio=None,
text_rec_score_thresh=None,
seal_det_limit_side_len=None,
seal_det_limit_type=None,
seal_det_thresh=None,
seal_det_box_thresh=None,
seal_det_unclip_ratio=None,
seal_rec_score_thresh=None,
use_wired_table_cells_trans_to_html=False,
use_wireless_table_cells_trans_to_html=False,
use_table_orientation_classify=True,
use_ocr_results_with_table_cells=True,
use_e2e_wired_table_rec_model=False,
use_e2e_wireless_table_rec_model=True,
**kwargs,
):
return list(
self.visual_predict_iter(
input,
use_doc_orientation_classify=use_doc_orientation_classify,
use_doc_unwarping=use_doc_unwarping,
use_textline_orientation=use_textline_orientation,
use_seal_recognition=use_seal_recognition,
use_table_recognition=use_table_recognition,
use_formula_recognition=use_formula_recognition,
use_chart_recognition=use_chart_recognition,
use_region_detection=use_region_detection,
layout_threshold=layout_threshold,
layout_nms=layout_nms,
layout_unclip_ratio=layout_unclip_ratio,
layout_merge_bboxes_mode=layout_merge_bboxes_mode,
text_det_limit_side_len=text_det_limit_side_len,
text_det_limit_type=text_det_limit_type,
text_det_thresh=text_det_thresh,
text_det_box_thresh=text_det_box_thresh,
text_det_unclip_ratio=text_det_unclip_ratio,
text_rec_score_thresh=text_rec_score_thresh,
seal_det_limit_side_len=seal_det_limit_side_len,
seal_det_limit_type=seal_det_limit_type,
seal_det_thresh=seal_det_thresh,
seal_det_box_thresh=seal_det_box_thresh,
seal_det_unclip_ratio=seal_det_unclip_ratio,
seal_rec_score_thresh=seal_rec_score_thresh,
use_wired_table_cells_trans_to_html=use_wired_table_cells_trans_to_html,
use_wireless_table_cells_trans_to_html=use_wireless_table_cells_trans_to_html,
use_table_orientation_classify=use_table_orientation_classify,
use_ocr_results_with_table_cells=use_ocr_results_with_table_cells,
use_e2e_wired_table_rec_model=use_e2e_wired_table_rec_model,
use_e2e_wireless_table_rec_model=use_e2e_wireless_table_rec_model,
**kwargs,
)
)
def translate_iter(
self,
ori_md_info_list,
*,
target_language="zh",
chunk_size=5000,
task_description=None,
output_format=None,
rules_str=None,
few_shot_demo_text_content=None,
few_shot_demo_key_value_list=None,
chat_bot_config=None,
**kwargs,
):
return self.paddlex_pipeline.translate(
ori_md_info_list,
target_language=target_language,
chunk_size=chunk_size,
task_description=task_description,
output_format=output_format,
rules_str=rules_str,
few_shot_demo_text_content=few_shot_demo_text_content,
few_shot_demo_key_value_list=few_shot_demo_key_value_list,
chat_bot_config=chat_bot_config,
**kwargs,
)
def translate(
self,
ori_md_info_list,
*,
target_language="zh",
chunk_size=5000,
task_description=None,
output_format=None,
rules_str=None,
few_shot_demo_text_content=None,
few_shot_demo_key_value_list=None,
chat_bot_config=None,
**kwargs,
):
return list(
self.translate_iter(
ori_md_info_list,
target_language=target_language,
chunk_size=chunk_size,
task_description=task_description,
output_format=output_format,
rules_str=rules_str,
few_shot_demo_text_content=few_shot_demo_text_content,
few_shot_demo_key_value_list=few_shot_demo_key_value_list,
chat_bot_config=chat_bot_config,
**kwargs,
)
)
def load_from_markdown(self, input):
return self.paddlex_pipeline.load_from_markdown(input)
def concatenate_markdown_pages(self, markdown_list):
return self.paddlex_pipeline.concatenate_markdown_pages(markdown_list)
@classmethod
def get_cli_subcommand_executor(cls):
return PPDocTranslationCLISubcommandExecutor()
def _get_paddlex_config_overrides(self):
# HACK: We should consider reducing duplication.
STRUCTURE = {
"SubPipelines.LayoutParser.SubPipelines.DocPreprocessor.use_doc_orientation_classify": self._params[
"use_doc_orientation_classify"
],
"SubPipelines.LayoutParser.SubPipelines.DocPreprocessor.use_doc_unwarping": self._params[
"use_doc_unwarping"
],
"SubPipelines.LayoutParser.SubPipelines.GeneralOCR.use_textline_orientation": self._params[
"use_textline_orientation"
],
"SubPipelines.LayoutParser.use_seal_recognition": self._params[
"use_seal_recognition"
],
"SubPipelines.LayoutParser.use_table_recognition": self._params[
"use_table_recognition"
],
"SubPipelines.LayoutParser.use_formula_recognition": self._params[
"use_formula_recognition"
],
"SubPipelines.LayoutParser.use_chart_recognition": self._params[
"use_chart_recognition"
],
"SubPipelines.LayoutParser.use_region_detection": self._params[
"use_region_detection"
],
"SubPipelines.LayoutParser.SubModules.LayoutDetection.model_name": self._params[
"layout_detection_model_name"
],
"SubPipelines.LayoutParser.SubModules.LayoutDetection.model_dir": self._params[
"layout_detection_model_dir"
],
"SubPipelines.LayoutParser.SubModules.LayoutDetection.threshold": self._params[
"layout_threshold"
],
"SubPipelines.LayoutParser.SubModules.LayoutDetection.layout_nms": self._params[
"layout_nms"
],
"SubPipelines.LayoutParser.SubModules.LayoutDetection.layout_unclip_ratio": self._params[
"layout_unclip_ratio"
],
"SubPipelines.LayoutParser.SubModules.LayoutDetection.layout_merge_bboxes_mode": self._params[
"layout_merge_bboxes_mode"
],
"SubPipelines.LayoutParser.SubModules.ChartRecognition.model_name": self._params[
"chart_recognition_model_name"
],
"SubPipelines.LayoutParser.SubModules.ChartRecognition.model_dir": self._params[
"chart_recognition_model_dir"
],
"SubPipelines.LayoutParser.SubModules.ChartRecognition.batch_size": self._params[
"chart_recognition_batch_size"
],
"SubPipelines.LayoutParser.SubModules.RegionDetection.model_name": self._params[
"region_detection_model_name"
],
"SubPipelines.LayoutParser.SubModules.RegionDetection.model_dir": self._params[
"region_detection_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.DocPreprocessor.SubModules.DocOrientationClassify.model_name": self._params[
"doc_orientation_classify_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.DocPreprocessor.SubModules.DocOrientationClassify.model_dir": self._params[
"doc_orientation_classify_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.DocPreprocessor.SubModules.DocUnwarping.model_name": self._params[
"doc_unwarping_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.DocPreprocessor.SubModules.DocUnwarping.model_dir": self._params[
"doc_unwarping_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.GeneralOCR.SubModules.TextDetection.model_name": self._params[
"text_detection_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.GeneralOCR.SubModules.TextDetection.model_dir": self._params[
"text_detection_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.GeneralOCR.SubModules.TextDetection.limit_side_len": self._params[
"text_det_limit_side_len"
],
"SubPipelines.LayoutParser.SubPipelines.GeneralOCR.SubModules.TextDetection.limit_type": self._params[
"text_det_limit_type"
],
"SubPipelines.LayoutParser.SubPipelines.GeneralOCR.SubModules.TextDetection.thresh": self._params[
"text_det_thresh"
],
"SubPipelines.LayoutParser.SubPipelines.GeneralOCR.SubModules.TextDetection.box_thresh": self._params[
"text_det_box_thresh"
],
"SubPipelines.LayoutParser.SubPipelines.GeneralOCR.SubModules.TextDetection.unclip_ratio": self._params[
"text_det_unclip_ratio"
],
"SubPipelines.LayoutParser.SubPipelines.GeneralOCR.SubModules.TextLineOrientation.model_name": self._params[
"textline_orientation_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.GeneralOCR.SubModules.TextLineOrientation.model_dir": self._params[
"textline_orientation_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.GeneralOCR.SubModules.TextLineOrientation.batch_size": self._params[
"textline_orientation_batch_size"
],
"SubPipelines.LayoutParser.SubPipelines.GeneralOCR.SubModules.TextRecognition.model_name": self._params[
"text_recognition_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.GeneralOCR.SubModules.TextRecognition.model_dir": self._params[
"text_recognition_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.GeneralOCR.SubModules.TextRecognition.batch_size": self._params[
"text_recognition_batch_size"
],
"SubPipelines.LayoutParser.SubPipelines.GeneralOCR.SubModules.TextRecognition.score_thresh": self._params[
"text_rec_score_thresh"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubModules.TableClassification.model_name": self._params[
"table_classification_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubModules.TableClassification.model_dir": self._params[
"table_classification_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubModules.WiredTableStructureRecognition.model_name": self._params[
"wired_table_structure_recognition_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubModules.WiredTableStructureRecognition.model_dir": self._params[
"wired_table_structure_recognition_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubModules.WirelessTableStructureRecognition.model_name": self._params[
"wireless_table_structure_recognition_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubModules.WirelessTableStructureRecognition.model_dir": self._params[
"wireless_table_structure_recognition_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubModules.WiredTableCellsDetection.model_name": self._params[
"wired_table_cells_detection_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubModules.WiredTableCellsDetection.model_dir": self._params[
"wired_table_cells_detection_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubModules.WirelessTableCellsDetection.model_name": self._params[
"wireless_table_cells_detection_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubModules.WirelessTableCellsDetection.model_dir": self._params[
"wireless_table_cells_detection_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubModules.TableOrientationClassify.model_name": self._params[
"table_orientation_classify_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubModules.TableOrientationClassify.model_dir": self._params[
"table_orientation_classify_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubPipelines.GeneralOCR.SubModules.TextDetection.model_name": self._params[
"text_detection_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubPipelines.GeneralOCR.SubModules.TextDetection.model_dir": self._params[
"text_detection_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubPipelines.GeneralOCR.SubModules.TextDetection.limit_side_len": self._params[
"text_det_limit_side_len"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubPipelines.GeneralOCR.SubModules.TextDetection.limit_type": self._params[
"text_det_limit_type"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubPipelines.GeneralOCR.SubModules.TextDetection.thresh": self._params[
"text_det_thresh"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubPipelines.GeneralOCR.SubModules.TextDetection.box_thresh": self._params[
"text_det_box_thresh"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubPipelines.GeneralOCR.SubModules.TextDetection.unclip_ratio": self._params[
"text_det_unclip_ratio"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubPipelines.GeneralOCR.SubModules.TextLineOrientation.model_name": self._params[
"textline_orientation_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubPipelines.GeneralOCR.SubModules.TextLineOrientation.model_dir": self._params[
"textline_orientation_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubPipelines.GeneralOCR.SubModules.TextLineOrientation.batch_size": self._params[
"textline_orientation_batch_size"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubPipelines.GeneralOCR.SubModules.TextRecognition.model_name": self._params[
"text_recognition_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubPipelines.GeneralOCR.SubModules.TextRecognition.model_dir": self._params[
"text_recognition_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubPipelines.GeneralOCR.SubModules.TextRecognition.batch_size": self._params[
"text_recognition_batch_size"
],
"SubPipelines.LayoutParser.SubPipelines.TableRecognition.SubPipelines.GeneralOCR.SubModules.TextRecognition.score_thresh": self._params[
"text_rec_score_thresh"
],
"SubPipelines.LayoutParser.SubPipelines.SealRecognition.SubPipelines.SealOCR.SubModules.TextDetection.model_name": self._params[
"seal_text_detection_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.SealRecognition.SubPipelines.SealOCR.SubModules.TextDetection.model_dir": self._params[
"seal_text_detection_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.SealRecognition.SubPipelines.SealOCR.SubModules.TextDetection.limit_side_len": self._params[
"text_det_limit_side_len"
],
"SubPipelines.LayoutParser.SubPipelines.SealRecognition.SubPipelines.SealOCR.SubModules.TextDetection.limit_type": self._params[
"seal_det_limit_type"
],
"SubPipelines.LayoutParser.SubPipelines.SealRecognition.SubPipelines.SealOCR.SubModules.TextDetection.thresh": self._params[
"seal_det_thresh"
],
"SubPipelines.LayoutParser.SubPipelines.SealRecognition.SubPipelines.SealOCR.SubModules.TextDetection.box_thresh": self._params[
"seal_det_box_thresh"
],
"SubPipelines.LayoutParser.SubPipelines.SealRecognition.SubPipelines.SealOCR.SubModules.TextDetection.unclip_ratio": self._params[
"seal_det_unclip_ratio"
],
"SubPipelines.LayoutParser.SubPipelines.SealRecognition.SubPipelines.SealOCR.SubModules.TextRecognition.model_name": self._params[
"seal_text_recognition_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.SealRecognition.SubPipelines.SealOCR.SubModules.TextRecognition.model_dir": self._params[
"seal_text_recognition_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.SealRecognition.SubPipelines.SealOCR.SubModules.TextRecognition.batch_size": self._params[
"seal_text_recognition_batch_size"
],
"SubPipelines.LayoutParser.SubPipelines.FormulaRecognition.SubModules.FormulaRecognition.model_name": self._params[
"formula_recognition_model_name"
],
"SubPipelines.LayoutParser.SubPipelines.FormulaRecognition.SubModules.FormulaRecognition.model_dir": self._params[
"formula_recognition_model_dir"
],
"SubPipelines.LayoutParser.SubPipelines.FormulaRecognition.SubModules.FormulaRecognition.batch_size": self._params[
"formula_recognition_batch_size"
],
"SubModules.LLM_Chat": self._params["chat_bot_config"],
}
return create_config_from_structure(STRUCTURE)
class PPDocTranslationCLISubcommandExecutor(PipelineCLISubcommandExecutor):
@property
def subparser_name(self):
return "pp_doctranslation"
def _update_subparser(self, subparser):
subparser.add_argument(
"-i",
"--input",
type=str,
required=True,
help="Input path or URL.",
)
subparser.add_argument(
"--save_path",
type=str,
help="Path to the output directory.",
)
subparser.add_argument(
"--target_language",
type=str,
default="zh",
help="Target language.",
)
subparser.add_argument(
"--layout_detection_model_name",
type=str,
help="Name of the layout detection model.",
)
subparser.add_argument(
"--layout_detection_model_dir",
type=str,
help="Path to the layout detection model directory.",
)
subparser.add_argument(
"--layout_threshold",
type=float,
help="Score threshold for the layout detection model.",
)
subparser.add_argument(
"--layout_nms",
type=str2bool,
help="Whether to use NMS in layout detection.",
)
subparser.add_argument(
"--layout_unclip_ratio",
type=float,
help="Expansion coefficient for layout detection.",
)
subparser.add_argument(
"--layout_merge_bboxes_mode",
type=str,
help="Overlapping box filtering method.",
)
subparser.add_argument(
"--chart_recognition_model_name",
type=str,
help="Name of the chart recognition model.",
)
subparser.add_argument(
"--chart_recognition_model_dir",
type=str,
help="Path to the chart recognition model directory.",
)
subparser.add_argument(
"--chart_recognition_batch_size",
type=int,
help="Batch size for the chart recognition model.",
)
subparser.add_argument(
"--region_detection_model_name",
type=str,
help="Name of the region detection model.",
)
subparser.add_argument(
"--region_detection_model_dir",
type=str,
help="Path to the region detection model directory.",
)
subparser.add_argument(
"--doc_orientation_classify_model_name",
type=str,
help="Name of the document image orientation classification model.",
)
subparser.add_argument(
"--doc_orientation_classify_model_dir",
type=str,
help="Path to the document image orientation classification model directory.",
)
subparser.add_argument(
"--doc_unwarping_model_name",
type=str,
help="Name of the text image unwarping model.",
)
subparser.add_argument(
"--doc_unwarping_model_dir",
type=str,
help="Path to the image unwarping model directory.",
)
subparser.add_argument(
"--text_detection_model_name",
type=str,
help="Name of the text detection model.",
)
subparser.add_argument(
"--text_detection_model_dir",
type=str,
help="Path to the text detection model directory.",
)
subparser.add_argument(
"--text_det_limit_side_len",
type=int,
help="This sets a limit on the side length of the input image for the text detection model.",
)
subparser.add_argument(
"--text_det_limit_type",
type=str,
help="This determines how the side length limit is applied to the input image before feeding it into the text deteciton model.",
)
subparser.add_argument(
"--text_det_thresh",
type=float,
help="Detection pixel threshold for the text detection model. Pixels with scores greater than this threshold in the output probability map are considered text pixels.",
)
subparser.add_argument(
"--text_det_box_thresh",
type=float,
help="Detection box threshold for the text detection model. A detection result is considered a text region if the average score of all pixels within the border of the result is greater than this threshold.",
)
subparser.add_argument(
"--text_det_unclip_ratio",
type=float,
help="Text detection expansion coefficient, which expands the text region using this method. The larger the value, the larger the expansion area.",
)
subparser.add_argument(
"--textline_orientation_model_name",
type=str,
help="Name of the text line orientation classification model.",
)
subparser.add_argument(
"--textline_orientation_model_dir",
type=str,
help="Path to the text line orientation classification directory.",
)
subparser.add_argument(
"--textline_orientation_batch_size",
type=int,
help="Batch size for the text line orientation classification model.",
)
subparser.add_argument(
"--text_recognition_model_name",
type=str,
help="Name of the text recognition model.",
)
subparser.add_argument(
"--text_recognition_model_dir",
type=str,
help="Path to the text recognition model directory.",
)
subparser.add_argument(
"--text_recognition_batch_size",
type=int,
help="Batch size for the text recognition model.",
)
subparser.add_argument(
"--text_rec_score_thresh",
type=float,
help="Text recognition threshold used in general OCR. Text results with scores greater than this threshold are retained.",
)
subparser.add_argument(
"--table_classification_model_name",
type=str,
help="Name of the table classification model.",
)
subparser.add_argument(
"--table_classification_model_dir",
type=str,
help="Path to the table classification model directory.",
)
subparser.add_argument(
"--wired_table_structure_recognition_model_name",
type=str,
help="Name of the wired table structure recognition model.",
)
subparser.add_argument(
"--wired_table_structure_recognition_model_dir",
type=str,
help="Path to the wired table structure recognition model directory.",
)
subparser.add_argument(
"--wireless_table_structure_recognition_model_name",
type=str,
help="Name of the wireless table structure recognition model.",
)
subparser.add_argument(
"--wireless_table_structure_recognition_model_dir",
type=str,
help="Path to the wired table structure recognition model directory.",
)
subparser.add_argument(
"--wired_table_cells_detection_model_name",
type=str,
help="Name of the wired table cells detection model.",
)
subparser.add_argument(
"--wired_table_cells_detection_model_dir",
type=str,
help="Path to the wired table cells detection model directory.",
)
subparser.add_argument(
"--wireless_table_cells_detection_model_name",
type=str,
help="Name of the wireless table cells detection model.",
)
subparser.add_argument(
"--wireless_table_cells_detection_model_dir",
type=str,
help="Path to the wireless table cells detection model directory.",
)
subparser.add_argument(
"--seal_text_detection_model_name",
type=str,
help="Name of the seal text detection model.",
)
subparser.add_argument(
"--seal_text_detection_model_dir",
type=str,
help="Path to the seal text detection model directory.",
)
subparser.add_argument(
"--seal_det_limit_side_len",
type=int,
help="This sets a limit on the side length of the input image for the seal text detection model.",
)
subparser.add_argument(
"--seal_det_limit_type",
type=str,
help="This determines how the side length limit is applied to the input image before feeding it into the seal text deteciton model.",
)
subparser.add_argument(
"--seal_det_thresh",
type=float,
help="Detection pixel threshold for the seal text detection model. Pixels with scores greater than this threshold in the output probability map are considered text pixels.",
)
subparser.add_argument(
"--seal_det_box_thresh",
type=float,
help="Detection box threshold for the seal text detection model. A detection result is considered a text region if the average score of all pixels within the border of the result is greater than this threshold.",
)
subparser.add_argument(
"--seal_det_unclip_ratio",
type=float,
help="Seal text detection expansion coefficient, which expands the text region using this method. The larger the value, the larger the expansion area.",
)
subparser.add_argument(
"--seal_text_recognition_model_name",
type=str,
help="Name of the seal text recognition model.",
)
subparser.add_argument(
"--seal_text_recognition_model_dir",
type=str,
help="Path to the seal text recognition model directory.",
)
subparser.add_argument(
"--seal_text_recognition_batch_size",
type=int,
help="Batch size for the seal text recognition model.",
)
subparser.add_argument(
"--seal_rec_score_thresh",
type=float,
help="Seal text recognition threshold. Text results with scores greater than this threshold are retained.",
)
subparser.add_argument(
"--formula_recognition_model_name",
type=str,
help="Name of the formula recognition model.",
)
subparser.add_argument(
"--formula_recognition_model_dir",
type=str,
help="Path to the formula recognition model directory.",
)
subparser.add_argument(
"--formula_recognition_batch_size",
type=int,
help="Batch size for the formula recognition model.",
)
subparser.add_argument(
"--use_doc_orientation_classify",
type=str2bool,
default=False,
help="Whether to use document image orientation classification.",
)
subparser.add_argument(
"--use_doc_unwarping",
type=str2bool,
default=False,
help="Whether to use text image unwarping.",
)
subparser.add_argument(
"--use_textline_orientation",
type=str2bool,
help="Whether to use text line orientation classification.",
)
subparser.add_argument(
"--use_seal_recognition",
type=str2bool,
help="Whether to use seal recognition.",
)
subparser.add_argument(
"--use_table_recognition",
type=str2bool,
help="Whether to use table recognition.",
)
subparser.add_argument(
"--use_formula_recognition",
type=str2bool,
help="Whether to use formula recognition.",
)
subparser.add_argument(
"--use_chart_recognition",
type=str2bool,
default=False,
help="Whether to use chart recognition.",
)
subparser.add_argument(
"--use_region_detection",
type=str2bool,
help="Whether to use region detection.",
)
# FIXME: Passing API key through CLI is not secure; consider using
# environment variables.
subparser.add_argument(
"--qianfan_api_key",
type=str,
help="Configuration for the embedding model.",
)
def execute_with_args(self, args):
params = get_subcommand_args(args)
input = params.pop("input")
target_language = params.pop("target_language")
save_path = params.pop("save_path")
qianfan_api_key = params.pop("qianfan_api_key")
if qianfan_api_key is not None:
params["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": qianfan_api_key,
}
chatocr = PPDocTranslation(**params)
logger.info("Start analyzing images")
result_visual = chatocr.visual_predict_iter(input)
ori_md_info_list = []
for res in result_visual:
ori_md_info_list.append(res["layout_parsing_result"].markdown)
if save_path:
res["layout_parsing_result"].save_all(save_path)
logger.info("Start translation")
result_translate = chatocr.translate_iter(
ori_md_info_list,
target_language=target_language,
)
for res in result_translate:
res.print()
if save_path:
res.save_to_markdown(save_path)
+2
View File
@@ -104,6 +104,7 @@ class PPStructureV3(PaddleXPipelineWrapper):
def predict_iter(
self,
input,
*,
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=None,
@@ -174,6 +175,7 @@ class PPStructureV3(PaddleXPipelineWrapper):
def predict(
self,
input,
*,
use_doc_orientation_classify=False,
use_doc_unwarping=False,
use_textline_orientation=None,
@@ -72,6 +72,7 @@ class TableRecognitionPipelineV2(PaddleXPipelineWrapper):
def predict_iter(
self,
input,
*,
use_doc_orientation_classify=None,
use_doc_unwarping=None,
use_layout_detection=None,
@@ -118,6 +119,7 @@ class TableRecognitionPipelineV2(PaddleXPipelineWrapper):
def predict(
self,
input,
*,
use_doc_orientation_classify=None,
use_doc_unwarping=None,
use_layout_detection=None,
+1 -1
View File
@@ -39,7 +39,7 @@ classifiers = [
"Topic :: Utilities",
]
dependencies = [
"paddlex[ocr,ie,multimodal]>=3.0.3",
"paddlex[ocr,ie,multimodal,trans]>=3.1.0",
"PyYAML>=6",
"typing-extensions>=4.12",
]
@@ -25,4 +25,5 @@ def test_predict(text_recognition_predictor, image_path):
"input_img",
"rec_text",
"rec_score",
"vis_font",
}
+80
View File
@@ -0,0 +1,80 @@
import pytest
from paddleocr import PPDocTranslation
from ..testing_utils import TEST_DATA_DIR
@pytest.fixture(scope="module")
def pp_doctranslation_pipeline():
return PPDocTranslation()
@pytest.mark.parametrize(
"image_path",
[
TEST_DATA_DIR / "book.jpg",
],
)
def test_visual_predict(pp_doctranslation_pipeline, image_path):
result = pp_doctranslation_pipeline.visual_predict(str(image_path))
assert result is not None
assert isinstance(result, list)
assert len(result) == 1
res = result[0]
assert isinstance(res, dict)
assert res.keys() == {"layout_parsing_result"}
assert isinstance(res["layout_parsing_result"], dict)
@pytest.mark.parametrize(
"params",
[
{"use_doc_orientation_classify": False},
{"use_doc_unwarping": False},
{"use_table_recognition": False},
{"use_formula_recognition": False},
{"layout_threshold": 0.88},
{"layout_threshold": [0.45, 0.4]},
{"layout_threshold": {0: 0.45, 2: 0.48, 7: 0.4}},
{"layout_nms": False},
{"layout_unclip_ratio": 1.1},
{"layout_unclip_ratio": [1.2, 1.5]},
{"layout_unclip_ratio": {0: 1.2, 2: 1.5, 7: 1.8}},
{"layout_merge_bboxes_mode": "large"},
{"layout_merge_bboxes_mode": {0: "large", 2: "small", 7: "union"}},
{"text_det_limit_side_len": 640, "text_det_limit_type": "min"},
{"text_det_thresh": 0.5},
{"text_det_box_thresh": 0.3},
{"text_det_unclip_ratio": 3.0},
{"text_rec_score_thresh": 0.5},
],
)
def test_predict_params(
monkeypatch,
pp_doctranslation_pipeline,
params,
):
def _dummy_visual_predict(input, **params):
yield {"layout_parsing_result": params}
monkeypatch.setattr(
pp_doctranslation_pipeline.paddlex_pipeline,
"visual_predict",
_dummy_visual_predict,
)
result = pp_doctranslation_pipeline.visual_predict(
input,
**params,
)
assert isinstance(result, list)
assert len(result) == 1
res = result[0]
res = res["layout_parsing_result"]
for k, v in params.items():
assert res[k] == v
# TODO: Test constructor and other methods