Sunflower7788 1 жил өмнө
parent
commit
2754af7581

+ 409 - 0
docs/practical_tutorials/document_scene_information_extraction(seal_recognition)_tutorial.md

@@ -0,0 +1,409 @@
+简体中文 | [English](document_scene_information_extraction(seal_recognition)_tutorial_en.md)
+
+# PaddleX 3.0 文档场景信息抽取v3(PP-ChatOCRv3_doc) —— 印章信息抽取教程
+
+
+PaddleX 提供了丰富的模型产线,模型产线由一个或多个模型组合实现,每个模型产线都能够解决特定的场景任务问题。PaddleX 所提供的模型产线均支持快速体验,如果效果不及预期,也同样支持使用私有数据微调模型,并且 PaddleX 提供了 Python API,方便将产线集成到个人项目中。在使用之前,您首先需要安装 PaddleX, 安装方式请参考 [PaddleX本地安装教程](../installation/installation.md)。此处以一个印章的文档场景信息抽取任务为例子,介绍该产线的在实际场景中的使用流程。
+
+
+## 1. 选择产线
+
+印章信息抽取是文档处理的一部分,在很多场景都有用途,例如合同比对,出入库审核以及发票报销审核等场景。采用人工智能技术进行印章自动识别,可以为企业有效节省人力成本,提高效率。
+
+首先,需要根据任务场景,选择对应的 PaddleX 产线,本节为印章信息抽取任务,不难发现印章信息抽取任务与文档场景信息抽取任务存在着紧密的关联。文档场景信息抽取,即从文档或图像中提取文本信息,是计算机视觉领域的一个经典问题。对应 PaddleX 的文档场景信息抽取v3产线。如果无法确定任务和产线的对应关系,您可以在 PaddleX 支持的[产线列表](../support_list/pipelines_list.md)中了解相关产线的能力介绍。
+
+
+## 2. 快速体验
+
+PaddleX 提供了两种体验的方式,你可以在线体验文档场景信息抽取v3产线的效果,也可以在本地使用 Python 体验文档场景信息抽取v3 产线的效果。
+
+
+### 2.1 本地体验
+
+在本地使用文档场景信息抽取v3产线前,请确保您已经按照[PaddleX本地安装教程](../installation/installation.md)完成了PaddleX的wheel包安装。几行代码即可完成产线的快速推理:
+
+
+```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()
+```
+
+**注**:目前仅支持文心大模型,支持在[百度云千帆平台](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。
+
+
+输出打印的结果如下:
+
+```
+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': ''}
+```
+
+在`output` 目录中,保存了印章文本检测、OCR(如有表格,还有表格识别可视化结果以及表格html和xlsx)结果。
+
+其中印章文本识别结果可视化如下:
+
+![](https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/practical_tutorials/PP-ChatOCRv3_doc/seal_01.png)
+
+
+通过上面的文档场景信息抽取的快速体验可以进行 Badcase 分析,发现文档场景信息抽取产线的官方模型,在当前需求场景中存在下面的问题:在OCR识别的可视化中,印章的文本弯曲检测框有偏差,导致印章文本识别错误;印章的信息没有被正确的抽取出来。在`{'chat_res': {'印章': '未知'}, 'prompt': ''}`中的结果是未知。因此,本节工作聚焦于印章信息抽取的场景,对文档场景信息抽取产线中的印章文本检测模型进行微调,从而达到能够精确提取文档中印章文本信息的能力。
+
+
+### 2.2 在线体验
+
+您可以在 **AI Studio 星河社区** 体验文档场景信息抽取v3产线的效果,点击链接下载 [印章测试文件](https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_seal/test.png),上传至[官方文档场景信息抽取v3 应用](https://aistudio.baidu.com/community/app/182491/webUI?source=appCenter) 体验抽取效果。如下:
+
+![](https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_seal/06.png)
+
+
+
+## 3. 选择模型
+
+PaddleX 提供了 2 个端到端的印章文本检测模型,具体可参考 [模型列表](../support_list/models_list.md),其中印章文本检测模型的 benchmark 如下:
+
+|模型名称|检测Hmean(%)|GPU推理耗时(ms)|CPU推理耗时(ms)|模型存储大小|yaml 文件|
+|-|-|-|-|-|-|
+|PP-OCRv4_mobile_seal_det|96.47|10.5878|131.813|4.7M |[PP-OCRv4_mobile_seal_det.yaml](../../paddlex/configs/text_detection_seal/PP-OCRv4_mobile_seal_det.yaml)|
+|PP-OCRv4_server_seal_det|98.21|84.341|2425.06|108.3 M|[PP-OCRv4_server_seal_det.yaml](../../paddlex/configs/text_detection_seal/PP-OCRv4_server_seal_det.yaml)|
+
+**注:以上精度指标的评估集是 PaddleX 自建的印章数据集,包含500印章图像。**
+
+
+## 4. 数据准备和校验
+### 4.1 数据准备
+
+本教程采用 `印章文本检测数据集` 作为示例数据集,可通过以下命令获取示例数据集。如果您使用自备的已标注数据集,需要按照 PaddleX 的格式要求对自备数据集进行调整,以满足 PaddleX 的数据格式要求。关于数据格式介绍,您可以参考 [PaddleX 目标检测模块数据标注教程](../data_annotations/ocr_modules/text_detection_recognition.md)。
+
+数据集获取命令:
+```bash
+cd /path/to/paddlex
+wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/practical_seal.tar -P ./dataset
+tar -xf ./dataset/practical_seal.tar -C ./dataset/
+```
+
+### 4.2 数据集校验
+
+在对数据集校验时,只需一行命令:
+
+```bash
+python main.py -c paddlex/configs/text_detection_seal/PP-OCRv4_server_seal_det.yaml \
+    -o Global.mode=check_dataset \
+    -o Global.dataset_dir=./dataset/practical_seal/
+```
+
+执行上述命令后,PaddleX 会对数据集进行校验,并统计数据集的基本信息。命令运行成功后会在 log 中打印出 `Check dataset passed !` 信息,同时相关产出会保存在当前目录的 `./output/check_dataset` 目录下,产出目录中包括可视化的示例样本图片和样本检测框长宽比分布直方图。校验结果文件保存在 `./output/check_dataset_result.json`,校验结果文件具体内容为
+```
+{
+  "done_flag": true,
+  "check_pass": true,
+  "attributes": {
+    "train_samples": 793,
+    "train_sample_paths": [
+      "..\/dataset\/practical_seal\/images\/PMC4055390_00006_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC3712248_00008_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC4227328_00001_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC3745965_00007_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC3980931_00001_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC5896212_00003_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC3838814_00003_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC4677212_00002_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC4058803_00001_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC4925966_00001_seal_0_crop.png"
+    ],
+    "val_samples": 277,
+    "val_sample_paths": [
+      "..\/dataset\/practical_seal\/images\/15.jpg",
+      "..\/dataset\/practical_seal\/images\/16.jpg",
+      "..\/dataset\/practical_seal\/images\/17.jpg",
+      "..\/dataset\/practical_seal\/images\/18.jpg",
+      "..\/dataset\/practical_seal\/images\/19.jpg",
+      "..\/dataset\/practical_seal\/images\/20.jpg",
+      "..\/dataset\/practical_seal\/images\/21.jpg",
+      "..\/dataset\/practical_seal\/images\/22.jpg",
+      "..\/dataset\/practical_seal\/images\/23.jpg",
+      "..\/dataset\/practical_seal\/images\/24.jpg"
+    ]
+  },
+  "analysis": {
+    "histogram": "check_dataset\/histogram.png"
+  },
+  "dataset_path": ".\/dataset\/practical_seal\/",
+  "show_type": "image",
+  "dataset_type": "TextDetDataset"
+}
+```
+上述校验结果中,check_pass 为 True 表示数据集格式符合要求,其他部分指标的说明如下:
+
+- attributes.train_samples:该数据集训练集样本数量为 793;
+- attributes.val_samples:该数据集验证集样本数量为 277;
+- attributes.train_sample_paths:该数据集训练集样本可视化图片相对路径列表;
+- attributes.val_sample_paths:该数据集验证集样本可视化图片相对路径列表;
+
+另外,数据集校验还对数据集中所有类别的样本长宽比分布情况进行了分析,并绘制了分布直方图(histogram.png):
+
+<center>
+
+<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/practical_tutorials/PP-ChatOCRv3_doc/seal_02.png" width=600>
+
+</center>
+
+**注**:只有通过数据校验的数据才可以训练和评估。
+
+
+### 4.3 数据集划分(非必选)
+
+如需对数据集格式进行转换或是重新划分数据集,可通过修改配置文件或是追加超参数的方式进行设置。
+
+数据集校验相关的参数可以通过修改配置文件中 `CheckDataset` 下的字段进行设置,配置文件中部分参数的示例说明如下:
+
+* `CheckDataset`:
+    * `split`:
+        * `enable`: 是否进行重新划分数据集,为 `True` 时进行数据集格式转换,默认为 `False`;
+        * `train_percent`: 如果重新划分数据集,则需要设置训练集的百分比,类型为 0-100 之间的任意整数,需要保证和 `val_percent` 值加和为 100;
+        * `val_percent`: 如果重新划分数据集,则需要设置验证集的百分比,类型为 0-100 之间的任意整数,需要保证和 `train_percent` 值加和为 100;
+
+数据划分时,原有标注文件会被在原路径下重命名为 `xxx.bak`,以上参数同样支持通过追加命令行参数的方式进行设置,例如重新划分数据集并设置训练集与验证集比例:`-o CheckDataset.split.enable=True -o CheckDataset.split.train_percent=80 -o CheckDataset.split.val_percent=20`。
+
+
+## 5. 模型训练和评估
+### 5.1 模型训练
+
+在训练之前,请确保您已经对数据集进行了校验。完成 PaddleX 模型的训练,只需如下一条命令:
+
+```bash
+python main.py -c paddlex/configs/text_detection_seal/PP-OCRv4_server_seal_det.yaml \
+    -o Global.mode=train \
+    -o Global.dataset_dir=./dataset/practical_seal \
+    -o Global.epochs_iters=30 \
+    -o Global.batch_size=4 \
+    -o Global.learning_rate=0.0001
+```
+
+在 PaddleX 中模型训练支持:修改训练超参数、单机单卡/多卡训练等功能,只需修改配置文件或追加命令行参数。
+
+PaddleX 中每个模型都提供了模型开发的配置文件,用于设置相关参数。模型训练相关的参数可以通过修改配置文件中 `Train` 下的字段进行设置,配置文件中部分参数的示例说明如下:
+
+* `Global`:
+    * `mode`:模式,支持数据校验(`check_dataset`)、模型训练(`train`)、模型评估(`evaluate`);
+    * `device`:训练设备,可选`cpu`、`gpu`、`xpu`、`npu`、`mlu`,除 cpu 外,多卡训练可指定卡号,如:`gpu:0,1,2,3`;
+* `Train`:训练超参数设置;
+    * `epochs_iters`:训练轮次数设置;
+    * `learning_rate`:训练学习率设置;
+
+更多超参数介绍,请参考 [PaddleX 通用模型配置文件参数说明](../module_usage/instructions/config_parameters_common.md)。
+
+**注:**
+- 以上参数可以通过追加令行参数的形式进行设置,如指定模式为模型训练:`-o Global.mode=train`;指定前 2 卡 gpu 训练:`-o Global.device=gpu:0,1`;设置训练轮次数为 10:`-o Train.epochs_iters=10`。
+- 模型训练过程中,PaddleX 会自动保存模型权重文件,默认为`output`,如需指定保存路径,可通过配置文件中 `-o Global.output` 字段
+- PaddleX 对您屏蔽了动态图权重和静态图权重的概念。在模型训练的过程中,会同时产出动态图和静态图的权重,在模型推理时,默认选择静态图权重推理。
+
+**训练产出解释:**
+
+在完成模型训练后,所有产出保存在指定的输出目录(默认为`./output/`)下,通常有以下产出:
+
+* train_result.json:训练结果记录文件,记录了训练任务是否正常完成,以及产出的权重指标、相关文件路径等;
+* train.log:训练日志文件,记录了训练过程中的模型指标变化、loss 变化等;
+* config.yaml:训练配置文件,记录了本次训练的超参数的配置;
+* .pdparams、.pdopt、.pdstates、.pdiparams、.pdmodel:模型权重相关文件,包括网络参数、优化器、静态图网络参数、静态图网络结构等;
+
+
+### 5.2 模型评估
+
+在完成模型训练后,可以对指定的模型权重文件在验证集上进行评估,验证模型精度。使用 PaddleX 进行模型评估,只需一行命令:
+
+```bash
+python main.py -c paddlex/configs/text_detection_seal/PP-OCRv4_server_seal_det.yaml \
+    -o Global.mode=evaluate \
+    -o Global.dataset_dir=./dataset/practical_seal
+```
+
+与模型训练类似,模型评估支持修改配置文件或追加命令行参数的方式设置。
+
+**注:** 在模型评估时,需要指定模型权重文件路径,每个配置文件中都内置了默认的权重保存路径,如需要改变,只需要通过追加命令行参数的形式进行设置即可,如`-o Evaluate.weight_path=./output/best_accuracy/best_accuracy.pdparams`。
+
+### 5.3 模型调优
+
+在学习了模型训练和评估后,我们可以通过调整超参数来提升模型的精度。通过合理调整训练轮数,您可以控制模型的训练深度,避免过拟合或欠拟合;而学习率的设置则关乎模型收敛的速度和稳定性。因此,在优化模型性能时,务必审慎考虑这两个参数的取值,并根据实际情况进行灵活调整,以获得最佳的训练效果。
+
+推荐在调试参数时遵循控制变量法:
+1. 首先固定训练轮次为 30,批大小为 4。
+2. 基于 `PP-OCRv4_server_seal_det` 模型启动三个实验,学习率分别为:0.001,0.0001,0.00001。
+3. 可以发现实验1精度最高的配置为学习率为 0.001,同时观察验证集分数,精度在最后几轮仍在上涨。因此可以提升训练轮次为 100,模型精度会有进一步的提升。
+
+学习率探寻实验结果:
+
+<center>
+
+| 实验ID           | 学习率 |  检测 Hmean(%) | 
+| --------------- | ------------- | -------------------- |
+| **1** | **0.001**     | **97.35**       | 
+| 2 | 0.0001   | 93.32       |
+| 3 | 0.00001       | 87.63    |
+
+
+</center>
+
+接下来,我们可以在学习率设置为 0.001 的基础上,增加训练轮次,对比下面实验 [1,4] 可知,训练轮次增大,模型精度有了进一步的提升。
+
+<center>
+
+
+| 实验ID           | 训练轮次 |  检测 Hmean(%) | 
+| --------------- | ------------- | -------------------- |
+| 1 | 30    |97.35   |
+| 4 |100  | 98.13   |
+
+</center>
+
+** 注:本教程为 4 卡教程,如果您只有 1 张 GPU,可通过调整训练卡数完成本次实验,但最终指标未必和上述指标完全对齐,属正常情况。**
+
+在选择训练环境时,要考虑训练卡数和总 batch_size,以及学习率的关系。首先训练卡数乘以单卡 batch_size 等于总 batch_size。其次,总 batch_size 和学习率是相关的,学习率应与总 batch_size 保持同步调整。 目前默认学习率对应基于 4 卡训练的总 batch_size,若您打算在单卡环境下进行训练,则设置学习率时需相应除以 4。若您打算在 8 卡环境下进行训练,则设置学习率时需相应乘以 2。
+
+调整不同参数执行训练的命令可以参考:
+
+```bash
+python main.py -c paddlex/configs/text_detection_seal/PP-OCRv4_server_seal_det.yaml \
+    -o Global.mode=train \
+    -o Global.dataset_dir=./dataset/practical_seal \
+    -o Train.learning_rate=0.0001 \
+    -o Train.epochs_iters=30 \
+    -o Train.batch_size=4
+```
+
+## 6. 产线测试
+
+将产线中的模型替换为微调后的模型进行测试,使用 [印章测试文件](https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_seal/test.png),进行预测:
+
+首先获取并更新文档信息抽取v3的配置文件,执行下面的命令获取配置文件,(假设自定义保存位置为 `./my_path` ):
+
+```bash
+paddlex --get_pipeline_config PP-ChatOCRv3-doc --save_path ./my_path
+```
+
+将`PP-ChatOCRv3-doc.yaml`中的`Pipeline.seal_text_det_model`字段修改为上面微调后的模型路径,修改后配置如下:
+
+```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:
+```
+
+修改后,只需要修改 `create_pipeline` 方法中的 `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()
+```
+
+通过上述可在`./output_ft`下生成预测结果,打印的关键信息抽取结果:
+
+
+```
+{'chat_res': {'印章名称': '广关市国士资源局'}, 'prompt': ''}
+```
+
+可以发现,在模型微调之后,关键信息已经被正确的提取出来。
+
+印章文本检测的可视化结果如下,已经正确抽取印章信息:
+
+![](https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/practical_tutorials/PP-ChatOCRv3_doc/seal_04.png)
+
+
+## 7. 开发集成/部署
+
+如果文档场景信息抽取v3产线可以达到您对产线推理速度和精度的要求,您可以直接进行开发集成/部署。
+
+1. 直接将训练好的模型产线应用在您的 Python 项目中,如下面代码所示:
+
+```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()
+```
+
+更多参数请参考 [文档场景信息抽取v3产线使用教程](../pipeline_usage/tutorials/information_extraction_pipelines/document_scene_information_extraction.md)。
+
+2. 此外,PaddleX 也提供了其他三种部署方式,详细说明如下:
+
+* 高性能部署:在实际生产环境中,许多应用对部署策略的性能指标(尤其是响应速度)有着较严苛的标准,以确保系统的高效运行与用户体验的流畅性。为此,PaddleX 提供高性能推理插件,旨在对模型推理及前后处理进行深度性能优化,实现端到端流程的显著提速,详细的高性能部署流程请参考 [PaddleX 高性能部署指南](../pipeline_deploy/high_performance_inference.md)。
+* 服务化部署:服务化部署是实际生产环境中常见的一种部署形式。通过将推理功能封装为服务,客户端可以通过网络请求来访问这些服务,以获取推理结果。PaddleX 支持用户以低成本实现产线的服务化部署,详细的服务化部署流程请参考 [PaddleX 服务化部署指南](../pipeline_deploy/service_deploy.md)。
+* 端侧部署:端侧部署是一种将计算和数据处理功能放在用户设备本身上的方式,设备可以直接处理数据,而不需要依赖远程的服务器。PaddleX 支持将模型部署在 Android 等端侧设备上,详细的端侧部署流程请参考 [PaddleX端侧部署指南](../pipeline_deploy/edge_deploy.md)。
+
+您可以根据需要选择合适的方式部署模型产线,进而进行后续的 AI 应用集成。
+
+

+ 409 - 0
docs/practical_tutorials/document_scene_information_extraction(seal_recognition)_tutorial_en.md

@@ -0,0 +1,409 @@
+[简体中文](document_scene_information_extraction(seal_recognition)_tutorial.md) | English
+
+# PaddleX 3.0 Document Scene Information Extraction v3 (PP-ChatOCRv3_doc) —— Tutorial on Seal Information Extraction
+
+PaddleX offers a rich set of pipelines, each consisting of one or more models that can tackle specific scenario tasks. All PaddleX pipelines support quick trials, and if the results are not satisfactory, you can fine-tune the models with your private data. PaddleX also provides Python APIs for easy integration into personal projects. Before use, you need to install PaddleX. For installation instructions, please refer to [PaddleX Installation](../installation/installation_en.md). This tutorial introduces the usage of the pipeline tool with a garbage classification task as an example.
+
+## 1. Select a Pipeline
+
+Seal information extraction is a part of document processing and has applications in many scenarios, such as contract comparison, inventory review, and invoice reimbursement review. Using artificial intelligence technology for automatic seal recognition can effectively save labor costs and improve efficiency for enterprises.
+
+Firstly, it is necessary to select the corresponding PaddleX production line based on the task scenario. This section is about the seal information extraction task, and it is not difficult to find that the seal information extraction task is closely related to the document scenario information extraction task. Document scene information extraction, which extracts text information from documents or images, is a classic problem in the field of computer vision. Corresponding to PaddleX's document scene information extraction v3 production line. If you are unable to determine the correspondence between tasks and production lines, you can learn about the capabilities of the relevant production lines in [PaddleX Supported Pipelines List](../support_list/pipelines_list_en.md).
+
+## 2. Quick Start
+
+PaddleX offers two ways to experience its capabilities. You can try out the Document Scene Information Extraction v3 pipeline online, or you can use Python locally to experience the effects of the Document Scene Information Extraction v3 pipeline.
+
+
+### 2.1 Local Experience
+
+Before using the Document Scene Information Extraction v3 pipeline locally, please ensure that you have completed the installation of the PaddleX wheel package according to the [PaddleX Local Installation Tutorial](../../docs/installation/installation_en.md). With just a few lines of code, you can quickly perform inference using the pipeline:
+
+
+```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": ""} # To use the Qianfan API, please fill in your Access Key (ak) and Secret Key (sk), as you will not be able to invoke large models without them.
+    # llm_params={"api_type": "aistudio", "access_token": ""} # Or, to use the AIStudio API, please fill in your access_token, as you will not be able to invoke large models without it.
+    )
+
+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()
+```
+
+**Note**: Currently, the large language model only supports Ernie. You can obtain the relevant ak/sk (access_token) on the [Baidu Cloud Qianfan Platform](https://console.bce.baidu.com/qianfan/ais/console/onlineService) or [Baidu AIStudio Community](https://aistudio.baidu.com/). If you use the Baidu Cloud Qianfan Platform, you can refer to the [AK and SK Authentication API Calling Process](https://cloud.baidu.com/doc/WENXINWORKSHOP/s/Hlwerugt8) to obtain ak/sk. If you use Baidu AIStudio Community, you can obtain the access_token from the [Baidu AIStudio Community Access Token](https://aistudio.baidu.com/account/accessToken).
+
+
+The printed output results are as follows:
+
+```
+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': ''}
+
+```
+
+In the `output` directory, the visualization results of seal_recognition and OCR (if table exits, table recognition, as well as the table results in HTML and XLSX formats), are saved.
+
+Among them, the visualization of the seal_recognition results is as follows:
+
+![](https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/practical_tutorials/PP-ChatOCRv3_doc/seal_01.png)
+
+Through the online experience of the document scene information extraction, a Badcase analysis can be conducted to identify issues with the official model of the document scene information extraction pipeline. The official model of the document scene information extraction production line has been found to have the following issues in the current demand scenario: in the visualization of OCR recognition, there is a deviation in the text bending detection box of the seal, resulting in incorrect seal text recognition; The information on the seal was not correctly extracted. The results for these in `{'chat_res': {'seal': 'unknown'}, 'prompt': ''}` are unknown. Therefore, this section focuses on the scenario of Seal Text Recognitions. Utilizing a dataset of Seal Text Recognition, with the extraction of seal information as examples, the seal text detection model within the document scene information extraction pipeline is fine-tuned to achieve the ability to accurately extract seal information from the document.
+
+
+### 2.2 Online Experience
+
+You can experience the effectiveness of the Document Scene Information Extraction v3 pipeline on the **AIStudio Community**. Click the link to download the [Test Seal File](https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_seal/test.png), and then upload it to the [official Document Scene Information Extraction v3 application](https://aistudio.baidu.com/community/app/182491/webUI?source=appCenter) to experience the extraction results. The process is as follows:
+
+![](https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_seal/06.png)
+
+
+## 3. Choosing a Model
+
+PaddleX provides 2 end-to-end seal text detection models, which can be referenced in the [Model List](../support_list/models_list_en.md). Some of the benchmarks for these models are as follows:
+
+| Model | mAP(0.5) (%) | GPU Inference Time (ms) | CPU Inference Time (ms) | Model Size (M) | Description |
+|-|-|-|-|-|-|
+|-|-|-|-|-|-|
+|PP-OCRv4_mobile_seal_det|96.47|10.5878|131.813|4.7M |[PP-OCRv4_mobile_seal_det.yaml](../../paddlex/configs/text_detection_seal/PP-OCRv4_mobile_seal_det.yaml)|
+|PP-OCRv4_server_seal_det|98.21|84.341|2425.06|108.3 M|[PP-OCRv4_server_seal_det.yaml](../../paddlex/configs/text_detection_seal/PP-OCRv4_server_seal_det.yaml)|
+
+**Note: The evaluation set for the above accuracy metrics is our self-built seal text detection dataset, containing 500 images of circle seal types. GPU inference time is based on an NVIDIA Tesla T4 machine with FP32 precision. CPU inference speed is based on an Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz with 8 threads and FP32 precision.**
+
+
+## 4. Data Preparation and Verification
+### 4.1 Data Preparation
+
+This tutorial uses the `Seal Text Detection Dataset` as an example dataset. You can obtain the example dataset using the following commands. If you are using your own annotated dataset, you need to adjust it according to PaddleX's format requirements to meet PaddleX's data format specifications. For an introduction to data formats, you can refer to the [PaddleX Object Detection Task Module Data Annotation Tutorial](../data_annotations/ocr_modules/text_detection_recognition_en.md).
+
+Dataset acquisition commands:
+```bash
+cd /path/to/paddlex
+wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/practical_seal.tar -P ./dataset
+tar -xf ./dataset/practical_seal.tar -C ./dataset/
+```
+
+### 4.2 Dataset Verification
+
+To verify the dataset, simply run the following command:
+
+```bash
+python main.py -c paddlex/configs/text_detection_seal/PP-OCRv4_server_seal_det.yaml \
+    -o Global.mode=check_dataset \
+    -o Global.dataset_dir=./dataset/practical_seal/
+```
+
+After executing the above command, PaddleX will verify the dataset and count the basic information of the dataset. If the command runs successfully, it will print `Check dataset passed !` in the log, and the relevant outputs will be saved in the current directory's `./output/check_dataset` directory. The output directory includes visualized example images and a histogram of sample distribution. The verification result file is saved in `./output/check_dataset_result.json`, and the specific content of the verification result file is as follows:
+
+```
+{
+  "done_flag": true,
+  "check_pass": true,
+  "attributes": {
+    "train_samples": 793,
+    "train_sample_paths": [
+      "..\/dataset\/practical_seal\/images\/PMC4055390_00006_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC3712248_00008_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC4227328_00001_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC3745965_00007_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC3980931_00001_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC5896212_00003_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC3838814_00003_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC4677212_00002_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC4058803_00001_seal_0_crop.png",
+      "..\/dataset\/practical_seal\/images\/PMC4925966_00001_seal_0_crop.png"
+    ],
+    "val_samples": 277,
+    "val_sample_paths": [
+      "..\/dataset\/practical_seal\/images\/15.jpg",
+      "..\/dataset\/practical_seal\/images\/16.jpg",
+      "..\/dataset\/practical_seal\/images\/17.jpg",
+      "..\/dataset\/practical_seal\/images\/18.jpg",
+      "..\/dataset\/practical_seal\/images\/19.jpg",
+      "..\/dataset\/practical_seal\/images\/20.jpg",
+      "..\/dataset\/practical_seal\/images\/21.jpg",
+      "..\/dataset\/practical_seal\/images\/22.jpg",
+      "..\/dataset\/practical_seal\/images\/23.jpg",
+      "..\/dataset\/practical_seal\/images\/24.jpg"
+    ]
+  },
+  "analysis": {
+    "histogram": "check_dataset\/histogram.png"
+  },
+  "dataset_path": ".\/dataset\/practical_seal\/",
+  "show_type": "image",
+  "dataset_type": "TextDetDataset"
+}
+```
+
+In the above verification results, `check_pass` being `True` indicates that the dataset format meets the requirements. Explanations for other indicators are as follows:
+
+- `attributes.train_samples`: The number of training set samples in this dataset is 739;
+- `attributes.val_samples`: The number of validation set samples in this dataset is 277;
+- `attributes.train_sample_paths`: A list of relative paths to the visualized images of the training set samples in this dataset;
+- `attributes.val_sample_paths`: A list of relative paths to the visualized images of the validation set samples in this dataset;
+
+In addition, the dataset verification also analyzes the sample number distribution of all boxes's width and height in the dataset and draws a distribution histogram (`histogram.png`):
+
+<center>
+
+<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/practical_tutorials/PP-ChatOCRv3_doc/seal_02.png" width=600>
+
+</center>
+
+**Note**: Only data that passes the verification can be used for training and evaluation.
+
+### 4.3 Dataset Splitting (Optional)
+
+If you need to convert the dataset format or re-split the dataset, you can set it by modifying the configuration file or appending hyperparameters.
+
+The parameters related to dataset verification can be set by modifying the fields under `CheckDataset` in the configuration file. Some example explanations of the parameters in the configuration file are as follows:
+
+* `CheckDataset`:
+    * `split`:
+        * `enable`: Whether to re-split the dataset. When set to `True`, the dataset format will be converted. The default is `False`;
+        * `train_percent`: If the dataset is to be re-split, you need to set the percentage of the training set. The type is any integer between 0-100, and it needs to ensure that the sum with `val_percent` is 100;
+        * `val_percent`: If the dataset is to be re-split, you need to set the percentage of the validation set. The type is any integer between 0-100, and it needs to ensure that the sum with `train_percent` is 100;
+
+## Data Splitting
+When splitting data, the original annotation files will be renamed as `xxx.bak` in the original path. The above parameters can also be set by appending command line arguments, for example, to re-split the dataset and set the ratio of training set to validation set: `-o CheckDataset.split.enable=True -o CheckDataset.split.train_percent=80 -o CheckDataset.split.val_percent=20`.
+
+
+## 5. Model Training and Evaluation
+### 5.1 Model Training
+
+Before training, please ensure that you have validated the dataset. To complete PaddleX model training, simply use the following command:
+
+```bash
+python main.py -c paddlex/configs/text_detection_seal/PP-OCRv4_server_seal_det.yaml \
+    -o Global.mode=train \
+    -o Global.dataset_dir=./dataset/practical_seal \
+    -o Global.epochs_iters=30 \
+    -o Global.batch_size=4 \
+    -o Global.learning_rate=0.0001
+```
+
+
+PaddleX supports modifying training hyperparameters, single/multi-GPU training, etc., by modifying the configuration file or appending command line arguments.
+
+Each model in PaddleX provides a configuration file for model development to set relevant parameters. Model training-related parameters can be set by modifying the `Train` fields in the configuration file. Some example explanations of parameters in the configuration file are as follows:
+
+* `Global`:
+    * `mode`: Mode, supporting dataset validation (`check_dataset`), model training (`train`), and model evaluation (`evaluate`);
+    * `device`: Training device, options include `cpu`, `gpu`, `xpu`, `npu`, `mlu`. For multi-GPU training, specify the card numbers, e.g., `gpu:0,1,2,3`;
+* `Train`: Training hyperparameter settings;
+    * `epochs_iters`: Number of training epochs;
+    * `learning_rate`: Training learning rate;
+
+For more hyperparameter introductions, please refer to [PaddleX General Model Configuration File Parameter Explanation](../module_usage/instructions/config_parameters_common_en.md).
+
+**Note**:
+- The above parameters can be set by appending command line arguments, e.g., specifying the mode as model training: `-o Global.mode=train`; specifying the first two GPUs for training: `-o Global.device=gpu:0,1`; setting the number of training epochs to 10: `-o Train.epochs_iters=10`.
+- During model training, PaddleX automatically saves model weight files, with the default being `output`. If you need to specify a save path, you can use the `-o Global.output` field in the configuration file.
+- PaddleX shields you from the concepts of dynamic graph weights and static graph weights. During model training, both dynamic and static graph weights are produced, and static graph weights are selected by default for model inference.
+
+**Explanation of Training Outputs**:
+
+After completing model training, all outputs are saved in the specified output directory (default is `./output/`), typically including the following:
+
+* train_result.json: Training result record file, recording whether the training task was completed normally, as well as the output weight metrics and related file paths;
+* train.log: Training log file, recording changes in model metrics and loss during training;
+* config.yaml: Training configuration file, recording the hyperparameter configuration for this training session;
+* .pdparams, .pdopt, .pdstates, .pdiparams, .pdmodel: Model weight-related files, including network parameters, optimizer, static graph network parameters, static graph network structure, etc.;
+
+### 5.2 Model Evaluation
+
+After completing model training, you can evaluate the specified model weight file on the validation set to verify the model accuracy. To evaluate a model using PaddleX, simply use the following command:
+
+```bash
+python main.py -c paddlex/configs/text_detection_seal/PP-OCRv4_server_seal_det.yaml \
+    -o Global.mode=evaluate \
+    -o Global.dataset_dir=./dataset/practical_seal
+```
+
+Similar to model training, model evaluation supports setting by modifying the configuration file or appending command line arguments.
+
+**Note**: When evaluating the model, you need to specify the model weight file path. Each configuration file has a default weight save path. If you need to change it, simply set it by appending a command line argument, e.g., `-o Evaluate.weight_path=./output/best_accuracy/best_accuracy.pdparams`.
+
+### 5.3 Model Optimization
+
+After learning about model training and evaluation, we can enhance model accuracy by adjusting hyperparameters. By carefully tuning the number of training epochs, you can control the depth of model training to avoid overfitting or underfitting. Meanwhile, the setting of the learning rate is crucial to the speed and stability of model convergence. Therefore, when optimizing model performance, it is essential to consider the values of these two parameters prudently and adjust them flexibly based on actual conditions to achieve the best training results.
+
+It is recommended to follow the controlled variable method when debugging parameters:
+
+1. First, fix the number of training epochs at 30, and set the batch size to 4 due to the small size of the training dataset.
+2. Initiate 3 experiments based on the `PP-OCRv4_server_seal_det` model, with learning rates of: 0.001,0.0001,0.00001.
+3. It can be observed that the configuration with the highest accuracy in Experiment 1 is a learning rate of 0.001. Based on this training hyperparameter, change the number of epochs and observe the accuracy results at different epochs, finding that the best accuracy is generally achieved at 100 epochs.
+
+Learning Rate Exploration Results:
+
+<center>
+
+| Experiment ID           | Learning Rate|  Hmean(%) |
+| --------------- | ------------- | -------------------- |
+| **1** | **0.001**     | **97.35**       | 
+| 2 | 0.0001   | 93.32       |
+| 3 | 0.00001       | 87.63    |
+
+</center>
+
+Next, we can increase the number of training epochs based on a learning rate set to 0.001. Comparing experiments [1, 4] below, it can be seen that as the number of training epochs increases, the model's accuracy further improves.
+
+<center>
+
+| Experiment ID           | Learning Rate|  Hmean(%) |
+| --------------- | ------------- | -------------------- |
+| 1 | 30    |97.35   |
+| 4 |100  | 98.13   |
+
+</center>
+
+**Note:** This tutorial is designed for a 4-GPU setup. If you only have 1 GPU, you can complete the experiment by adjusting the number of training GPUs, but the final metrics may not align perfectly with the above indicators, which is normal.
+
+When selecting a training environment, it is important to consider the relationship between the number of training GPUs, the total batch_size, and the learning rate. Firstly, the total batch_size is equal to the number of training GPUs multiplied by the batch_size per GPU. Secondly, the total batch_size and the learning rate are related, and the learning rate should be adjusted in synchronization with the total batch_size. The default learning rate corresponds to a total batch_size based on 4 GPUs. If you plan to train in a single-GPU environment, you need to divide the learning rate by 4 accordingly. If you plan to train in an 8-GPU environment, you need to multiply the learning rate by 2 accordingly.
+
+
+For reference, the command to execute training with different parameter adjustments can be:
+
+```bash
+python main.py -c paddlex/configs/text_detection_seal/PP-OCRv4_server_seal_det.yaml \
+    -o Global.mode=train \
+    -o Global.dataset_dir=./dataset/practical_seal \
+    -o Train.learning_rate=0.0001 \
+    -o Train.epochs_iters=30 \
+    -o Train.batch_size=4
+```
+
+
+## 6. Pipeline Inference
+
+Replace the model in the production line with the fine-tuned model for testing, and use the [test file](https://paddle-model-ecology.bj.bcebos.com/paddlex/PaddleX3.0/doc_images/practical_tutorial/PP-ChatOCRv3_doc_seal/test.png) to perform predictions.
+
+
+First, obtain and update the configuration file for the Document Information Extraction v3. Execute the following command to retrieve the configuration file (assuming a custom save location of `./my_path`):
+
+
+```bash
+paddlex --get_pipeline_config PP-ChatOCRv3-doc --save_path ./my_path
+```
+
+Modify the `Pipeline.seal_text_det_model` field in `PP-ChatOCRv3-doc.yaml` to the path of the fine-tuned model mentioned above. The modified configuration is as follows:
+
+```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:
+```
+
+After making the modifications, you only need to change the value of the `pipeline` parameter in the `create_pipeline` method to the path of the production line configuration file to apply the configuration.
+
+```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()
+```
+
+By following the above steps, prediction results can be generated under `./output_ft`, and the printed key information extraction results are as follows:
+
+```
+{'chat_res': {'印章名称': '广关市国士资源局'}, 'prompt': ''}
+```
+
+It can be observed that after fine-tuning the model, the key information has been correctly extracted.
+
+The visualization result of the seal is as follows, with the correctly added ability to extract the seal text information:
+
+![](https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/practical_tutorials/PP-ChatOCRv3_doc/seal_04.png)
+
+
+## 7. Development Integration/Deployment
+
+If the Document Scene Information Extraction v3 production line meets your requirements for inference speed and accuracy, you can proceed directly with development integration/deployment.
+
+1. Directly apply the trained model production line in your Python project, as shown in the following code:
+
+
+```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": ""} # To use the Qianfan API, please fill in your Access Key (ak) and Secret Key (sk), as you will not be able to invoke large models without them.
+    # llm_params={"api_type": "aistudio", "access_token": ""} # Or, to use the AIStudio API, please fill in your access_token, as you will not be able to invoke large models without it.
+    )
+
+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=["seal"],
+    visual_info=visual_info,
+    vector=vector,
+    )
+chat_result.print()
+```
+
+For more parameters, please refer to the [Document Scene Information Extraction Pipeline Usage Tutorial](../pipeline_usage/tutorials/information_extraction_pipelines/document_scene_information_extraction_en.md).
+
+2. Additionally, PaddleX offers three other deployment methods, detailed as follows:
+
+* high-performance inference: In actual production environments, many applications have stringent standards for deployment strategy performance metrics (especially response speed) to ensure efficient system operation and smooth user experience. To this end, PaddleX provides high-performance inference plugin aimed at deeply optimizing model inference and pre/post-processing for significant end-to-end process acceleration. For detailed high-performance inference procedures, please refer to the [PaddleX High-Performance Inference Guide](../pipeline_deploy/high_performance_inference_en.md).
+* Service-Oriented Deployment: Service-oriented deployment is a common deployment form in actual production environments. By encapsulating inference functions as services, clients can access these services through network requests to obtain inference results. PaddleX supports users in achieving cost-effective service-oriented deployment of production lines. For detailed service-oriented deployment procedures, please refer to the [PaddleX Service-Oriented Deployment Guide](../pipeline_deploy/service_deploy_en.md).
+* Edge Deployment: Edge deployment is a method that places computing and data processing capabilities directly on user devices, allowing devices to process data without relying on remote servers. PaddleX supports deploying models on edge devices such as Android. For detailed edge deployment procedures, please refer to the [PaddleX Edge Deployment Guide](../pipeline_deploy/edge_deploy_en.md).
+
+You can select the appropriate deployment method for your model pipeline according to your needs, and proceed with subsequent AI application integration.