Explorar o código

refine pipeline docs (#2971)

Co-authored-by: cuicheng01 <45199522+cuicheng01@users.noreply.github.com>
学卿 hai 9 meses
pai
achega
af4a36aa84

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
docs/module_usage/tutorials/cv_modules/face_detection.md


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 4 - 6
docs/module_usage/tutorials/cv_modules/face_feature.md


+ 22 - 8
docs/module_usage/tutorials/cv_modules/human_keypoint_detection.md

@@ -58,22 +58,37 @@ model = create_model(model_name="PP-TinyPose_128x96")
 output = model.predict("keypoint_detection_002.jpg", batch_size=1)
 
 for res in output:
-    res.print(json_format=False)
+    res.print()
     res.save_to_img("./output/")
-    res.save_to_json("./output/res.json")
-
+    res.save_to_json("./output/")
 ```
 
-<details><summary>👉 <b>运行后,得到的结果为:(点击展开)</b></summary>
+<details><summary>👉 运行后,得到的结果为:(点击展开)</summary>
 
 ```bash
-{'res': {'input_path': 'keypoint_detection_002.jpg', 'kpts': [{'keypoints': [[175.2838134765625, 56.043609619140625, 0.6522828936576843], [181.32794189453125, 49.642051696777344, 0.7338210940361023], [169.46002197265625, 50.59111022949219, 0.6837076544761658], [193.3421173095703, 51.91969680786133, 0.8676544427871704], [164.50787353515625, 55.6519889831543, 0.8232858777046204], [219.7235870361328, 90.28710174560547, 0.8812915086746216], [152.90377807617188, 95.07806396484375, 0.9093065857887268], [233.1095733642578, 149.6704864501953, 0.7706904411315918], [139.5576629638672, 144.38327026367188, 0.7555014491081238], [245.22830200195312, 202.4243927001953, 0.706590473651886], [117.83794403076172, 188.56410217285156, 0.8892115950584412], [203.29542541503906, 200.2967071533203, 0.838330864906311], [172.00791931152344, 201.1993865966797, 0.7636935710906982], [181.18797302246094, 273.0669250488281, 0.8719099164009094], [185.1750030517578, 278.4797668457031, 0.6878190040588379], [171.55068969726562, 362.42730712890625, 0.7994316816329956], [201.6941375732422, 354.5953369140625, 0.6789217591285706]], 'kpt_score': 0.7831441760063171}]}}
+{'res': {'input_path': 'keypoint_detection_002.jpg', 'kpts': [{'keypoints': array([[175.28381   ,  56.04361   ,   0.6522829 ],
+       [181.32794   ,  49.64205   ,   0.7338211 ],
+       [169.46002   ,  50.59111   ,   0.68370765],
+       [193.34212   ,  51.919697  ,   0.86765444],
+       [164.50787   ,  55.65199   ,   0.8232859 ],
+       [219.72359   ,  90.2871    ,   0.8812915 ],
+       [152.90378   ,  95.078064  ,   0.9093066 ],
+       [233.10957   , 149.67049   ,   0.77069044],
+       [139.55766   , 144.38327   ,   0.75550145],
+       [245.2283    , 202.4244    ,   0.7065905 ],
+       [117.837944  , 188.5641    ,   0.8892116 ],
+       [203.29543   , 200.2967    ,   0.83833086],
+       [172.00792   , 201.19939   ,   0.7636936 ],
+       [181.18797   , 273.06693   ,   0.8719099 ],
+       [185.175     , 278.47977   ,   0.687819  ],
+       [171.55069   , 362.4273    ,   0.7994317 ],
+       [201.69414   , 354.59534   ,   0.67892176]], dtype=float32), 'kpt_score': 0.7831442}]}}
 ```
 
 参数含义如下:
 - `input_path`:输入的待预测图像的路径
 - `kpts`:预测的关键点信息,一个字典列表。每个字典包含以下信息:
-  - `keypoints`:关键点坐标和置信度列表,一个列表。每个元素是一个包含关键点信息的列表,格式为<code>[x, y, score]</code>,其中score为关键点的置信度
+  - `keypoints`:关键点坐标信息,一个numpy数组,形状为[num_keypoints, 3],其中每个关键点由[x, y, score]组成,score为该关键点的置信度
   - `kpt_score`:关键点整体的置信度,即关键点的平均置信度
 
 </details>
@@ -247,8 +262,7 @@ for res in output:
 如果你追求更高精度的现有模型,可以使用PaddleX的二次开发能力,开发更好的关键点检测模型。在使用PaddleX开发关键点检测模型之前,请务必安装PaddleX的PaddleDetection插件,安装过程可以参考 [PaddleX本地安装教程](../../../installation/installation.md)。
 
 ### 4.1 数据准备
-在进行模型训练前,需要准备相应任务模块的数据集。PaddleX 针对每一个模块提供了数据校验功能,**只有通过数据校验的数据才可以进行模型训练**。此外,PaddleX为每一个模块都提供了demo数据集,您可以基于官方提供的 Demo 数据完成后续的开发。若您希望用私有数据集进行后续的模型训练,可以参考[PaddleX关键点检测任务模块数据标注教程](../../../data_annotations/cv_modules/keypoint_detection.md)。
-
+在进行模型训练前,需要准备相应任务模块的数据集。PaddleX 针对每一个模块提供了数据校验功能,**只有通过数据校验的数据才可以进行模型训练**。此外,PaddleX为每一个模块都提供了demo数据集,您可以基于官方提供的 Demo 数据完成后续的开发。
 #### 4.1.1 Demo 数据下载
 您可以参考下面的命令将 Demo 数据集下载到指定文件夹:
 

+ 26 - 24
docs/module_usage/tutorials/cv_modules/object_detection.md

@@ -373,31 +373,36 @@ comments: true
 
 ```python
 from paddlex import create_model
-model = create_model("PicoDet-S")
-output = model.predict("general_object_detection_002.png", batch_size=1)
+
+model = create_model(model_name="PicoDet-S")
+
+output = model.predict(
+  "general_object_detection_002.png",
+  batch_size=1,
+  threshold=0.5
+)
+
 for res in output:
     res.print(json_format=False)
     res.save_to_img("./output/")
-    res.save_to_json("./output/res.json")
+    res.save_to_json("./output/")
 ```
 
-<details><summary>👉 <b>运行后,得到的结果为:(点击展开)</b></summary>
+运行后,得到的结果为:
 
 ```bash
-{'res': {'input_path': 'general_object_detection_002.png', 'boxes': [{'cls_id': 49, 'label': 'orange', 'score': 0.8188614249229431, 'coordinate': [661.351806640625, 93.0582275390625, 870.759033203125, 305.9371337890625]}, {'cls_id': 47, 'label': 'apple', 'score': 0.7745078206062317, 'coordinate': [76.80911254882812, 274.7490539550781, 330.5422058105469, 520.0427856445312]}, {'cls_id': 47, 'label': 'apple', 'score': 0.7271787524223328, 'coordinate': [285.3264465332031, 94.31749725341797, 469.7364501953125, 297.4034423828125]}, {'cls_id': 46, 'label': 'banana', 'score': 0.5576589703559875, 'coordinate': [310.8041076660156, 361.4362487792969, 685.1868896484375, 712.591552734375]}, {'cls_id': 47, 'label': 'apple', 'score': 0.5490103363990784, 'coordinate': [764.6251831054688, 285.7609558105469, 924.8153076171875, 440.9289245605469]}, {'cls_id': 47, 'label': 'apple', 'score': 0.515821635723114, 'coordinate': [853.9830932617188, 169.4142303466797, 987.802978515625, 303.5861511230469]}, {'cls_id': 60, 'label': 'dining table', 'score': 0.514293372631073, 'coordinate': [0.5308971405029297, 0.32445716857910156, 1072.953369140625, 720]}, {'cls_id': 47, 'label': 'apple', 'score': 0.510750949382782, 'coordinate': [57.36802673339844, 23.455347061157227, 213.39601135253906, 176.45611572265625]}]}}
+{'res': {'input_path': 'general_object_detection_002.png', 'page_index': None, 'boxes': [{'cls_id': 49, 'label': 'orange', 'score': 0.8188614249229431, 'coordinate': [661.3518, 93.05823, 870.75903, 305.93713]}, {'cls_id': 47, 'label': 'apple', 'score': 0.7745078206062317, 'coordinate': [76.80911, 274.74905, 330.5422, 520.0428]}, {'cls_id': 47, 'label': 'apple', 'score': 0.7271787524223328, 'coordinate': [285.32645, 94.3175, 469.73645, 297.40344]}, {'cls_id': 46, 'label': 'banana', 'score': 0.5576589703559875, 'coordinate': [310.8041, 361.43625, 685.1869, 712.59155]}, {'cls_id': 47, 'label': 'apple', 'score': 0.5490103363990784, 'coordinate': [764.6252, 285.76096, 924.8153, 440.92892]}, {'cls_id': 47, 'label': 'apple', 'score': 0.515821635723114, 'coordinate': [853.9831, 169.41423, 987.803, 303.58615]}, {'cls_id': 60, 'label': 'dining table', 'score': 0.514293372631073, 'coordinate': [0.53089714, 0.32445717, 1072.9534, 720]}, {'cls_id': 47, 'label': 'apple', 'score': 0.510750949382782, 'coordinate': [57.368027, 23.455347, 213.39601, 176.45612]}]}}
 ```
 
 参数含义如下:
-- `input_path`:输入的待预测图像的路径
+- `input_path`:表示输入图像的路径
+- `page_index`:如果输入是PDF文件,则表示当前是PDF的第几页,否则为 `None`
 - `boxes`:预测的目标框信息,一个字典列表。每个字典代表一个检出的目标,包含以下信息:
   - `cls_id`:类别ID,一个整数
   - `label`:类别标签,一个字符串
   - `score`:目标框置信度,一个浮点数
   - `coordinate`:目标框坐标,一个浮点数列表,格式为<code>[xmin, ymin, xmax, ymax]</code>
 
-</details>
-
-
 可视化图像如下:
 
 <img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/refs/heads/main/images/modules/obj_det/general_object_detection_002_res.png">
@@ -432,26 +437,26 @@ for res in output:
 <tr>
 <td><code>img_size</code></td>
 <td>输入图像大小;如果不指定,将默认使用PaddleX官方模型配置</td>
-<td><code>int/list</code></td>
+<td><code>int/list/None</code></td>
 <td>
 <ul>
   <li><b>int</b>, 如 640 , 表示将输入图像resize到640x640大小</li>
-  <li><b>列表</b>, 如 [640, 512] , 表示将输入图像resize到宽为640,高为512大小</li>
+  <li><b>列表</b>, 如 [512, 640] , 表示将输入图像resize到宽为640,高为512大小</li>
 </ul>
 </td>
-<td></td>
+<td><code>None</code></td>
 </tr>
 <tr>
 <td><code>threshold</code></td>
 <td>用于过滤掉低置信度预测结果的阈值;如果不指定,将默认使用PaddleX官方模型配置</td>
-<td><code>float/dict</code></td>
+<td><code>float/dict/None</code></td>
 <td>
 <ul>
   <li><b>float</b>,如 0.2, 表示过滤掉所有阈值小于0.2的目标框</li>
   <li><b>字典</b>,字典的key为<b>int</b>类型,代表<code>cls_id</code>,val为<b>float</b>类型阈值。如 <code>{0: 0.45, 2: 0.48, 7: 0.4}</code>,表示对cls_id为0的类别应用阈值0.45、cls_id为1的类别应用阈值0.48、cls_id为7的类别应用阈值0.4</li>
 </ul>
 </td>
-<td></td>
+<td><code>None</code></td>
 </tr>
 </table>
 
@@ -471,16 +476,13 @@ for res in output:
 </thead>
 <tr>
 <td><code>input</code></td>
-<td>待预测数据,支持多种输入类型</td>
-<td><code>Python Var</code>/<code>str</code>/<code>dict</code>/<code>list</code></td>
+<td>待预测数据,支持多种输入类型,必填</td>
+<td><code>Python Var|str|list</code></td>
 <td>
 <ul>
-  <li><b>Python变量</b>,如<code>numpy.ndarray</code>表示的图像数据</li>
-  <li><b>文件路径</b>,如图像文件的本地路径:<code>/root/data/img.jpg</code></li>
-  <li><b>URL链接</b>,如图像文件的网络URL:<a href = "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_rec_001.png">示例</a></li>
-  <li><b>本地目录</b>,该目录下需包含待预测数据文件,如本地路径:<code>/root/data/</code></li>
-  <li><b>字典</b>,字典的<code>key</code>需与具体任务对应,如图像分类任务对应<code>\"img\"</code>,字典的<code>val</code>支持上述类型数据,例如:<code>{\"img\": \"/root/data1\"}</code></li>
-  <li><b>列表</b>,列表元素需为上述类型数据,如<code>[numpy.ndarray, numpy.ndarray]</code>,<code>[\"/root/data/img1.jpg\", \"/root/data/img2.jpg\"]</code>,<code>[\"/root/data1\", \"/root/data2\"]</code>,<code>[{\"img\": \"/root/data1\"}, {\"img\": \"/root/data2/img.jpg\"}]</code></li>
+  <li><b>Python Var</b>:如 <code>numpy.ndarray</code> 表示的图像数据</li>
+  <li><b>str</b>:如图像文件或者PDF文件的本地路径:<code>/root/data/img.jpg</code>;<b>如URL链接</b>,如图像文件或PDF文件的网络URL:<a href = "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png">示例</a>;<b>如本地目录</b>,该目录下需包含待预测图像,如本地路径:<code>/root/data/</code>(当前不支持目录中包含PDF文件的预测,PDF文件需要指定到具体文件路径)</li>
+  <li><b>List</b>:列表元素需为上述类型数据,如<code>[numpy.ndarray, numpy.ndarray]</code>,<code>[\"/root/data/img1.jpg\", \"/root/data/img2.jpg\"]</code>,<code>[\"/root/data1\", \"/root/data2\"]</code></li>
 </ul>
 </td>
 <td>无</td>
@@ -495,14 +497,14 @@ for res in output:
 <tr>
 <td><code>threshold</code></td>
 <td>用于过滤掉低置信度预测结果的阈值;如果不指定,将默认使用 <code>creat_model</code> 指定的 <code>threshold</code> 参数,如果 <code>creat_model</code> 也没有指定,则默认使用PaddleX官方模型配置</td>
-<td><code>float/dict</code></td>
+<td><code>float/dict/None</code></td>
 <td>
 <ul>
   <li><b>float</b>,如 0.2, 表示过滤掉所有阈值小于0.2的目标框</li>
   <li><b>字典</b>,字典的key为<b>int</b>类型,代表<code>cls_id</code>,val为<b>float</b>类型阈值。如 <code>{0: 0.45, 2: 0.48, 7: 0.4}</code>,表示对cls_id为0的类别应用阈值0.45、cls_id为1的类别应用阈值0.48、cls_id为7的类别应用阈值0.4</li>
 </ul>
 </td>
-<td></td>
+<td><code>None</code></td>
 </tr>
 </table>
 

+ 250 - 113
docs/pipeline_usage/tutorials/cv_pipelines/face_recognition.md

@@ -9,7 +9,7 @@ comments: true
 
 人脸识别产线是专注于解决人脸定位和识别任务的端到端串联系统,可以从图像中快速准确地定位人脸区域、提取人脸特征,并与特征库中预先建立的特征做检索比对,从而确认身份信息。
 
-<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/refs/heads/main/images/pipelines/face_recognition/01.jpg">
+<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/refs/heads/main/images/pipelines/face_recognition/02.jpg">
 
 <b>人脸识别产线中包含了人脸检测模块和人脸特征模块</b>,每个模块中包含了若干模型,具体使用哪些模型,您可以根据下边的 benchmark 数据来选择。<b>如您更考虑模型精度,请选择精度较高的模型,如您更考虑模型推理速度,请选择推理速度较快的模型,如您更考虑模型存储大小,请选择存储大小较小的模型</b>。
 
@@ -18,7 +18,7 @@ comments: true
 <thead>
 <tr>
 <th>模型</th><th>模型下载链接</th>
-<th>AP (%)<br/>Easy/Medium/Hard</th>
+<th>AP(%)</th>
 <th>GPU推理耗时 (ms)</th>
 <th>CPU推理耗时 (ms)</th>
 <th>模型存储大小 (M)</th>
@@ -28,15 +28,16 @@ comments: true
 <tbody>
 <tr>
 <td>BlazeFace</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0rc0/BlazeFace_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/BlazeFace_pretrained.pdparams">训练模型</a></td>
-<td>77.7/73.4/49.5</td>
+<td>15.4</td>
 <td>49.9</td>
 <td>68.2</td>
 <td>0.447</td>
 <td>轻量高效的人脸检测模型</td>
 </tr>
 <tr>
+<tr>
 <td>BlazeFace-FPN-SSH</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0rc0/BlazeFace-FPN-SSH_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/BlazeFace-FPN-SSH_pretrained.pdparams">训练模型</a></td>
-<td>83.2/80.5/60.5</td>
+<td>18.7</td>
 <td>52.4</td>
 <td>73.2</td>
 <td>0.606</td>
@@ -44,7 +45,7 @@ comments: true
 </tr>
 <tr>
 <td>PicoDet_LCNet_x2_5_face</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0rc0/PicoDet_LCNet_x2_5_face_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/PicoDet_LCNet_x2_5_face_pretrained.pdparams">训练模型</a></td>
-<td>93.7/90.7/68.1</td>
+<td>31.4</td>
 <td>33.7</td>
 <td>185.1</td>
 <td>28.9</td>
@@ -52,7 +53,7 @@ comments: true
 </tr>
 <tr>
 <td>PP-YOLOE_plus-S_face</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0rc0/PP-YOLOE_plus-S_face_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/PP-YOLOE_plus-S_face_pretrained.pdparams">训练模型</a></td>
-<td>93.9/91.8/79.8</td>
+<td>36.1</td>
 <td>25.8</td>
 <td>159.9</td>
 <td>26.5</td>
@@ -60,7 +61,7 @@ comments: true
 </tr>
 </tbody>
 </table>
-<p>注:以上精度指标是在WIDER-FACE验证集上,以640
+<p>注:以上精度指标是在 COCO 格式的 WIDER-FACE 验证集上,以640
 *640作为输入尺寸评估得到的。所有模型 GPU 推理耗时基于 NVIDIA V100 机器,精度类型为 FP32, CPU 推理速度基于 Intel(R) Xeon(R) Gold 6271C CPU @ 2.60GHz,精度类型为 FP32。</p>
 <p><b>人脸特征模块:</b></p>
 <table>
@@ -99,7 +100,7 @@ comments: true
 <p>注:以上精度指标是分别在 AgeDB-30、CFP-FP 和 LFW 数据集上测得的 Accuracy。所有模型 GPU 推理耗时基于 NVIDIA Tesla T4 机器,精度类型为 FP32, CPU 推理速度基于 Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz,线程数为8,精度类型为 FP32。</p>
 
 ## 2. 快速开始
-PaddleX 所提供的预训练的模型产线均可以快速体验效果,你可以在线体验人脸识别产线的效果,也可以在本地使用命令行或 Python 体验人脸识别产线的效果。
+PaddleX 所提供的模型产线均可以快速体验效果,你可以在线体验人脸识别产线的效果,也可以在本地使用命令行或 Python 体验人脸识别产线的效果。
 
 ### 2.1 在线体验
 
@@ -112,16 +113,6 @@ PaddleX 所提供的预训练的模型产线均可以快速体验效果,你可
 
 暂不支持命令行体验
 
-默认使用内置的的通用图像识别产线配置文件,若您需要自定义配置文件,可执行如下命令获取:
-
-<details><summary> 👉点击展开</summary>
-
-<pre><code class="language-bash">paddlex --get_pipeline_config face_recognition
-</code></pre>
-<p>执行后,通用图像识别产线配置文件将被保存在当前路径。若您希望自定义保存位置,可执行如下命令(假设自定义保存位置为<code>./my_path</code>):</p>
-<pre><code class="language-bash">paddlex --get_pipeline_config face_recognition --save_path ./my_path
-</code></pre></details>
-
 #### 2.2.2 Python脚本方式集成
 请下载[测试图像](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/friends1.jpg)进行测试。
 在该产线的运行示例中需要预先构建人脸特征库,您可以参考如下指令下载官方提供的demo数据用来后续构建人脸特征库。
@@ -147,11 +138,12 @@ output = pipeline.predict("friends1.jpg", index=index_data)
 for res in output:
     res.print()
     res.save_to_img("./output/")
+    res.save_to_json("./output/")
 ```
 
 在上述 Python 脚本中,执行了如下几个步骤:
 
-(1)实例化 `create_pipeline` 实例化 人脸识别 产线对象。具体参数说明如下:
+(1)调用 `create_pipeline` 实例化人脸识别产线对象。具体参数说明如下:
 
 <table>
 <thead>
@@ -170,16 +162,10 @@ for res in output:
 <td>无</td>
 </tr>
 <tr>
-<td><code>index</code></td>
-<td>产线推理预测所用的特征库,支持:1. <code>str</code>类型表示的目录(该目录下需要包含索引库文件,包括<code>vector.index</code>和<code>index_info.yaml</code>);2. <code>IndexData</code>对象。如不传入该参数,则需要在<code>predict()</code>中指定<code>index</code>。</td>
-<td><code>str</code></td>
-<td>None</td>
-</tr>
-<tr>
 <td><code>device</code></td>
-<td>产线模型推理设备。支持:“gpu”,“cpu”。</td>
+<td>产线推理设备。支持指定GPU具体卡号,如“gpu:0”,其他硬件具体卡号,如“npu:0”,CPU如“cpu”。</td>
 <td><code>str</code></td>
-<td><code>gpu</code></td>
+<td><code>gpu:0</code></td>
 </tr>
 <tr>
 <td><code>use_hpip</code></td>
@@ -189,7 +175,8 @@ for res in output:
 </tr>
 </tbody>
 </table>
-(2)调用人脸识别产线对象的 `build_index` 方法,构建人脸特征库。具体参数为说明如下:
+
+(2)调用人脸识别产线对象的 `build_index` 方法,构建人脸特征库。具体参数说明如下:
 
 <table>
 <thead>
@@ -197,26 +184,64 @@ for res in output:
 <th>参数</th>
 <th>参数说明</th>
 <th>参数类型</th>
+<th>可选项</th>
 <th>默认值</th>
 </tr>
 </thead>
 <tbody>
 <tr>
 <td><code>gallery_imgs</code></td>
-<td>要添加的底库图片,支持:1. <code>str</code>类型表示的图片根目录,数据组织方式与构建索引库时相同,参考<a href="#2.3-构建特征库的数据组织方式">2.3节 构建特征库的数据组织方式</a>;2. <code>[numpy.ndarray, numpy.ndarray, ..]</code>类型的底库图片数据。</td>
+<td>要添加的底库图片,必需参数</td>
 <td><code>str</code>|<code>list</code></td>
+<td>
+<ul>
+  <li><b>str</b>:图片根目录,数据组织方式参考<a href="#2.3-构建特征库的数据组织方式">2.3节 构建特征库的数据组织方式</a></li>
+  <li><b>List[numpy.ndarray]</b>:numpy.array列表类型的底库图片数据</li>
+</ul>
+</td>
 <td>无</td>
 </tr>
 <tr>
 <td><code>gallery_label</code></td>
-<td>底库图片的标注信息,支持:1. <code>str</code>类型表示的标注文件的路径,数据组织方式与构建特征库时相同,参考<a href="#2.3-构建特征库的数据组织方式">2.3节 构建特征库的数据组织方式</a>;2. <code>[str, str, ..]</code>类型表示的底库图片标注。</td>
-<td><code>str</code></td>
+<td>底库图片的标注信息,必需参数</td>
+<td><code>str|list</code></td>
+<td>
+<ul>
+  <li><b>str</b>:标注文件的路径,数据组织方式与构建特征库时相同,参考<a href="#2.3-构建特征库的数据组织方式">2.3节 构建特征库的数据组织方式</a></li>
+  <li><b>List[str]</b>:str列表类型的底库图片标注</li>
+</ul>
+</td>
 <td>无</td>
 </tr>
+<tr>
+<td><code>metric_type</code></td>
+<td>特征度量方式,可选参数</td>
+<td><code>str</code></td>
+<td>
+<ul>
+  <li><code>"IP"</code>:内积(Inner Product)</li>
+  <li><code>"L2"</code>:欧几里得距离(Euclidean Distance)</li>
+</ul>
+</td>
+<td><code>"IP"</code></td>
+</tr>
+<tr>
+<td><code>index_type</code></td>
+<td>索引类型,可选参数</td>
+<td><code>str</code></td>
+<td>
+<ul>
+  <li><code>"HNSW32"</code>:检索速度较快且精度较高,但不支持 <code>remove_index()</code> 操作</li>
+  <li><code>"IVF"</code>:检索速度较快但精度相对较低,支持 <code>append_index()</code> 和 <code>remove_index()</code> 操作</li>
+  <li><code>"Flat"</code>:检索速度较低精度较高,支持 <code>append_index()</code> 和 <code>remove_index()</code> 操作</li>
+</ul>
+</td>
+<td><code>"HNSW32"</code></td>
+</tr>
 </tbody>
 </table>
 
-特征库对象 `index` 支持 `save` 方法,用于将特征库保存到磁盘:
+- 特征库对象 `index` 支持 `save` 方法,用于将特征库保存到磁盘:
 
 <table>
 <thead>
@@ -238,100 +263,169 @@ for res in output:
 </table>
 
 (3)调用人脸识别产线对象的 `predict` 方法进行推理预测:`predict` 方法参数为`input`,用于输入待预测数据,支持多种输入方式,具体示例如下:
-
 <table>
 <thead>
 <tr>
-<th>参数类型</th>
+<th>参数</th>
 <th>参数说明</th>
+<th>参数类型</th>
+<th>可选项</th>
+<th>默认值</th>
 </tr>
 </thead>
-<tbody>
 <tr>
-<td>Python Var</td>
-<td>支持直接传入Python变量,如numpy.ndarray表示的图像数据。</td>
+<td><code>input</code></td>
+<td>待预测数据,支持多种输入类型,必需参数</td>
+<td><code>Python Var|str|list</code></td>
+<td>
+<ul>
+  <li><b>Python Var</b>:如 <code>numpy.ndarray</code> 表示的图像数据</li>
+  <li><b>str</b>:如图像文件的本地路径:<code>/root/data/img.jpg</code>;<b>如URL链接</b>,如图像文件的网络URL:<a href = "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png">示例</a>;<b>如本地目录</b>,该目录下需包含待预测图像,如本地路径:<code>/root/data/</code></li>
+  <li><b>List</b>:列表元素需为上述类型数据,如<code>[numpy.ndarray, numpy.ndarray]</code>,<code>[\"/root/data/img1.jpg\", \"/root/data/img2.jpg\"]</code>,<code>[\"/root/data1\", \"/root/data2\"]</code></li>
+</ul>
+</td>
+<td>无</td>
 </tr>
 <tr>
-<td>str</td>
-<td>支持传入待预测数据文件路径,如图像文件的本地路径:<code>/root/data/img.jpg</code>。</td>
+<td><code>index</code></td>
+<td>产线推理预测所用的特征库,可选参数。如不传入该参数,则默认使用产线配置文件中指定的索引库。</td>
+<td><code>str|paddlex.inference.components.retrieval.faiss.IndexData|None</code></td>
+<td>
+<ul>
+    <li><b>str</b>类型表示的目录(该目录下需要包含特征库文件,包括<code>vector.index</code>和<code>index_info.yaml</code>)</li>
+    <li><code>build_index</code>方法创建的<b>IndexData</b>对象</li>
+</ul>
+</td>
+<td><code>None</code></td>
 </tr>
+</table>
+
+(4)对预测结果进行处理:每个样本的预测结果均为`dict`类型,且支持打印,或保存为文件,支持保存的类型与具体产线相关,如:
+
+<table>
+<thead>
 <tr>
-<td>str</td>
-<td>支持传入待预测数据文件URL,如图像文件的网络URL:<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/friends1.jpg">示例</a>。</td>
+<th>方法</th>
+<th>方法说明</th>
+<th>参数</th>
+<th>参数类型</th>
+<th>参数说明</th>
+<th>默认值</th>
 </tr>
+</thead>
 <tr>
-<td>str</td>
-<td>支持传入本地目录,该目录下需包含待预测数据文件,如本地路径:<code>/root/data/</code>。</td>
+<td rowspan = "3"><code>print()</code></td>
+<td rowspan = "3">打印结果到终端</td>
+<td><code>format_json</code></td>
+<td><code>bool</code></td>
+<td>是否对输出内容进行使用 <code>JSON</code> 缩进格式化</td>
+<td><code>True</code></td>
 </tr>
 <tr>
-<td>dict</td>
-<td>支持传入字典类型,字典的key需与具体任务对应,如图像分类任务对应\"img\",字典的val支持上述类型数据,例如:<code>{\"img\": \"/root/data1\"}</code>。</td>
+<td><code>indent</code></td>
+<td><code>int</code></td>
+<td>指定缩进级别,以美化输出的 <code>JSON</code> 数据,使其更具可读性,仅当 <code>format_json</code> 为 <code>True</code> 时有效</td>
+<td>4</td>
 </tr>
 <tr>
-<td>list</td>
-<td>支持传入列表,列表元素需为上述类型数据,如<code>[numpy.ndarray, numpy.ndarray],[\"/root/data/img1.jpg\", \"/root/data/img2.jpg\"]</code>,<code>[\"/root/data1\", \"/root/data2\"]</code>,<code>[{\"img\": \"/root/data1\"}, {\"img\": \"/root/data2/img.jpg\"}]</code>。</td>
+<td><code>ensure_ascii</code></td>
+<td><code>bool</code></td>
+<td>控制是否将非 <code>ASCII</code> 字符转义为 <code>Unicode</code>。设置为 <code>True</code> 时,所有非 <code>ASCII</code> 字符将被转义;<code>False</code> 则保留原始字符,仅当<code>format_json</code>为<code>True</code>时有效</td>
+<td><code>False</code></td>
 </tr>
-</tbody>
-</table>
-另外,`predict`方法支持参数`index`用于设置索引库:
-<table>
-<thead>
 <tr>
-<th>参数类型</th>
-<th>参数说明</th>
+<td rowspan = "3"><code>save_to_json()</code></td>
+<td rowspan = "3">将结果保存为json格式的文件</td>
+<td><code>save_path</code></td>
+<td><code>str</code></td>
+<td>保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致</td>
+<td>无</td>
 </tr>
-</thead>
-<tbody>
 <tr>
-<td><code>index</code></td>
-<td>产线推理预测所用的特征库,支持:1. <code>str</code>类型表示的目录(该目录下需要包含特征库文件,包括<code>vector.index</code>和<code>index_info.yaml</code>);2. <code>IndexData</code>对象。如不传入该参数,则默认使用在<code>create_pipeline()</code>中通过参数<code>index</code>指定的特征库。</td>
+<td><code>indent</code></td>
+<td><code>int</code></td>
+<td>指定缩进级别,以美化输出的 <code>JSON</code> 数据,使其更具可读性,仅当 <code>format_json</code> 为 <code>True</code> 时有效</td>
+<td>4</td>
+</tr>
+<tr>
+<td><code>ensure_ascii</code></td>
+<td><code>bool</code></td>
+<td>控制是否将非 <code>ASCII</code> 字符转义为 <code>Unicode</code>。设置为 <code>True</code> 时,所有非 <code>ASCII</code> 字符将被转义;<code>False</code> 则保留原始字符,仅当<code>format_json</code>为<code>True</code>时有效</td>
+<td><code>False</code></td>
+</tr>
+<tr>
+<td><code>save_to_img()</code></td>
+<td>将结果保存为图像格式的文件</td>
+<td><code>save_path</code></td>
+<td><code>str</code></td>
+<td>保存的文件路径,支持目录或文件路径</td>
+<td>无</td>
 </tr>
-</tbody>
 </table>
-(4)调用`predict`方法获取预测结果:`predict` 方法为`generator`,因此需要通过调用获得预测结果,`predict`方法以batch为单位对数据进行预测。
 
-(5)对预测结果进行处理:每个样本的预测结果均为`dict`类型,且支持打印,或保存为文件,支持保存的类型与具体产线相关,如:
+- 调用 `print()` 方法会将如下结果打印到终端:
+```bash
+{'res': {'input_path': 'friends1.jpg', 'boxes': [{'labels': ['Chandler', 'Chandler', 'Chandler', 'Chandler', 'Chandler'], 'rec_scores': [0.5884832143783569, 0.5777347087860107, 0.5082703828811646, 0.48792028427124023, 0.4842316806316376], 'det_score': 0.9119220972061157, 'coordinate': [790.40015, 170.34453, 868.47626, 279.54446]}, {'labels': ['Joey', 'Joey', 'Joey', 'Joey', 'Joey'], 'rec_scores': [0.5654032826423645, 0.5601680278778076, 0.5382657051086426, 0.5320160984992981, 0.5209866762161255], 'det_score': 0.9052104353904724, 'coordinate': [1274.6246, 184.58124, 1353.4016, 300.0643]}, {'labels': ['Phoebe', 'Phoebe', 'Phoebe', 'Phoebe', 'Phoebe'], 'rec_scores': [0.6462339162826538, 0.6003466844558716, 0.5999515652656555, 0.583031415939331, 0.5640993118286133], 'det_score': 0.9041699171066284, 'coordinate': [1052.4514, 192.52296, 1129.5226, 292.84177]}, {'labels': ['Ross', 'Ross', 'Ross', 'Ross', 'Ross'], 'rec_scores': [0.5012176036834717, 0.49081552028656006, 0.48970693349838257, 0.4808862805366516, 0.4794950783252716], 'det_score': 0.9031845331192017, 'coordinate': [162.41049, 156.96768, 242.07184, 266.13004]}, {'labels': ['Monica', 'Monica', 'Monica', 'Monica', 'Monica'], 'rec_scores': [0.5704089403152466, 0.5037636756896973, 0.4877302646636963, 0.46702104806900024, 0.4376206696033478], 'det_score': 0.8862134218215942, 'coordinate': [572.18176, 216.25815, 639.2387, 311.08417]}, {'labels': ['Rachel', 'Rachel', 'Rachel', 'Rachel', 'Rachel'], 'rec_scores': [0.6107711791992188, 0.5915063619613647, 0.5776835083961487, 0.569993257522583, 0.5594189167022705], 'det_score': 0.8822972774505615, 'coordinate': [303.12866, 231.94759, 374.5314, 330.2883]}]}}
+```
+
+- 输出结果参数含义如下:
+    - `input_path`:表示输入图像的路径
+    - `boxes`:检测到的人脸信息,一个字典列表,每个字典包含以下信息:
+        - `labels`:识别标签列表,按照分数从高到低排序
+        - `rec_scores`:识别分数列表,其中元素与`labels`一一对应
+        - `det_score`:检测得分
+        - `coordinate`:人脸框坐标,格式为[xmin, ymin, xmax, ymax]
+
+- 调用`save_to_json()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}.json`,如果指定为文件,则直接保存到该文件中。
+- 调用`save_to_img()` 方法会将可视化结果保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}_res.{your_img_extension}`,如果指定为文件,则直接保存到该文件中。(产线通常包含较多结果图片,不建议直接指定为具体的文件路径,否则多张图会被覆盖,仅保留最后一张图),上述示例中,可视化结果如下所示:
+
+<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/refs/heads/main/images/pipelines/face_recognition/02.jpg">
+
+* 此外,也支持通过属性获取带结果的可视化图像和预测结果,具体如下:
 
 <table>
 <thead>
 <tr>
-<th>方法</th>
-<th>说明</th>
-<th>方法参数</th>
+<th>属性</th>
+<th>属性说明</th>
 </tr>
 </thead>
-<tbody>
-<tr>
-<td>print</td>
-<td>打印结果到终端</td>
-<td><code>- format_json</code>:bool类型,是否对输出内容进行使用json缩进格式化,默认为True;<br/><code>- indent</code>:int类型,json格式化设置,仅当format_json为True时有效,默认为4;<br/><code>- ensure_ascii</code>:bool类型,json格式化设置,仅当format_json为True时有效,默认为False;</td>
-</tr>
 <tr>
-<td>save_to_json</td>
-<td>将结果保存为json格式的文件</td>
-<td><code>- save_path</code>:str类型,保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致;<br/><code>- indent</code>:int类型,json格式化设置,默认为4;<br/><code>- ensure_ascii</code>:bool类型,json格式化设置,默认为False;</td>
+<td rowspan = "1"><code>json</code></td>
+<td rowspan = "1">获取预测的 <code>json</code> 格式的结果</td>
 </tr>
 <tr>
-<td>save_to_img</td>
-<td>将结果保存为图像格式的文件</td>
-<td><code>- save_path</code>:str类型,保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致;</td>
+<td rowspan = "2"><code>img</code></td>
+<td rowspan = "2">获取格式为 <code>dict</code> 的可视化图像</td>
 </tr>
-</tbody>
 </table>
-若您获取了配置文件,即可对人脸识别产线各项配置进行自定义,只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为产线配置文件路径即可。
 
-例如,若您的配置文件保存在 `./my_path/face_recognition.yaml` ,则只需执行:
+- `json` 属性获取的预测结果为dict类型的数据,相关内容与调用 `save_to_json()` 方法保存的内容一致。
+- `img` 属性返回的预测结果是一个字典类型的数据。键为 `res` ,对应的值是一个用于可视化人脸识别结果的 `Image.Image` 对象。
+
+上述Python脚本集成方式默认使用 PaddleX 官方配置文件中的参数设置,若您需要自定义配置文件,可先执行如下命令获取官方配置文件,并保存在 `my_path` 中:
+
+```bash
+paddlex --get_pipeline_config face_recognition --save_path ./my_path
+```
+
+若您获取了配置文件,即可对人脸识别产线各项配置进行自定义。只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为自定义产线配置文件路径即可。
+
+例如,若您的自定义配置文件保存在 `./my_path/face_recognition.yaml` ,则只需执行:
 
 ```python
 from paddlex import create_pipeline
-pipeline = create_pipeline(pipeline="./my_path/face_recognition.yaml", index="face_index")
+pipeline = create_pipeline(pipeline="./my_path/face_recognition.yaml")
 
-output = pipeline.predict("friends1.jpg")
+output = pipeline.predict("friends1.jpg", index="face_index")
 for res in output:
     res.print()
+    res.save_to_json("./output/")
     res.save_to_img("./output/")
 ```
 
+<b>注:</b> 配置文件中的参数为产线初始化参数,如果希望更改人脸识别产线初始化参数,可以直接修改配置文件中的参数,并加载配置文件进行预测。
+
 #### 2.2.3 人脸特征库的添加和删除操作
 
 若您希望将更多的人脸图像添加到特征库中,则可以调用 `append_index` 方法;删除人脸图像特征,则可以调用 `remove_index` 方法。
@@ -354,50 +448,89 @@ index_data.save("face_index")
 <th>参数</th>
 <th>参数说明</th>
 <th>参数类型</th>
+<th>可选项</th>
 <th>默认值</th>
 </tr>
 </thead>
 <tbody>
 <tr>
 <td><code>gallery_imgs</code></td>
-<td>要添加的底库图片,支持:1. <code>str</code>类型表示的图片根目录,数据组织方式与构建索引库时相同,参考<a href="#2.3-构建特征库的数据组织方式">2.3节 构建特征库的数据组织方式</a>;2. <code>[numpy.ndarray, numpy.ndarray, ..]</code>类型的底库图片数据。</td>
+<td>要添加的底库图片,必需参数</td>
 <td><code>str</code>|<code>list</code></td>
+<td>
+<ul>
+  <li><b>str</b>:图片根目录,数据组织方式参考<a href="#2.3-构建特征库的数据组织方式">2.3节 构建特征库的数据组织方式</a></li>
+  <li><b>List[numpy.ndarray]</b>:numpy.array列表类型的底库图片数据</li>
+</ul>
+</td>
 <td>无</td>
 </tr>
 <tr>
 <td><code>gallery_label</code></td>
-<td>底库图片的标注信息,支持:1. <code>str</code>类型表示的标注文件的路径,数据组织方式与构建特征库时相同,参考<a href="#2.3-构建特征库的数据组织方式">2.3节 构建特征库的数据组织方式</a>;2. <code>[str, str, ..]</code>类型表示的底库图片标注。</td>
-<td><code>str</code>|<code>list</code></td>
+<td>底库图片的标注信息,必需参数</td>
+<td><code>str|list</code></td>
+<td>
+<ul>
+  <li><b>str</b>:标注文件的路径,数据组织方式与构建特征库时相同,参考<a href="#2.3-构建特征库的数据组织方式">2.3节 构建特征库的数据组织方式</a></li>
+  <li><b>List[str]</b>:str列表类型的底库图片标注</li>
+</ul>
+</td>
 <td>无</td>
 </tr>
 <tr>
+<td><code>metric_type</code></td>
+<td>特征度量方式,可选参数</td>
+<td><code>str</code></td>
+<td>
+<ul>
+  <li><code>"IP"</code>:内积(Inner Product)</li>
+  <li><code>"L2"</code>:欧几里得距离(Euclidean Distance)</li>
+</ul>
+</td>
+<td><code>"IP"</code></td>
+</tr>
+<tr>
+<td><code>index_type</code></td>
+<td>索引类型,可选参数</td>
+<td><code>str</code></td>
+<td>
+<ul>
+  <li><code>"HNSW32"</code>:检索速度较快且精度较高,但不支持 <code>remove_index()</code> 操作</li>
+  <li><code>"IVF"</code>:检索速度较快但精度相对较低,支持 <code>append_index()</code> 和 <code>remove_index()</code> 操作</li>
+  <li><code>"Flat"</code>:检索速度较低精度较高,支持 <code>append_index()</code> 和 <code>remove_index()</code> 操作</li>
+</ul>
+</td>
+<td><code>"HNSW32"</code></td>
+</tr>
+<tr>
 <td><code>remove_ids</code></td>
-<td>待删除的索引序号,支持:1. <code>str</code>类型表示的txt文件的路径,内容为待删除的索引id,每行一个“id”;2. <code>[int, int, ..]</code>类型表示的待删除的索引序号。仅在 <code>remove_index</code> 中有效。</td>
+<td>待删除的索引序号,</td>
 <td><code>str</code>|<code>list</code></td>
+<td>
+<ul>
+<li><b>str</b>:表示的txt文件的路径,内容为待删除的索引id,每行一个“id”;</li>
+<li><b>List[int]</b>:表示的待删除的索引序号。仅在 <code>remove_index</code> 中有效。</li></ul>
+</td>
 <td>无</td>
 </tr>
 <tr>
 <td><code>index</code></td>
-<td>特征库,支持:1. 特征库文件(<code>vector.index</code>和<code>index_info.yaml</code>)所在目录的路径;2. <code>IndexData</code>类型的特征库对象,仅在 <code>append_index</code> 和 <code>remove_index</code> 中有效,表示待修改的特征库。</td>
-<td><code>str</code>|<code>IndexData</code></td>
+<td>产线推理预测所用的特征库</td>
+<td><code>str|paddlex.inference.components.retrieval.faiss.IndexData</code></td>
+<td>
+<ul>
+    <li><b>str</b>类型表示的目录(该目录下需要包含特征库文件,包括<code>vector.index</code>和<code>index_info.yaml</code>)</li>
+    <li><code>build_index</code>方法创建的<b>IndexData</b>对象</li>
+</ul>
+</td>
 <td>无</td>
 </tr>
-<tr>
-<td><code>index_type</code></td>
-<td>支持 <code>HNSW32</code>、<code>IVF</code>、<code>Flat</code>。其中,<code>HNSW32</code> 检索速度较快且精度较高,但不支持 <code>remove_index()</code> 操作;<code>IVF</code> 检索速度较快但精度相对较低,支持 <code>append_index()</code> 和 <code>remove_index()</code> 操作;<code>Flat</code> 检索速度较低精度较高,支持 <code>append_index()</code> 和 <code>remove_index()</code> 操作。</td>
-<td><code>str</code></td>
-<td><code>HNSW32</code></td>
-</tr>
-<tr>
-<td><code>metric_type</code></td>
-<td>支持:<code>IP</code>,内积(Inner Product);<code>L2</code>,欧几里得距离(Euclidean Distance)。</td>
-<td><code>str</code></td>
-<td><code>IP</code></td>
-</tr>
 </tbody>
 </table>
-### 2.3 构建特征库的数据组织方式
 
+<b>注意</b>:<code>HNSW32</code>在windows平台存在兼容性问题,可能导致索引库无法构建、加载。
+
+### 2.3 构建特征库的数据组织方式
 PaddleX的人脸识别产线示例需要使用预先构建好的特征库进行人脸特征检索。如果您希望用私有数据构建人脸特征库,则需要按照如下方式组织数据:
 
 ```bash
@@ -896,27 +1029,31 @@ pprint.pp(result_infer[&quot;faces&quot;])
 ### 4.1 模型微调
 由于人脸识别产线包含两个模块(人脸检测和人脸特征),模型产线的效果不及预期可能来自于其中任何一个模块。
 
-您可以对识别效果差的图片进行分析,如果在分析过程中发现有较多的人脸未被检测出来,那么可能是人脸检测模型存在不足,您需要参考[人脸检测模块开发教程](../../../module_usage/tutorials/cv_modules/face_detection.md)中的[二次开发](../../../module_usage/tutorials/cv_modules/face_detection.md#四二次开发)章节,使用您的私有数据集对人脸检测模型进行微调;如果在已检测到的人脸出现匹配错误,这表明人脸特征模块需要进一步改进,您需要参考[人脸特征模块开发教程](../../../module_usage/tutorials/cv_modules/face_feature.md)中的[二次开发](../../../module_usage/tutorials/cv_modules/face_feature.md#四二次开发)章节,对人脸特征模块进行微调。
+您可以对识别效果差的图片进行分析,如果在分析过程中发现有较多的人脸未被检测出来,那么可能是人脸检测模型存在不足,您需要参考[人脸检测模块开发教程](../../../module_usage/tutorials/cv_modules/face_detection.md)中的[二次开发](../../../module_usage/tutorials/cv_modules/face_detection.md#四二次开发)章节,使用您的私有数据集对人脸检测模型进行微调;如果在已检测到的人脸出现匹配错误,这表明人脸特征模块需要进一步改进,您需要参考[人脸特征模块开发教程](../../../module_usage/tutorials/cv_modules/face_feature.md)中的[二次开发](../../../module_usage/tutorials/cv_modules/face_feature.md#四二次开发)章节对人脸特征模块进行微调。
 
 ### 4.2 模型应用
 当您使用私有数据集完成微调训练后,可获得本地模型权重文件。
 
 若您需要使用微调后的模型权重,只需对产线配置文件做修改,将微调后模型权重的本地路径替换至产线配置文件中的对应位置即可:
 
-```bash
-
-......
-Pipeline:
-  device: "gpu:0"
-  det_model: "BlazeFace"        #可修改为微调后人脸检测模型的本地路径
-  rec_model: "MobileFaceNet"    #可修改为微调后人脸特征模型的本地路径
-  det_batch_size: 1
-  rec_batch_size: 1
-  device: gpu
-......
+```yaml
+
+...
+
+SubModules:
+  Detection:
+    module_name: face_detection
+    model_name: PP-YOLOE_plus-S_face
+    model_dir: null #可修改为微调后人脸检测模型的本地路径
+    batch_size: 1
+  Recognition:
+    module_name: face_feature
+    model_name: ResNet50_face
+    model_dir: null #可修改为微调后人脸特征模型的本地路径
+    batch_size: 1
 ```
+
 随后, 参考[2.2 本地体验](#22-本地体验)中的命令行方式或Python脚本方式,加载修改后的产线配置文件即可。
-注:目前暂不支持为人脸检测和人脸特征模型设置单独的batch_size。
 
 ##  5. 多硬件支持
 PaddleX 支持英伟达 GPU、昆仑芯 XPU、昇腾 NPU和寒武纪 MLU 等多种主流硬件设备,<b>仅需修改 `--device`参数</b>即可完成不同硬件之间的无缝切换。

+ 235 - 98
docs/pipeline_usage/tutorials/cv_pipelines/general_image_recognition.md

@@ -94,16 +94,6 @@ PaddleX 所提供的预训练的模型产线均可以快速体验效果,你可
 
 该产线暂不支持命令行体验。
 
-默认使用内置的的通用图像识别产线配置文件,若您需要自定义配置文件,可执行如下命令获取:
-
-<details><summary> 👉点击展开</summary>
-
-<pre><code class="language-bash">paddlex --get_pipeline_config PP-ShiTuV2
-</code></pre>
-<p>执行后,通用图像识别产线配置文件将被保存在当前路径。若您希望自定义保存位置,可执行如下命令(假设自定义保存位置为<code>./my_path</code>):</p>
-<pre><code class="language-bash">paddlex --get_pipeline_config PP-ShiTuV2 --save_path ./my_path
-</code></pre></details>
-
 #### 2.2.2 Python脚本方式集成
 
 * 在该产线的运行示例中需要预先构建索引库,您可以下载官方提供的饮料识别测试数据集[drink_dataset_v2.0](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/drink_dataset_v2.0.tar) 构建索引库。若您希望用私有数据集,可以参考[2.3节 构建索引库的数据组织方式](#23-构建索引库的数据组织方式)。之后通过几行代码即可完成建立索引库和通用图像识别产线的快速推理。
@@ -116,15 +106,16 @@ pipeline = create_pipeline(pipeline="PP-ShiTuV2")
 index_data = pipeline.build_index(gallery_imgs="drink_dataset_v2.0/", gallery_label="drink_dataset_v2.0/gallery.txt")
 index_data.save("drink_index")
 
-output = pipeline.predict("./drink_dataset_v2.0/test_images/", index=index_data)
+output = pipeline.predict("./drink_dataset_v2.0/test_images/001.jpeg", index=index_data)
 for res in output:
     res.print()
     res.save_to_img("./output/")
+    res.save_to_json("./output/")
 ```
 
 在上述 Python 脚本中,执行了如下几个步骤:
 
-(1)实例化 `create_pipeline` 实例化 通用图像识别 产线对象。具体参数说明如下:
+(1)调用 `create_pipeline` 实例化通用图像识别产线对象。具体参数说明如下:
 
 <table>
 <thead>
@@ -143,16 +134,10 @@ for res in output:
 <td>无</td>
 </tr>
 <tr>
-<td><code>index</code></td>
-<td>产线推理预测所用的索引库,支持:1. <code>str</code>类型表示的目录(该目录下需要包含索引库文件,包括<code>vector.index</code>和<code>index_info.yaml</code>);2. <code>IndexData</code>对象。如不传入该参数,则需要在<code>predict()</code>中指定<code>index</code>。</td>
-<td><code>str</code></td>
-<td>None</td>
-</tr>
-<tr>
 <td><code>device</code></td>
-<td>产线模型推理设备。支持:“gpu”,“cpu”。</td>
+<td>产线推理设备。支持指定GPU具体卡号,如“gpu:0”,其他硬件具体卡号,如“npu:0”,CPU如“cpu”。</td>
 <td><code>str</code></td>
-<td><code>gpu</code></td>
+<td><code>gpu:0</code></td>
 </tr>
 <tr>
 <td><code>use_hpip</code></td>
@@ -162,6 +147,7 @@ for res in output:
 </tr>
 </tbody>
 </table>
+
 (2)调用通用图像识别产线对象的 `build_index` 方法,构建索引库。具体参数为说明如下:
 
 <table>
@@ -170,22 +156,60 @@ for res in output:
 <th>参数</th>
 <th>参数说明</th>
 <th>参数类型</th>
+<th>可选项</th>
 <th>默认值</th>
 </tr>
 </thead>
 <tbody>
 <tr>
 <td><code>gallery_imgs</code></td>
-<td>数据集的根目录,数据组织方式参考<a href="#2.3-构建索引库的数据组织方式">2.3节 构建索引库的数据组织方式</a></td>
-<td><code>str</code></td>
+<td>要添加的底库图片,必需参数</td>
+<td><code>str</code>|<code>list</code></td>
+<td>
+<ul>
+  <li><b>str</b>:数据集的根目录,数据组织方式参考<a href="#2.3-构建索引库的数据组织方式">2.3节 构建索引库的数据组织方式</a></li>
+  <li><b>List[numpy.ndarray]</b>:numpy.array列表类型的底库图片数据</li>
+</ul>
+</td>
 <td>无</td>
 </tr>
 <tr>
 <td><code>gallery_label</code></td>
-<td>数据标注文件路径,数据组织方式参考<a href="#2.3-构建索引库的数据组织方式">2.3节 构建索引库的数据组织方式</a></td>
-<td><code>str</code></td>
+<td>底库图片的标注信息,必需参数</td>
+<td><code>str|list</code></td>
+<td>
+<ul>
+  <li><b>str</b>:数据标注文件路径,数据组织方式参考<a href="#2.3-构建索引库的数据组织方式">2.3节 构建索引库的数据组织方式</a></li>
+  <li><b>List[str]</b>:str列表类型的底库图片标注</li>
+</ul>
+</td>
 <td>无</td>
 </tr>
+<tr>
+<td><code>metric_type</code></td>
+<td>特征度量方式,可选参数</td>
+<td><code>str</code></td>
+<td>
+<ul>
+  <li><code>"IP"</code>:内积(Inner Product)</li>
+  <li><code>"L2"</code>:欧几里得距离(Euclidean Distance)</li>
+</ul>
+</td>
+<td><code>"IP"</code></td>
+</tr>
+<tr>
+<td><code>index_type</code></td>
+<td>索引类型,可选参数</td>
+<td><code>str</code></td>
+<td>
+<ul>
+  <li><code>"HNSW32"</code>:检索速度较快且精度较高,但不支持 <code>remove_index()</code> 操作</li>
+  <li><code>"IVF"</code>:检索速度较快但精度相对较低,支持 <code>append_index()</code> 和 <code>remove_index()</code> 操作</li>
+  <li><code>"Flat"</code>:检索速度较低精度较高,支持 <code>append_index()</code> 和 <code>remove_index()</code> 操作</li>
+</ul>
+</td>
+<td><code>"HNSW32"</code></td>
+</tr>
 </tbody>
 </table>
 
@@ -215,96 +239,165 @@ for res in output:
 <table>
 <thead>
 <tr>
-<th>参数类型</th>
+<th>参数</th>
 <th>参数说明</th>
+<th>参数类型</th>
+<th>可选项</th>
+<th>默认值</th>
 </tr>
 </thead>
-<tbody>
 <tr>
-<td>Python Var</td>
-<td>支持直接传入Python变量,如<code>numpy.ndarray</code>表示的图像数据。</td>
+<td><code>input</code></td>
+<td>待预测数据,支持多种输入类型,必需参数</td>
+<td><code>Python Var|str|list</code></td>
+<td>
+<ul>
+  <li><b>Python Var</b>:如 <code>numpy.ndarray</code> 表示的图像数据</li>
+  <li><b>str</b>:如图像文件的本地路径:<code>/root/data/img.jpg</code>;<b>如URL链接</b>,如图像文件的网络URL:<a href = "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png">示例</a>;<b>如本地目录</b>,该目录下需包含待预测图像,如本地路径:<code>/root/data/</code></li>
+  <li><b>List</b>:列表元素需为上述类型数据,如<code>[numpy.ndarray, numpy.ndarray]</code>,<code>[\"/root/data/img1.jpg\", \"/root/data/img2.jpg\"]</code>,<code>[\"/root/data1\", \"/root/data2\"]</code></li>
+</ul>
+</td>
+<td>无</td>
 </tr>
 <tr>
-<td>str</td>
-<td>支持传入待预测数据文件路径,如图像文件的本地路径:<code>/root/data/img.jpg</code>。</td>
+<td><code>index</code></td>
+<td>产线推理预测所用的特征库,可选参数。如不传入该参数,则默认使用产线配置文件中指定的索引库。</td>
+<td><code>str|paddlex.inference.components.retrieval.faiss.IndexData|None</code></td>
+<td>
+<ul>
+    <li><b>str</b>类型表示的目录(该目录下需要包含特征库文件,包括<code>vector.index</code>和<code>index_info.yaml</code>)</li>
+    <li><code>build_index</code>方法创建的<b>IndexData</b>对象</li>
+</ul>
+</td>
+<td><code>None</code></td>
 </tr>
+</table>
+
+(4)对预测结果进行处理:每个样本的预测结果均为`dict`类型,且支持打印,或保存为文件,支持保存的类型与具体产线相关,如:
+
+<table>
+<thead>
 <tr>
-<td>str</td>
-<td>支持传入待预测数据文件URL,如图像文件的网络URL:<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/yuanqisenlin.jpeg">示例</a>。</td>
+<th>方法</th>
+<th>方法说明</th>
+<th>参数</th>
+<th>参数类型</th>
+<th>参数说明</th>
+<th>默认值</th>
 </tr>
+</thead>
 <tr>
-<td>str</td>
-<td>支持传入本地目录,该目录下需包含待预测数据文件,如本地路径:<code>/root/data/</code>。</td>
+<td rowspan = "3"><code>print()</code></td>
+<td rowspan = "3">打印结果到终端</td>
+<td><code>format_json</code></td>
+<td><code>bool</code></td>
+<td>是否对输出内容进行使用 <code>JSON</code> 缩进格式化</td>
+<td><code>True</code></td>
 </tr>
 <tr>
-<td>dict</td>
-<td>支持传入字典类型,字典的key需与具体任务对应,如图像分类任务对应\"img\",字典的val支持上述类型数据,例如:<code>{\"img\": \"/root/data1\"}</code>。</td>
+<td><code>indent</code></td>
+<td><code>int</code></td>
+<td>指定缩进级别,以美化输出的 <code>JSON</code> 数据,使其更具可读性,仅当 <code>format_json</code> 为 <code>True</code> 时有效</td>
+<td>4</td>
 </tr>
 <tr>
-<td>list</td>
-<td>支持传入列表,列表元素需为上述类型数据,如<code>[numpy.ndarray, numpy.ndarray],[\"/root/data/img1.jpg\", \"/root/data/img2.jpg\"]</code>,<code>[\"/root/data1\", \"/root/data2\"]</code>,<code>[{\"img\": \"/root/data1\"}, {\"img\": \"/root/data2/img.jpg\"}]</code>。</td>
+<td><code>ensure_ascii</code></td>
+<td><code>bool</code></td>
+<td>控制是否将非 <code>ASCII</code> 字符转义为 <code>Unicode</code>。设置为 <code>True</code> 时,所有非 <code>ASCII</code> 字符将被转义;<code>False</code> 则保留原始字符,仅当<code>format_json</code>为<code>True</code>时有效</td>
+<td><code>False</code></td>
 </tr>
-</tbody>
-</table>
-另外,`predict`方法支持参数`index`用于设置索引库:
-<table>
-<thead>
 <tr>
-<th>参数类型</th>
-<th>参数说明</th>
+<td rowspan = "3"><code>save_to_json()</code></td>
+<td rowspan = "3">将结果保存为json格式的文件</td>
+<td><code>save_path</code></td>
+<td><code>str</code></td>
+<td>保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致</td>
+<td>无</td>
 </tr>
-</thead>
-<tbody>
 <tr>
-<td><code>index</code></td>
-<td>产线推理预测所用的索引库,支持:1. <code>str</code>类型表示的目录(该目录下需要包含索引库文件,包括<code>vector.index</code>和<code>index_info.yaml</code>);2. <code>IndexData</code>对象。如不传入该参数,则默认使用在<code>create_pipeline()</code>中通过参数<code>index</code>指定的索引库。</td>
+<td><code>indent</code></td>
+<td><code>int</code></td>
+<td>指定缩进级别,以美化输出的 <code>JSON</code> 数据,使其更具可读性,仅当 <code>format_json</code> 为 <code>True</code> 时有效</td>
+<td>4</td>
+</tr>
+<tr>
+<td><code>ensure_ascii</code></td>
+<td><code>bool</code></td>
+<td>控制是否将非 <code>ASCII</code> 字符转义为 <code>Unicode</code>。设置为 <code>True</code> 时,所有非 <code>ASCII</code> 字符将被转义;<code>False</code> 则保留原始字符,仅当<code>format_json</code>为<code>True</code>时有效</td>
+<td><code>False</code></td>
+</tr>
+<tr>
+<td><code>save_to_img()</code></td>
+<td>将结果保存为图像格式的文件</td>
+<td><code>save_path</code></td>
+<td><code>str</code></td>
+<td>保存的文件路径,支持目录或文件路径</td>
+<td>无</td>
 </tr>
-</tbody>
 </table>
-(4)调用 `predict` 方法获取预测结果:`predict` 方法为 `generator`,因此需要通过调用获得预测结果,`predict` 将方法以 batch 为单位对数据进行预测。
 
-(5)对预测结果进行处理:每个样本的预测结果均为 `dict` 类型,且支持打印,或保存为文件,支持保存的类型与具体产线相关,如:
+- 调用 `print()` 方法会将如下结果打印到终端:
+```bash
+{'res': {'input_path': './drink_dataset_v2.0/test_images/001.jpeg', 'boxes': [{'labels': ['红牛-强化型', '红牛-强化型', '红牛-强化型', '红牛-强化型', '红牛-强化型'], 'rec_scores': [0.720183789730072, 0.7044230699539185, 0.6812724471092224, 0.6583285927772522, 0.6578206419944763], 'det_score': 0.6135568618774414, 'coordinate': [343.8184, 98.96374, 528.0366, 593.3813]}]}}
+```
+
+- 输出结果参数含义如下:
+    - `input_path`:表示输入图像的路径
+    - `boxes`:检测到的物体信息,一个字典列表,每个字典包含以下信息:
+        - `labels`:识别标签列表,按照分数从高到低排序
+        - `rec_scores`:识别分数列表,其中元素与`labels`一一对应
+        - `det_score`:检测得分
+        - `coordinate`:目标框坐标,格式为[xmin, ymin, xmax, ymax]
+
+- 调用`save_to_json()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}.json`,如果指定为文件,则直接保存到该文件中。
+- 调用`save_to_img()` 方法会将可视化结果保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}_res.{your_img_extension}`,如果指定为文件,则直接保存到该文件中。(产线通常包含较多结果图片,不建议直接指定为具体的文件路径,否则多张图会被覆盖,仅保留最后一张图),上述示例中,可视化结果如下所示:
+
+<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/refs/heads/main/images/pipelines/general_image_recognition/01.jpg">
+
+* 此外,也支持通过属性获取带结果的可视化图像和预测结果,具体如下:
 
 <table>
 <thead>
 <tr>
-<th>方法</th>
-<th>说明</th>
-<th>方法参数</th>
+<th>属性</th>
+<th>属性说明</th>
 </tr>
 </thead>
-<tbody>
 <tr>
-<td>print</td>
-<td>打印结果到终端</td>
-<td><code>- format_json</code>:bool类型,是否对输出内容进行使用json缩进格式化,默认为True;<br/><code>- indent</code>:int类型,json格式化设置,仅当format_json为True时有效,默认为4;<br/><code>- ensure_ascii</code>:bool类型,json格式化设置,仅当format_json为True时有效,默认为False;</td>
+<td rowspan = "1"><code>json</code></td>
+<td rowspan = "1">获取预测的 <code>json</code> 格式的结果</td>
 </tr>
 <tr>
-<td>save_to_json</td>
-<td>将结果保存为json格式的文件</td>
-<td><code>- save_path</code>:str类型,保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致;<br/><code>- indent</code>:int类型,json格式化设置,默认为4;<br/><code>- ensure_ascii</code>:bool类型,json格式化设置,默认为False;</td>
+<td rowspan = "2"><code>img</code></td>
+<td rowspan = "2">获取格式为 <code>dict</code> 的可视化图像</td>
 </tr>
-<tr>
-<td>save_to_img</td>
-<td>将结果保存为图像格式的文件</td>
-<td><code>- save_path</code>:str类型,保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致;</td>
-</tr>
-</tbody>
 </table>
-若您获取了配置文件,即可对通用图像识别产线各项配置进行自定义,只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为产线配置文件路径即可。
 
-例如,若您的配置文件保存在 `./my_path/PP-ShiTuV2.yaml` ,则只需执行:
+- `json` 属性获取的预测结果为dict类型的数据,相关内容与调用 `save_to_json()` 方法保存的内容一致。
+- `img` 属性返回的预测结果是一个字典类型的数据。键为 `res` ,对应的值是一个用于可视化通用图像识别结果的 `Image.Image` 对象。
+
+上述Python脚本集成方式默认使用 PaddleX 官方配置文件中的参数设置,若您需要自定义配置文件,可先执行如下命令获取官方配置文件,并保存在 `my_path` 中:
+
+```bash
+paddlex --get_pipeline_config PP-ShiTuV2 --save_path ./my_path
+```
+
+若您获取了配置文件,即可对通用图像识别产线各项配置进行自定义。只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为自定义产线配置文件路径即可。
+
+例如,若您的自定义配置文件保存在 `./my_path/PP-ShiTuV2.yaml` ,则只需执行:
 
 ```python
 from paddlex import create_pipeline
-pipeline = create_pipeline(pipeline="./my_path/PP-ShiTuV2.yaml", index="drink_index")
+pipeline = create_pipeline(pipeline="./my_path/PP-ShiTuV2.yaml")
 
-output = pipeline.predict("./drink_dataset_v2.0/test_images/")
+output = pipeline.predict("./drink_dataset_v2.0/test_images/001.jpeg", index="drink_index")
 for res in output:
     res.print()
+    res.save_to_json("./output/")
     res.save_to_img("./output/")
 ```
 
+<b>注:</b> 配置文件中的参数为产线初始化参数,如果希望更改通用图像识别产线初始化参数,可以直接修改配置文件中的参数,并加载配置文件进行预测。
 
 #### 2.2.3 索引库的添加和删除操作
 
@@ -327,46 +420,83 @@ index_data.save("drink_index")
 <th>参数</th>
 <th>参数说明</th>
 <th>参数类型</th>
+<th>可选项</th>
 <th>默认值</th>
 </tr>
 </thead>
 <tbody>
 <tr>
 <td><code>gallery_imgs</code></td>
-<td>要添加的底库图片,支持:1. <code>str</code>类型表示的图片根目录,数据组织方式与构建索引库时相同,参考<a href="#2.3-构建索引库的数据组织方式">2.3节 构建索引库的数据组织方式</a>;2. <code>[numpy.ndarray, numpy.ndarray, ..]</code>类型的底库图片数据。</td>
+<td>要添加的底库图片,必需参数</td>
 <td><code>str</code>|<code>list</code></td>
+<td>
+<ul>
+  <li><b>str</b>:图片根目录,数据组织方式参考<a href="#2.3-构建索引库的数据组织方式">2.3节 构建索引库的数据组织方式</a></li>
+  <li><b>List[numpy.ndarray]</b>:numpy.array列表类型的底库图片数据</li>
+</ul>
+</td>
 <td>无</td>
 </tr>
 <tr>
 <td><code>gallery_label</code></td>
-<td>底库图片的标注信息,支持:1. <code>str</code>类型表示的标注文件的路径,数据组织方式与构建索引库时相同,参考<a href="#2.3-构建索引库的数据组织方式">2.3节 构建索引库的数据组织方式</a>;2. <code>[str, str, ..]</code>类型表示的底库图片标注。</td>
-<td><code>str</code>|<code>list</code></td>
+<td>底库图片的标注信息,必需参数</td>
+<td><code>str|list</code></td>
+<td>
+<ul>
+  <li><b>str</b>:标注文件的路径,数据组织方式与构建特征库时相同,参考<a href="#2.3-构建索引库的数据组织方式">2.3节 构建索引库的数据组织方式</a></li>
+  <li><b>List[str]</b>:str列表类型的底库图片标注</li>
+</ul>
+</td>
 <td>无</td>
 </tr>
 <tr>
+<td><code>metric_type</code></td>
+<td>特征度量方式,可选参数</td>
+<td><code>str</code></td>
+<td>
+<ul>
+  <li><code>"IP"</code>:内积(Inner Product)</li>
+  <li><code>"L2"</code>:欧几里得距离(Euclidean Distance)</li>
+</ul>
+</td>
+<td><code>"IP"</code></td>
+</tr>
+<tr>
+<td><code>index_type</code></td>
+<td>索引类型,可选参数</td>
+<td><code>str</code></td>
+<td>
+<ul>
+  <li><code>"HNSW32"</code>:检索速度较快且精度较高,但不支持 <code>remove_index()</code> 操作</li>
+  <li><code>"IVF"</code>:检索速度较快但精度相对较低,支持 <code>append_index()</code> 和 <code>remove_index()</code> 操作</li>
+  <li><code>"Flat"</code>:检索速度较低精度较高,支持 <code>append_index()</code> 和 <code>remove_index()</code> 操作</li>
+</ul>
+</td>
+<td><code>"HNSW32"</code></td>
+</tr>
+<tr>
 <td><code>remove_ids</code></td>
-<td>待删除的索引序号,支持:1. <code>str</code>类型表示的txt文件的路径,内容为待删除的索引id,每行一个“id”;2. <code>[int, int, ..]</code>类型表示的待删除的索引序号。仅在 <code>remove_index</code> 中有效。</td>
+<td>待删除的索引序号,</td>
 <td><code>str</code>|<code>list</code></td>
+<td>
+<ul>
+<li><b>str</b>:表示的txt文件的路径,内容为待删除的索引id,每行一个“id”;</li>
+<li><b>List[int]</b>:表示的待删除的索引序号。仅在 <code>remove_index</code> 中有效。</li></ul>
+</td>
 <td>无</td>
 </tr>
 <tr>
 <td><code>index</code></td>
-<td>索引库,支持:1. 索引库文件(<code>vector.index</code>和<code>index_info.yaml</code>)所在目录的路径;2. <code>IndexData</code>类型的索引库对象,仅在 <code>append_index</code> 和 <code>remove_index</code> 中有效,表示待修改的索引库。</td>
-<td><code>str</code>|<code>IndexData</code></td>
+<td>产线推理预测所用的特征库</td>
+<td><code>str|paddlex.inference.components.retrieval.faiss.IndexData</code></td>
+<td>
+<ul>
+    <li><b>str</b>类型表示的目录(该目录下需要包含特征库文件,包括<code>vector.index</code>和<code>index_info.yaml</code>)</li>
+    <li><code>build_index</code>方法创建的<b>IndexData</b>对象</li>
+</ul>
+</td>
 <td>无</td>
 </tr>
-<tr>
-<td><code>index_type</code></td>
-<td>支持 <code>HNSW32</code>、<code>IVF</code>、<code>Flat</code>。其中,<code>HNSW32</code> 检索速度较快且精度较高,但不支持 <code>remove_index()</code> 操作;<code>IVF</code> 检索速度较快但精度相对较低,支持 <code>append_index()</code> 和 <code>remove_index()</code> 操作;<code>Flat</code> 检索速度较低精度较高,支持 <code>append_index()</code> 和 <code>remove_index()</code> 操作。</td>
-<td><code>str</code></td>
-<td><code>HNSW32</code></td>
-</tr>
-<tr>
-<td><code>metric_type</code></td>
-<td>支持:<code>IP</code>,内积(Inner Product);<code>L2</code>,欧几里得距离(Euclidean Distance)。</td>
-<td><code>str</code></td>
-<td><code>IP</code></td>
-</tr>
 </tbody>
 </table>
 
@@ -876,19 +1006,26 @@ pprint.pp(result_infer[&quot;detectedObjects&quot;])
 若您需要使用微调后的模型权重,只需对产线配置文件做修改,将微调后模型权重的本地路径替换至产线配置文件中的对应位置即可:
 
 ```yaml
-Pipeline:
-  device: "gpu:0"
-  det_model: "./PP-ShiTuV2_det_infer/"        #可修改为微调后主体检测模型的本地路径
-  rec_model: "./PP-ShiTuV2_rec_infer/"        #可修改为微调后图像特征模型的本地路径
-  det_batch_size: 1
-  rec_batch_size: 1
-  device: gpu
+
+...
+
+SubModules:
+  Detection:
+    module_name: text_detection
+    model_name: PP-ShiTuV2_det
+    model_dir: null #可修改为微调后主体检测模型的本地路径
+    batch_size: 1
+  Recognition:
+    module_name: text_recognition
+    model_name: PP-ShiTuV2_rec
+    model_dir: null #可修改为微调后图像特征模型的本地路径
+    batch_size: 1
 ```
 随后, 参考[2.2 本地体验](#22-本地体验)中的命令行方式或Python脚本方式,加载修改后的产线配置文件即可。
 
 ##  5. 多硬件支持
 
-PaddleX 支持英伟达 GPU、昆仑芯 XPU、昇腾 NPU和寒武纪 MLU 等多种主流硬件设备,<b>仅需修改 `--device`参数</b>即可完成不同硬件之间的无缝切换。
+PaddleX 支持英伟达 GPU、昆仑芯 XPU、昇腾 NPU 和寒武纪 MLU 等多种主流硬件设备,<b>仅需修改 `--device`参数</b>即可完成不同硬件之间的无缝切换。
 
 例如,使用Python运行通用图像识别产线时,将运行设备从英伟达 GPU 更改为昇腾 NPU,仅需将脚本中的 `device` 修改为 npu 即可:
 

+ 358 - 574
docs/pipeline_usage/tutorials/cv_pipelines/human_keypoint_detection.md

@@ -100,306 +100,407 @@ PaddleX 所提供的预训练的模型产线均可以快速体验效果,你可
 一行命令即可快速体验人体关键点检测产线效果,使用 [测试文件](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/keypoint_detection_001.jpg),并将 `--input` 替换为本地路径,进行预测
 
 ```bash
-paddlex --pipeline object_detection --input keypoint_detection_001.jpg --device gpu:0
+paddlex --pipeline human_keypoint_detection \
+        --input keypoint_detection_001.jpg \
+        --det_threshold 0.5 \
+        --save_path ./output/ \
+        --device gpu:0
 ```
-参数说明:
+相关参数和运行结果说明可以参考[2.2.2 Python脚本方式集成](#222-python脚本方式集成)中的参数说明和结果解释。
 
-```
---pipeline:产线名称,此处为人体关键点检测产线
---input:待处理的输入图片的本地路径或URL
---device 使用的GPU序号(例如gpu:0表示使用第0块GPU,gpu:1,2表示使用第1、2块GPU),也可选择使用CPU(--device cpu)
-```
-
-在执行上述命令时,加载的是默认的人体关键点检测产线配置文件,若您需要自定义配置文件,可执行如下命令获取:
-
-<details><summary> 👉点击展开</summary>
+可视化结果保存至`save_path`,如下所示:
 
-<pre><code class="language-bash">paddlex --get_pipeline_config human_keypoint_detection
-</code></pre>
-<p>执行后,人体关键点检测产线配置文件将被保存在当前路径。若您希望自定义保存位置,可执行如下命令(假设自定义保存位置为<code>./my_path</code>):</p>
-<pre><code class="language-bash">paddlex --get_pipeline_config human_keypoint_detection --save_path ./my_path
-</code></pre></details>
+<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/refs/heads/main/images/pipelines/human_keypoint_detection/01.jpg">
 
 #### 2.2.2 Python脚本方式集成
-几行代码即可完成人体关键点检测产线的快速推理。
+通过上述命令行方式可快速体验查看效果,在项目中往往需要代码集成,您可以通过如下几行代码完成产线的快速推理:
 
 ```python
 from paddlex import create_pipeline
 
 pipeline = create_pipeline(pipeline="human_keypoint_detection")
 
-output = pipeline.predict("keypoint_detection_001.jpg")
+output = pipeline.predict("keypoint_detection_001.jpg", det_threshold=0.5)
 for res in output:
     res.print()
     res.save_to_img("./output/")
+    res.save_to_json("./output/")
 ```
 
 在上述 Python 脚本中,执行了如下几个步骤:
 
-(1)实例化 `create_pipeline` 实例化产线对象:具体参数说明如下:
-
-|参数|参数说明|参数类型|默认值|
-|-|-|-|-|
-|`pipeline`|产线名称或是产线配置文件路径。如为产线名称,则必须为 PaddleX 所支持的产线。|`str`|无|
-|`device`|产线模型推理设备。支持:“gpu”,“cpu”。|`str`|`gpu`|
-|`enable_hpi`|是否启用高性能推理,仅当该产线支持高性能推理时可用。|`bool`|`False`|
-
-(2)调用产线对象的 `predict` 方法进行推理预测:`predict` 方法参数为`x`,用于输入待预测数据,支持多种输入方式,具体示例如下:
-
-| 参数类型      | 参数说明                                                                                                  |
-|---------------|-----------------------------------------------------------------------------------------------------------|
-| Python Var    | 支持直接传入Python变量,如numpy.ndarray表示的图像数据。                                               |
-| str         | 支持传入待预测数据文件路径,如图像文件的本地路径:`/root/data/img.jpg`。                                   |
-| str           | 支持传入待预测数据文件URL,如图像文件的网络URL:[示例](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_object_detection_002.png)。|
-| str           | 支持传入本地目录,该目录下需包含待预测数据文件,如本地路径:`/root/data/`。                               |
-| dict          | 支持传入字典类型,字典的key需与具体任务对应,如图像分类任务对应\"img\",字典的val支持上述类型数据,例如:`{\"img\": \"/root/data1\"}`。|
-| list          | 支持传入列表,列表元素需为上述类型数据,如`[numpy.ndarray, numpy.ndarray],[\"/root/data/img1.jpg\", \"/root/data/img2.jpg\"]`,`[\"/root/data1\", \"/root/data2\"]`,`[{\"img\": \"/root/data1\"}, {\"img\": \"/root/data2/img.jpg\"}]`。|
-
-(3)调用`predict`方法获取预测结果:`predict` 方法为`generator`,因此需要通过调用获得预测结果,`predict`方法以batch为单位对数据进行预测,因此预测结果为list形式表示的一组预测结果。
-
-(4)对预测结果进行处理:每个样本的预测结果均为`dict`类型,且支持打印,或保存为文件,支持保存的类型与具体产线相关,如:
-
-| 方法         | 说明                        | 方法参数                                                                                               |
-|--------------|-----------------------------|--------------------------------------------------------------------------------------------------------|
-| print        | 打印结果到终端              | `- format_json`:bool类型,是否对输出内容进行使用json缩进格式化,默认为True;<br>`- indent`:int类型,json格式化设置,仅当format_json为True时有效,默认为4;<br>`- ensure_ascii`:bool类型,json格式化设置,仅当format_json为True时有效,默认为False; |
-| save_to_json | 将结果保存为json格式的文件   | `- save_path`:str类型,保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致;<br>`- indent`:int类型,json格式化设置,默认为4;<br>`- ensure_ascii`:bool类型,json格式化设置,默认为False; |
-| save_to_img  | 将结果保存为图像格式的文件  | `- save_path`:str类型,保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致; |
-
-若您获取了配置文件,即可对目标检测产线各项配置进行自定义,只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为产线配置文件路径即可。
-
-例如,若您的配置文件保存在 `./my_path/human_keypoint_detection.yaml` ,则只需执行:
-
-```python
-from paddlex import create_pipeline
-pipeline = create_pipeline(pipeline="./my_path/human_keypoint_detection.yaml")
-output = pipeline.predict("keypoint_detection_001.jpg")
-for res in output:
-    res.print() ## 打印预测的结构化输出
-    res.save_to_img("./output/") ## 保存结果可视化图像
-    res.save_to_json("./output/") ## 保存预测的结构化输出
-```
-
-## 3. 开发集成/部署
-
-如果人体关键点检测产线可以达到您对产线推理速度和精度的要求,您可以直接进行开发集成/部署。
-
-若您需要将通用图像识别产线直接应用在您的Python项目中,可以参考 [2.2.2 Python脚本方式](#222-python脚本方式集成)中的示例代码。
-
-此外,PaddleX 也提供了其他三种部署方式,详细说明如下:
-
-🚀 <b>高性能推理</b>:在实际生产环境中,许多应用对部署策略的性能指标(尤其是响应速度)有着较严苛的标准,以确保系统的高效运行与用户体验的流畅性。为此,PaddleX 提供高性能推理插件,旨在对模型推理及前后处理进行深度性能优化,实现端到端流程的显著提速,详细的高性能推理流程请参考[PaddleX高性能推理指南](../../../pipeline_deploy/high_performance_inference.md)。
-
-☁️ <b>服务化部署</b>:服务化部署是实际生产环境中常见的一种部署形式。通过将推理功能封装为服务,客户端可以通过网络请求来访问这些服务,以获取推理结果。PaddleX 支持多种产线服务化部署方案,详细的产线服务化部署流程请参考[PaddleX服务化部署指南](../../../pipeline_deploy/serving.md)。
-
-以下是基础服务化部署的API参考与多语言服务调用示例:
-
-<details><summary>API参考</summary>
+(1)调用 `create_pipeline` 实例化产线对象:具体参数说明如下:
 
-<p>对于服务提供的主要操作:</p>
-<ul>
-<li>响应体以及POST请求的请求体均为JSON数据(JSON对象)。</li>
-<li>当请求处理成功时,响应状态码为<code>200</code>,响应体的属性如下:</li>
-</ul>
 <table>
 <thead>
 <tr>
-<th>名称</th>
-<th>类型</th>
-<th>含义</th>
+<th>参数</th>
+<th>参数说明</th>
+<th>参数类型</th>
+<th>默认值</th>
 </tr>
 </thead>
 <tbody>
 <tr>
-<td><code>errorCode</code></td>
-<td><code>integer</code></td>
-<td>错误码。固定为<code>0</code>。</td>
+<td><code>pipeline</code></td>
+<td>产线名称或是产线配置文件路径。如为产线名称,则必须为 PaddleX 所支持的产线。</td>
+<td><code>str</code></td>
+<td><code>None</code></td>
 </tr>
 <tr>
-<td><code>errorMsg</code></td>
-<td><code>string</code></td>
-<td>错误说明。固定为<code>"Success"</code>。</td>
+<td><code>device</code></td>
+<td>产线推理设备。支持指定GPU具体卡号,如“gpu:0”,其他硬件具体卡号,如“npu:0”,CPU如“cpu”。</td>
+<td><code>str</code></td>
+<td><code>gpu:0</code></td>
+</tr>
+<tr>
+<td><code>use_hpip</code></td>
+<td>是否启用高性能推理,仅当该产线支持高性能推理时可用。</td>
+<td><code>bool</code></td>
+<td><code>False</code></td>
 </tr>
 </tbody>
 </table>
-<p>响应体还可能有<code>result</code>属性,类型为<code>object</code>,其中存储操作结果信息。</p>
-<ul>
-<li>当请求处理未成功时,响应体的属性如下:</li>
-</ul>
+
+(2)调用人体关键点检测产线对象的 `predict()` 方法进行推理预测。该方法将返回一个 `generator`。以下是 `predict()` 方法的参数及其说明:
+
 <table>
 <thead>
 <tr>
-<th>名称</th>
-<th>类型</th>
-<th>含义</th>
+<th>参数</th>
+<th>参数说明</th>
+<th>参数类型</th>
+<th>可选项</th>
+<th>默认值</th>
 </tr>
 </thead>
-<tbody>
-<tr>
-<td><code>errorCode</code></td>
-<td><code>integer</code></td>
-<td>错误码。与响应状态码相同。</td>
-</tr>
 <tr>
-<td><code>errorMsg</code></td>
-<td><code>string</code></td>
-<td>错误说明。</td>
-</tr>
-</tbody>
-</table>
-<p>服务提供的操作如下:</p>
+<td><code>input</code></td>
+<td>待预测数据,支持多种输入类型,必需参数</td>
+<td><code>Python Var|str|list</code></td>
+<td>
 <ul>
-<li><b><code>infer</code></b></li>
+  <li><b>Python Var</b>:如 <code>numpy.ndarray</code> 表示的图像数据</li>
+  <li><b>str</b>:如图像文件的本地路径:<code>/root/data/img.jpg</code>;<b>如URL链接</b>,如图像文件的网络URL:<a href = "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png">示例</a>;<b>如本地目录</b>,该目录下需包含待预测图像,如本地路径:<code>/root/data/</code></li>
+  <li><b>List</b>:列表元素需为上述类型数据,如<code>[numpy.ndarray, numpy.ndarray]</code>,<code>[\"/root/data/img1.jpg\", \"/root/data/img2.jpg\"]</code>,<code>[\"/root/data1\", \"/root/data2\"]</code></li>
 </ul>
-<p>获取图像OCR结果。</p>
-<p><code>POST /ocr</code></p>
+</td>
+<td>无</td>
+</tr>
+<tr>
+<td><code>threshold</code></td>
+<td>人体检测模型阈值</td>
+<td><code>float|None</code></td>
+<td>
 <ul>
-<li>请求体的属性如下:</li>
+  <li><b>float</b>:如<code>0.5</code>, 表示过滤掉所有阈值小于<code>0.5</code>的目标框;</li>
+  <li><b>None</b>:如果设置为<code>None</code>, 将默认使用产线初始化的该参数值,初始化为<code>0.5</code>;</li>
 </ul>
+</td>
+<td><code>None</code></td>
+</tr>
+</table>
+
+(3)对预测结果进行处理,每个样本的预测结果均为`dict`类型,且支持打印、保存为图片、保存为`json`文件的操作:
+
 <table>
 <thead>
 <tr>
-<th>名称</th>
-<th>类型</th>
-<th>含义</th>
-<th>是否必填</th>
+<th>方法</th>
+<th>方法说明</th>
+<th>参数</th>
+<th>参数类型</th>
+<th>参数说明</th>
+<th>默认值</th>
 </tr>
 </thead>
-<tbody>
 <tr>
-<td><code>image</code></td>
-<td><code>string</code></td>
-<td>服务器可访问的图像文件的URL或图像文件内容的Base64编码结果。</td>
-<td>是</td>
+<td rowspan = "3"><code>print()</code></td>
+<td rowspan = "3">打印结果到终端</td>
+<td><code>format_json</code></td>
+<td><code>bool</code></td>
+<td>是否对输出内容进行使用 <code>JSON</code> 缩进格式化</td>
+<td><code>True</code></td>
 </tr>
 <tr>
-<td><code>inferenceParams</code></td>
-<td><code>object</code></td>
-<td>推理参数。</td>
-<td></td>
+<td><code>indent</code></td>
+<td><code>int</code></td>
+<td>指定缩进级别,以美化输出的 <code>JSON</code> 数据,使其更具可读性,仅当 <code>format_json</code> 为 <code>True</code> 时有效</td>
+<td>4</td>
 </tr>
-</tbody>
-</table>
-<p><code>inferenceParams</code>的属性如下:</p>
-<table>
-<thead>
 <tr>
-<th>名称</th>
-<th>类型</th>
-<th>含义</th>
-<th>是否必填</th>
+<td><code>ensure_ascii</code></td>
+<td><code>bool</code></td>
+<td>控制是否将非 <code>ASCII</code> 字符转义为 <code>Unicode</code>。设置为 <code>True</code> 时,所有非 <code>ASCII</code> 字符将被转义;<code>False</code> 则保留原始字符,仅当<code>format_json</code>为<code>True</code>时有效</td>
+<td><code>False</code></td>
 </tr>
-</thead>
-<tbody>
 <tr>
-<td><code>maxLongSide</code></td>
-<td><code>integer</code></td>
-<td>推理时,若文本检测模型的输入图像较长边的长度大于<code>maxLongSide</code>,则将对图像进行缩放,使其较长边的长度等于<code>maxLongSide</code>。</td>
-<td>否</td>
+<td rowspan = "3"><code>save_to_json()</code></td>
+<td rowspan = "3">将结果保存为json格式的文件</td>
+<td><code>save_path</code></td>
+<td><code>str</code></td>
+<td>保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致</td>
+<td>无</td>
 </tr>
-</tbody>
-</table>
-<ul>
-<li>请求处理成功时,响应体的<code>result</code>具有如下属性:</li>
-</ul>
-<table>
-<thead>
 <tr>
-<th>名称</th>
-<th>类型</th>
-<th>含义</th>
+<td><code>indent</code></td>
+<td><code>int</code></td>
+<td>指定缩进级别,以美化输出的 <code>JSON</code> 数据,使其更具可读性,仅当 <code>format_json</code> 为 <code>True</code> 时有效</td>
+<td>4</td>
 </tr>
-</thead>
-<tbody>
 <tr>
-<td><code>texts</code></td>
-<td><code>array</code></td>
-<td>文本位置、内容和得分。</td>
+<td><code>ensure_ascii</code></td>
+<td><code>bool</code></td>
+<td>控制是否将非 <code>ASCII</code> 字符转义为 <code>Unicode</code>。设置为 <code>True</code> 时,所有非 <code>ASCII</code> 字符将被转义;<code>False</code> 则保留原始字符,仅当<code>format_json</code>为<code>True</code>时有效</td>
+<td><code>False</code></td>
 </tr>
 <tr>
-<td><code>image</code></td>
-<td><code>string</code></td>
-<td>OCR结果图,其中标注检测到的文本位置。图像为JPEG格式,使用Base64编码。</td>
+<td><code>save_to_img()</code></td>
+<td>将结果保存为图像格式的文件</td>
+<td><code>save_path</code></td>
+<td><code>str</code></td>
+<td>保存的文件路径,支持目录或文件路径</td>
+<td>无</td>
 </tr>
-</tbody>
 </table>
-<p><code>texts</code>中的每个元素为一个<code>object</code>,具有如下属性:</p>
+
+<ul><li><details><summary>👉 调用 <code>print()</code> 方法会将如下结果打印到终端(点击展开):</summary>
+
+```bash
+{'res': {'input_path': 'keypoint_detection_001.jpg', 'boxes': [{'coordinate': [325.65088, 74.46718, 391.5512, 209.46529], 'det_score': 0.9316536784172058, 'keypoints': array([[3.52227936e+02, 8.88497543e+01, 5.41676700e-01],
+       [3.51974579e+02, 8.66366196e+01, 6.21515572e-01],
+       [3.52865662e+02, 8.64902344e+01, 5.60755610e-01],
+       [3.50862457e+02, 8.75393066e+01, 5.66961825e-01],
+       [3.57415802e+02, 8.63235092e+01, 5.54250121e-01],
+       [3.39434937e+02, 9.99389191e+01, 6.28665030e-01],
+       [3.69297821e+02, 1.01169853e+02, 6.00828469e-01],
+       [3.36788544e+02, 1.18020966e+02, 5.31029820e-01],
+       [3.71721039e+02, 1.22033646e+02, 6.07613802e-01],
+       [3.66371948e+02, 1.40476746e+02, 1.52681962e-01],
+       [3.67885651e+02, 1.39969559e+02, 3.90044987e-01],
+       [3.47553253e+02, 1.42274353e+02, 5.21435857e-01],
+       [3.60833710e+02, 1.42503479e+02, 4.64817137e-01],
+       [3.40133362e+02, 1.67570465e+02, 5.92474759e-01],
+       [3.74433594e+02, 1.69982712e+02, 5.48423827e-01],
+       [3.37616333e+02, 1.92737564e+02, 5.85887253e-01],
+       [3.82684723e+02, 1.96479385e+02, 6.19615853e-01]], dtype=float32), 'kpt_score': 0.53462815}, {'coordinate': [271.96713, 69.02892, 336.77832, 217.54662], 'det_score': 0.9304604530334473, 'keypoints': array([[2.96400787e+02, 8.58611679e+01, 7.14319646e-01],
+       [2.97301758e+02, 8.28755493e+01, 7.04051554e-01],
+       [2.94497406e+02, 8.29398193e+01, 6.89844370e-01],
+       [3.00162109e+02, 8.35247955e+01, 5.55446565e-01],
+       [2.93188751e+02, 8.33744202e+01, 6.51386738e-01],
+       [3.12854675e+02, 9.81457520e+01, 7.32430100e-01],
+       [2.86463226e+02, 1.01262375e+02, 6.10454917e-01],
+       [3.19350311e+02, 1.18383713e+02, 5.93547344e-01],
+       [2.82401520e+02, 1.21164886e+02, 5.71586847e-01],
+       [3.23966248e+02, 1.39364532e+02, 5.18607676e-01],
+       [2.82263916e+02, 1.44509521e+02, 2.59432912e-01],
+       [3.09791840e+02, 1.43603912e+02, 6.89817309e-01],
+       [2.94868561e+02, 1.44677597e+02, 5.97069323e-01],
+       [3.14365845e+02, 1.74088943e+02, 6.36058152e-01],
+       [2.92653442e+02, 1.75070770e+02, 5.97140312e-01],
+       [3.19849792e+02, 2.02162598e+02, 6.80035114e-01],
+       [2.94255920e+02, 2.03049500e+02, 6.08293772e-01]], dtype=float32), 'kpt_score': 0.6123249}, {'coordinate': [293.55933, 188.65804, 419.47382, 305.4712], 'det_score': 0.9179267883300781, 'keypoints': array([[3.33173096e+02, 2.05474487e+02, 5.18341482e-01],
+       [3.36098663e+02, 2.03492996e+02, 5.60671568e-01],
+       [3.37248505e+02, 2.03364868e+02, 5.00729203e-01],
+       [3.40604095e+02, 2.02393539e+02, 4.98033434e-01],
+       [3.43625671e+02, 2.01539536e+02, 6.13991261e-01],
+       [3.24516022e+02, 2.18521667e+02, 3.14208776e-01],
+       [3.52951965e+02, 2.12051971e+02, 4.42923039e-01],
+       [3.14448853e+02, 2.22776672e+02, 2.55664617e-01],
+       [3.65774384e+02, 2.25498718e+02, 8.26140717e-02],
+       [3.06869843e+02, 2.34243729e+02, 1.35185301e-01],
+       [3.08855865e+02, 2.36824249e+02, 1.00039296e-01],
+       [3.82195679e+02, 2.42062302e+02, 5.45506418e-01],
+       [3.88757233e+02, 2.42933960e+02, 5.79574823e-01],
+       [3.50280792e+02, 2.56009766e+02, 7.92343557e-01],
+       [3.70955750e+02, 2.74127930e+02, 5.06902397e-01],
+       [3.61553833e+02, 2.83896454e+02, 6.03924632e-01],
+       [3.94064087e+02, 2.88825836e+02, 3.72752368e-01]], dtype=float32), 'kpt_score': 0.43667096}, {'coordinate': [238.98825, 182.67476, 372.81628, 307.61395], 'det_score': 0.914400041103363, 'keypoints': array([[281.63354   , 197.61014   ,   0.76263565],
+       [283.38297   , 195.05458   ,   0.8535259 ],
+       [277.73865   , 192.96712   ,   0.7486459 ],
+       [282.2258    , 197.37396   ,   0.5293759 ],
+       [267.41278   , 193.56656   ,   0.6177453 ],
+       [269.7986    , 215.17424   ,   0.6587688 ],
+       [259.27332   , 214.76183   ,   0.7745857 ],
+       [277.53683   , 237.42062   ,   0.48790172],
+       [260.1237    , 240.18477   ,   0.44012186],
+       [293.51572   , 250.89894   ,   0.49827316],
+       [290.2274    , 252.19504   ,   0.58322966],
+       [279.096     , 260.06042   ,   0.6834831 ],
+       [269.9528    , 265.9034    ,   0.74632865],
+       [313.1393    , 260.79523   ,   0.6337413 ],
+       [310.01425   , 262.5001    ,   0.7376388 ],
+       [348.17996   , 283.56802   ,   0.6096815 ],
+       [334.12622   , 292.06284   ,   0.805234  ]], dtype=float32), 'kpt_score': 0.6571127}, {'coordinate': [66.23172, 93.531204, 124.48463, 217.99655], 'det_score': 0.9086756110191345, 'keypoints': array([[ 91.31993   , 108.413284  ,   0.615049  ],
+       [ 92.08924   , 106.03603   ,   0.63400346],
+       [ 88.434235  , 105.775925  ,   0.6342117 ],
+       [ 94.41964   , 106.27531   ,   0.5885308 ],
+       [ 84.07658   , 105.80367   ,   0.6773151 ],
+       [100.38561   , 118.80038   ,   0.74734527],
+       [ 79.46563   , 119.58027   ,   0.7821885 ],
+       [102.27228   , 136.0127    ,   0.5907435 ],
+       [ 73.76375   , 135.51848   ,   0.7132327 ],
+       [101.763245  , 148.3819    ,   0.35871926],
+       [ 72.33199   , 148.83861   ,   0.5405212 ],
+       [ 99.1199    , 151.6756    ,   0.83278877],
+       [ 86.4599    , 152.03287   ,   0.78065455],
+       [106.40269   , 176.46979   ,   0.75466657],
+       [ 84.909454  , 178.44617   ,   0.76010597],
+       [110.97942   , 201.19633   ,   0.7917331 ],
+       [ 79.87372   , 202.87093   ,   0.79150075]], dtype=float32), 'kpt_score': 0.68195945}, {'coordinate': [160.1294, 78.35935, 212.01868, 153.2241], 'det_score': 0.8295672535896301, 'keypoints': array([[1.8115924e+02, 1.0371443e+02, 2.5303254e-01],
+       [1.8318883e+02, 9.6959526e+01, 1.5748371e-01],
+       [1.8303551e+02, 9.8071350e+01, 2.1673845e-01],
+       [1.8769695e+02, 9.1113632e+01, 1.4220884e-01],
+       [1.8665227e+02, 9.1424126e+01, 1.2998220e-01],
+       [1.9881558e+02, 9.9527107e+01, 2.6830634e-01],
+       [1.8619264e+02, 9.9051491e+01, 1.8842754e-01],
+       [1.9972902e+02, 1.2386106e+02, 4.7812667e-01],
+       [1.8038458e+02, 1.2146417e+02, 1.7550260e-01],
+       [1.8155409e+02, 1.3735040e+02, 3.2514629e-01],
+       [1.7971712e+02, 1.3371999e+02, 1.1313542e-01],
+       [1.9606516e+02, 1.4140919e+02, 2.3604973e-01],
+       [1.8650092e+02, 1.4260675e+02, 1.3515554e-01],
+       [1.9617020e+02, 1.2273723e+02, 9.6943676e-02],
+       [1.6671684e+02, 1.2564886e+02, 1.2711491e-01],
+       [1.8317670e+02, 1.3923177e+02, 1.0834377e-01],
+       [1.7997801e+02, 1.3850316e+02, 9.3360245e-02]], dtype=float32), 'kpt_score': 0.19088578}, {'coordinate': [52.482475, 59.36664, 96.47121, 135.45993], 'det_score': 0.7726763486862183, 'keypoints': array([[7.38075943e+01, 7.33277664e+01, 1.63257480e-01],
+       [7.37732239e+01, 7.15934525e+01, 1.55248597e-01],
+       [7.20166702e+01, 7.13588028e+01, 1.96659654e-01],
+       [6.95982971e+01, 7.10932083e+01, 1.26999229e-01],
+       [6.98693237e+01, 7.16391983e+01, 1.35578454e-01],
+       [8.22228088e+01, 7.77278976e+01, 2.35379949e-01],
+       [6.47475586e+01, 7.88423233e+01, 2.10787609e-01],
+       [8.33889618e+01, 9.05893707e+01, 2.98420697e-01],
+       [8.30510330e+01, 9.10888824e+01, 1.13309503e-01],
+       [8.09216843e+01, 9.85093231e+01, 1.84670463e-01],
+       [7.77405396e+01, 1.01128220e+02, 1.49517819e-01],
+       [7.58817215e+01, 1.02311646e+02, 7.63842911e-02],
+       [6.97640839e+01, 1.01978600e+02, 9.00617689e-02],
+       [8.89746017e+01, 9.87928925e+01, 2.00097740e-01],
+       [6.45541153e+01, 1.04130150e+02, 1.00787796e-01],
+       [8.81069489e+01, 1.19858818e+02, 1.84717909e-01],
+       [7.08108673e+01, 1.38108154e+02, 9.07213315e-02]], dtype=float32), 'kpt_score': 0.15956473}, {'coordinate': [7.081953, 80.3705, 46.81927, 161.72012], 'det_score': 0.6587498784065247, 'keypoints': array([[2.68747215e+01, 9.24635468e+01, 3.17601502e-01],
+       [2.71188889e+01, 9.08834305e+01, 2.46545449e-01],
+       [2.69905357e+01, 9.03851013e+01, 3.27626228e-01],
+       [2.34424419e+01, 8.87997513e+01, 2.75899678e-01],
+       [3.25261230e+01, 8.93143845e+01, 3.42958122e-01],
+       [1.98818531e+01, 9.67693405e+01, 2.83849210e-01],
+       [3.82729301e+01, 9.91002884e+01, 3.19851965e-01],
+       [1.63669338e+01, 1.10157967e+02, 1.96907550e-01],
+       [4.11151352e+01, 1.10147133e+02, 2.70823181e-01],
+       [1.86983719e+01, 1.17376358e+02, 1.15746662e-01],
+       [1.98090267e+01, 1.16526924e+02, 1.02475688e-01],
+       [2.51145611e+01, 1.23519379e+02, 3.24807376e-01],
+       [3.34709854e+01, 1.24678688e+02, 2.65269905e-01],
+       [2.82129307e+01, 1.42196121e+02, 2.98054874e-01],
+       [2.94088726e+01, 1.42497360e+02, 3.57838601e-01],
+       [2.95637341e+01, 1.57201065e+02, 2.14882523e-01],
+       [3.03766575e+01, 1.57535706e+02, 2.10423440e-01]], dtype=float32), 'kpt_score': 0.26303306}, {'coordinate': [126.131096, 30.263107, 168.5759, 134.09885], 'det_score': 0.6441988348960876, 'keypoints': array([[148.10135   ,  40.584896  ,   0.44685563],
+       [150.00848   ,  38.423157  ,   0.5721373 ],
+       [146.84933   ,  38.88104   ,   0.5450204 ],
+       [153.57166   ,  38.53051   ,   0.58872294],
+       [144.609     ,  38.854267  ,   0.54383296],
+       [158.78825   ,  51.609245  ,   0.6847385 ],
+       [141.20293   ,  49.92705   ,   0.52605945],
+       [157.85371   ,  70.32525   ,   0.7879656 ],
+       [136.42497   ,  68.15052   ,   0.4752547 ],
+       [144.46915   ,  79.161385  ,   0.5807479 ],
+       [135.84734   ,  75.86984   ,   0.32583416],
+       [155.16513   ,  78.74157   ,   0.56849873],
+       [141.66093   ,  77.88423   ,   0.45576522],
+       [152.68689   , 100.64953   ,   0.5331878 ],
+       [130.97485   ,  87.03784   ,   0.73304355],
+       [153.57033   , 123.742294  ,   0.39946193],
+       [132.91501   , 114.52923   ,   0.36085486]], dtype=float32), 'kpt_score': 0.5369401}, {'coordinate': [112.50212, 64.127, 150.35353, 125.85529], 'det_score': 0.5013833045959473, 'keypoints': array([[1.34417511e+02, 7.67317352e+01, 8.11196864e-02],
+       [1.33561203e+02, 7.61824722e+01, 5.88811524e-02],
+       [1.33302322e+02, 7.54709702e+01, 3.77583615e-02],
+       [1.33238602e+02, 7.65276260e+01, 8.76586884e-02],
+       [1.27832169e+02, 7.29993439e+01, 5.68802767e-02],
+       [1.32234711e+02, 8.55900650e+01, 6.25893995e-02],
+       [1.29263702e+02, 8.66081772e+01, 7.35298842e-02],
+       [1.17821297e+02, 6.38808823e+01, 1.47604376e-01],
+       [1.17373665e+02, 6.40265808e+01, 1.84295043e-01],
+       [1.39441742e+02, 9.73589020e+01, 6.45915419e-02],
+       [1.24748589e+02, 1.04544739e+02, 5.86665794e-02],
+       [1.35098206e+02, 7.81749954e+01, 8.30232948e-02],
+       [1.34638489e+02, 7.91068802e+01, 8.16871747e-02],
+       [1.36119888e+02, 8.93165436e+01, 1.34096310e-01],
+       [1.30067749e+02, 9.34937820e+01, 8.98712277e-02],
+       [1.36004654e+02, 1.16780487e+02, 1.60800099e-01],
+       [1.28087891e+02, 1.15956802e+02, 1.99588016e-01]], dtype=float32), 'kpt_score': 0.097802415}]}}
+```
+</details></li></ul>
+
+- 输出结果参数含义如下:
+    - `input_path`:表示输入图像的路径
+    - `boxes`:检测到人体信息,一个字典列表,每个字典包含以下信息:
+        - `coordinate`:人体目标框坐标,格式为[xmin, ymin, xmax, ymax]
+        - `det_score`:人体目标框置信度
+        - `keypoints`:关键点坐标信息,一个numpy数组,形状为[num_keypoints, 3],其中每个关键点由[x, y, score]组成,score为该关键点的置信度
+        - `kpt_score`:关键点整体的置信度,即关键点的平均置信度
+
+- 调用`save_to_json()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}.json`,如果指定为文件,则直接保存到该文件中。由于json文件不支持保存numpy数组,因此会将其中的`numpy.array`类型转换为列表形式。
+- 调用`save_to_img()` 方法会将可视化结果保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}_res.{your_img_extension}`,如果指定为文件,则直接保存到该文件中。(产线通常包含较多结果图片,不建议直接指定为具体的文件路径,否则多张图会被覆盖,仅保留最后一张图)
+
+* 此外,也支持通过属性获取带结果的可视化图像和预测结果,具体如下:
+
 <table>
 <thead>
 <tr>
-<th>名称</th>
-<th>类型</th>
-<th>含义</th>
+<th>属性</th>
+<th>属性说明</th>
 </tr>
 </thead>
-<tbody>
-<tr>
-<td><code>poly</code></td>
-<td><code>array</code></td>
-<td>文本位置。数组中元素依次为包围文本的多边形的顶点坐标。</td>
-</tr>
 <tr>
-<td><code>text</code></td>
-<td><code>string</code></td>
-<td>文本内容。</td>
+<td rowspan = "1"><code>json</code></td>
+<td rowspan = "1">获取预测的 <code>json</code> 格式的结果</td>
 </tr>
 <tr>
-<td><code>score</code></td>
-<td><code>number</code></td>
-<td>文本识别得分。</td>
+<td rowspan = "2"><code>img</code></td>
+<td rowspan = "2">获取格式为 <code>dict</code> 的可视化图像</td>
 </tr>
-</tbody>
 </table>
-<p><code>result</code>示例如下:</p>
-<pre><code class="language-json">{
-&quot;texts&quot;: [
-{
-&quot;poly&quot;: [
-[
-444,
-244
-],
-[
-705,
-244
-],
-[
-705,
-311
-],
-[
-444,
-311
-]
-],
-&quot;text&quot;: &quot;北京南站&quot;,
-&quot;score&quot;: 0.9
-},
-{
-&quot;poly&quot;: [
-[
-992,
-248
-],
-[
-1263,
-251
-],
-[
-1263,
-318
-],
-[
-992,
-315
-]
-],
-&quot;text&quot;: &quot;天津站&quot;,
-&quot;score&quot;: 0.5
-}
-],
-&quot;image&quot;: &quot;xxxxxx&quot;
-}
-</code></pre></details>
+
+- `json` 属性获取的预测结果为dict类型的数据,相关内容与调用 `save_to_json()` 方法保存的内容一致。
+- `img` 属性返回的预测结果是一个字典类型的数据。键为 `res` ,对应的值是一个用于可视化人体关键点检测结果的 `Image.Image` 对象。
+
+上述Python脚本集成方式默认使用 PaddleX 官方配置文件中的参数设置,若您需要自定义配置文件,可先执行如下命令获取官方配置文件,并保存在 `my_path` 中:
+
+```bash
+paddlex --get_pipeline_config human_keypoint_detection --save_path ./my_path
+```
+
+若您获取了配置文件,即可对人体关键点检测产线各项配置进行自定义。只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为自定义产线配置文件路径即可。
+
+例如,若您的自定义配置文件保存在 `./my_path/human_keypoint_detection.yaml` ,则只需执行:
+
+```python
+from paddlex import create_pipeline
+pipeline = create_pipeline(pipeline="./my_path/human_keypoint_detection.yaml")
+output = pipeline.predict("keypoint_detection_001.jpg")
+for res in output:
+    res.print()
+    res.save_to_img("./output/")
+    res.save_to_json("./output/")
+```
+
+## 3. 开发集成/部署
+
+如果人体关键点检测产线可以达到您对产线推理速度和精度的要求,您可以直接进行开发集成/部署。
+
+若您需要将通用图像识别产线直接应用在您的Python项目中,可以参考 [2.2.2 Python脚本方式](#222-python脚本方式集成)中的示例代码。
+
+此外,PaddleX 也提供了其他三种部署方式,详细说明如下:
+
+🚀 <b>高性能推理</b>:在实际生产环境中,许多应用对部署策略的性能指标(尤其是响应速度)有着较严苛的标准,以确保系统的高效运行与用户体验的流畅性。为此,PaddleX 提供高性能推理插件,旨在对模型推理及前后处理进行深度性能优化,实现端到端流程的显著提速,详细的高性能推理流程请参考[PaddleX高性能推理指南](../../../pipeline_deploy/high_performance_inference.md)。
+
+☁️ <b>服务化部署</b>:服务化部署是实际生产环境中常见的一种部署形式。通过将推理功能封装为服务,客户端可以通过网络请求来访问这些服务,以获取推理结果。PaddleX 支持多种产线服务化部署方案,详细的产线服务化部署流程请参考[PaddleX服务化部署指南](../../../pipeline_deploy/serving.md)。
+
+以下是基础服务化部署的API参考与多语言服务调用示例:
+
+<details><summary>API参考</summary>
+
+</details>
 
 <details><summary>多语言调用服务示例</summary>
 
@@ -432,337 +533,10 @@ with open(output_image_path, &quot;wb&quot;) as file:
 print(f&quot;Output image saved at {output_image_path}&quot;)
 print(&quot;\nDetected texts:&quot;)
 print(result[&quot;texts&quot;])
-</code></pre></details>
-
-<details><summary>C++</summary>
-
-<pre><code class="language-cpp">#include &lt;iostream&gt;
-#include &quot;cpp-httplib/httplib.h&quot; // https://github.com/Huiyicc/cpp-httplib
-#include &quot;nlohmann/json.hpp&quot; // https://github.com/nlohmann/json
-#include &quot;base64.hpp&quot; // https://github.com/tobiaslocker/base64
-
-int main() {
-    httplib::Client client(&quot;localhost:8080&quot;);
-    const std::string imagePath = &quot;./demo.jpg&quot;;
-    const std::string outputImagePath = &quot;./out.jpg&quot;;
-
-    httplib::Headers headers = {
-        {&quot;Content-Type&quot;, &quot;application/json&quot;}
-    };
-
-    // 对本地图像进行Base64编码
-    std::ifstream file(imagePath, std::ios::binary | std::ios::ate);
-    std::streamsize size = file.tellg();
-    file.seekg(0, std::ios::beg);
-
-    std::vector&lt;char&gt; buffer(size);
-    if (!file.read(buffer.data(), size)) {
-        std::cerr &lt;&lt; &quot;Error reading file.&quot; &lt;&lt; std::endl;
-        return 1;
-    }
-    std::string bufferStr(reinterpret_cast&lt;const char*&gt;(buffer.data()), buffer.size());
-    std::string encodedImage = base64::to_base64(bufferStr);
-
-    nlohmann::json jsonObj;
-    jsonObj[&quot;image&quot;] = encodedImage;
-    std::string body = jsonObj.dump();
-
-    // 调用API
-    auto response = client.Post(&quot;/ocr&quot;, headers, body, &quot;application/json&quot;);
-    // 处理接口返回数据
-    if (response &amp;&amp; response-&gt;status == 200) {
-        nlohmann::json jsonResponse = nlohmann::json::parse(response-&gt;body);
-        auto result = jsonResponse[&quot;result&quot;];
-
-        encodedImage = result[&quot;image&quot;];
-        std::string decodedString = base64::from_base64(encodedImage);
-        std::vector&lt;unsigned char&gt; decodedImage(decodedString.begin(), decodedString.end());
-        std::ofstream outputImage(outPutImagePath, std::ios::binary | std::ios::out);
-        if (outputImage.is_open()) {
-            outputImage.write(reinterpret_cast&lt;char*&gt;(decodedImage.data()), decodedImage.size());
-            outputImage.close();
-            std::cout &lt;&lt; &quot;Output image saved at &quot; &lt;&lt; outPutImagePath &lt;&lt; std::endl;
-        } else {
-            std::cerr &lt;&lt; &quot;Unable to open file for writing: &quot; &lt;&lt; outPutImagePath &lt;&lt; std::endl;
-        }
-
-        auto texts = result[&quot;texts&quot;];
-        std::cout &lt;&lt; &quot;\nDetected texts:&quot; &lt;&lt; std::endl;
-        for (const auto&amp; text : texts) {
-            std::cout &lt;&lt; text &lt;&lt; std::endl;
-        }
-    } else {
-        std::cout &lt;&lt; &quot;Failed to send HTTP request.&quot; &lt;&lt; std::endl;
-        return 1;
-    }
-
-    return 0;
-}
-</code></pre></details>
-
-<details><summary>Java</summary>
-
-<pre><code class="language-java">import okhttp3.*;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Base64;
-
-public class Main {
-    public static void main(String[] args) throws IOException {
-        String API_URL = &quot;http://localhost:8080/ocr&quot;; // 服务URL
-        String imagePath = &quot;./demo.jpg&quot;; // 本地图像
-        String outputImagePath = &quot;./out.jpg&quot;; // 输出图像
-
-        // 对本地图像进行Base64编码
-        File file = new File(imagePath);
-        byte[] fileContent = java.nio.file.Files.readAllBytes(file.toPath());
-        String imageData = Base64.getEncoder().encodeToString(fileContent);
-
-        ObjectMapper objectMapper = new ObjectMapper();
-        ObjectNode params = objectMapper.createObjectNode();
-        params.put(&quot;image&quot;, imageData); // Base64编码的文件内容或者图像URL
-
-        // 创建 OkHttpClient 实例
-        OkHttpClient client = new OkHttpClient();
-        MediaType JSON = MediaType.Companion.get(&quot;application/json; charset=utf-8&quot;);
-        RequestBody body = RequestBody.Companion.create(params.toString(), JSON);
-        Request request = new Request.Builder()
-                .url(API_URL)
-                .post(body)
-                .build();
-
-        // 调用API并处理接口返回数据
-        try (Response response = client.newCall(request).execute()) {
-            if (response.isSuccessful()) {
-                String responseBody = response.body().string();
-                JsonNode resultNode = objectMapper.readTree(responseBody);
-                JsonNode result = resultNode.get(&quot;result&quot;);
-                String base64Image = result.get(&quot;image&quot;).asText();
-                JsonNode texts = result.get(&quot;texts&quot;);
-
-                byte[] imageBytes = Base64.getDecoder().decode(base64Image);
-                try (FileOutputStream fos = new FileOutputStream(outputImagePath)) {
-                    fos.write(imageBytes);
-                }
-                System.out.println(&quot;Output image saved at &quot; + outputImagePath);
-                System.out.println(&quot;\nDetected texts: &quot; + texts.toString());
-            } else {
-                System.err.println(&quot;Request failed with code: &quot; + response.code());
-            }
-        }
-    }
-}
-</code></pre></details>
-
-<details><summary>Go</summary>
-
-<pre><code class="language-go">package main
-
-import (
-    &quot;bytes&quot;
-    &quot;encoding/base64&quot;
-    &quot;encoding/json&quot;
-    &quot;fmt&quot;
-    &quot;io/ioutil&quot;
-    &quot;net/http&quot;
-)
-
-func main() {
-    API_URL := &quot;http://localhost:8080/ocr&quot;
-    imagePath := &quot;./demo.jpg&quot;
-    outputImagePath := &quot;./out.jpg&quot;
-
-    // 对本地图像进行Base64编码
-    imageBytes, err := ioutil.ReadFile(imagePath)
-    if err != nil {
-        fmt.Println(&quot;Error reading image file:&quot;, err)
-        return
-    }
-    imageData := base64.StdEncoding.EncodeToString(imageBytes)
-
-    payload := map[string]string{&quot;image&quot;: imageData} // Base64编码的文件内容或者图像URL
-    payloadBytes, err := json.Marshal(payload)
-    if err != nil {
-        fmt.Println(&quot;Error marshaling payload:&quot;, err)
-        return
-    }
-
-    // 调用API
-    client := &amp;http.Client{}
-    req, err := http.NewRequest(&quot;POST&quot;, API_URL, bytes.NewBuffer(payloadBytes))
-    if err != nil {
-        fmt.Println(&quot;Error creating request:&quot;, err)
-        return
-    }
-
-    res, err := client.Do(req)
-    if err != nil {
-        fmt.Println(&quot;Error sending request:&quot;, err)
-        return
-    }
-    defer res.Body.Close()
-
-    // 处理接口返回数据
-    body, err := ioutil.ReadAll(res.Body)
-    if err != nil {
-        fmt.Println(&quot;Error reading response body:&quot;, err)
-        return
-    }
-    type Response struct {
-        Result struct {
-            Image      string   `json:&quot;image&quot;`
-            Texts []map[string]interface{} `json:&quot;texts&quot;`
-        } `json:&quot;result&quot;`
-    }
-    var respData Response
-    err = json.Unmarshal([]byte(string(body)), &amp;respData)
-    if err != nil {
-        fmt.Println(&quot;Error unmarshaling response body:&quot;, err)
-        return
-    }
-
-    outputImageData, err := base64.StdEncoding.DecodeString(respData.Result.Image)
-    if err != nil {
-        fmt.Println(&quot;Error decoding base64 image data:&quot;, err)
-        return
-    }
-    err = ioutil.WriteFile(outputImagePath, outputImageData, 0644)
-    if err != nil {
-        fmt.Println(&quot;Error writing image to file:&quot;, err)
-        return
-    }
-    fmt.Printf(&quot;Image saved at %s.jpg\n&quot;, outputImagePath)
-    fmt.Println(&quot;\nDetected texts:&quot;)
-    for _, text := range respData.Result.Texts {
-        fmt.Println(text)
-    }
-}
-</code></pre></details>
-
-<details><summary>C#</summary>
-
-<pre><code class="language-csharp">using System;
-using System.IO;
-using System.Net.Http;
-using System.Net.Http.Headers;
-using System.Text;
-using System.Threading.Tasks;
-using Newtonsoft.Json.Linq;
-
-class Program
-{
-    static readonly string API_URL = &quot;http://localhost:8080/ocr&quot;;
-    static readonly string imagePath = &quot;./demo.jpg&quot;;
-    static readonly string outputImagePath = &quot;./out.jpg&quot;;
-
-    static async Task Main(string[] args)
-    {
-        var httpClient = new HttpClient();
-
-        // 对本地图像进行Base64编码
-        byte[] imageBytes = File.ReadAllBytes(imagePath);
-        string image_data = Convert.ToBase64String(imageBytes);
-
-        var payload = new JObject{ { &quot;image&quot;, image_data } }; // Base64编码的文件内容或者图像URL
-        var content = new StringContent(payload.ToString(), Encoding.UTF8, &quot;application/json&quot;);
-
-        // 调用API
-        HttpResponseMessage response = await httpClient.PostAsync(API_URL, content);
-        response.EnsureSuccessStatusCode();
-
-        // 处理接口返回数据
-        string responseBody = await response.Content.ReadAsStringAsync();
-        JObject jsonResponse = JObject.Parse(responseBody);
-
-        string base64Image = jsonResponse[&quot;result&quot;][&quot;image&quot;].ToString();
-        byte[] outputImageBytes = Convert.FromBase64String(base64Image);
-
-        File.WriteAllBytes(outputImagePath, outputImageBytes);
-        Console.WriteLine($&quot;Output image saved at {outputImagePath}&quot;);
-        Console.WriteLine(&quot;\nDetected texts:&quot;);
-        Console.WriteLine(jsonResponse[&quot;result&quot;][&quot;texts&quot;].ToString());
-    }
-}
-</code></pre></details>
-
-<details><summary>Node.js</summary>
-
-<pre><code class="language-js">const axios = require('axios');
-const fs = require('fs');
-
-const API_URL = 'http://localhost:8080/ocr'
-const imagePath = './demo.jpg'
-const outputImagePath = &quot;./out.jpg&quot;;
-
-let config = {
-   method: 'POST',
-   maxBodyLength: Infinity,
-   url: API_URL,
-   data: JSON.stringify({
-    'image': encodeImageToBase64(imagePath)  // Base64编码的文件内容或者图像URL
-  })
-};
-
-// 对本地图像进行Base64编码
-function encodeImageToBase64(filePath) {
-  const bitmap = fs.readFileSync(filePath);
-  return Buffer.from(bitmap).toString('base64');
-}
-
-// 调用API
-axios.request(config)
-.then((response) =&gt; {
-    // 处理接口返回数据
-    const result = response.data[&quot;result&quot;];
-    const imageBuffer = Buffer.from(result[&quot;image&quot;], 'base64');
-    fs.writeFile(outputImagePath, imageBuffer, (err) =&gt; {
-      if (err) throw err;
-      console.log(`Output image saved at ${outputImagePath}`);
-    });
-    console.log(&quot;\nDetected texts:&quot;);
-    console.log(result[&quot;texts&quot;]);
-})
-.catch((error) =&gt; {
-  console.log(error);
-});
-</code></pre></details>
-
-<details><summary>PHP</summary>
-
-<pre><code class="language-php">&lt;?php
-
-$API_URL = &quot;http://localhost:8080/ocr&quot;; // 服务URL
-$image_path = &quot;./demo.jpg&quot;;
-$output_image_path = &quot;./out.jpg&quot;;
-
-// 对本地图像进行Base64编码
-$image_data = base64_encode(file_get_contents($image_path));
-$payload = array(&quot;image&quot; =&gt; $image_data); // Base64编码的文件内容或者图像URL
-
-// 调用API
-$ch = curl_init($API_URL);
-curl_setopt($ch, CURLOPT_POST, true);
-curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
-curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-$response = curl_exec($ch);
-curl_close($ch);
-
-// 处理接口返回数据
-$result = json_decode($response, true)[&quot;result&quot;];
-file_put_contents($output_image_path, base64_decode($result[&quot;image&quot;]));
-echo &quot;Output image saved at &quot; . $output_image_path . &quot;\n&quot;;
-echo &quot;\nDetected texts:\n&quot;;
-print_r($result[&quot;texts&quot;]);
-
-?&gt;
-</code></pre></details>
+</code></pre>
+</details>
 </details>
-<br/>
+
 
 📱 <b>端侧部署</b>:端侧部署是一种将计算和数据处理功能放在用户设备本身上的方式,设备可以直接处理数据,而不需要依赖远程的服务器。PaddleX 支持将模型部署在 Android 等端侧设备上,详细的端侧部署流程请参考[PaddleX端侧部署指南](../../../pipeline_deploy/edge_deploy.md)。
 您可以根据需要选择合适的方式部署模型产线,进而进行后续的 AI 应用集成。
@@ -785,28 +559,38 @@ print_r($result[&quot;texts&quot;]);
 若您需要使用微调后的模型权重,只需对产线配置文件做修改,将微调后模型权重的本地路径替换至产线配置文件中的对应位置即可:
 
 ```yaml
-Pipeline:
-  human_det_model: PP-YOLOE-S_human       #可修改为微调后行人检测模型的本地路径
-  keypoint_det_model: PP-TinyPose_128x96  #可修改为微调后关键点检测模型的本地路径
-  human_det_batch_size: 1
-  keypoint_det_batch_size: 1
-  device: gpu
+pipeline_name: human_keypoint_detection
+
+SubModules:
+  ObjectDetection:
+    module_name: object_detection
+    model_name: PP-YOLOE-S_human
+    model_dir: null #可修改为微调后行人检测模型的本地路径
+    batch_size: 1
+    threshold: null
+    img_size: null
+  KeypointDetection:
+    module_name: keypoint_detection
+    model_name: PP-TinyPose_128x96
+    model_dir: #可修改为微调后关键点检测模型的本地路径
+    batch_size: 1
+    flip: False
+    use_udp: null
 ```
 随后, 参考[2.2 本地体验](#22-本地体验)中的命令行方式或Python脚本方式,加载修改后的产线配置文件即可。
 
 ##  5. 多硬件支持
 
-PaddleX 支持英伟达 GPU、昆仑芯 XPU、昇腾 NPU和寒武纪 MLU 等多种主流硬件设备,<b>仅需修改 `--device`参数</b>即可完成不同硬件之间的无缝切换。
+PaddleX 支持英伟达 GPU、昆仑芯 XPU、昇腾 NPU 和寒武纪 MLU 等多种主流硬件设备,<b>仅需修改 `--device`参数</b>即可完成不同硬件之间的无缝切换。
 
-例如,使用Python运行通用图像识别产线时,将运行设备从英伟达 GPU 更改为昇腾 NPU,仅需将脚本中的 `device` 修改为 npu 即可:
+例如,使用昇腾 NPU 进行人体关键点检测产线快速推理
 
-```python
-from paddlex import create_pipeline
-
-pipeline = create_pipeline(
-    pipeline="human_keypoint_detection",
-    device="npu:0" # gpu:0 --> npu:0
-    )
+```bash
+paddlex --pipeline human_keypoint_detection \
+        --input keypoint_detection_001.jpg \
+        --det_threshold 0.5 \
+        --save_path ./output/ \
+        --device npu:0
 ```
 
 若您想在更多种类的硬件上使用通用图像识别产线,请参考[PaddleX多硬件使用指南](../../../other_devices_support/multi_devices_use_guide.md)。

+ 173 - 94
docs/pipeline_usage/tutorials/cv_pipelines/object_detection.md

@@ -349,6 +349,21 @@ comments: true
 <td>2067.84</td>
 <td>351.5 M</td>
 </tr>
+<tr>
+<td>Co-Deformable-DETR-R50</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/Co-Deformable-DETR-R50_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/Co-Deformable-DETR-R50_pretrained.pdparams">训练模型</a></td>
+<td>49.7</td>
+<td></td>
+<td></td>
+<td>184 M</td>
+<td rowspan="2">Co-DETR是一种先进的端到端目标检测器。它基于DETR架构,通过引入协同混合分配训练策略,将目标检测任务中的传统一对多标签分配与一对一匹配相结合,从而显著提高了检测性能和训练效率</td>
+</tr>
+<tr>
+<td>Co-Deformable-DETR-Swin-T</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/Co-Deformable-DETR-Swin-T_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/Co-Deformable-DETR-Swin-T_pretrained.pdparams">训练模型</a></td>
+<td>48.0</td>
+<td></td>
+<td></td>
+<td>187 M</td>
+</tr>
 </table>
 
 <p><b>注:以上精度指标为<a href="https://cocodataset.org/#home">COCO2017</a>验证集 mAP(0.5:0.95)。所有模型 GPU 推理耗时基于 NVIDIA Tesla T4 机器,精度类型为 FP32, CPU 推理速度基于 Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz,线程数为8,精度类型为 FP32。</b></p></details>
@@ -370,60 +385,36 @@ PaddleX 所提供的预训练的模型产线均可以快速体验效果,你可
 一行命令即可快速体验目标检测产线效果,使用 [测试文件](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_object_detection_002.png),并将 `--input` 替换为本地路径,进行预测
 
 ```bash
-paddlex --pipeline object_detection --input general_object_detection_002.png --device gpu:0
-```
-参数说明:
-
-```
---pipeline:产线名称,此处为目标检测产线
---input:待处理的输入图片的本地路径或URL
---device 使用的GPU序号(例如gpu:0表示使用第0块GPU,gpu:1,2表示使用第1、2块GPU),也可选择使用CPU(--device cpu)
+paddlex --pipeline object_detection \
+        --input general_object_detection_002.png \
+        --threshold 0.5 \
+        --save_path ./output/ \
+        --device gpu:0
 ```
+相关参数和运行结果说明可以参考[2.2.2 Python脚本方式集成](#222-python脚本方式集成)中的参数说明和结果解释。
 
-在执行上述 Python 脚本时,加载的是默认的目标检测产线配置文件,若您需要自定义配置文件,可执行如下命令获取:
-
-<details><summary> 👉点击展开</summary>
-
-<pre><code>paddlex --get_pipeline_config object_detection
-</code></pre>
-<p>执行后,目标检测产线配置文件将被保存在当前路径。若您希望自定义保存位置,可执行如下命令(假设自定义保存位置为 <code>./my_path</code> ):</p>
-<pre><code>paddlex --get_pipeline_config object_detection --save_path ./my_path
-</code></pre>
-<p>获取产线配置文件后,可将 <code>--pipeline</code> 替换为配置文件保存路径,即可使配置文件生效。例如,若配置文件保存路径为 <code>./object_detection.yaml</code>,只需执行:</p>
-<pre><code class="language-bash">paddlex --pipeline ./object_detection.yaml --input general_object_detection_002.png --device gpu:0
-</code></pre>
-<p>其中,<code>--model</code>、<code>--device</code> 等参数无需指定,将使用配置文件中的参数。若依然指定了参数,将以指定的参数为准。</p></details>
-
-运行后,得到的结果为:
-
-```
-{'input_path': 'general_object_detection_002.png', 'boxes': [{'cls_id': 49, 'label': 'orange', 'score': 0.8188097476959229, 'coordinate': [661, 93, 870, 305]}, {'cls_id': 47, 'label': 'apple', 'score': 0.7743489146232605, 'coordinate': [76, 274, 330, 520]}, {'cls_id': 47, 'label': 'apple', 'score': 0.7270504236221313, 'coordinate': [285, 94, 469, 297]}, {'cls_id': 46, 'label': 'banana', 'score': 0.5570532083511353, 'coordinate': [310, 361, 685, 712]}, {'cls_id': 47, 'label': 'apple', 'score': 0.5484835505485535, 'coordinate': [764, 285, 924, 440]}, {'cls_id': 47, 'label': 'apple', 'score': 0.5160726308822632, 'coordinate': [853, 169, 987, 303]}, {'cls_id': 60, 'label': 'dining table', 'score': 0.5142655968666077, 'coordinate': [0, 0, 1072, 720]}, {'cls_id': 47, 'label': 'apple', 'score': 0.5101479291915894, 'coordinate': [57, 23, 213, 176]}]}
-```
+可视化结果保存至`save_path`,如下所示:
 
 <img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/pipelines/object_detection/03.png">
 
-可视化图片默认不进行保存,您可以通过 `--save_path` 自定义保存路径,随后所有结果将被保存在指定路径下。
-
 #### 2.2.2 Python脚本方式集成
-几行代码即可完成产线的快速推理,以通用目标检测产线为例
+通过上述命令行方式可快速体验查看效果,在项目中往往需要代码集成,您可以通过如下几行代码完成产线的快速推理:
 
 ```python
 from paddlex import create_pipeline
 
 pipeline = create_pipeline(pipeline="object_detection")
 
-output = pipeline.predict("general_object_detection_002.png")
+output = pipeline.predict("general_object_detection_002.png", threshold=0.5)
 for res in output:
-    res.print() ## 打印预测的结构化输出
-    res.save_to_img("./output/") ## 保存结果可视化图像
-    res.save_to_json("./output/") ## 保存预测的结构化输出
+    res.print()
+    res.save_to_img("./output/")
+    res.save_to_json("./output/")
 ```
-得到的结果与命令行方式相同。
 
 在上述 Python 脚本中,执行了如下几个步骤:
 
-(1)实例化 `create_pipeline` 实例化产线对象:具体参数说明如下:
-
+(1)调用 `create_pipeline` 实例化产线对象:具体参数说明如下:
 <table>
 <thead>
 <tr>
@@ -438,101 +429,186 @@ for res in output:
 <td><code>pipeline</code></td>
 <td>产线名称或是产线配置文件路径。如为产线名称,则必须为 PaddleX 所支持的产线。</td>
 <td><code>str</code></td>
-<td></td>
+<td><code>None</code></td>
 </tr>
 <tr>
 <td><code>device</code></td>
-<td>产线模型推理设备。支持:“gpu”,“cpu”。</td>
+<td>产线推理设备。支持指定GPU具体卡号,如“gpu:0”,其他硬件具体卡号,如“npu:0”,CPU如“cpu”。</td>
 <td><code>str</code></td>
-<td><code>gpu</code></td>
+<td><code>gpu:0</code></td>
 </tr>
 <tr>
-<td><code>enable_hpi</code></td>
+<td><code>use_hpip</code></td>
 <td>是否启用高性能推理,仅当该产线支持高性能推理时可用。</td>
 <td><code>bool</code></td>
 <td><code>False</code></td>
 </tr>
 </tbody>
 </table>
-(2)调用产线对象的 `predict` 方法进行推理预测:`predict` 方法参数为`x`,用于输入待预测数据,支持多种输入方式,具体示例如下:
+
+2)调用通用目标检测产线对象的 `predict()` 方法进行推理预测。该方法将返回一个 `generator`。以下是 `predict()` 方法的参数及其说明:
 
 <table>
 <thead>
 <tr>
+<th>参数</th>
+<th>参数说明</th>
+<th>参数类型</th>
+<th>可选项</th>
+<th>默认值</th>
+</tr>
+</thead>
+<tr>
+<td><code>input</code></td>
+<td>待预测数据,支持多种输入类型,必填</td>
+<td><code>Python Var|str|list</code></td>
+<td>
+<ul>
+  <li><b>Python Var</b>:如 <code>numpy.ndarray</code> 表示的图像数据</li>
+  <li><b>str</b>:如图像文件或者PDF文件的本地路径:<code>/root/data/img.jpg</code>;<b>如URL链接</b>,如图像文件或PDF文件的网络URL:<a href = "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png">示例</a>;<b>如本地目录</b>,该目录下需包含待预测图像,如本地路径:<code>/root/data/</code>(当前不支持目录中包含PDF文件的预测,PDF文件需要指定到具体文件路径)</li>
+  <li><b>List</b>:列表元素需为上述类型数据,如<code>[numpy.ndarray, numpy.ndarray]</code>,<code>[\"/root/data/img1.jpg\", \"/root/data/img2.jpg\"]</code>,<code>[\"/root/data1\", \"/root/data2\"]</code></li>
+</ul>
+</td>
+<td>无</td>
+</tr>
+<tr>
+<td><code>threshold</code></td>
+<td>用于过滤掉低置信度预测结果的阈值;如果不指定,则默认使用PaddleX官方模型配置</td>
+<td><code>float/dict/None</code></td>
+<td>
+<ul>
+  <li><b>float</b>,如 0.2, 表示过滤掉所有阈值小于0.2的目标框</li>
+  <li><b>字典</b>,字典的key为<b>int</b>类型,代表<code>cls_id</code>,val为<b>float</b>类型阈值。如 <code>{0: 0.45, 2: 0.48, 7: 0.4}</code>,表示对cls_id为0的类别应用阈值0.45、cls_id为1的类别应用阈值0.48、cls_id为7的类别应用阈值0.4</li>
+</ul>
+</td>
+<td><code>None</code></td>
+</tr>
+</table>
+
+(3)对预测结果进行处理,每个样本的预测结果均为`dict`类型,且支持打印、保存为图片、保存为`json`文件的操作:
+
+<table>
+<thead>
+<tr>
+<th>方法</th>
+<th>方法说明</th>
+<th>参数</th>
 <th>参数类型</th>
 <th>参数说明</th>
+<th>默认值</th>
 </tr>
 </thead>
-<tbody>
 <tr>
-<td>Python Var</td>
-<td>支持直接传入Python变量,如numpy.ndarray表示的图像数据。</td>
+<td rowspan = "3"><code>print()</code></td>
+<td rowspan = "3">打印结果到终端</td>
+<td><code>format_json</code></td>
+<td><code>bool</code></td>
+<td>是否对输出内容进行使用 <code>JSON</code> 缩进格式化</td>
+<td><code>True</code></td>
+</tr>
+<tr>
+<td><code>indent</code></td>
+<td><code>int</code></td>
+<td>指定缩进级别,以美化输出的 <code>JSON</code> 数据,使其更具可读性,仅当 <code>format_json</code> 为 <code>True</code> 时有效</td>
+<td>4</td>
 </tr>
 <tr>
-<td>str</td>
-<td>支持传入待预测数据文件路径,如图像文件的本地路径:<code>/root/data/img.jpg</code>。</td>
+<td><code>ensure_ascii</code></td>
+<td><code>bool</code></td>
+<td>控制是否将非 <code>ASCII</code> 字符转义为 <code>Unicode</code>。设置为 <code>True</code> 时,所有非 <code>ASCII</code> 字符将被转义;<code>False</code> 则保留原始字符,仅当<code>format_json</code>为<code>True</code>时有效</td>
+<td><code>False</code></td>
 </tr>
 <tr>
-<td>str</td>
-<td>支持传入待预测数据文件URL,如图像文件的网络URL:<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_object_detection_002.png">示例</a>。</td>
+<td rowspan = "3"><code>save_to_json()</code></td>
+<td rowspan = "3">将结果保存为json格式的文件</td>
+<td><code>save_path</code></td>
+<td><code>str</code></td>
+<td>保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致</td>
+<td>无</td>
 </tr>
 <tr>
-<td>str</td>
-<td>支持传入本地目录,该目录下需包含待预测数据文件,如本地路径:<code>/root/data/</code>。</td>
+<td><code>indent</code></td>
+<td><code>int</code></td>
+<td>指定缩进级别,以美化输出的 <code>JSON</code> 数据,使其更具可读性,仅当 <code>format_json</code> 为 <code>True</code> 时有效</td>
+<td>4</td>
 </tr>
 <tr>
-<td>dict</td>
-<td>支持传入字典类型,字典的key需与具体任务对应,如图像分类任务对应\"img\",字典的val支持上述类型数据,例如:<code>{\"img\": \"/root/data1\"}</code>。</td>
+<td><code>ensure_ascii</code></td>
+<td><code>bool</code></td>
+<td>控制是否将非 <code>ASCII</code> 字符转义为 <code>Unicode</code>。设置为 <code>True</code> 时,所有非 <code>ASCII</code> 字符将被转义;<code>False</code> 则保留原始字符,仅当<code>format_json</code>为<code>True</code>时有效</td>
+<td><code>False</code></td>
 </tr>
 <tr>
-<td>list</td>
-<td>支持传入列表,列表元素需为上述类型数据,如<code>[numpy.ndarray, numpy.ndarray],[\"/root/data/img1.jpg\", \"/root/data/img2.jpg\"]</code>,<code>[\"/root/data1\", \"/root/data2\"]</code>,<code>[{\"img\": \"/root/data1\"}, {\"img\": \"/root/data2/img.jpg\"}]</code>。</td>
+<td><code>save_to_img()</code></td>
+<td>将结果保存为图像格式的文件</td>
+<td><code>save_path</code></td>
+<td><code>str</code></td>
+<td>保存的文件路径,支持目录或文件路径</td>
+<td>无</td>
 </tr>
-</tbody>
 </table>
-(3)调用`predict`方法获取预测结果:`predict` 方法为`generator`,因此需要通过调用获得预测结果,`predict`方法以batch为单位对数据进行预测,因此预测结果为list形式表示的一组预测结果。
 
-(4)对预测结果进行处理:每个样本的预测结果均为`dict`类型,且支持打印,或保存为文件,支持保存的类型与具体产线相关,如:
+- 调用 <code>print()</code> 方法会将如下结果打印到终端:
+
+```bash
+{'res': {'input_path': 'general_object_detection_002.png', 'page_index': None, 'boxes': [{'cls_id': 49, 'label': 'orange', 'score': 0.8188614249229431, 'coordinate': [661.3518, 93.05823, 870.75903, 305.93713]}, {'cls_id': 47, 'label': 'apple', 'score': 0.7745078206062317, 'coordinate': [76.80911, 274.74905, 330.5422, 520.0428]}, {'cls_id': 47, 'label': 'apple', 'score': 0.7271787524223328, 'coordinate': [285.32645, 94.3175, 469.73645, 297.40344]}, {'cls_id': 46, 'label': 'banana', 'score': 0.5576589703559875, 'coordinate': [310.8041, 361.43625, 685.1869, 712.59155]}, {'cls_id': 47, 'label': 'apple', 'score': 0.5490103363990784, 'coordinate': [764.6252, 285.76096, 924.8153, 440.92892]}, {'cls_id': 47, 'label': 'apple', 'score': 0.515821635723114, 'coordinate': [853.9831, 169.41423, 987.803, 303.58615]}, {'cls_id': 60, 'label': 'dining table', 'score': 0.514293372631073, 'coordinate': [0.53089714, 0.32445717, 1072.9534, 720]}, {'cls_id': 47, 'label': 'apple', 'score': 0.510750949382782, 'coordinate': [57.368027, 23.455347, 213.39601, 176.45612]}]}}
+```
+
+- 输出结果参数含义如下:
+    - `input_path`:表示输入图像的路径
+    - `page_index`:如果输入是PDF文件,则表示当前是PDF的第几页,否则为 `None`
+    - `boxes`:预测的目标框信息,一个字典列表。每个字典代表一个检出的目标,包含以下信息:
+        - `cls_id`:类别ID,一个整数
+        - `label`:类别标签,一个字符串
+        - `score`:目标框置信度,一个浮点数
+        - `coordinate`:目标框坐标,一个浮点数列表,格式为<code>[xmin, ymin, xmax, ymax]</code>
+
+- 调用`save_to_json()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}.json`,如果指定为文件,则直接保存到该文件中。由于json文件不支持保存numpy数组,因此会将其中的`numpy.array`类型转换为列表形式。
+- 调用`save_to_img()` 方法会将可视化结果保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}_res.{your_img_extension}`,如果指定为文件,则直接保存到该文件中。(产线通常包含较多结果图片,不建议直接指定为具体的文件路径,否则多张图会被覆盖,仅保留最后一张图)
+
+* 此外,也支持通过属性获取带结果的可视化图像和预测结果,具体如下:
 
 <table>
 <thead>
 <tr>
-<th>方法</th>
-<th>说明</th>
-<th>方法参数</th>
+<th>属性</th>
+<th>属性说明</th>
 </tr>
 </thead>
-<tbody>
-<tr>
-<td>print</td>
-<td>打印结果到终端</td>
-<td><code>- format_json</code>:bool类型,是否对输出内容进行使用json缩进格式化,默认为True;<br/><code>- indent</code>:int类型,json格式化设置,仅当format_json为True时有效,默认为4;<br/><code>- ensure_ascii</code>:bool类型,json格式化设置,仅当format_json为True时有效,默认为False;</td>
-</tr>
 <tr>
-<td>save_to_json</td>
-<td>将结果保存为json格式的文件</td>
-<td><code>- save_path</code>:str类型,保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致;<br/><code>- indent</code>:int类型,json格式化设置,默认为4;<br/><code>- ensure_ascii</code>:bool类型,json格式化设置,默认为False;</td>
+<td rowspan = "1"><code>json</code></td>
+<td rowspan = "1">获取预测的 <code>json</code> 格式的结果</td>
 </tr>
 <tr>
-<td>save_to_img</td>
-<td>将结果保存为图像格式的文件</td>
-<td><code>- save_path</code>:str类型,保存的文件路径,当为目录时,保存文件命名与输入文件类型命名一致;</td>
+<td rowspan = "2"><code>img</code></td>
+<td rowspan = "2">获取格式为 <code>dict</code> 的可视化图像</td>
 </tr>
-</tbody>
 </table>
-若您获取了配置文件,即可对目标检测产线各项配置进行自定义,只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为产线配置文件路径即可。
 
-例如,若您的配置文件保存在 `./my_path/object_detection.yaml` ,则只需执行:
+- `json` 属性获取的预测结果为dict类型的数据,相关内容与调用 `save_to_json()` 方法保存的内容一致。
+- `img` 属性返回的预测结果是一个字典类型的数据。键为 `res` ,对应的值是一个用于可视化目标检测结果的 `Image.Image` 对象。
+
+上述Python脚本集成方式默认使用 PaddleX 官方配置文件中的参数设置,若您需要自定义配置文件,可先执行如下命令获取官方配置文件,并保存在 `my_path` 中:
+
+```bash
+paddlex --get_pipeline_config object_detection --save_path ./my_path
+```
+
+若您获取了配置文件,即可对目标检测产线各项配置进行自定义。只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为自定义产线配置文件路径即可。
+
+例如,若您的自定义配置文件保存在 `./my_path/object_detection.yaml` ,则只需执行:
 
 ```python
 from paddlex import create_pipeline
 pipeline = create_pipeline(pipeline="./my_path/object_detection.yaml")
 output = pipeline.predict("general_object_detection_002.png")
 for res in output:
-    res.print() ## 打印预测的结构化输出
-    res.save_to_img("./output/") ## 保存结果可视化图像
-    res.save_to_json("./output/") ## 保存预测的结构化输出
+    res.print()
+    res.save_to_img("./output/")
+    res.save_to_json("./output/")
 ```
+<b>注:</b> 配置文件中的参数为产线初始化参数,如果希望更改通用目标检测产线初始化参数,可以直接修改配置文件中的参数,并加载配置文件进行预测。
+
 ## 3. 开发集成/部署
 
 如果产线可以达到您对产线推理速度和精度的要求,您可以直接进行开发集成/部署。
@@ -1099,27 +1175,30 @@ print_r($result[&quot;detectedObjects&quot;]);
 
 若您需要使用微调后的模型权重,只需对产线配置文件做修改,将微调后模型权重的本地路径替换至产线配置文件中的对应位置即可:
 
-```python
-......
-Pipeline:
-  model: PicoDet-S  #可修改为微调后模型的本地路径
-  device: "gpu"
-  batch_size: 1
-......
+```yaml
+pipeline_name: object_detection
+
+SubModules:
+  ObjectDetection:
+    module_name: object_detection
+    model_name: PicoDet-S
+    model_dir: null #可修改为微调后模型的本地路径
+    batch_size: 1
+    img_size: null
+    threshold: null
 ```
 随后, 参考本地体验中的命令行方式或 Python 脚本方式,加载修改后的产线配置文件即可。
 
 ## 5. 多硬件支持
-PaddleX 支持英伟达 GPU、昆仑芯 XPU、昇腾 NPU和寒武纪 MLU 等多种主流硬件设备,<b>仅需修改  `--device` 参数</b>即可完成不同硬件之间的无缝切换。
-
-例如,您使用英伟达 GPU 进行目标检测产线的推理,使用的 Python 命令为:
+PaddleX 支持英伟达 GPU、昆仑芯 XPU、昇腾 NPU 和寒武纪 MLU 等多种主流硬件设备,<b>仅需修改  `--device` 参数</b>即可完成不同硬件之间的无缝切换。
 
-```bash
-paddlex --pipeline object_detection --input general_object_detection_002.png --device gpu:0
-```
-此时,若您想将硬件切换为昇腾 NPU,仅需对 Python 命令中的 `--device` 修改为 npu:0 即可:
+例如,使用昇腾 NPU 进行目标检测产线快速推理:
 
 ```bash
-paddlex --pipeline object_detection --input general_object_detection_002.png --device npu:0
+paddlex --pipeline object_detection \
+        --input general_object_detection_002.png \
+        --threshold 0.5 \
+        --save_path ./output/ \
+        --device npu:0
 ```
 若您想在更多种类的硬件上使用通用目标检测产线,请参考[PaddleX多硬件使用指南](../../../other_devices_support/multi_devices_use_guide.md)。

+ 7 - 0
paddlex/utils/pipeline_arguments.py

@@ -135,6 +135,13 @@ PIPELINE_ARGUMENTS = {
             "help": "Sets the threshold for vehicle attribute recognition.",
         },
     ],
+    "human_keypoint_detection": [
+        {
+            "name": "--det_threshold",
+            "type": float,
+            "help": "Sets the threshold for human detection.",
+        },
+    ],
     "table_recognition": None,
     "layout_parsing": None,
     "seal_recognition": [

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio