Ver Fonte

fix docs (#3269)

* fix docs

* fix docs

* fix docs

* fix docs

---------

Co-authored-by: cuicheng01 <45199522+cuicheng01@users.noreply.github.com>
Sunflower7788 há 9 meses atrás
pai
commit
481533703b

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
docs/module_usage/tutorials/ocr_modules/layout_detection.md


+ 2 - 1
docs/module_usage/tutorials/ocr_modules/text_detection.md

@@ -76,11 +76,12 @@ for res in output:
 运行后,得到的结果为:
 
 ```bash
-{'res': {'input_path': 'general_ocr_001.png', 'dt_polys': [[[73, 553], [443, 541], [444, 574], [74, 585]], [[17, 507], [515, 489], [517, 534], [19, 552]], [[191, 458], [398, 449], [400, 481], [193, 490]], [[41, 413], [483, 390], [485, 431], [43, 453]]], 'dt_scores': [0.7555687038101032, 0.701620896397861, 0.8839516283528792, 0.8123399529333318]}}
+{'res': {'input_path': 'general_ocr_001.png', "page_index": None, 'dt_polys': [[[73, 552], [453, 542], [454, 575], [74, 585]], [[17, 506], [515, 486], [517, 535], [19, 555]], [[189, 457], [398, 449], [399, 482], [190, 490]], [[41, 412], [484, 387], [486, 433], [43, 457]]], 'dt_scores': [0.7555687038101032, 0.701620896397861, 0.8839516283528792, 0.8123399529333318]}}
 ```
 
 运行结果参数含义如下:
 - `input_path`:表示输入待预测图像的路径
+- `page_index`:如果输入是PDF文件,则表示当前是PDF的第几页,否则为 `None`
 - `dt_polys`:表示预测的文本检测框,其中每个文本检测框包含一个四边形的四个顶点。其中每个顶点都是一个二元组,分别表示该顶点的x坐标和y坐标
 - `dt_scores`:表示预测的文本检测框的置信度
 

+ 1 - 1
docs/pipeline_usage/tutorials/time_series_pipelines/time_series_forecasting.md

@@ -75,7 +75,7 @@ comments: true
 </tbody>
 </table>
 
-<p><b>注:以上精度指标测量自</b>[ETTH1](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/Etth1.tar)<b>测试数据集,输入序列长度为96,预测序列长度除 TiDE 外为96,TiDE为720 。</b></p>
+<p><b>注:以上精度指标测量自 </b><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/data/Etth1.tar">ETTH1</a><b> 测试数据集,输入序列长度为96,预测序列长度除 TiDE 外为96,TiDE为720 。</b></p>
 
 ## 2. 快速开始
 

+ 77 - 41
docs/practical_tutorials/anomaly_detection_tutorial.md

@@ -34,13 +34,25 @@ PaddleX 提供了以下快速体验的方式,可以直接通过 PaddleX wheel
 
 ## 3. 选择模型
 
-PaddleX 提供了 1 个端到端的高精度异常检测模型,具体可参考 [模型列表](../support_list/models_list.md),其中部分模型的benchmark如下:
-
-|模型名称|Avg(%)|GPU推理耗时(ms)|CPU推理耗时(ms)|模型存储大小|yaml 文件|
-|-|-|-|-|-|-|
-|STFPM|96.2|-|-|21.5 M|[STFPM.yaml](../../paddlex/configs/modules/image_anomaly_detection/STFPM.yaml)|
-
-**注:以上精度指标为 **[MVTec AD](https://www.mvtec.com/company/research/datasets/mvtec-ad)** 验证集 平均异常分数。**
+PaddleX 提供了 1 个端到端的高精度异常检测模型,具体可参考 [模型列表](../support_list/models_list.md),其中模型的benchmark如下:
+
+<table>
+<thead>
+<tr>
+<th>模型</th>
+<th>mIoU</th>
+<th>模型存储大小(M)</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>STFPM</td>
+<td>0.9901</td>
+<td>22.5</td>
+</tr>
+</tbody>
+</table>
+<b>以上模型精度指标测量自 MVTec_AD 数据集中的grid类别。</b>
 
 
 ## 4. 数据准备和校验
@@ -60,7 +72,7 @@ tar -xf ./dataset/anomaly_detection_hazelnut.tar -C ./dataset/
 在对数据集校验时,只需一行命令:
 
 ```bash
-python main.py -c paddlex/configs/image_anomaly_detection/STFPM.yaml \
+python main.py -c paddlex/configs/modules/modules/image_anomaly_detection/STFPM.yaml \
     -o Global.mode=check_dataset \
     -o Global.dataset_dir=./dataset/anomaly_detection_hazelnut
 ```
@@ -72,37 +84,37 @@ python main.py -c paddlex/configs/image_anomaly_detection/STFPM.yaml \
   "check_pass": true,
   "attributes": {
     "train_sample_paths": [
-      "check_dataset\/demo_img\/294.png",
-      "check_dataset\/demo_img\/260.png",
-      "check_dataset\/demo_img\/297.png",
-      "check_dataset\/demo_img\/170.png",
-      "check_dataset\/demo_img\/068.png",
-      "check_dataset\/demo_img\/212.png",
-      "check_dataset\/demo_img\/204.png",
-      "check_dataset\/demo_img\/233.png",
-      "check_dataset\/demo_img\/367.png",
-      "check_dataset\/demo_img\/383.png"
+      "check_dataset/demo_img/294.png",
+      "check_dataset/demo_img/260.png",
+      "check_dataset/demo_img/297.png",
+      "check_dataset/demo_img/170.png",
+      "check_dataset/demo_img/068.png",
+      "check_dataset/demo_img/212.png",
+      "check_dataset/demo_img/204.png",
+      "check_dataset/demo_img/233.png",
+      "check_dataset/demo_img/367.png",
+      "check_dataset/demo_img/383.png"
     ],
     "train_samples": 391,
     "val_sample_paths": [
-      "check_dataset\/demo_img\/012.png",
-      "check_dataset\/demo_img\/017.png",
-      "check_dataset\/demo_img\/006.png",
-      "check_dataset\/demo_img\/013.png",
-      "check_dataset\/demo_img\/014.png",
-      "check_dataset\/demo_img\/010.png",
-      "check_dataset\/demo_img\/007.png",
-      "check_dataset\/demo_img\/001.png",
-      "check_dataset\/demo_img\/002.png",
-      "check_dataset\/demo_img\/009.png"
+      "check_dataset/demo_img/012.png",
+      "check_dataset/demo_img/017.png",
+      "check_dataset/demo_img/006.png",
+      "check_dataset/demo_img/013.png",
+      "check_dataset/demo_img/014.png",
+      "check_dataset/demo_img/010.png",
+      "check_dataset/demo_img/007.png",
+      "check_dataset/demo_img/001.png",
+      "check_dataset/demo_img/002.png",
+      "check_dataset/demo_img/009.png"
     ],
     "val_samples": 70,
     "num_classes": 1
   },
   "analysis": {
-    "histogram": "check_dataset\/histogram.png"
+    "histogram": "check_dataset/histogram.png"
   },
-  "dataset_path": ".\/dataset\/hazelnut",
+  "dataset_path": "anomaly_detection_hazelnut",
   "show_type": "image",
   "dataset_type": "SegDataset"
 }
@@ -148,7 +160,7 @@ python main.py -c paddlex/configs/image_anomaly_detection/STFPM.yaml \
 在训练之前,请确保您已经对数据集进行了校验。完成 PaddleX 模型的训练,只需如下一条命令:
 
 ```bash
-python main.py -c paddlex/configs/image_anomaly_detection/STFPM.yaml \
+python main.py -c paddlex/configs/modules/image_anomaly_detection/STFPM.yaml \
     -o Global.mode=train \
     -o Global.dataset_dir=./dataset/anomaly_detection_hazelnut \
     -o Train.epochs_iters=4000
@@ -159,7 +171,7 @@ python main.py -c paddlex/configs/image_anomaly_detection/STFPM.yaml \
 PaddleX 中每个模型都提供了模型开发的配置文件,用于设置相关参数。模型训练相关的参数可以通过修改配置文件中 `Train` 下的字段进行设置,配置文件中部分参数的示例说明如下:
 
 * `Global`:
-    * `mode`:模式,支持数据校验(`check_dataset`)、模型训练(`train`)、模型评估(`evaluate`);
+    * `mode`:模式,支持数据校验(`check_dataset`)、模型训练(`train`)、模型评估(`evaluate`)和 模型推理 (`predict`)
     * `device`:训练设备,可选`cpu`、`gpu`、`xpu`、`npu`、`mlu`,除 cpu 外,多卡训练可指定卡号,如:`gpu:0,1,2,3`;
 * `Train`:训练超参数设置;
     * `epochs_iters`:训练迭代次数数设置;
@@ -186,7 +198,7 @@ PaddleX 中每个模型都提供了模型开发的配置文件,用于设置相
 在完成模型训练后,可以对指定的模型权重文件在验证集上进行评估,验证模型精度。使用 PaddleX 进行模型评估,只需一行命令:
 
 ```bash
-python main.py -c paddlex/configs/image_anomaly_detection/STFPM.yaml \
+python main.py -c paddlex/configs/modules/image_anomaly_detection/STFPM.yaml \
     -o Global.mode=evaluate \
     -o Global.dataset_dir=./dataset/anomaly_detection_hazelnut
 ```
@@ -229,13 +241,35 @@ python main.py -c paddlex/configs/image_anomaly_detection/STFPM.yaml \
 
 ## 6. 产线测试
 
-将产线中的模型替换为微调后的模型进行测试,如:
+将产线中的模型替换为微调后的模型进行测试, 可以获取 anomaly_detection 产线配置文件并加载配置文件进行预测。可执行下命令将配置保存在 `my_path` 中
 
-```bash
-python main.py -c paddlex/configs/image_anomaly_detection/STFPM.yaml \
-    -o Global.mode=predict \
-    -o Predict.model_dir="output/best_model/inference" \
-    -o Predict.input="https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/uad_hazelnut.png"
+```
+paddlex --get_pipeline_config anomaly_detection --save_path ./my_path
+```
+
+将`my_path/anomaly_detection.yaml`配置文件中的`SubModules.AnomalyDetection.model_dir`修改为自己的模型路径`output/best_model/inference`:
+
+```yaml
+pipeline_name: anomaly_detection
+
+SubModules:
+  AnomalyDetection:
+    module_name: anomaly_detection
+    model_name: STFPM
+    model_dir: output/best_model/inference  # 替换为微调后的图像异常检测模型权重路径
+    batch_size: 1
+```
+
+随后在 Python 代码中,您可以这样调用产线:
+
+```python
+from paddlex import create_pipeline
+pipeline = create_pipeline(pipeline="./my_path/anomaly_detection.yaml")
+output = pipeline.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/uad_hazelnut.png")
+for res in output:
+    res.print() ## 打印预测的结构化输出
+    res.save_to_img("./output/") ## 保存结果可视化图像
+    res.save_to_json("./output/") ## 保存预测的结构化输出
 ```
 
 通过上述可在`./output`下生成预测结果,其中`uad_hazelnut.png`的预测结果如下:
@@ -247,10 +281,12 @@ python main.py -c paddlex/configs/image_anomaly_detection/STFPM.yaml \
 
 ## 7. 开发集成/部署
 如果通用异常检测产线可以达到您对产线推理速度和精度的要求,您可以直接进行开发集成/部署。
-1. 直接将训练好的模型应用在您的 Python 项目中,可以参考如下示例代码,并将`paddlex/pipelines/anomaly_detection.yaml`配置文件中的`Pipeline.model`修改为自己的模型路径`output/best_model/inference`:
+
+1. 直接将训练好的模型应用在您的 Python 项目中,可以参考如下示例:
+
 ```python
 from paddlex import create_pipeline
-pipeline = create_pipeline(pipeline="paddlex/pipelines/anomaly_detection.yaml")
+pipeline = create_pipeline(pipeline="my_path/anomaly_detection.yaml")
 output = pipeline.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/uad_hazelnut.png")
 for res in output:
     res.print() # 打印预测的结构化输出

+ 247 - 131
docs/practical_tutorials/document_scene_information_extraction(layout_detection)_tutorial.md

@@ -23,51 +23,71 @@ PaddleX 提供了两种体验的方式,你可以在线体验文档场景信息
 
 ### 2.1 本地体验
 
-在本地使用文档场景信息抽取v3产线前,请确保您已经按照[PaddleX本地安装教程](../installation/installation.md)完成了PaddleX的wheel包安装。几行代码即可完成产线的快速推理:
+在本地使用文档场景信息抽取v3产线前,请确保您已经按照[PaddleX本地安装教程](../installation/installation.md)完成了PaddleX的wheel包安装。
+
+首先需要配置获取 `PP-ChatOCRv3-doc` 产线的配置文件,可以通过以下命令获取:
+```bash
+python -m paddlex --get_pipeline_config PP-ChatOCRv3-doc --save_path ./
+```
+
+执行上述命令后,配置文件会存储在当前路径下,打开配置文件,填写大语言模型的 ak/sk(access_token),如下所示:
+
+```yaml
+......
+SubModules:
+  LLM_Chat:
+    module_name: chat_bot
+    model_name: ernie-3.5
+    api_type: qianfan
+    ak: "" # Your LLM API key
+    sk: ""  # Your LLM secret key
+
+  LLM_Retriever:
+    module_name: retriever
+    model_name: ernie-3.5
+    api_type: qianfan
+    ak: "" # Your LLM API key
+    sk: ""  # Your LLM secret key
+......
+```
+
+PP-ChatOCRv3 仅支持文心大模型,支持在[百度云千帆平台](https://console.bce.baidu.com/qianfan/ais/console/onlineService)或者[星河社区 AIStudio](https://aistudio.baidu.com/)上获取相关的 ak/sk(access_token)。如果使用百度云千帆平台,可以参考[AK和SK鉴权调用API流程](https://cloud.baidu.com/doc/WENXINWORKSHOP/s/Hlwerugt8) 获取ak/sk,如果使用星河社区 AIStudio,可以在[星河社区 AIStudio 访问令牌](https://aistudio.baidu.com/account/accessToken)中获取 access_token。
+
+更新配置文件后,即可使用几行Python代码完成快速推理:
 
 
 ```python
 from paddlex import create_pipeline
 
-pipeline = create_pipeline(
-    pipeline="PP-ChatOCRv3-doc",
-    llm_name="ernie-3.5",
-    llm_params={"api_type": "qianfan", "ak": "", "sk": ""} # 使用千帆接口,请填入您的ak与sk,否则无法调用大模型
-    # llm_params={"api_type": "aistudio", "access_token": ""} # 或者使用AIStudio接口,请填入您的access_token,否则无法调用大模型
-    )
-
-visual_result, visual_info = pipeline.visual_predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_layout/test.jpg")
-
-for res in visual_result:
-    res.save_to_img("./output")
-    res.save_to_html('./output')
-    res.save_to_xlsx('./output')
-
-vector = pipeline.build_vector(visual_info=visual_info)
-chat_result = pipeline.chat(
-    key_list=["页眉", "表格标题"],
-    visual_info=visual_info,
-    vector=vector,
-    )
-chat_result.print()
-```
+pipeline = create_pipeline(pipeline="./PP-ChatOCRv3-doc.yaml")
 
-<b>注</b>:目前仅支持文心大模型,支持在[百度云千帆平台](https://console.bce.baidu.com/qianfan/ais/console/onlineService)或者[星河社区 AIStudio](https://aistudio.baidu.com/)上获取相关的 ak/sk(access_token)。如果使用百度云千帆平台,可以参考[AK和SK鉴权调用API流程](https://cloud.baidu.com/doc/WENXINWORKSHOP/s/Hlwerugt8) 获取ak/sk,如果使用星河社区 AIStudio,可以在[星河社区 AIStudio 访问令牌](https://aistudio.baidu.com/account/accessToken)中获取 access_token。
+visual_predict_res = pipeline.visual_predict(input="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_layout/test.jpg",
+    use_doc_orientation_classify=False,
+    use_doc_unwarping=False,
+    use_common_ocr=True,
+    use_seal_recognition=True,
+    use_table_recognition=True)
 
+visual_info_list = []
+for res in visual_predict_res:
+    visual_info_list.append(res["visual_info"])
+    layout_parsing_result = res["layout_parsing_result"]
+    layout_parsing_result.save_to_img("./output")
+    # layout_parsing_result.save_to_json("./output")
+    # layout_parsing_result.save_to_xlsx("./output")
+    # layout_parsing_result.save_to_html("./output")
 
-输出打印的结果如下:
+vector_info = pipeline.build_vector(visual_info_list, flag_save_bytes_vector=True)
+chat_result = pipeline.chat(key_list=["页眉", "表格标题"], visual_info=visual_info_list, vector_info=vector_info)
+print(chat_result)
 
 ```
-The result has been saved in output/tmpfnss9sq9_layout.jpg.
-The result has been saved in output/tmpfnss9sq9_ocr.jpg.
-The result has been saved in output/tmpfnss9sq9_table.jpg.
-The result has been saved in output/tmpfnss9sq9_table.jpg.
-The result has been saved in output/tmpfnss9sq9/tmpfnss9sq9.html.
-The result has been saved in output/tmpfnss9sq9/tmpfnss9sq9.html.
-The result has been saved in output/tmpfnss9sq9/tmpfnss9sq9.xlsx.
-The result has been saved in output/tmpfnss9sq9/tmpfnss9sq9.xlsx.
 
-{'chat_res': {'页眉': '未知', '表格标题': '未知'}, 'prompt': ''}
+
+输出打印的结果如下:
+
+```
+{'chat_res': {'页眉': '未知', '表格标题': '未知'}}
 
 ```
 
@@ -91,7 +111,9 @@ The result has been saved in output/tmpfnss9sq9/tmpfnss9sq9.xlsx.
 
 ## 3. 选择模型
 
-PaddleX 提供了 4 个端到端的版面区域定位模型,具体可参考 [模型列表](../support_list/models_list.md),其中版面区域检测模型的 benchmark 如下:
+PaddleX 提供了 11 个版面区域定位模型,具体可参考 [模型列表](../support_list/models_list.md),其中版面区域检测模型的 benchmark 如下:
+
+* <b>版面检测模型,包含23个常见的类别:文档标题、段落标题、文本、页码、摘要、目录、参考文献、脚注、页眉、页脚、算法、公式、公式编号、图像、图表标题、表格、表格标题、印章、图表标题、图表、页眉图像、页脚图像、侧栏文本</b>
 
 <table>
 <thead>
@@ -106,74 +128,181 @@ PaddleX 提供了 4 个端到端的版面区域定位模型,具体可参考 [
 </thead>
 <tbody>
 <tr>
-<td>PicoDet_layout_1x</td>
-<td>86.8</td>
-<td>13.0</td>
-<td>91.3</td>
-<td>7.4</td>
-<td>基于PicoDet-1x在PubLayNet数据集训练的高效率版面区域定位模型,可定位包含文字、标题、表格、图片以及列表这5类区域</td>
+<td>PP-DocLayout-L</td>
+<td>90.4</td>
+<td>34.5252</td>
+<td>1454.27</td>
+<td>123.76 M</td>
+<td>基于RT-DETR-L在包含中英文论文、杂志、合同、书本、试卷和研报等场景的自建数据集训练的高精度版面区域定位模型</td>
 </tr>
 <tr>
+<td>PP-DocLayout-M</td>
+<td>75.2</td>
+<td>15.9</td>
+<td>160.1</td>
+<td>22.578</td>
+<td>基于PicoDet-L在包含中英文论文、杂志、合同、书本、试卷和研报等场景的自建数据集训练的精度效率平衡的版面区域定位模型</td>
+</tr>
+<tr>
+<td>PP-DocLayout-S</td>
+<td>70.9</td>
+<td>13.8</td>
+<td>46.7</td>
+<td>4.834</td>
+<td>基于PicoDet-S在中英文论文、杂志、合同、书本、试卷和研报等场景上自建数据集训练的高效率版面区域定位模型</td>
+</tr>
+</tbody>
+</table>
+
+<b>注:以上精度指标的评估集是 PaddleOCR 自建的版面区域检测数据集,包含中英文论文、杂志、合同、书本、试卷和研报等常见的 500 张文档类型图片。GPU 推理耗时基于 NVIDIA Tesla T4 机器,精度类型为 FP32, CPU 推理速度基于 Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz,线程数为 8,精度类型为 FP32。</b>
+
+
+> ❗ 以上列出的是版面检测模块重点支持的<b>3个核心模型</b>,该模块总共支持<b>11个全量模型</b>,包含多个预定义了不同类别的模型,完整的模型列表如下:
+
+<details><summary> 👉模型列表详情</summary>
+
+* <b>表格版面检测模型</b>
+
+<table>
+<thead>
+<tr>
+<th>模型</th>
+<th>mAP(0.5)(%)</th>
+<th>GPU推理耗时(ms)</th>
+<th>CPU推理耗时 (ms)</th>
+<th>模型存储大小(M)</th>
+<th>介绍</th>
+</tr>
+</thead>
+<tbody>
+<tr>
 <td>PicoDet_layout_1x_table</td>
-<td>95.7</td>
+<td>97.5</td>
 <td>12.623</td>
 <td>90.8934</td>
 <td>7.4 M</td>
-<td>基于PicoDet-1x在自建数据集训练的高效率版面区域定位模型,可定位包含表格1个类别</td>
+<td>基于PicoDet-1x在自建数据集训练的高效率版面区域定位模型,可定位表格这1类区域</td>
+</tr>
+</table>
+
+<b>注:以上精度指标的评估集是 PaddleOCR 自建的版面表格区域检测数据集,包含中英文 7835 张带有表格的论文文档类型图片。GPU 推理耗时基于 NVIDIA Tesla T4 机器,精度类型为 FP32, CPU 推理速度基于 Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz,线程数为 8,精度类型为 FP32。</b>
+
+* <b>3类版面检测模型,包含表格、图像、印章</b>
+
+<table>
+<thead>
+<tr>
+<th>模型</th>
+<th>mAP(0.5)(%)</th>
+<th>GPU推理耗时(ms)</th>
+<th>CPU推理耗时 (ms)</th>
+<th>模型存储大小(M)</th>
+<th>介绍</th>
 </tr>
+</thead>
+<tbody>
 <tr>
 <td>PicoDet-S_layout_3cls</td>
-<td>87.1</td>
+<td>88.2</td>
 <td>13.5</td>
 <td>45.8</td>
 <td>4.8</td>
-<td>基于PicoDet-S轻量模型在中英文论文、杂志和研报等场景上自建数据集训练的高效率版面区域定位模型,包含3个类别:表格,图像和印章</td>
-</tr>
-<tr>
-<td>PicoDet-S_layout_17cls</td>
-<td>70.3</td>
-<td>13.6</td>
-<td>46.2</td>
-<td>4.8</td>
-<td>基于PicoDet-S轻量模型在中英文论文、杂志和研报等场景上自建数据集训练的高效率版面区域定位模型,包含17个版面常见类别,分别是:段落标题、图片、文本、数字、摘要、内容、图表标题、公式、表格、表格标题、参考文献、文档标题、脚注、页眉、算法、页脚、印章</td>
+<td>基于PicoDet-S轻量模型在中英文论文、杂志和研报等场景上自建数据集训练的高效率版面区域定位模型</td>
 </tr>
 <tr>
 <td>PicoDet-L_layout_3cls</td>
-<td>89.3</td>
+<td>89.0</td>
 <td>15.7</td>
 <td>159.8</td>
 <td>22.6</td>
-<td>基于PicoDet-L在中英文论文、杂志和研报等场景上自建数据集训练的高效率版面区域定位模型,包含3个类别:表格,图像和印章</td>
-</tr>
-<tr>
-<td>PicoDet-L_layout_17cls</td>
-<td>79.9</td>
-<td>17.2</td>
-<td>160.2</td>
-<td>22.6</td>
-<td>基于PicoDet-L在中英文论文、杂志和研报等场景上自建数据集训练的高效率版面区域定位模型,包含17个版面常见类别,分别是:段落标题、图片、文本、数字、摘要、内容、图表标题、公式、表格、表格标题、参考文献、文档标题、脚注、页眉、算法、页脚、印章</td>
+<td>基于PicoDet-L在中英文论文、杂志和研报等场景上自建数据集训练的效率精度均衡版面区域定位模型</td>
 </tr>
 <tr>
 <td>RT-DETR-H_layout_3cls</td>
-<td>95.9</td>
+<td>95.8</td>
 <td>114.6</td>
 <td>3832.6</td>
 <td>470.1</td>
-<td>基于RT-DETR-H在中英文论文、杂志和研报等场景上自建数据集训练的高精度版面区域定位模型,包含3个类别:表格,图像和印章</td>
+<td>基于RT-DETR-H在中英文论文、杂志和研报等场景上自建数据集训练的高精度版面区域定位模型</td>
+</tr>
+</table>
+
+<b>注:以上精度指标的评估集是 PaddleOCR 自建的版面区域检测数据集,包含中英文论文、杂志和研报等常见的 1154 张文档类型图片。GPU 推理耗时基于 NVIDIA Tesla T4 机器,精度类型为 FP32, CPU 推理速度基于 Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz,线程数为 8,精度类型为 FP32。</b>
+
+* <b>5类英文文档区域检测模型,包含文字、标题、表格、图片以及列表</b>
+
+<table>
+<thead>
+<tr>
+<th>模型</th>
+<th>mAP(0.5)(%)</th>
+<th>GPU推理耗时(ms)</th>
+<th>CPU推理耗时 (ms)</th>
+<th>模型存储大小(M)</th>
+<th>介绍</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>PicoDet_layout_1x</td>
+<td>97.8</td>
+<td>13.0</td>
+<td>91.3</td>
+<td>7.4</td>
+<td>基于PicoDet-1x在PubLayNet数据集训练的高效率英文文档版面区域定位模型</td>
+</tr>
+</table>
+
+<b>注:以上精度指标的评估集是 [PubLayNet](https://developer.ibm.com/exchanges/data/all/publaynet/) 的评估数据集,包含英文文档的 11245 张文图片。GPU 推理耗时基于 NVIDIA Tesla T4 机器,精度类型为 FP32, CPU 推理速度基于 Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz,线程数为 8,精度类型为 FP32。</b>
+
+* <b>17类区域检测模型,包含17个版面常见类别,分别是:段落标题、图片、文本、数字、摘要、内容、图表标题、公式、表格、表格标题、参考文献、文档标题、脚注、页眉、算法、页脚、印章</b>
+
+<table>
+<thead>
+<tr>
+<th>模型</th>
+<th>mAP(0.5)(%)</th>
+<th>GPU推理耗时(ms)</th>
+<th>CPU推理耗时 (ms)</th>
+<th>模型存储大小(M)</th>
+<th>介绍</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>PicoDet-S_layout_17cls</td>
+<td>87.4</td>
+<td>13.6</td>
+<td>46.2</td>
+<td>4.8</td>
+<td>基于PicoDet-S轻量模型在中英文论文、杂志和研报等场景上自建数据集训练的高效率版面区域定位模型</td>
+</tr>
+
+<tr>
+<td>PicoDet-L_layout_17cls</td>
+<td>89.0</td>
+<td>17.2</td>
+<td>160.2</td>
+<td>22.6</td>
+<td>基于PicoDet-L在中英文论文、杂志和研报等场景上自建数据集训练的效率精度均衡版面区域定位模型</td>
 </tr>
+
 <tr>
 <td>RT-DETR-H_layout_17cls</td>
-<td>92.6</td>
+<td>98.3</td>
 <td>115.1</td>
 <td>3827.2</td>
 <td>470.2</td>
-<td>基于RT-DETR-H在中英文论文、杂志和研报等场景上自建数据集训练的高精度版面区域定位模型,包含17个版面常见类别,分别是:段落标题、图片、文本、数字、摘要、内容、图表标题、公式、表格、表格标题、参考文献、文档标题、脚注、页眉、算法、页脚、印章</td>
+<td>基于RT-DETR-H在中英文论文、杂志和研报等场景上自建数据集训练的高精度版面区域定位模型</td>
 </tr>
 </tbody>
 </table>
-<b>注:以上精度指标的评估集是 PaddleOCR 自建的版面区域分析数据集,包含中英文论文、杂志和研报等常见的 1w 张文档类型图片。GPU 推理耗时基于 NVIDIA Tesla T4 机器,精度类型为 FP32, CPU 推理速度基于 Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz,线程数为 8,精度类型为 FP32。</b>
 
 
+<b>注:以上精度指标的评估集是 PaddleOCR 自建的版面区域检测数据集,包含中英文论文、杂志和研报等常见的 892 张文档类型图片。GPU 推理耗时基于 NVIDIA Tesla T4 机器,精度类型为 FP32, CPU 推理速度基于 Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz,线程数为 8,精度类型为 FP32。</b>
+
+</details>
+
 ## 4. 数据准备和校验
 ### 4.1 数据准备
 
@@ -191,7 +320,7 @@ tar -xf ./dataset/paperlayout.tar -C ./dataset/
 在对数据集校验时,只需一行命令:
 
 ```bash
-python main.py -c paddlex/configs/layout_detection/RT-DETR-H_layout_3cls.yaml \
+python main.py -c paddlex/configs/modules/layout_detection/RT-DETR-H_layout_3cls.yaml \
     -o Global.mode=check_dataset \
     -o Global.dataset_dir=./dataset/paperlayout/
 ```
@@ -233,7 +362,7 @@ python main.py -c paddlex/configs/layout_detection/RT-DETR-H_layout_3cls.yaml \
   "analysis": {
     "histogram": "check_dataset\/histogram.png"
   },
-  "dataset_path": ".\/dataset\/paperlayout\/",
+  "dataset_path": "paperlayout",
   "show_type": "image",
   "dataset_type": "COCODetDataset"
 }
@@ -278,7 +407,7 @@ python main.py -c paddlex/configs/layout_detection/RT-DETR-H_layout_3cls.yaml \
 在训练之前,请确保您已经对数据集进行了校验。完成 PaddleX 模型的训练,只需如下一条命令:
 
 ```bash
-python main.py -c paddlex/configs/layout_detection/RT-DETR-H_layout_3cls.yaml \
+python main.py -c paddlex/configs/modules/layout_detection/RT-DETR-H_layout_3cls.yaml \
     -o Global.mode=train \
     -o Global.dataset_dir=./dataset/paperlayout \
     -o Train.num_classes=4
@@ -317,7 +446,7 @@ PaddleX 中每个模型都提供了模型开发的配置文件,用于设置相
 在完成模型训练后,可以对指定的模型权重文件在验证集上进行评估,验证模型精度。使用 PaddleX 进行模型评估,只需一行命令:
 
 ```bash
-python main.py -c paddlex/configs/layout_detection/RT-DETR-H_layout_3cls.yaml \
+python main.py -c paddlex/configs/modules/layout_detection/RT-DETR-H_layout_3cls.yaml \
     -o Global.mode=evaluate \
     -o Global.dataset_dir=./dataset/paperlayout
 ```
@@ -412,7 +541,7 @@ python main.py -c paddlex/configs/layout_detection/RT-DETR-H_layout_3cls.yaml \
 调整不同参数执行训练的命令可以参考:
 
 ```bash
-python main.py -c paddlex/configs/layout_detection/RT-DETR-H_layout_3cls.yaml \
+python main.py -c paddlex/configs/modules/layout_detection/RT-DETR-H_layout_3cls.yaml \
     -o Global.mode=train \
     -o Global.dataset_dir=./dataset/paperlayout \
     -o Train.num_classes=4 \
@@ -426,7 +555,7 @@ python main.py -c paddlex/configs/layout_detection/RT-DETR-H_layout_3cls.yaml \
 可以将微调后的单模型进行测试,使用 [测试文件](https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_layout/test.jpg),进行预测:
 
 ```bash
-python main.py -c paddlex/configs/layout_detection/RT-DETR-H_layout_3cls.yaml \
+python main.py -c paddlex/configs/modules/layout_detection/RT-DETR-H_layout_3cls.yaml \
     -o Global.mode=predict \
     -o Predict.model_dir="output/best_model/inference" \
     -o Predict.input="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_layout/test.jpg"
@@ -447,22 +576,16 @@ python main.py -c paddlex/configs/layout_detection/RT-DETR-H_layout_3cls.yaml \
 paddlex --get_pipeline_config PP-ChatOCRv3-doc --save_path ./my_path
 ```
 
-将`PP-ChatOCRv3-doc.yaml`中的`Pipeline.layout_model`字段修改为上面微调后的模型路径,修改后配置如下:
+参考2.1 填写大语言模型的 ak/sk(access_token), 同时将`PP-ChatOCRv3-doc.yaml`中的`LayoutDetection.model_dir`字段修改为上面微调后的模型路径,修改后版面模型部分的配置如下:
 
 ```yaml
-Pipeline:
-  layout_model: ./output/best_model/inference
-  table_model: SLANet_plus
-  text_det_model: PP-OCRv4_server_det
-  text_rec_model: PP-OCRv4_server_rec
-  seal_text_det_model: PP-OCRv4_server_seal_det
-  doc_image_ori_cls_model: null
-  doc_image_unwarp_model: null
-  llm_name: "ernie-3.5"
-  llm_params:
-    api_type: qianfan
-    ak:
-    sk:
+......
+    SubModules:
+      LayoutDetection:
+        module_name: layout_detection
+        model_name: RT-DETR-H_layout_3cls
+        model_dir: output/best_model/inference
+......
 ```
 
 修改后,只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为产线配置文件路径即可应用配置。
@@ -470,34 +593,31 @@ Pipeline:
 ```python
 from paddlex import create_pipeline
 
-pipeline = create_pipeline(
-    pipeline="./my_path/PP-ChatOCRv3-doc.yaml",
-    llm_name="ernie-3.5",
-    llm_params={"api_type": "qianfan", "ak": "", "sk": ""} # 请填入您的ak与sk,否则无法调用大模型
-    # llm_params={"api_type": "aistudio", "access_token": ""} # 或者使用AIStudio接口,请填入您的access_token,否则无法调用大模型
-    )
-
-visual_result, visual_info = pipeline.visual_predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_layout/test.jpg")
-
-for res in visual_result:
-    res.save_to_img("./output_ft")
-    res.save_to_html('./output_ft')
-    res.save_to_xlsx('./output_ft')
-
-vector = pipeline.build_vector(visual_info=visual_info)
-chat_result = pipeline.chat(
-    key_list=["页眉", "表格标题"],
-    visual_info=visual_info,
-    vector=vector,
-    )
-chat_result.print()
+pipeline = create_pipeline(pipeline="./my_path/PP-ChatOCRv3-doc.yaml")
+
+visual_predict_res = pipeline.visual_predict(input="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_layout/test.jpg",
+    use_doc_orientation_classify=False,
+    use_doc_unwarping=False,
+    use_common_ocr=True,
+    use_seal_recognition=True,
+    use_table_recognition=True)
+
+visual_info_list = []
+for res in visual_predict_res:
+    visual_info_list.append(res["visual_info"])
+    layout_parsing_result = res["layout_parsing_result"]
+    layout_parsing_result.save_to_img("./output_ft")
+
+vector_info = pipeline.build_vector(visual_info_list, flag_save_bytes_vector=True)
+chat_result = pipeline.chat(key_list=["页眉", "表格标题"], visual_info=visual_info_list, vector_info=vector_info)
+print(chat_result)
 ```
 
 通过上述可在`./output_ft`下生成预测结果,打印的关键信息抽取结果:
 
 
 ```
-{'chat_res': {'页眉': '第43卷\n 航空发动机\n 44', '表格标题': '表1模拟来流Ma=5飞行的空气加热器工作参数'}, 'prompt': ''}
+{'chat_res': {'页眉': '第43卷\n 航空发动机\n 44', '表格标题': '表1模拟来流Ma=5飞行的空气加热器工作参数'}}
 ```
 
 可以发现,在模型微调之后,关键信息已经被正确的提取出来。
@@ -516,27 +636,23 @@ chat_result.print()
 ```python
 from paddlex import create_pipeline
 
-pipeline = create_pipeline(
-    pipeline="./my_path/PP-ChatOCRv3-doc.yaml",
-    llm_name="ernie-3.5",
-    llm_params={"api_type": "qianfan", "ak": "", "sk": ""} # 请填入您的ak与sk,否则无法调用大模型
-    # llm_params={"api_type": "aistudio", "access_token": ""} # 或者使用AIStudio接口,请填入您的access_token,否则无法调用大模型
-    )
-
-visual_result, visual_info = pipeline.visual_predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_layout/test.jpg")
-
-for res in visual_result:
-    res.save_to_img("./output")
-    res.save_to_html('./output')
-    res.save_to_xlsx('./output')
-
-vector = pipeline.build_vector(visual_info=visual_info)
-chat_result = pipeline.chat(
-    key_list=["页眉", "表格标题"],
-    visual_info=visual_info,
-    vector=vector,
-    )
-chat_result.print()
+pipeline = create_pipeline(pipeline="./my_path/PP-ChatOCRv3-doc.yaml")
+
+visual_predict_res = pipeline.visual_predict(input="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_layout/test.jpg",
+    use_doc_orientation_classify=False,
+    use_doc_unwarping=False,
+    use_common_ocr=True,
+    use_seal_recognition=True,
+    use_table_recognition=True)
+
+visual_info_list = []
+for res in visual_predict_res:
+    visual_info_list.append(res["visual_info"])
+    layout_parsing_result = res["layout_parsing_result"]
+
+vector_info = pipeline.build_vector(visual_info_list, flag_save_bytes_vector=True)
+chat_result = pipeline.chat(key_list=["页眉", "表格标题"], visual_info=visual_info_list, vector_info=vector_info)
+
 ```
 
 更多参数请参考 [文档场景信息抽取v3产线使用教程](../pipeline_usage/tutorials/information_extraction_pipelines/document_scene_information_extraction_v3.md)。

+ 116 - 92
docs/practical_tutorials/document_scene_information_extraction(seal_recognition)_tutorial.md

@@ -22,47 +22,73 @@ PaddleX 提供了两种体验的方式,你可以在线体验文档场景信息
 
 ### 2.1 本地体验
 
-在本地使用文档场景信息抽取v3产线前,请确保您已经按照[PaddleX本地安装教程](../installation/installation.md)完成了PaddleX的wheel包安装。几行代码即可完成产线的快速推理:
+在本地使用文档场景信息抽取v3产线前,请确保您已经按照[PaddleX本地安装教程](../installation/installation.md)完成了PaddleX的wheel包安装。
+
+
+首先需要配置获取 `PP-ChatOCRv3-doc` 产线的配置文件,可以通过以下命令获取:
+```bash
+python -m paddlex --get_pipeline_config PP-ChatOCRv3-doc --save_path ./
+```
+
+执行上述命令后,配置文件会存储在当前路径下,打开配置文件,填写大语言模型的 ak/sk(access_token),如下所示:
+
+```yaml
+......
+SubModules:
+  LLM_Chat:
+    module_name: chat_bot
+    model_name: ernie-3.5
+    api_type: qianfan
+    ak: "" # Your LLM API key
+    sk: ""  # Your LLM secret key
+
+  LLM_Retriever:
+    module_name: retriever
+    model_name: ernie-3.5
+    api_type: qianfan
+    ak: "" # Your LLM API key
+    sk: ""  # Your LLM secret key
+......
+```
+
+PP-ChatOCRv3 仅支持文心大模型,支持在[百度云千帆平台](https://console.bce.baidu.com/qianfan/ais/console/onlineService)或者[星河社区 AIStudio](https://aistudio.baidu.com/)上获取相关的 ak/sk(access_token)。如果使用百度云千帆平台,可以参考[AK和SK鉴权调用API流程](https://cloud.baidu.com/doc/WENXINWORKSHOP/s/Hlwerugt8) 获取ak/sk,如果使用星河社区 AIStudio,可以在[星河社区 AIStudio 访问令牌](https://aistudio.baidu.com/account/accessToken)中获取 access_token。
+
+更新配置文件后,即可使用几行Python代码完成快速推理:
+
 
 
 ```python
 from paddlex import create_pipeline
 
-pipeline = create_pipeline(
-    pipeline="PP-ChatOCRv3-doc",
-    llm_name="ernie-3.5",
-    llm_params={"api_type": "qianfan", "ak": "", "sk": ""} # 使用千帆接口,请填入您的ak与sk,否则无法调用大模型
-    # llm_params={"api_type": "aistudio", "access_token": ""} # 或者使用AIStudio接口,请填入您的access_token,否则无法调用大模型
-    )
-
-visual_result, visual_info = pipeline.visual_predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_seal/test.png")
-
-for res in visual_result:
-    res.save_to_img("./output")
-    res.save_to_html('./output')
-    res.save_to_xlsx('./output')
-
-vector = pipeline.build_vector(visual_info=visual_info)
-chat_result = pipeline.chat(
-    key_list=["印章名称"],
-    visual_info=visual_info,
-    vector=vector,
-    )
-chat_result.print()
-```
+pipeline = create_pipeline(pipeline="./PP-ChatOCRv3-doc.yaml")
 
-<b>注</b>:目前仅支持文心大模型,支持在[百度云千帆平台](https://console.bce.baidu.com/qianfan/ais/console/onlineService)或者[星河社区 AIStudio](https://aistudio.baidu.com/)上获取相关的 ak/sk(access_token)。如果使用百度云千帆平台,可以参考[AK和SK鉴权调用API流程](https://cloud.baidu.com/doc/WENXINWORKSHOP/s/Hlwerugt8) 获取ak/sk,如果使用星河社区 AIStudio,可以在[星河社区 AIStudio 访问令牌](https://aistudio.baidu.com/account/accessToken)中获取 access_token。
 
+visual_predict_res = pipeline.visual_predict(input="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_seal/test.png",
+    use_doc_orientation_classify=False,
+    use_doc_unwarping=False,
+    use_common_ocr=True,
+    use_seal_recognition=True,
+    use_table_recognition=True)
+
+visual_info_list = []
+for res in visual_predict_res:
+    visual_info_list.append(res["visual_info"])
+    layout_parsing_result = res["layout_parsing_result"]
+    layout_parsing_result.save_to_img("./output")
+    # layout_parsing_result.save_to_json("./output")
+    # layout_parsing_result.save_to_xlsx("./output")
+    # layout_parsing_result.save_to_html("./output")
+
+vector_info = pipeline.build_vector(visual_info_list, flag_save_bytes_vector=True)
+chat_result = pipeline.chat(key_list=["印章名称"], visual_info=visual_info_list, vector_info=vector_info)
+print(chat_result)
+```
 
 输出打印的结果如下:
 
 ```
-The result has been saved in output/tmpx5tmgsem_curve_0.jpg.
-The result has been saved in output/tmpx5tmgsem_layout.jpg.
-The result has been saved in output/tmpx5tmgsem_ocr.jpg.
-The retrieved vectorstore is not for PaddleX and will return vectorstore directly
 
-{'chat_res': {'印章名称': '击资源局'}, 'prompt': ''}
+{'chat_res': {'印章名称': '大中国土资源局'}}
 ```
 
 在`output` 目录中,保存了印章文本检测、OCR(如有表格,还有表格识别可视化结果以及表格html和xlsx)结果。
@@ -72,7 +98,7 @@ The retrieved vectorstore is not for PaddleX and will return vectorstore directl
 <img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/practical_tutorials/PP-ChatOCRv3_doc/seal_01.png">
 
 
-通过上面的文档场景信息抽取的快速体验可以进行 Badcase 分析,发现文档场景信息抽取产线的官方模型,在当前需求场景中存在下面的问题:在OCR识别的可视化中,印章的文本弯曲检测框有偏差,导致印章文本识别错误;印章的信息没有被正确的抽取出来。在`{'chat_res': {'印章': '未知'}, 'prompt': ''}`中的结果是未知。因此,本节工作聚焦于印章信息抽取的场景,对文档场景信息抽取产线中的印章文本检测模型进行微调,从而达到能够精确提取文档中印章文本信息的能力。
+通过上面的文档场景信息抽取的快速体验可以进行 Badcase 分析,发现文档场景信息抽取产线的官方模型,在当前需求场景中存在下面的问题:在OCR识别的可视化中,印章的文本弯曲检测框有偏差,导致印章文本识别错误;印章的信息没有被正确的抽取出来。在`{'chat_res': {'印章名称': '大中国土资源局'}`中的结果是错误的。因此,本节工作聚焦于印章信息抽取的场景,对文档场景信息抽取产线中的印章文本检测模型进行微调,从而达到能够精确提取文档中印章文本信息的能力。
 
 
 ### 2.2 在线体验
@@ -137,7 +163,7 @@ tar -xf ./dataset/practical_seal.tar -C ./dataset/
 在对数据集校验时,只需一行命令:
 
 ```bash
-python main.py -c paddlex/configs/seal_text_detection/PP-OCRv4_server_seal_det.yaml \
+python main.py -c paddlex/configs/modules/seal_text_detection/PP-OCRv4_server_seal_det.yaml \
     -o Global.mode=check_dataset \
     -o Global.dataset_dir=./dataset/practical_seal/
 ```
@@ -178,7 +204,7 @@ python main.py -c paddlex/configs/seal_text_detection/PP-OCRv4_server_seal_det.y
   "analysis": {
     "histogram": "check_dataset\/histogram.png"
   },
-  "dataset_path": ".\/dataset\/practical_seal\/",
+  "dataset_path": "practical_seal/",
   "show_type": "image",
   "dataset_type": "TextDetDataset"
 }
@@ -222,7 +248,7 @@ python main.py -c paddlex/configs/seal_text_detection/PP-OCRv4_server_seal_det.y
 在训练之前,请确保您已经对数据集进行了校验。完成 PaddleX 模型的训练,只需如下一条命令:
 
 ```bash
-python main.py -c paddlex/configs/seal_text_detection/PP-OCRv4_server_seal_det.yaml \
+python main.py -c paddlex/configs/modules/seal_text_detection/PP-OCRv4_server_seal_det.yaml \
     -o Global.mode=train \
     -o Global.dataset_dir=./dataset/practical_seal \
     -o Train.epochs_iters=30 \
@@ -263,7 +289,7 @@ PaddleX 中每个模型都提供了模型开发的配置文件,用于设置相
 在完成模型训练后,可以对指定的模型权重文件在验证集上进行评估,验证模型精度。使用 PaddleX 进行模型评估,只需一行命令:
 
 ```bash
-python main.py -c paddlex/configs/seal_text_detection/PP-OCRv4_server_seal_det.yaml \
+python main.py -c paddlex/configs/modules/seal_text_detection/PP-OCRv4_server_seal_det.yaml \
     -o Global.mode=evaluate \
     -o Global.dataset_dir=./dataset/practical_seal
 ```
@@ -348,7 +374,7 @@ python main.py -c paddlex/configs/seal_text_detection/PP-OCRv4_server_seal_det.y
 调整不同参数执行训练的命令可以参考:
 
 ```bash
-python main.py -c paddlex/configs/seal_text_detection/PP-OCRv4_server_seal_det.yaml \
+python main.py -c paddlex/configs/modules/seal_text_detection/PP-OCRv4_server_seal_det.yaml \
     -o Global.mode=train \
     -o Global.dataset_dir=./dataset/practical_seal \
     -o Train.learning_rate=0.0001 \
@@ -366,22 +392,27 @@ python main.py -c paddlex/configs/seal_text_detection/PP-OCRv4_server_seal_det.y
 paddlex --get_pipeline_config PP-ChatOCRv3-doc --save_path ./my_path
 ```
 
-将`PP-ChatOCRv3-doc.yaml`中的`Pipeline.seal_text_det_model`字段修改为上面微调后的模型路径,修改后配置如下:
+参考2.1 填写大语言模型的 ak/sk(access_token), 并将`PP-ChatOCRv3-doc.yaml`中的`SubPipelines.SealRecognition.SealOCR.SubModules.TextDetection.model_dir`字段修改为上面微调后的模型路径,修改后配置如下:
 
 ```yaml
-Pipeline:
-  layout_model: RT-DETR-H_layout_3cls
-  table_model: SLANet_plus
-  text_det_model: PP-OCRv4_server_det
-  text_rec_model: PP-OCRv4_server_rec
-  seal_text_det_model: ./output/best_accuracy/inference
-  doc_image_ori_cls_model: null
-  doc_image_unwarp_model: null
-  llm_name: "ernie-3.5"
-  llm_params:
-    api_type: qianfan
-    ak:
-    sk:
+......
+SubPipelines:
+    ...
+    SealRecognition:
+        ...
+          SealOCR:
+            ...
+            SubModules:
+              TextDetection:
+                module_name: seal_text_detection
+                model_name: PP-OCRv4_server_seal_det
+                model_dir: output/best_accuracy/inference # 修改为微调后的模型路径
+                limit_side_len: 736
+                limit_type: min
+                thresh: 0.2
+                box_thresh: 0.6
+                unclip_ratio: 0.5
+......
 ```
 
 修改后,只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为产线配置文件路径即可应用配置。
@@ -389,34 +420,32 @@ Pipeline:
 ```python
 from paddlex import create_pipeline
 
-pipeline = create_pipeline(
-    pipeline="./my_path/PP-ChatOCRv3-doc.yaml",
-    llm_name="ernie-3.5",
-    llm_params={"api_type": "qianfan", "ak": "", "sk": ""} # 请填入您的ak与sk,否则无法调用大模型
-    # llm_params={"api_type": "aistudio", "access_token": ""} # 或者使用AIStudio接口,请填入您的access_token,否则无法调用大模型
-    )
-
-visual_result, visual_info = pipeline.visual_predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_seal/test.png")
-
-for res in visual_result:
-    res.save_to_img("./output_ft")
-    res.save_to_html('./output_ft')
-    res.save_to_xlsx('./output_ft')
-
-vector = pipeline.build_vector(visual_info=visual_info)
-chat_result = pipeline.chat(
-    key_list=["印章名称"],
-    visual_info=visual_info,
-    vector=vector,
-    )
-chat_result.print()
+pipeline = create_pipeline(pipeline="./my_path/PP-ChatOCRv3-doc.yaml")
+
+visual_predict_res = pipeline.visual_predict(input="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_seal/test.png",
+    use_doc_orientation_classify=False,
+    use_doc_unwarping=False,
+    use_common_ocr=True,
+    use_seal_recognition=True,
+    use_table_recognition=True)
+
+visual_info_list = []
+for res in visual_predict_res:
+    visual_info_list.append(res["visual_info"])
+    layout_parsing_result = res["layout_parsing_result"]
+    layout_parsing_result.save_to_img("./output_ft")
+
+vector_info = pipeline.build_vector(visual_info_list, flag_save_bytes_vector=True)
+chat_result = pipeline.chat(key_list=["印章名称"], visual_info=visual_info_list, vector_info=vector_info)
+print(chat_result)
+
 ```
 
 通过上述可在`./output_ft`下生成预测结果,打印的关键信息抽取结果:
 
 
 ```
-{'chat_res': {'印章名称': '广关市国士资源局'}, 'prompt': ''}
+{'chat_res': {'印章名称': '广关市国士资源局'}}
 ```
 
 可以发现,在模型微调之后,关键信息已经被正确的提取出来。
@@ -435,27 +464,22 @@ chat_result.print()
 ```python
 from paddlex import create_pipeline
 
-pipeline = create_pipeline(
-    pipeline="./my_path/PP-ChatOCRv3-doc.yaml",
-    llm_name="ernie-3.5",
-    llm_params={"api_type": "qianfan", "ak": "", "sk": ""} # 请填入您的ak与sk,否则无法调用大模型
-    # llm_params={"api_type": "aistudio", "access_token": ""} # 或者使用AIStudio接口,请填入您的access_token,否则无法调用大模型
-    )
-
-visual_result, visual_info = pipeline.visual_predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_seal/test.png")
-
-for res in visual_result:
-    res.save_to_img("./output")
-    res.save_to_html('./output')
-    res.save_to_xlsx('./output')
-
-vector = pipeline.build_vector(visual_info=visual_info)
-chat_result = pipeline.chat(
-    key_list=["印章名称"],
-    visual_info=visual_info,
-    vector=vector,
-    )
-chat_result.print()
+pipeline = create_pipeline(pipeline="./my_path/PP-ChatOCRv3-doc.yaml")
+
+visual_predict_res = pipeline.visual_predict(input="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_seal/test.png",
+    use_doc_orientation_classify=False,
+    use_doc_unwarping=False,
+    use_common_ocr=True,
+    use_seal_recognition=True,
+    use_table_recognition=True)
+
+visual_info_list = []
+for res in visual_predict_res:
+    visual_info_list.append(res["visual_info"])
+    layout_parsing_result = res["layout_parsing_result"]
+
+vector_info = pipeline.build_vector(visual_info_list, flag_save_bytes_vector=True)
+chat_result = pipeline.chat(key_list=["印章名称"], visual_info=visual_info_list, vector_info=vector_info)
 ```
 
 更多参数请参考 [文档场景信息抽取v3产线使用教程](../pipeline_usage/tutorials/information_extraction_pipelines/document_scene_information_extraction_v3.md)。

+ 108 - 57
docs/practical_tutorials/ocr_det_license_tutorial.md

@@ -34,40 +34,54 @@ PaddleX 提供了两种体验的方式,一种是可以直接通过 PaddleX whe
 
 ## 3. 选择模型
 
-PaddleX 提供了 2 个端到端的文本检测模型,具体可参考 [模型列表](../support_list/models_list.md),其中模型的 benchmark 如下:
+PaddleX 提供了 4 个端到端的文本检测模型,具体可参考 [模型列表](../support_list/models_list.md),其中模型的 benchmark 如下:
 
 <table>
 <thead>
 <tr>
-<th>模型列表</th>
-<th>检测Hmean(%)</th>
-<th>识别 Avg Accuracy(%)</th>
-<th>GPU 推理耗时(ms)</th>
-<th>CPU 推理耗时(ms)</th>
-<th>模型存储大小(M)</th>
+<th>模型</th>
+<th>检测Hmean(%)</th>
+<th>GPU推理耗时(ms)</th>
+<th>CPU推理耗时 (ms)</th>
+<th>模型存储大小(M)</th>
+<th>介绍</th>
 </tr>
 </thead>
 <tbody>
 <tr>
-<td>PP-OCRv4_server</td>
-<td>82.69</td>
-<td>79.20</td>
-<td>22.20346</td>
-<td>2662.158</td>
-<td>198</td>
+<td>PP-OCRv4_server_det</td>
+<td>82.56</td>
+<td>83.3501</td>
+<td>2434.01</td>
+<td>109</td>
+<td>PP-OCRv4 的服务端文本检测模型,精度更高,适合在性能较好的服务器上部署</td>
+</tr>
+<tr>
+<td>PP-OCRv4_mobile_det</td>
+<td>77.35</td>
+<td>10.6923</td>
+<td>120.177</td>
+<td>4.7</td>
+<td>PP-OCRv4 的移动端文本检测模型,效率更高,适合在端侧设备部署</td>
 </tr>
 <tr>
-<td>PP-OCRv4_mobile</td>
-<td>77.79</td>
-<td>78.20</td>
-<td>2.719474</td>
-<td>79.1097</td>
-<td>15</td>
+<td>PP-OCRv3_mobile_det</td>
+<td>78.68</td>
+<td>-</td>
+<td>-</td>
+<td>2.1</td>
+<td>PP-OCRv3 的移动端文本检测模型,效率更高,适合在端侧设备部署</td>
+</tr>
+<tr>
+<td>PP-OCRv3_server_det</td>
+<td>80.11</td>
+<td>-</td>
+<td>-</td>
+<td>102.1</td>
+<td>PP-OCRv3 的服务端文本检测模型,精度更高,适合在性能较好的服务器上部署</td>
 </tr>
 </tbody>
 </table>
-<b>注:以上精度指标为 PaddleOCR 自建中文数据集验证集 检测Hmean 和 识别 Avg Accuracy,GPU 推理耗时基于 NVIDIA Tesla T4 机器,精度类型为 FP32, CPU 推理速度基于 Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz,线程数为 8,精度类型为 FP32。</b>
-简单来说,表格从上到下,模型推理速度更快,从下到上,模型精度更高。本教程以 `PP-OCRv4_server` 模型为例,完成一次模型全流程开发。你可以依据自己的实际使用场景,判断并选择一个合适的模型做训练,训练完成后可在产线内评估合适的模型权重,并最终用于实际使用场景中。
 
 ## 4. 数据准备和校验
 ### 4.1 数据准备
@@ -86,7 +100,7 @@ tar -xf ./dataset/ccpd_text_det.tar -C ./dataset/
 在对数据集校验时,只需一行命令:
 
 ```bash
-python main.py -c paddlex/configs/text_detection/PP-OCRv4_server_det.yaml \
+python main.py -c paddlex/configs/modules/text_detection/PP-OCRv4_server_det.yaml \
     -o Global.mode=check_dataset \
     -o Global.dataset_dir=./dataset/ccpd_text_det
 ```
@@ -99,35 +113,35 @@ python main.py -c paddlex/configs/text_detection/PP-OCRv4_server_det.yaml \
   "attributes": {
     "train_samples": 5769,
     "train_sample_paths": [
-      "..\/..\/ccpd_text_det\/images\/0274305555556-90_266-204&460_520&548-516&548_209&547_204&464_520&460-0_0_3_25_24_24_24_26-63-89.jpg",
-      "..\/..\/ccpd_text_det\/images\/0126171875-90_267-294&424_498&486-498&486_296&485_294&425_496&424-0_0_3_24_33_32_30_31-157-29.jpg",
-      "..\/..\/ccpd_text_det\/images\/0371516927083-89_254-178&423_517&534-517&534_204&525_178&431_496&423-1_0_3_24_33_31_29_31-117-667.jpg",
-      "..\/..\/ccpd_text_det\/images\/03349609375-90_268-211&469_526&576-526&567_214&576_211&473_520&469-0_0_3_27_31_32_29_32-174-48.jpg",
-      "..\/..\/ccpd_text_det\/images\/0388454861111-90_269-138&409_496&518-496&518_138&517_139&410_491&409-0_0_3_24_27_26_26_30-174-148.jpg",
-      "..\/..\/ccpd_text_det\/images\/0198741319444-89_112-208&517_449&600-423&593_208&600_233&517_449&518-0_0_3_24_28_26_26_26-87-268.jpg",
-      "..\/..\/ccpd_text_det\/images\/3027782118055555555-91_92-186&493_532&574-529&574_199&565_186&497_532&493-0_0_3_27_26_30_33_32-73-336.jpg",
-      "..\/..\/ccpd_text_det\/images\/034375-90_258-168&449_528&546-528&542_186&546_168&449_525&449-0_0_3_26_30_30_26_33-94-221.jpg",
-      "..\/..\/ccpd_text_det\/images\/0286501736111-89_92-290&486_577&587-576&577_290&587_292&491_577&486-0_0_3_17_25_28_30_33-134-122.jpg",
-      "..\/..\/ccpd_text_det\/images\/02001953125-92_103-212&486_458&569-458&569_224&555_212&486_446&494-0_0_3_24_24_25_24_24-88-24.jpg"
+      "check_dataset\/demo_img\/0274305555556-90_266-204&460_520&548-516&548_209&547_204&464_520&460-0_0_3_25_24_24_24_26-63-89.jpg",
+      "check_dataset\/demo_img\/0126171875-90_267-294&424_498&486-498&486_296&485_294&425_496&424-0_0_3_24_33_32_30_31-157-29.jpg",
+      "check_dataset\/demo_img\/0371516927083-89_254-178&423_517&534-517&534_204&525_178&431_496&423-1_0_3_24_33_31_29_31-117-667.jpg",
+      "check_dataset\/demo_img\/03349609375-90_268-211&469_526&576-526&567_214&576_211&473_520&469-0_0_3_27_31_32_29_32-174-48.jpg",
+      "check_dataset\/demo_img\/0388454861111-90_269-138&409_496&518-496&518_138&517_139&410_491&409-0_0_3_24_27_26_26_30-174-148.jpg",
+      "check_dataset\/demo_img\/0198741319444-89_112-208&517_449&600-423&593_208&600_233&517_449&518-0_0_3_24_28_26_26_26-87-268.jpg",
+      "check_dataset\/demo_img\/3027782118055555555-91_92-186&493_532&574-529&574_199&565_186&497_532&493-0_0_3_27_26_30_33_32-73-336.jpg",
+      "check_dataset\/demo_img\/034375-90_258-168&449_528&546-528&542_186&546_168&449_525&449-0_0_3_26_30_30_26_33-94-221.jpg",
+      "check_dataset\/demo_img\/0286501736111-89_92-290&486_577&587-576&577_290&587_292&491_577&486-0_0_3_17_25_28_30_33-134-122.jpg",
+      "check_dataset\/demo_img\/02001953125-92_103-212&486_458&569-458&569_224&555_212&486_446&494-0_0_3_24_24_25_24_24-88-24.jpg"
     ],
     "val_samples": 1001,
     "val_sample_paths": [
-      "..\/..\/ccpd_text_det\/images\/3056141493055555554-88_93-205&455_603&597-603&575_207&597_205&468_595&455-0_0_3_24_32_27_31_33-90-213.jpg",
-      "..\/..\/ccpd_text_det\/images\/0680295138889-88_94-120&474_581&623-577&605_126&623_120&483_581&474-0_0_5_24_31_24_24_24-116-518.jpg",
-      "..\/..\/ccpd_text_det\/images\/0482421875-87_265-154&388_496&530-490&495_154&530_156&411_496&388-0_0_5_25_33_33_33_33-84-104.jpg",
-      "..\/..\/ccpd_text_det\/images\/0347504340278-105_106-235&443_474&589-474&589_240&518_235&443_473&503-0_0_3_25_30_33_27_30-162-4.jpg",
-      "..\/..\/ccpd_text_det\/images\/0205338541667-93_262-182&428_410&519-410&519_187&499_182&428_402&442-0_0_3_24_26_29_32_24-83-63.jpg",
-      "..\/..\/ccpd_text_det\/images\/0380913628472-97_250-234&403_529&534-529&534_250&480_234&403_528&446-0_0_3_25_25_24_25_25-185-85.jpg",
-      "..\/..\/ccpd_text_det\/images\/020598958333333334-93_267-256&471_482&563-478&563_256&546_262&471_482&484-0_0_3_26_24_25_32_24-102-115.jpg",
-      "..\/..\/ccpd_text_det\/images\/3030323350694444445-86_131-170&495_484&593-434&569_170&593_226&511_484&495-11_0_5_30_30_31_33_24-118-59.jpg",
-      "..\/..\/ccpd_text_det\/images\/3016158854166666667-86_97-243&471_462&546-462&527_245&546_243&479_453&471-0_0_3_24_30_27_24_29-98-40.jpg",
-      "..\/..\/ccpd_text_det\/images\/0340831163194-89_264-177&412_488&523-477&506_177&523_185&420_488&412-0_0_3_24_30_29_31_31-109-46.jpg"
+      "check_dataset\/demo_img\/3056141493055555554-88_93-205&455_603&597-603&575_207&597_205&468_595&455-0_0_3_24_32_27_31_33-90-213.jpg",
+      "check_dataset\/demo_img\/0680295138889-88_94-120&474_581&623-577&605_126&623_120&483_581&474-0_0_5_24_31_24_24_24-116-518.jpg",
+      "check_dataset\/demo_img\/0482421875-87_265-154&388_496&530-490&495_154&530_156&411_496&388-0_0_5_25_33_33_33_33-84-104.jpg",
+      "check_dataset\/demo_img\/0347504340278-105_106-235&443_474&589-474&589_240&518_235&443_473&503-0_0_3_25_30_33_27_30-162-4.jpg",
+      "check_dataset\/demo_img\/0205338541667-93_262-182&428_410&519-410&519_187&499_182&428_402&442-0_0_3_24_26_29_32_24-83-63.jpg",
+      "check_dataset\/demo_img\/0380913628472-97_250-234&403_529&534-529&534_250&480_234&403_528&446-0_0_3_25_25_24_25_25-185-85.jpg",
+      "check_dataset\/demo_img\/020598958333333334-93_267-256&471_482&563-478&563_256&546_262&471_482&484-0_0_3_26_24_25_32_24-102-115.jpg",
+      "check_dataset\/demo_img\/3030323350694444445-86_131-170&495_484&593-434&569_170&593_226&511_484&495-11_0_5_30_30_31_33_24-118-59.jpg",
+      "check_dataset\/demo_img\/3016158854166666667-86_97-243&471_462&546-462&527_245&546_243&479_453&471-0_0_3_24_30_27_24_29-98-40.jpg",
+      "check_dataset\/demo_img\/0340831163194-89_264-177&412_488&523-477&506_177&523_185&420_488&412-0_0_3_24_30_29_31_31-109-46.jpg"
     ]
   },
   "analysis": {
     "histogram": "check_dataset\/histogram.png"
   },
-  "dataset_path": "\/mnt\/liujiaxuan01\/new\/new2\/ccpd_text_det",
+  "dataset_path": "ccpd_text_det",
   "show_type": "image",
   "dataset_type": "TextDetDataset"
 }
@@ -169,7 +183,7 @@ python main.py -c paddlex/configs/text_detection/PP-OCRv4_server_det.yaml \
 在训练之前,请确保您已经对数据集进行了校验。完成 PaddleX 模型的训练,只需如下一条命令:
 
 ```bash
-python main.py -c paddlex/configs/text_detection/PP-OCRv4_server_det.yaml \
+python main.py -c paddlex/configs/modules/text_detection/PP-OCRv4_server_det.yaml \
     -o Global.mode=train \
     -o Global.dataset_dir=./dataset/ccpd_text_det
 ```
@@ -206,7 +220,7 @@ PaddleX 中每个模型都提供了模型开发的配置文件,用于设置相
 在完成模型训练后,可以对指定的模型权重文件在验证集上进行评估,验证模型精度。使用 PaddleX 进行模型评估,只需一行命令:
 
 ```bash
-python main.py -c paddlex/configs/text_detection/PP-OCRv4_server_det.yaml \
+python main.py -c paddlex/configs/modules/text_detection/PP-OCRv4_server_det.yaml \
     -o Global.mode=evaluate \
     -o Global.dataset_dir=./dataset/ccpd_text_det
 ```
@@ -291,13 +305,41 @@ python main.py -c paddlex/configs/text_detection/PP-OCRv4_server_det.yaml \
 
 ## 6. 产线测试
 
-将产线中的模型替换为微调后的模型进行测试,如:
+产线中的模型替换为微调后的模型进行测试,可以获取 OCR 产线配置文件,并加载配置文件进行预测。可执行如下命令将结果保存在 `my_path` 中:
+
+```
+paddlex --get_pipeline_config OCR --save_path ./my_path
+```
+
+将配置文件中的`SubModules.TextDetection.model_dir`修改为自己的模型路径:
+
+```yaml
+SubModules:
+  TextDetection:
+    module_name: text_detection
+    model_name: PP-OCRv4_mobile_det
+    model_dir: output/best_accuracy/inference # 替换为微调后的文本检测模型权重路径
+    ...
+```
+
+随后,基于Python脚本方式,加载修改后的产线配置文件即可:
+
+```python
+from paddlex import create_pipeline
+
+pipeline = create_pipeline(pipeline="my_path/OCR.yaml")
+
+output = pipeline.predict(
+    input="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/OCR/case1.jpg",
+    use_doc_orientation_classify=False,
+    use_doc_unwarping=False,
+    use_textline_orientation=False,
+)
+for res in output:
+    res.print()
+    res.save_to_img(save_path="./output/")
+    res.save_to_json(save_path="./output/")
 
-```bash
-paddlex --pipeline OCR \
-        --model PP-OCRv4_server_det PP-OCRv4_server_rec \
-        --model_dir output/best_accuracy/inference None \
-        --input https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/OCR/case1.jpg
 ```
 
 通过上述可在`./output`下生成预测结果,其中`case1.jpg`的预测结果如下:
@@ -309,15 +351,24 @@ paddlex --pipeline OCR \
 
 ## 7. 开发集成/部署
 如果通用 OCR 产线可以达到您对产线推理速度和精度的要求,您可以直接进行开发集成/部署。
-1. 直接将训练好的模型应用在您的 Python 项目中,可以参考如下示例代码,并将`paddlex/pipelines/OCR.yaml`配置文件中的`Pipeline.model`修改为自己的模型路径:
+1. 直接将训练好的模型应用在您的 Python 项目中,可以参考如下示例代码:
+
 ```python
 from paddlex import create_pipeline
-pipeline = create_pipeline(pipeline="paddlex/pipelines/OCR.yaml")
-output = pipeline.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/OCR/case1.jpg")
+
+pipeline = create_pipeline(pipeline="paddlex/configs/pipelines/OCR.yaml")
+
+output = pipeline.predict(
+    input="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/OCR/case1.jpg",
+    use_doc_orientation_classify=False,
+    use_doc_unwarping=False,
+    use_textline_orientation=False,
+)
 for res in output:
-    res.print() # 打印预测的结构化输出
-    res.save_to_img("./output/") # 保存结果可视化图像
-    res.save_to_json("./output/") # 保存预测的结构化输出
+    res.print()
+    res.save_to_img(save_path="./output/")
+    res.save_to_json(save_path="./output/")
+
 ```
 更多参数请参考 [OCR 产线使用教程](../pipeline_usage/tutorials/ocr_pipelines/OCR.md)。
 

+ 33 - 16
docs/practical_tutorials/ts_anomaly_detection.md

@@ -13,7 +13,8 @@ PaddleX 提供了丰富的模型产线,模型产线由一个或多个模型组
 PaddleX 提供了两种体验的方式,一种是可以直接通过 PaddleX 在本地体验,另外一种是可以在 <b>AI Studio 星河社区</b>上体验。
 
 * 本地体验方式:
-```
+
+```python
 from paddlex import create_model
 model = create_model("PatchTST_ad")
 output = model.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/ts/demo_ts/ts_ad.csv", batch_size=1)
@@ -25,7 +26,7 @@ for res in output:
 注:由于时序数据和场景紧密相关,时序任务的在线体验官方内置模型仅是在一个特定场景下的模型方案,并非通用方案,不适用其他场景,因此体验方式不支持使用任意的文件来体验官方模型方案效果。但是,在完成自己场景数据下的模型训练之后,可以选择自己训练的模型方案,并使用对应场景的数据进行在线体验。
 
 ## 3. 选择模型
-PaddleX 提供了5个端到端的时序异常检测模型,具体可参考 [模型列表](../support_list/models_list.md),其中模型的benchmark如下:
+PaddleX 提供了4个端到端的时序异常检测模型,具体可参考 [模型列表](../support_list/models_list.md),其中模型的benchmark如下:
 
 <table>
 <thead>
@@ -71,17 +72,10 @@ PaddleX 提供了5个端到端的时序异常检测模型,具体可参考 [模
 <td>164K</td>
 <td>PatchTST是兼顾局部模式和全局依赖关系的高精度时序异常检测模型</td>
 </tr>
-<tr>
-<td>TimesNet_ad</td>
-<td>0.9837</td>
-<td>0.9480</td>
-<td>0.9656</td>
-<td>732K</td>
-<td>通过多周期分析,TimesNet是适应性强的高精度时序异常检测模型</td>
-</tr>
 </tbody>
 </table>
 > <b>注:以上精度指标测量自</b>[PSM](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/ts_anomaly_examples.tar)<b>数据集,时序长度为100。</b>
+
 ## 4. 数据准备和校验
 ### 4.1 数据准备
 为了演示时序异常检测任务整个流程,我们将使用公开的 MSL 数据集进行模型训练及验证。PSM(火星科学实验室)数据集由来自美国国家航空航天局,具有 55 个维度,其中包含来自航天器监测系统的意外事件异常(ISA)报告的遥测异常数据。具有实际应用背景,能够更好地反映真实场景中的异常情况,通常用于测试和验证时间序列异常检测模型的性能。本教程中基于该数据集进行异常检测。
@@ -104,7 +98,7 @@ tar -xf ./dataset/msl.tar -C ./dataset/
 在对数据集校验时,只需一行命令:
 
 ```
-python main.py -c paddlex/configs/ts_anomaly_detection/PatchTST_ad.yaml \
+python main.py -c paddlex/configs/modules/ts_anomaly_detection/PatchTST_ad.yaml \
     -o Global.mode=check_dataset \
     -o Global.dataset_dir=./dataset/msl
 ```
@@ -153,7 +147,7 @@ python main.py -c paddlex/configs/ts_anomaly_detection/PatchTST_ad.yaml \
 在训练之前,请确保您已经对数据集进行了校验。完成 PaddleX 模型的训练,只需如下一条命令:
 
 ```
-  python main.py -c paddlex/configs/ts_anomaly_detection/PatchTST_ad.yaml \
+  python main.py -c paddlex/configs/modules/ts_anomaly_detection/PatchTST_ad.yaml \
     -o Global.mode=train \
     -o Global.dataset_dir=./dataset/msl \
     -o Train.epochs_iters=5 \
@@ -206,7 +200,7 @@ PaddleX 中每个模型都提供了模型开发的配置文件,用于设置相
 在完成模型训练后,可以对指定的模型权重文件在验证集上进行评估,验证模型精度。使用 PaddleX 进行模型评估,只需一行命令:
 
 ```
-    python main.py -c paddlex/configs/ts_anomaly_detection/PatchTST_ad.yaml \
+    python main.py -c paddlex/configs/modules/ts_anomaly_detection/PatchTST_ad.yaml \
     -o Global.mode=evaluate \
     -o Global.dataset_dir=./dataset/msl
 ```
@@ -308,11 +302,13 @@ PaddleX 中每个模型都提供了模型开发的配置文件,用于设置相
 </tr>
 </tbody>
 </table>
+
 ## 6. 产线测试
+
 将产线中的模型替换为微调后的模型进行测试,使用[测试文件](https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/timeseries_anomaly_detection/test.csv)进行预测:
 
 ```
-python main.py -c paddlex/configs/ts_anomaly_detection/PatchTST_ad.yaml \
+python main.py -c paddlex/configs/modules/ts_anomaly_detection/PatchTST_ad.yaml \
     -o Global.mode=predict \
     -o Predict.model_dir="./output/inference" \
     -o Predict.input="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/timeseries_anomaly_detection/test.csv"
@@ -328,15 +324,36 @@ python main.py -c paddlex/configs/ts_anomaly_detection/PatchTST_ad.yaml \
 ## 7.开发集成/部署
 如果通用时序异常检测产线可以达到您对产线推理速度和精度的要求,您可以直接进行开发集成/部署。
 
-1. 若您需要将通用时序异常检测产线直接应用在您的 Python 项目中,可以参考 如下示例代码:
+1. 若您需要使用微调后的模型权重,可以获取 ts_anomaly_detection 产线配置文件,并加载配置文件进行预测。可执行如下命令将结果保存在 `my_path` 中:
+
 ```
+paddlex --get_pipeline_config ts_anomaly_detection --save_path ./my_path
+```
+
+将微调后模型权重的本地路径填写至产线配置文件中的 `model_dir` 即可, 若您需要将通用时序分类产线直接应用在您的 Python 项目中,可以参考 如下示例:
+
+```yaml
+pipeline_name: ts_anomaly_detection
+
+SubModules:
+  TSAnomalyDetection:
+    module_name: ts_anomaly_detection
+    model_name: PatchTST_ad
+    model_dir: ./output/inference  # 此处替换为您训练后得到的模型权重本地路径
+    batch_size: 1
+```
+
+随后执行如下代码即可完成预测:
+
+```python
 from paddlex import create_pipeline
-pipeline = create_pipeline(pipeline="ts_anomaly_detection")
+pipeline = create_pipeline(pipeline="my_path/ts_anomaly_detection.yaml")
 output = pipeline.predict("pre_ts.csv")
 for res in output:
     res.print() # 打印预测的结构化输出
     res.save_to_csv("./output/") # 保存csv格式结果
 ```
+
 更多参数请参考[时序异常检测产线使用教程](../pipeline_usage/tutorials/time_series_pipelines/time_series_anomaly_detection.md)
 
 2. 此外,PaddleX 时序异常检测产线也提供了服务化部署方式,详细说明如下:

+ 27 - 7
docs/practical_tutorials/ts_classification.md

@@ -13,7 +13,7 @@ PaddleX 提供了丰富的模型产线,模型产线由一个或多个模型组
 PaddleX 提供了两种体验的方式,一种是可以直接通过 PaddleX 在本地体验,另外一种是可以在 <b>AI Studio 星河社区</b>上体验。
 
 * 本地体验方式:
-```
+```python
 from paddlex import create_model
 model = create_model("TimesNet_cls")
 output = model.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/ts/demo_ts/ts_cls.csv", batch_size=1)
@@ -70,7 +70,7 @@ tar -xf ./dataset/ts_classify_examples.tar -C ./dataset/
 在对数据集校验时,只需一行命令:
 
 ```
-python main.py -c paddlex/configs/ts_classification/TimesNet_cls.yaml \
+python main.py -c paddlex/configs/modules/ts_classification/TimesNet_cls.yaml \
     -o Global.mode=check_dataset \
     -o Global.dataset_dir=./dataset/ts_classify_examples
 ```
@@ -116,7 +116,7 @@ python main.py -c paddlex/configs/ts_classification/TimesNet_cls.yaml \
 在训练之前,请确保您已经对数据集进行了校验。完成 PaddleX 模型的训练,只需如下一条命令:
 
 ```
-    python main.py -c paddlex/configs/ts_classification/TimesNet_cls.yaml \
+    python main.py -c paddlex/configs/modules/ts_classification/TimesNet_cls.yaml \
     -o Global.mode=train \
     -o Global.dataset_dir=./dataset/ts_classify_examples \
     -o Train.epochs_iters=5 \
@@ -172,7 +172,7 @@ PaddleX 中每个模型都提供了模型开发的配置文件,用于设置相
 在完成模型训练后,可以对指定的模型权重文件在验证集上进行评估,验证模型精度。使用 PaddleX 进行模型评估,只需一行命令:
 
 ```
-    python main.py -c paddlex/configs/ts_classification/TimesNet_cls.yaml \
+    python main.py -c paddlex/configs/modules/ts_classification/TimesNet_cls.yaml \
     -o Global.mode=evaluate \
     -o Global.dataset_dir=./dataset/ts_classify_examples \
     -o Evaluate.weight_path=./output/best_model/model.pdparams
@@ -271,11 +271,12 @@ PaddleX 中每个模型都提供了模型开发的配置文件,用于设置相
 </tr>
 </tbody>
 </table>
+
 ## 6. 产线测试
 将模型目录设置为训练完成的模型进行测试,使用[测试文件](https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/timeseries_classification/test.csv),进行预测:
 
 ```
-python main.py -c paddlex/configs/ts_classification/TimesNet_cls.yaml \
+python main.py -c paddlex/configs/modules/ts_classification/TimesNet_cls.yaml \
     -o Global.mode=predict \
     -o Predict.model_dir="./output/inference" \
     -o Predict.input="https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/timeseries_classification/test.csv"
@@ -291,10 +292,29 @@ python main.py -c paddlex/configs/ts_classification/TimesNet_cls.yaml \
 ## 7. 开发集成/部署
 如果通用时序分类产线可以达到您对产线推理速度和精度的要求,您可以直接进行开发集成/部署。
 
-1. 若您需要将通用时序分类产线直接应用在您的 Python 项目中,可以参考 如下示例代码:
+1. 若您需要使用微调后的模型权重,可以获取 ts_classification 产线配置文件,并加载配置文件进行预测。可执行如下命令将结果保存在 `my_path` 中:
+
 ```
+paddlex --get_pipeline_config ts_classification --save_path ./my_path
+```
+
+将微调后模型权重的本地路径填写至产线配置文件中的 `model_dir` 即可, 若您需要将通用时序分类产线直接应用在您的 Python 项目中,可以参考 如下示例:
+
+```yaml
+pipeline_name: ts_classification
+
+SubModules:
+  TSClassification:
+    module_name: ts_classification
+    model_name: TimesNet_cls
+    model_dir: ./output/inference  # 此处替换为您训练后得到的模型权重本地路径
+    batch_size: 1
+```
+随后,在您的 Python 代码中,您可以这样使用产线:
+
+```python
 from paddlex import create_pipeline
-pipeline = create_pipeline(pipeline="ts_anomaly_detection")
+pipeline = create_pipeline(pipeline="my_path/ts_classification.yaml")
 output = pipeline.predict("pre_ts.csv")
 for res in output:
     res.print() # 打印预测的结构化输出

+ 26 - 6
docs/practical_tutorials/ts_forecast.md

@@ -101,7 +101,7 @@ tar -xf ./dataset/electricity.tar -C ./dataset/
 在对数据集校验时,只需一行命令:
 
 ```
-python main.py -c paddlex/configs/ts_forecast/DLinear.yaml \
+python main.py -c paddlex/configs/modules/ts_forecast/DLinear.yaml \
     -o Global.mode=check_dataset \
     -o Global.dataset_dir=./dataset/electricity
 ```
@@ -231,7 +231,7 @@ python main.py -c paddlex/configs/ts_forecast/DLinear.yaml \
 在训练之前,请确保您已经对数据集进行了校验。完成 PaddleX 模型的训练,只需如下一条命令:
 
 ```
-    python main.py -c paddlex/configs/ts_forecast/DLinear.yaml \
+    python main.py -c paddlex/configs/modules/ts_forecast/DLinear.yaml \
     -o Global.mode=train \
     -o Global.dataset_dir=./dataset/electricity \
     -o Train.epochs_iters=5 \
@@ -286,7 +286,7 @@ PaddleX 中每个模型都提供了模型开发的配置文件,用于设置相
 在完成模型训练后,可以对指定的模型权重文件在验证集上进行评估,验证模型精度。使用 PaddleX 进行模型评估,只需一行命令:
 
 ```
-    python main.py -c paddlex/configs/ts_forecast/DLinear.yaml \
+    python main.py -c paddlex/configs/modules/ts_forecast/DLinear.yaml \
     -o Global.mode=evaluate \
     -o Global.dataset_dir=./dataset/electricity \
 ```
@@ -433,7 +433,7 @@ PaddleX 中每个模型都提供了模型开发的配置文件,用于设置相
 将产线中的模型替换为微调后的模型进行测试,使用[本案例中的电力测试数据](https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/timeseries_forecast/test.csv),进行预测:
 
 ```
-python main.py -c paddlex/configs/ts_forecast/DLinear.yaml \
+python main.py -c paddlex/configs/modules/ts_forecast/DLinear.yaml \
     -o Global.mode=predict \
     -o Predict.model_dir="./output/inference" \
     -o Predict.input=https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/timeseries_forecast/test.csv
@@ -451,10 +451,30 @@ python main.py -c paddlex/configs/ts_forecast/DLinear.yaml \
 ## 7. 开发集成/部署
 如果通用时序预测产线可以达到您对产线推理速度和精度的要求,您可以直接进行开发集成/部署。
 
-1. 若您需要将通用时序预测产线直接应用在您的 Python 项目中,可以参考 如下示例代码:
+1. 若您需要使用微调后的模型权重,可以获取 ts_forecast 产线配置文件,并加载配置文件进行预测。可执行如下命令将结果保存在 `my_path` 中:
+
+```
+paddlex --get_pipeline_config ts_forecast --save_path ./my_path
+```
+
+将微调后模型权重的本地路径填写至产线配置文件中的 `model_dir` 即可, 若您需要将通用时序分类产线直接应用在您的 Python 项目中,可以参考 如下示例:
+
+```yaml
+pipeline_name: ts_forecast
+
+SubModules:
+  TSForecast:
+    module_name: ts_forecast
+    model_name: ./output/inference
+    model_dir: null # 此处替换为您训练后得到的模型权重本地路径
+    batch_size: 1
 ```
+
+随后,在您的 Python 代码中,您可以这样使用产线:
+
+```python
 from paddlex import create_pipeline
-pipeline = create_pipeline(pipeline="ts_forecast")
+pipeline = create_pipeline(pipeline="my_path/ts_forecast.yaml")
 output = pipeline.predict("pre_ts.csv")
 for res in output:
     res.print() # 打印预测的结构化输出

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff