Bladeren bron

modify_pipeline_and_module_docs (#3277)

Co-authored-by: cuicheng01 <45199522+cuicheng01@users.noreply.github.com>
zhangyubo0722 9 maanden geleden
bovenliggende
commit
51c3ccb97a

+ 2 - 2
docs/module_usage/tutorials/cv_modules/anomaly_detection.md

@@ -110,7 +110,7 @@ for res in output:
 <tr>
 <td><code>input</code></td>
 <td>待预测数据,支持多种输入类型</td>
-<td><code>Python Var</code>/<code>str</code>/<code>dict</code>/<code>list</code></td>
+<td><code>Python Var</code>/<code>str</code>/<code>list</code></td>
 <td>
 <ul>
   <li><b>Python变量</b>,如<code>numpy.ndarray</code>表示的图像数据</li>
@@ -265,7 +265,7 @@ python main.py -c paddlex/configs/modules/image_anomaly_detection/STFPM.yaml \
   &quot;analysis&quot;: {
     &quot;histogram&quot;: &quot;check_dataset/histogram.png&quot;
   },
-  &quot;dataset_path&quot;: &quot;./dataset/example_data/mvtec_examples&quot;,
+  &quot;dataset_path&quot;: &quot;mvtec_examples&quot;,
   &quot;show_type&quot;: &quot;image&quot;,
   &quot;dataset_type&quot;: &quot;SegDataset&quot;
 }

+ 1 - 1
docs/module_usage/tutorials/cv_modules/face_detection.md

@@ -161,7 +161,7 @@ for res in output:
 <tr>
 <td><code>input</code></td>
 <td>待预测数据,支持多种输入类型</td>
-<td><code>Python Var</code>/<code>str</code>/<code>dict</code>/<code>list</code></td>
+<td><code>Python Var</code>/<code>str</code>/<code>list</code></td>
 <td>
 <ul>
   <li><b>Python变量</b>,如<code>numpy.ndarray</code>表示的图像数据</li>

+ 1 - 1
docs/module_usage/tutorials/cv_modules/face_feature.md

@@ -151,7 +151,7 @@ for res in output:
 <tr>
 <td><code>input</code></td>
 <td>待预测数据,支持多种输入类型</td>
-<td><code>Python Var</code>/<code>str</code>/<code>dict</code>/<code>list</code></td>
+<td><code>Python Var</code>/<code>str</code>/<code>list</code></td>
 <td>
 <ul>
   <li><b>Python变量</b>,如<code>numpy.ndarray</code>表示的图像数据</li>

+ 1 - 1
docs/module_usage/tutorials/cv_modules/human_keypoint_detection.md

@@ -150,7 +150,7 @@ for res in output:
 <tr>
 <td><code>input</code></td>
 <td>待预测数据,支持多种输入类型</td>
-<td><code>Python Var</code>/<code>str</code>/<code>dict</code>/<code>list</code></td>
+<td><code>Python Var</code>/<code>str</code>/<code>list</code></td>
 <td>
 <ul>
   <li><b>Python变量</b>,如<code>numpy.ndarray</code>表示的图像数据</li>

+ 9 - 3
docs/module_usage/tutorials/cv_modules/image_classification.md

@@ -696,6 +696,7 @@ for res in output:
 
 运行结果参数含义如下:
 - `input_path`:表示输入图片的路径。
+- `page_index`:如果输入是PDF文件,则表示当前是PDF的第几页,否则为 `None`。
 - `class_ids`:表示预测结果的类别id。
 - `scores`:表示预测结果的置信度。
 - `label_names`:表示预测结果的类别名。
@@ -761,15 +762,14 @@ for res in output:
 <tr>
 <td><code>input</code></td>
 <td>待预测数据,支持多种输入类型</td>
-<td><code>Python Var</code>/<code>str</code>/<code>dict</code>/<code>list</code></td>
+<td><code>Python Var</code>/<code>str</code>/<code>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_image_classification_001.jpg">示例</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>列表</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>
@@ -925,9 +925,15 @@ python main.py -c paddlex/configs/modules/image_classification/PP-LCNet_x1_0.yam
   "analysis": {
     "histogram": "check_dataset/histogram.png"
   },
+<<<<<<< HEAD
   "dataset_path": "./dataset/cls_flowers_examples",
   "show_type": "image",
   "dataset_type": "ClsDataset"
+=======
+  &quot;dataset_path&quot;: &quot;cls_flowers_examples&quot;,
+  &quot;show_type&quot;: &quot;image&quot;,
+  &quot;dataset_type&quot;: &quot;ClsDataset&quot;
+>>>>>>> modify_pipeline_and_module_docs
 }
 </code></pre>
 <p>上述校验结果中,check_pass 为 True 表示数据集格式符合要求,其他部分指标的说明如下:</p>

+ 1 - 1
docs/module_usage/tutorials/cv_modules/image_feature.md

@@ -115,7 +115,7 @@ for res in output:
 <tr>
 <td><code>input</code></td>
 <td>待预测数据,支持多种输入类型</td>
-<td><code>Python Var</code>/<code>str</code>/<code>dict</code>/<code>list</code></td>
+<td><code>Python Var</code>/<code>str</code>/<code>list</code></td>
 <td>
 <ul>
   <li><b>Python变量</b>,如<code>numpy.ndarray</code>表示的图像数据</li>

+ 3 - 2
docs/module_usage/tutorials/cv_modules/image_multilabel_classification.md

@@ -77,6 +77,7 @@ for res in output:
 
 运行结果参数含义如下:
 - `input_path`:表示输入待预测多类别图像的路径
+- `page_index`:如果输入是PDF文件,则表示当前是PDF的第几页,否则为 `None`
 - `class_ids`:表示多类别图像的预测标签ID
 - `scores`:表示多类别图像的预测标签置信度
 - `label_names`:表示多类别图像的预测标签名称
@@ -145,7 +146,7 @@ for res in output:
 <tr>
 <td><code>input</code></td>
 <td>待预测数据,支持多种输入类型</td>
-<td><code>Python Var</code>/<code>str</code>/<code>dict</code>/<code>list</code></td>
+<td><code>Python Var</code>/<code>str</code>/<code>list</code></td>
 <td>
 <ul>
   <li><b>Python变量</b>,如<code>numpy.ndarray</code>表示的图像数据</li>
@@ -325,7 +326,7 @@ python main.py -c paddlex/configs/modules/image_multilabel_classification/PP-LCN
   &quot;analysis&quot;: {
     &quot;histogram&quot;: &quot;check_dataset/histogram.png&quot;
   },
-  &quot;dataset_path&quot;: &quot;./dataset/mlcls_nus_examples&quot;,
+  &quot;dataset_path&quot;: &quot;mlcls_nus_examples&quot;,
   &quot;show_type&quot;: &quot;image&quot;,
   &quot;dataset_type&quot;: &quot;MLClsDataset&quot;
 }

+ 1 - 1
docs/module_usage/tutorials/cv_modules/object_detection.md

@@ -650,7 +650,7 @@ python main.py -c paddlex/configs/modules/object_detection/PicoDet-S.yaml \
   "analysis": {
     "histogram": "check_dataset/histogram.png"
   },
-  "dataset_path": "./dataset/det_coco_examples",
+  "dataset_path": "det_coco_examples",
   "show_type": "image",
   "dataset_type": "COCODetDataset"
 }

+ 1 - 1
docs/module_usage/tutorials/cv_modules/open_vocabulary_detection.md

@@ -121,7 +121,7 @@ for res in results:
 <tr>
 <td><code>input</code></td>
 <td>待预测数据,支持多种输入类型</td>
-<td><code>Python Var</code>/<code>str</code>/<code>dict</code>/<code>list</code></td>
+<td><code>Python Var</code>/<code>str</code>/<code>list</code></td>
 <td>
 <ul>
   <li><b>Python变量</b>,如<code>numpy.ndarray</code>表示的图像数据</li>

+ 1 - 1
docs/module_usage/tutorials/cv_modules/open_vocabulary_segmentation.md

@@ -123,7 +123,7 @@ for res in results:
 <tr>
 <td><code>input</code></td>
 <td>待预测数据,支持多种输入类型</td>
-<td><code>Python Var</code>/<code>str</code>/<code>dict</code>/<code>list</code></td>
+<td><code>Python Var</code>/<code>str</code>/<code>list</code></td>
 <td>
 <ul>
   <li><b>Python变量</b>,如<code>numpy.ndarray</code>表示的图像数据</li>

+ 200 - 22
docs/module_usage/tutorials/cv_modules/pedestrian_attribute_recognition.md

@@ -39,36 +39,208 @@ comments: true
 
 完成 wheel 包的安装后,几行代码即可完成行人属性识别模块的推理,可以任意切换该模块下的模型,您也可以将行人属性识别的模块中的模型推理集成到您的项目中。运行以下代码前,请您下载[示例图片](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/pedestrian_attribute_006.jpg)到本地。
 
-```bash
+```python
 from paddlex import create_model
-model = create_model("PP-LCNet_x1_0_pedestrian_attribute")
+model = create_model(model_name="PP-LCNet_x1_0_pedestrian_attribute")
 output = model.predict("pedestrian_attribute_006.jpg", batch_size=1)
 for res in output:
     res.print(json_format=False)
     res.save_to_img("./output/")
     res.save_to_json("./output/res.json")
 ```
-关于更多 PaddleX 的单模型推理的 API 的使用方法,可以参考[PaddleX单模型Python脚本使用说明](../../instructions/model_python_API.md)。
-
-<b>备注</b>:其中 `output` 的值索引为0表示是否佩戴帽子,索引值为1表示是否佩戴眼镜,索引值2-7表示上衣风格,索引值8-13表示下装风格,索引值14表示是否穿靴子,索引值15-17表示背的包的类型,索引值18表示正面是否持物,索引值19-21表示年龄,索引值22表示性别,索引值23-25表示朝向。具体地,属性包含以下类型:
 
+运行后,得到的结果为:
+```bash
+{'res': {'input_path': 'pedestrian_attribute_006.jpg', 'page_index': None, 'class_ids': array([10, ..., 23]), 'scores': array([1.     , ..., 0.54777]), 'label_names': ['LongCoat(长外套)', 'Age18-60(年龄在18-60岁之间)', 'Trousers(长裤)', 'Front(面朝前)']}}
 ```
-- 性别:男、女
-- 年龄:小于18、18-60、大于60
-- 朝向:朝前、朝后、侧面
-- 配饰:眼镜、帽子、无
-- 正面持物:是、否
-- 包:双肩包、单肩包、手提包
-- 上衣风格:带条纹、带logo、带格子、拼接风格
-- 下装风格:带条纹、带图案
-- 短袖上衣:是、否
-- 长袖上衣:是、否
-- 长外套:是、否
-- 长裤:是、否
-- 短裤:是、否
-- 短裙&amp;裙子:是、否
-- 穿靴:是、否
-```
+
+运行结果参数含义如下:
+- `input_path`:表示输入待预测多类别图像的路径
+- `page_index`:如果输入是PDF文件,则表示当前是PDF的第几页,否则为 `None`
+- `class_ids`:表示行人属性图像的预测标签ID
+- `scores`:表示行人属性图像的预测标签置信度
+- `label_names`:表示行人属性图像的预测标签名称
+
+可视化图片如下:
+
+<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/refs/heads/main/images/modules/ped_attri/pedestrian_attribute_006_res.jpg">
+
+相关方法、参数等说明如下:
+
+* `create_model`实例化行人属性识别模型(此处以`PP-LCNet_x1_0_pedestrian_attribute`为例),具体说明如下:
+<table>
+<thead>
+<tr>
+<th>参数</th>
+<th>参数说明</th>
+<th>参数类型</th>
+<th>可选项</th>
+<th>默认值</th>
+</tr>
+</thead>
+<tr>
+<td><code>model_name</code></td>
+<td>模型名称</td>
+<td><code>str</code></td>
+<td>无</td>
+<td><code>PP-LCNet_x1_0_pedestrian_attribute</code></td>
+</tr>
+<tr>
+<td><code>model_dir</code></td>
+<td>模型存储路径</td>
+<td><code>str</code></td>
+<td>无</td>
+<td>无</td>
+</tr>
+<tr>
+<td><code>threshold</code></td>
+<td>行人属性识别阈值</td>
+<td><code>float/list/dict</code></td>
+<td><li><b>float类型变量</b>,任意[0-1]之间浮点数:<code>0.5</code></li>
+<li><b>list类型变量</b>,由多个[0-1]之间浮点数组成的列表:<code>[0.5,0.5,...]</code></li>
+<li><b>dict类型变量</b>,指定不同类别使用不同的阈值,其中"default"为必须包含的键:<code>{"default":0.5,1:0.1,...}</code>
+</li>
+</td>
+<td>0.5</td>
+</tr>
+</table>
+
+* 其中,`model_name` 必须指定,指定 `model_name` 后,默认使用 PaddleX 内置的模型参数,在此基础上,指定 `model_dir` 时,使用用户自定义的模型。
+
+* 其中,`threshold` 参数用于设置多标签分类的阈值,默认为0.7。当设置为浮点数时,表示所有类别均使用该阈值;当设置为列表时,表示不同类别使用不同的阈值,此时需保持列表长度与类别数量一致;当设置为字典时,`default` 为必须包含的键, 表示所有类别的默认阈值,其它类别使用各自的阈值。例如:{"default":0.5,1:0.1}。
+
+* 调用多标签分类模型的 `predict()` 方法进行推理预测,`predict()` 方法参数有 `input` , `batch_size` 和  `threshold`,具体说明如下:
+
+<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</code>/<code>str</code>/<code>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/multilabel_classification_005.png">示例</a></li>
+  <li><b>本地目录</b>,该目录下需包含待预测数据文件,如本地路径:<code>/root/data/</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></li>
+</ul>
+</td>
+<td>无</td>
+</tr>
+<tr>
+<td><code>batch_size</code></td>
+<td>批大小</td>
+<td><code>int</code></td>
+<td>任意整数</td>
+<td>1</td>
+</tr>
+<tr>
+<td><code>threshold</code></td>
+<td>行人属性识别阈值</td>
+<td><code>float/list/dict</code></td>
+<td><li><b>float类型变量</b>,任意[0-1]之间浮点数:<code>0.5</code></li>
+<li><b>list类型变量</b>,由多个[0-1]之间浮点数组成的列表:<code>[0.5,0.5,...]</code></li>
+<li><b>dict类型变量</b>,指定不同类别使用不同的阈值,其中"default"为必须包含的键:<code>{"default":0.5,1:0.1,...}</code>
+</li>
+</td>
+<td>0.5</td>
+</tr>
+</table>
+
+* 对预测结果进行处理,每个样本的预测结果均为对应的Result对象,且支持打印、保存为图片、保存为`json`文件的操作:
+
+<table>
+<thead>
+<tr>
+<th>方法</th>
+<th>方法说明</th>
+<th>参数</th>
+<th>参数类型</th>
+<th>参数说明</th>
+<th>默认值</th>
+</tr>
+</thead>
+<tr>
+<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><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 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><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>
+</table>
+
+* 此外,也支持通过属性获取带结果的可视化图像和预测结果,具体如下:
+
+<table>
+<thead>
+<tr>
+<th>属性</th>
+<th>属性说明</th>
+</tr>
+</thead>
+<tr>
+<td rowspan = "1"><code>json</code></td>
+<td rowspan = "1">获取预测的<code>json</code>格式的结果</td>
+</tr>
+<tr>
+<td rowspan = "1"><code>img</code></td>
+<td rowspan = "1">获取格式为<code>dict</code>的可视化图像</td>
+</tr>
+
+</table>
+
+
+关于更多 PaddleX 的单模型推理的 API 的使用方法,可以参考的使用方法,可以参考[PaddleX单模型Python脚本使用说明](../../instructions/model_python_API.md)。
 
 ## 四、二次开发
 如果你追求更高精度的现有模型,可以使用 PaddleX 的二次开发能力,开发更好的行人属性识别模型。在使用 PaddleX 开发行人属性识别之前,请务必安装 PaddleX 的分类相关模型训练插件,安装过程可以参考 [PaddleX本地安装教程](../../../installation/installation.md)中的二次开发部分。
@@ -131,9 +303,15 @@ python main.py -c paddlex/configs/modules/pedestrian_attribute_recognition/PP-LC
   "analysis": {
     "histogram": "check_dataset/histogram.png"
   },
+<<<<<<< HEAD
   "dataset_path": "./dataset/pedestrian_attribute_examples",
   "show_type": "image",
   "dataset_type": "MLClsDataset"
+=======
+  &quot;dataset_path&quot;: &quot;pedestrian_attribute_examples&quot;,
+  &quot;show_type&quot;: &quot;image&quot;,
+  &quot;dataset_type&quot;: &quot;MLClsDataset&quot;
+>>>>>>> modify_pipeline_and_module_docs
 }
 </code></pre>
 <p>上述校验结果中,check_pass 为 true 表示数据集格式符合要求,其他部分指标的说明如下:</p>
@@ -262,7 +440,7 @@ python main.py -c paddlex/configs/modules/pedestrian_attribute_recognition/PP-LC
 
 1.<b>产线集成</b>
 
-行人属性识别模块可以集成的PaddleX产线有[通用图像多标签分类产线](../../../pipeline_usage/tutorials/cv_pipelines/image_multi_label_classification.md),只需要替换模型路径即可完成相关产线的行人属性识别模块的模型更新。在产线集成中,你可以使用高性能部署和服务化部署来部署你得到的模型。
+行人属性识别模块可以集成的PaddleX产线有[行人属性识别产线](../../../pipeline_usage/tutorials/cv_pipelines/pedestrian_attribute_recognition.md),只需要替换模型路径即可完成相关产线的行人属性识别模块的模型更新。在产线集成中,你可以使用高性能部署和服务化部署来部署你得到的模型。
 
 2.<b>模块集成</b>
 

+ 2 - 2
docs/module_usage/tutorials/cv_modules/rotated_object_detection.md

@@ -129,7 +129,7 @@ for res in output:
 <tr>
 <td><code>input</code></td>
 <td>待预测数据,支持多种输入类型</td>
-<td><code>Python Var</code>/<code>str</code>/<code>dict</code>/<code>list</code></td>
+<td><code>Python Var</code>/<code>str</code>/<code>list</code></td>
 <td>
 <ul>
   <li><b>Python变量</b>,如<code>numpy.ndarray</code>表示的图像数据</li>
@@ -321,7 +321,7 @@ python main.py -c paddlex/configs/modules/rotated_object_detection/PP-YOLOE-R-L.
   &quot;analysis&quot;: {
     &quot;histogram&quot;: &quot;check_dataset/histogram.png&quot;
   },
-  &quot;dataset_path&quot;: &quot;./dataset/rdet_dota_examples&quot;,
+  &quot;dataset_path&quot;: &quot;rdet_dota_examples&quot;,
   &quot;show_type&quot;: &quot;image&quot;,
   &quot;dataset_type&quot;: &quot;COCODetDataset&quot;
 }

+ 197 - 7
docs/module_usage/tutorials/cv_modules/vehicle_attribute_recognition.md

@@ -40,18 +40,208 @@ comments: true
 
 完成 wheel 包的安装后,几行代码即可完成车辆属性识别模块的推理,可以任意切换该模块下的模型,您也可以将车辆属性识别的模块中的模型推理集成到您的项目中。运行以下代码前,请您下载[示例图片](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/vehicle_attribute_007.jpg)到本地。
 
-```bash
+```python
 from paddlex import create_model
-model = create_model("PP-LCNet_x1_0_vehicle_attribute")
+model = create_model(model_name="PP-LCNet_x1_0_vehicle_attribute")
 output = model.predict("vehicle_attribute_007.jpg", batch_size=1)
 for res in output:
     res.print(json_format=False)
     res.save_to_img("./output/")
     res.save_to_json("./output/res.json")
 ```
-关于更多 PaddleX 的单模型推理的 API 的使用方法,可以参考[PaddleX单模型Python脚本使用说明](../../instructions/model_python_API.md)。
 
-<b>备注</b>:其中 `output` 的值索引为0-9表示颜色属性,对应的颜色分别是:yellow(黄色), orange(橙色), green(绿色), gray(灰色), red(红色), blue(蓝色), white(白色), golden(金色), brown(棕色), black(黑色);索引为10-18表示车型属性,对应的车型分别是sedan(轿车), suv(越野车), van(面包车), hatchback(掀背车), mpv(多用途汽车), pickup(皮卡车), bus(公共汽车), truck(卡车), estate(旅行车)。
+运行后,得到的结果为:
+```bash
+{'res': {'input_path': 'vehicle_attribute_007.jpg', 'page_index': None, 'class_ids': array([ 0, 13]), 'scores': array([0.98929, 0.97349]), 'label_names': ['yellow(黄色)', 'hatchback(掀背车)']}}
+```
+
+运行结果参数含义如下:
+- `input_path`:表示输入待预测多类别图像的路径
+- `page_index`:如果输入是PDF文件,则表示当前是PDF的第几页,否则为 `None`
+- `class_ids`:表示车辆属性图像的预测标签ID
+- `scores`:表示车辆属性图像的预测标签置信度
+- `label_names`:表示车辆属性图像的预测标签名称
+
+可视化图片如下:
+
+<img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/refs/heads/main/images/modules/vehicle_attri/vehicle_attribute_007_res.jpg">
+
+相关方法、参数等说明如下:
+
+* `create_model`实例化车辆属性识别模型(此处以`PP-LCNet_x1_0_vehicle_attribute`为例),具体说明如下:
+<table>
+<thead>
+<tr>
+<th>参数</th>
+<th>参数说明</th>
+<th>参数类型</th>
+<th>可选项</th>
+<th>默认值</th>
+</tr>
+</thead>
+<tr>
+<td><code>model_name</code></td>
+<td>模型名称</td>
+<td><code>str</code></td>
+<td>无</td>
+<td><code>PP-LCNet_x1_0_vehicle_attribute</code></td>
+</tr>
+<tr>
+<td><code>model_dir</code></td>
+<td>模型存储路径</td>
+<td><code>str</code></td>
+<td>无</td>
+<td>无</td>
+</tr>
+<tr>
+<td><code>threshold</code></td>
+<td>车辆属性识别阈值</td>
+<td><code>float/list/dict</code></td>
+<td><li><b>float类型变量</b>,任意[0-1]之间浮点数:<code>0.5</code></li>
+<li><b>list类型变量</b>,由多个[0-1]之间浮点数组成的列表:<code>[0.5,0.5,...]</code></li>
+<li><b>dict类型变量</b>,指定不同类别使用不同的阈值,其中"default"为必须包含的键:<code>{"default":0.5,1:0.1,...}</code>
+</li>
+</td>
+<td>0.5</td>
+</tr>
+</table>
+
+* 其中,`model_name` 必须指定,指定 `model_name` 后,默认使用 PaddleX 内置的模型参数,在此基础上,指定 `model_dir` 时,使用用户自定义的模型。
+
+* 其中,`threshold` 参数用于设置多标签分类的阈值,默认为0.7。当设置为浮点数时,表示所有类别均使用该阈值;当设置为列表时,表示不同类别使用不同的阈值,此时需保持列表长度与类别数量一致;当设置为字典时,`default` 为必须包含的键, 表示所有类别的默认阈值,其它类别使用各自的阈值。例如:{"default":0.5,1:0.1}。
+
+* 调用多标签分类模型的 `predict()` 方法进行推理预测,`predict()` 方法参数有 `input` , `batch_size` 和  `threshold`,具体说明如下:
+
+<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</code>/<code>str</code>/<code>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/multilabel_classification_005.png">示例</a></li>
+  <li><b>本地目录</b>,该目录下需包含待预测数据文件,如本地路径:<code>/root/data/</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></li>
+</ul>
+</td>
+<td>无</td>
+</tr>
+<tr>
+<td><code>batch_size</code></td>
+<td>批大小</td>
+<td><code>int</code></td>
+<td>任意整数</td>
+<td>1</td>
+</tr>
+<tr>
+<td><code>threshold</code></td>
+<td>车辆属性识别阈值</td>
+<td><code>float/list/dict</code></td>
+<td><li><b>float类型变量</b>,任意[0-1]之间浮点数:<code>0.5</code></li>
+<li><b>list类型变量</b>,由多个[0-1]之间浮点数组成的列表:<code>[0.5,0.5,...]</code></li>
+<li><b>dict类型变量</b>,指定不同类别使用不同的阈值,其中"default"为必须包含的键:<code>{"default":0.5,1:0.1,...}</code>
+</li>
+</td>
+<td>0.5</td>
+</tr>
+</table>
+
+* 对预测结果进行处理,每个样本的预测结果均为对应的Result对象,且支持打印、保存为图片、保存为`json`文件的操作:
+
+<table>
+<thead>
+<tr>
+<th>方法</th>
+<th>方法说明</th>
+<th>参数</th>
+<th>参数类型</th>
+<th>参数说明</th>
+<th>默认值</th>
+</tr>
+</thead>
+<tr>
+<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><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 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><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>
+</table>
+
+* 此外,也支持通过属性获取带结果的可视化图像和预测结果,具体如下:
+
+<table>
+<thead>
+<tr>
+<th>属性</th>
+<th>属性说明</th>
+</tr>
+</thead>
+<tr>
+<td rowspan = "1"><code>json</code></td>
+<td rowspan = "1">获取预测的<code>json</code>格式的结果</td>
+</tr>
+<tr>
+<td rowspan = "1"><code>img</code></td>
+<td rowspan = "1">获取格式为<code>dict</code>的可视化图像</td>
+</tr>
+
+</table>
+
+
+关于更多 PaddleX 的单模型推理的 API 的使用方法,可以参考的使用方法,可以参考[PaddleX单模型Python脚本使用说明](../../instructions/model_python_API.md)。
 
 ## 四、二次开发
 如果你追求更高精度的现有模型,可以使用 PaddleX 的二次开发能力,开发更好的车辆属性识别模型。在使用 PaddleX 开发车辆属性识别模型之前,请务必安装 PaddleX 的 分类 相关模型训练插件,安装过程可以参考[PaddleX本地安装教程](../../../installation/installation.md)。
@@ -114,7 +304,7 @@ python main.py -c paddlex/configs/modules/vehicle_attribute_recognition/PP-LCNet
   "analysis": {
     "histogram": "check_dataset/histogram.png"
   },
-  "dataset_path": "./dataset/vehicle_attribute_examples",
+  "dataset_path": "vehicle_attribute_examples",
   "show_type": "image",
   "dataset_type": "MLClsDataset"
 }
@@ -239,14 +429,14 @@ python main.py -c paddlex/configs/modules/vehicle_attribute_recognition/PP-LCNet
 其他相关参数均可通过修改`.yaml`配置文件中的`Global`和`Predict`下的字段来进行设置,详细请参考[PaddleX通用模型配置文件参数说明](../../instructions/config_parameters_common.md)。
 
 #### 4.4.2 模型集成
-模型可以直接集成到您自己的项目中。您产出的权重可以直接集成到行人属性识别模块中,可以参考[快速集成](#三快速集成)的 Python 示例代码,只需要将模型替换为你训练的到的模型路径即可。
+模型可以直接集成到您自己的项目中。您产出的权重可以直接集成到车辆属性识别模块中,可以参考[快速集成](#三快速集成)的 Python 示例代码,只需要将模型替换为你训练的到的模型路径即可。
 
 #### 4.4.2 模型集成
 模型可以直接集成到 PaddleX 产线中,也可以直接集成到您自己的项目中。
 
 1.<b>产线集成</b>
 
-车辆属性识别模块可以集成的PaddleX产线有[通用图像多标签分类产线](../../../pipeline_usage/tutorials/cv_pipelines/image_multi_label_classification.md),只需要替换模型路径即可完成相关产线的车辆属性识别模块的模型更新。在产线集成中,你可以使用高性能部署和服务化部署来部署你得到的模型。
+车辆属性识别模块可以集成的PaddleX产线有[车辆属性识别产线](../../../pipeline_usage/tutorials/cv_pipelines/vehicle_attribute_recognition.md),只需要替换模型路径即可完成相关产线的车辆属性识别模块的模型更新。在产线集成中,你可以使用高性能部署和服务化部署来部署你得到的模型。
 
 2.<b>模块集成</b>
 

+ 21 - 6
docs/pipeline_usage/tutorials/cv_pipelines/image_classification.md

@@ -5,7 +5,7 @@ comments: true
 # 通用图像分类产线使用教程
 
 ## 1. 通用图像分类产线介绍
-图像分类是一种将图像分配到预定义类别的技术。它广泛应用于物体识别、场景理解和自动标注等领域。图像分类可以识别各种物体,如动物、植物、交通标志等,并根据其特征将其归类。通过使用深度学习模型,图像分类能够自动提取图像特征并进行准确分类。
+图像分类是一种将图像分配到预定义类别的技术。它广泛应用于物体识别、场景理解和自动标注等领域。图像分类可以识别各种物体,如动物、植物、交通标志等,并根据其特征将其归类。通过使用深度学习模型,图像分类能够自动提取图像特征并进行准确分类。本产线同时提供了灵活的服务化部署方式,支持在多种硬件上使用多种编程语言调用。不仅如此,本产线也提供了二次开发的能力,您可以基于本产线在您自己的数据集上训练调优,训练后的模型也可以无缝集成。
 
 <img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/main/images/pipelines/image_classification/01.png"/>
 <b>通用图像分类产线中包含了图像分类模块,如您更考虑模型精度,请选择精度较高的模型,如您更考虑模型推理速度,请选择推理速度较快的模型,如您更考虑模型存储大小,请选择存储大小较小的模型</b>。
@@ -17,6 +17,7 @@ comments: true
 <th>GPU推理耗时(ms)<br/>[常规模式 / 高性能模式]</th>
 <th>CPU推理耗时(ms)<br/>[常规模式 / 高性能模式]</th>
 <th>模型存储大小 (M)</th>
+<th>介绍</th>
 </tr>
 <tr>
 <td>CLIP_vit_base_patch16_224</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0rc0/CLIP_vit_base_patch16_224_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/CLIP_vit_base_patch16_224_pretrained.pdparams">训练模型</a></td>
@@ -24,6 +25,7 @@ comments: true
 <td>12.84 / 2.82</td>
 <td>60.52 / 60.52</td>
 <td>306.5 M</td>
+<td>视觉大模型 CLIP 在 ImageNet1k 数据集 fine-tune 的通用图像分类高精度模型</td>
 </tr>
 <tr>
 <td>MobileNetV3_small_x1_0</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0rc0/MobileNetV3_small_x1_0_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/MobileNetV3_small_x1_0_pretrained.pdparams">训练模型</a></td>
@@ -31,6 +33,7 @@ comments: true
 <td>3.76 / 0.53</td>
 <td>5.11 / 1.43</td>
 <td>10.5 M</td>
+<td>MobileNetV3 是 Google 于 2019 年提出的一种基于 NAS 的新的轻量级网络,为了进一步提升效果,将 relu 和 sigmoid 激活函数分别替换为 hard_swish 与 hard_sigmoid 激活函数,同时引入了一些专门减小网络计算量的改进策略。</td>
 </tr>
 <tr>
 <td>PP-HGNet_small</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0rc0/PP-HGNet_small_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/PP-HGNet_small_pretrained.pdparams">训练模型</a></td>
@@ -38,6 +41,7 @@ comments: true
 <td>5.12 / 1.73</td>
 <td>25.01 / 25.01</td>
 <td>86.5 M</td>
+<td>PP-HGNet(High Performance GPU Net) 是百度飞桨视觉团队自研的更适用于 GPU 平台的高性能骨干网络,该网络在 VOVNet 的基础上使用了可学习的下采样层(LDS Layer),融合了 ResNet_vd、PPHGNet 等模型的优点,该模型在 GPU 平台上与其他 SOTA 模型在相同的速度下有着更高的精度。</td>
 </tr>
 <tr>
 <td>PP-HGNetV2-B0</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0rc0/PP-HGNetV2-B0_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/PP-HGNetV2-B0_pretrained.pdparams">训练模型</a></td>
@@ -45,6 +49,7 @@ comments: true
 <td>3.83 / 0.57</td>
 <td>9.95 / 2.37</td>
 <td>21.4 M</td>
+<td rowspan="3">PP-HGNetV2(High Performance GPU Network V2) 是百度飞桨视觉团队自研的 PP-HGNet 的下一代版本,其在 PP-HGNet 的基础上,做了进一步优化和改进,最终在 NVIDIA GPU 设备上,将 "Accuracy-Latency Balance" 做到了极致,精度大幅超过了其他同样推理速度的模型。</td>
 </tr>
 <tr>
 <td>PP-HGNetV2-B4</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0rc0/PP-HGNetV2-B4_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/PP-HGNetV2-B4_pretrained.pdparams">训练模型</a></td>
@@ -66,6 +71,7 @@ comments: true
 <td>2.35 / 0.47</td>
 <td>4.03 / 1.35</td>
 <td>10.5 M</td>
+<td>PP-LCNet_x1_0针对 Intel CPU 设备以及其加速库 MKLDNN 设计了特定的骨干网络,比起其他的轻量级的 SOTA 模型,该骨干网络可以在不增加推理时间的情况下,进一步提升模型的性能,最终大幅度超越现有的 SOTA 模型</td>
 </tr>
 <tr>
 <td>ResNet50</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0rc0/ResNet50_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/ResNet50_pretrained.pdparams">训练模型</a></td>
@@ -73,6 +79,7 @@ comments: true
 <td>6.44 / 1.16</td>
 <td>15.04 / 11.63</td>
 <td>90.8 M</td>
+<td>ResNet 系列模型是在 2015 年提出的,一举在 ILSVRC2015 比赛中取得冠军,top5 错误率为 3.57%。该网络创新性的提出了残差结构,通过堆叠多个残差结构从而构建了 ResNet 网络。</td>
 </tr>
 <tr>
 <td>SwinTransformer_tiny_patch4_window7_224</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0rc0/SwinTransformer_tiny_patch4_window7_224_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SwinTransformer_tiny_patch4_window7_224_pretrained.pdparams">训练模型</a></td>
@@ -80,6 +87,7 @@ comments: true
 <td>6.66 / 2.15</td>
 <td>60.45 / 60.45</td>
 <td>100.1 M</td>
+<td>SwinTransformer 是一种新的视觉 Transformer 网络,可以用作计算机视觉领域的通用骨干网路。SwinTransformer 由移动窗口(shifted windows)表示的层次 Transformer 结构组成。移动窗口将自注意计算限制在非重叠的局部窗口上,同时允许跨窗口连接,从而提高了网络性能。</td>
 </tr>
 </table>
 
@@ -691,7 +699,7 @@ PaddleX 所提供的模型产线均可以快速体验效果,你可以在星河
 一行命令即可快速体验图像分类产线效果,使用 [测试文件](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_image_classification_001.jpg),并将 `--input` 替换为本地路径,进行预测
 
 ```bash
-paddlex --pipeline image_classification --input general_image_classification_001.jpg --device gpu:0
+paddlex --pipeline image_classification --input general_image_classification_001.jpg --device gpu:0 --save_path ./output/
 ```
 相关的参数说明可以参考[2.2.2 Python脚本方式集成](#222-python脚本方式集成)中的参数说明。
 
@@ -743,6 +751,12 @@ for res in output:
 <td>None</td>
 </tr>
 <tr>
+<td><code>config</code></td>
+<td>产线具体的配置信息(如果和<code>pipeline</code>同时设置,优先级高于<code>pipeline</code>,且要求产线名和<code>pipeline</code>一致)。</td>
+<td><code>dict[str, Any]</code></td>
+<td><code>None</code></td>
+</tr>
+<tr>
 <td><code>device</code></td>
 <td>产线推理设备。支持指定GPU具体卡号,如“gpu:0”,其他硬件具体卡号,如“npu:0”,CPU如“cpu”。</td>
 <td><code>str</code></td>
@@ -877,11 +891,12 @@ for res in output:
 - 调用`print()` 方法会将结果打印到终端,打印到终端的内容解释如下:
 
     - `input_path`: `(str)` 待预测图像的输入路径。
+    - `page_index`: `(Union[int, None])` 如果输入是PDF文件,则表示当前是PDF的第几页,否则为 `None`
     - `class_ids`: `(List[numpy.ndarray])` 表示预测结果的类别id。
     - `scores`: `(List[numpy.ndarray])` 表示预测结果的置信度。
     - `label_names`: `(List[str])` 表示预测结果的类别名称。
 
-- 调用`save_to_json()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}.json`,如果指定为文件,则直接保存到该文件中。由于json文件不支持保存numpy数组,因此会将其中的`numpy.array`类型转换为列表形式。
+- 调用`save_to_json()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}_res.json`,如果指定为文件,则直接保存到该文件中。由于json文件不支持保存numpy数组,因此会将其中的`numpy.array`类型转换为列表形式。
 - 调用`save_to_img()` 方法会将可视化结果保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}_res.{your_img_extension}`,如果指定为文件,则直接保存到该文件中。(产线通常包含较多结果图片,不建议直接指定为具体的文件路径,否则多张图会被覆盖,仅保留最后一张图)
 
 * 此外,也支持通过属性获取带结果的可视化图像和预测结果,具体如下:
@@ -912,7 +927,7 @@ for res in output:
 paddlex --get_pipeline_config image_classification --save_path ./my_path
 ```
 
-若您获取了配置文件,即可对OCR产线各项配置进行自定义,只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为产线配置文件路径即可。示例如下:
+若您获取了配置文件,即可对通用图像分类产线各项配置进行自定义,只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为产线配置文件路径即可。示例如下:
 
 ```python
 from paddlex import create_pipeline
@@ -1492,11 +1507,11 @@ SubModules:
   ImageClassification:
     module_name: image_classification
     model_name: PP-LCNet_x0_5
-    model_dir: null
+    model_dir: null # 替换为微调后的图像分类模型权重路径
     batch_size: 4
     topk: 5
 ```
-随后, 参考本地体验中的命令行方式或 Python 脚本方式,加载修改后的产线配置文件即可。
+随后, 参考[2.2 本地体验](#22-本地体验)中的命令行方式或Python脚本方式,加载修改后的产线配置文件即可。
 
 ##  5. 多硬件支持
 PaddleX 支持英伟达 GPU、昆仑芯 XPU、昇腾 NPU和寒武纪 MLU 等多种主流硬件设备,<b>仅需修改 `--device`参数</b>即可完成不同硬件之间的无缝切换。

+ 15 - 8
docs/pipeline_usage/tutorials/cv_pipelines/pedestrian_attribute_recognition.md

@@ -5,7 +5,7 @@ comments: true
 # 行人属性识别产线使用教程
 
 ## 1. 行人属性识别产线介绍
-行人属性识别是计算机视觉系统中的关键功能,用于在图像或视频中定位并标记行人的特定特征,如性别、年龄、衣物颜色和款式等。该任务不仅要求准确检测出行人,还需识别每个行人的详细属性信息。行人属性识别产线是定位并识别行人属性的端到端串联系统,广泛应用于智慧城市和安防监控等领域,可显著提升系统的智能化水平和管理效率。
+行人属性识别是计算机视觉系统中的关键功能,用于在图像或视频中定位并标记行人的特定特征,如性别、年龄、衣物颜色和款式等。该任务不仅要求准确检测出行人,还需识别每个行人的详细属性信息。行人属性识别产线是定位并识别行人属性的端到端串联系统,广泛应用于智慧城市和安防监控等领域,可显著提升系统的智能化水平和管理效率。本产线同时提供了灵活的服务化部署方式,支持在多种硬件上使用多种编程语言调用。不仅如此,本产线也提供了二次开发的能力,您可以基于本产线在您自己的数据集上训练调优,训练后的模型也可以无缝集成。
 
 <img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/refs/heads/main/images/pipelines/pedestrian_attribute_recognition/pedestrian_attribute.png"/>
 <b>行人属性识别产线中包含了行人检测模块和行人属性识别模块</b>,每个模块中包含了若干模型,具体使用哪些模型,您可以根据下边的 benchmark 数据来选择。<b>如您更考虑模型精度,请选择精度较高的模型,如您更考虑模型推理速度,请选择推理速度较快的模型,如您更考虑模型存储大小,请选择存储大小较小的模型</b>。
@@ -79,7 +79,7 @@ PaddleX 所提供的模型产线可以在本地使用命令行或 Python 体验
 一行命令即可快速体验行人属性识别产线效果,使用 [测试文件](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/pedestrian_attribute_002.jpg),并将 `--input` 替换为本地路径,进行预测
 
 ```bash
-paddlex --pipeline pedestrian_attribute_recognition --input pedestrian_attribute_002.jpg --device gpu:0
+paddlex --pipeline pedestrian_attribute_recognition --input pedestrian_attribute_002.jpg --device gpu:0 --save_path ./output/
 ```
 相关的参数说明可以参考[2.2.2 Python脚本方式集成](#222-python脚本方式集成)中的参数说明。
 
@@ -132,6 +132,12 @@ for res in output:
 <td>None</td>
 </tr>
 <tr>
+<td><code>config</code></td>
+<td>产线具体的配置信息(如果和<code>pipeline</code>同时设置,优先级高于<code>pipeline</code>,且要求产线名和<code>pipeline</code>一致)。</td>
+<td><code>dict[str, Any]</code></td>
+<td><code>None</code></td>
+</tr>
+<tr>
 <td><code>device</code></td>
 <td>产线推理设备。支持指定GPU具体卡号,如“gpu:0”,其他硬件具体卡号,如“npu:0”,CPU如“cpu”。</td>
 <td><code>str</code></td>
@@ -280,12 +286,13 @@ for res in output:
 - 调用`print()` 方法会将结果打印到终端,打印到终端的内容解释如下:
 
     - `input_path`: `(str)` 待预测图像的输入路径。
+    - `page_index`: `(Union[int, None])` 如果输入是PDF文件,则表示当前是PDF的第几页,否则为 `None`。
     - `boxes`: `(List[Dict])` 表示预测结果的类别id。
     - `labels`: `(List[str])` 表示预测结果的类别名称。
     - `cls_scores`: `(List[numpy.ndarray])` 表示属性预测结果的置信度。
     - `det_scores`: `(float)` 表示行人检测框的置信度。
 
-- 调用`save_to_json()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}.json`,如果指定为文件,则直接保存到该文件中。由于json文件不支持保存numpy数组,因此会将其中的`numpy.array`类型转换为列表形式。
+- 调用`save_to_json()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}_res.json`,如果指定为文件,则直接保存到该文件中。由于json文件不支持保存numpy数组,因此会将其中的`numpy.array`类型转换为列表形式。
 - 调用`save_to_img()` 方法会将可视化结果保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}_res.{your_img_extension}`,如果指定为文件,则直接保存到该文件中。(产线通常包含较多结果图片,不建议直接指定为具体的文件路径,否则多张图会被覆盖,仅保留最后一张图)
 
 * 此外,也支持通过属性获取带结果的可视化图像和预测结果,具体如下:
@@ -316,7 +323,7 @@ for res in output:
 paddlex --get_pipeline_config pedestrian_attribute_recognition --save_path ./my_path
 ```
 
-若您获取了配置文件,即可对OCR产线各项配置进行自定义,只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为产线配置文件路径即可。示例如下:
+若您获取了配置文件,即可对行人属性识别产线各项配置进行自定义,只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为产线配置文件路径即可。示例如下:
 
 ```python
 from paddlex import create_pipeline
@@ -604,17 +611,17 @@ SubModules:
   Detection:
     module_name: object_detection
     model_name: PP-YOLOE-L_human
-    model_dir: null
+    model_dir: null # 替换为微调后的行人检测模型权重路径
     batch_size: 1
     threshold: 0.5
   Classification:
     module_name: multilabel_classification
     model_name: PP-LCNet_x1_0_pedestrian_attribute
-    model_dir: null
+    model_dir: null # 替换为微调后的行人属性识别模型权重路径
     batch_size: 1
     threshold: 0.7
 ```
-随后, 参考本地体验中的命令行方式或 Python 脚本方式,加载修改后的产线配置文件即可。
+随后, 参考[2.2 本地体验](#22-本地体验)中的命令行方式或Python脚本方式,加载修改后的产线配置文件即可。
 
 ##  5. 多硬件支持
 PaddleX 支持英伟达 GPU、昆仑芯 XPU、昇腾 NPU和寒武纪 MLU 等多种主流硬件设备,<b>仅需修改 `--device`参数</b>即可完成不同硬件之间的无缝切换。
@@ -629,4 +636,4 @@ paddlex --pipeline pedestrian_attribute_recognition \
 
 当然,您也可以在 Python 脚本中 `create_pipeline()` 时或者 `predict()` 时指定硬件设备。
 
-若您想在更多种类的硬件上使用通用OCR产线,请参考[PaddleX多硬件使用指南](../../../other_devices_support/multi_devices_use_guide.md)。
+若您想在更多种类的硬件上使用行人属性识别产线,请参考[PaddleX多硬件使用指南](../../../other_devices_support/multi_devices_use_guide.md)。

+ 11 - 5
docs/pipeline_usage/tutorials/cv_pipelines/vehicle_attribute_recognition.md

@@ -5,7 +5,7 @@ comments: true
 # 车辆属性识别产线使用教程
 
 ## 1. 车辆属性识别产线介绍
-车辆属性识别是计算机视觉系统中的重要组成部分,其主要任务是在图像或视频中定位并标记出车辆的特定属性,如车辆类型、颜色、车牌号等。该任务不仅要求准确检测出车辆,还需识别每辆车的详细属性信息。车辆属性识别产线是定位并识别车辆属性的端到端串联系统,广泛应用于交通管理、智能停车、安防监控、自动驾驶等领域,显著提升了系统效率和智能化水平,并推动了相关行业的发展与创新。
+车辆属性识别是计算机视觉系统中的重要组成部分,其主要任务是在图像或视频中定位并标记出车辆的特定属性,如车辆类型、颜色、车牌号等。该任务不仅要求准确检测出车辆,还需识别每辆车的详细属性信息。车辆属性识别产线是定位并识别车辆属性的端到端串联系统,广泛应用于交通管理、智能停车、安防监控、自动驾驶等领域,显著提升了系统效率和智能化水平,并推动了相关行业的发展与创新。本产线同时提供了灵活的服务化部署方式,支持在多种硬件上使用多种编程语言调用。不仅如此,本产线也提供了二次开发的能力,您可以基于本产线在您自己的数据集上训练调优,训练后的模型也可以无缝集成。
 
 <img src="https://raw.githubusercontent.com/cuicheng01/PaddleX_doc_images/refs/heads/main/images/pipelines/vehicle_attribute_recognition/vehicle_attribute_1.jpg">
 
@@ -78,7 +78,7 @@ PaddleX 所提供的模型产线可以在本地使用命令行或 Python 体验
 一行命令即可快速体验车辆属性识别产线效果,使用 [测试文件](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/vehicle_attribute_002.jpg),并将 `--input` 替换为本地路径,进行预测
 
 ```bash
-paddlex --pipeline vehicle_attribute_recognition --input vehicle_attribute_002.jpg --device gpu:0
+paddlex --pipeline vehicle_attribute_recognition --input vehicle_attribute_002.jpg --device gpu:0 --save_path ./output/
 ```
 相关的参数说明可以参考[2.2.2 Python脚本方式集成](#222-python脚本方式集成)中的参数说明。
 
@@ -131,6 +131,12 @@ for res in output:
 <td>None</td>
 </tr>
 <tr>
+<td><code>config</code></td>
+<td>产线具体的配置信息(如果和<code>pipeline</code>同时设置,优先级高于<code>pipeline</code>,且要求产线名和<code>pipeline</code>一致)。</td>
+<td><code>dict[str, Any]</code></td>
+<td><code>None</code></td>
+</tr>
+<tr>
 <td><code>device</code></td>
 <td>产线推理设备。支持指定GPU具体卡号,如“gpu:0”,其他硬件具体卡号,如“npu:0”,CPU如“cpu”。</td>
 <td><code>str</code></td>
@@ -284,7 +290,7 @@ for res in output:
     - `cls_scores`: `(List[numpy.ndarray])` 表示属性预测结果的置信度。
     - `det_scores`: `(float)` 表示车辆检测框的置信度。
 
-- 调用`save_to_json()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}.json`,如果指定为文件,则直接保存到该文件中。由于json文件不支持保存numpy数组,因此会将其中的`numpy.array`类型转换为列表形式。
+- 调用`save_to_json()` 方法会将上述内容保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}_res.json`,如果指定为文件,则直接保存到该文件中。由于json文件不支持保存numpy数组,因此会将其中的`numpy.array`类型转换为列表形式。
 - 调用`save_to_img()` 方法会将可视化结果保存到指定的`save_path`中,如果指定为目录,则保存的路径为`save_path/{your_img_basename}_res.{your_img_extension}`,如果指定为文件,则直接保存到该文件中。(产线通常包含较多结果图片,不建议直接指定为具体的文件路径,否则多张图会被覆盖,仅保留最后一张图)
 
 * 此外,也支持通过属性获取带结果的可视化图像和预测结果,具体如下:
@@ -315,7 +321,7 @@ for res in output:
 paddlex --get_pipeline_config vehicle_attribute_recognition --save_path ./my_path
 ```
 
-若您获取了配置文件,即可对OCR产线各项配置进行自定义,只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为产线配置文件路径即可。示例如下:
+若您获取了配置文件,即可对车辆属性识别产线各项配置进行自定义,只需要修改 `create_pipeline` 方法中的 `pipeline` 参数值为产线配置文件路径即可。示例如下:
 
 ```python
 from paddlex import create_pipeline
@@ -633,4 +639,4 @@ paddlex --pipeline vehicle_attribute_recognition \
 
 当然,您也可以在 Python 脚本中 `create_pipeline()` 时或者 `predict()` 时指定硬件设备。
 
-若您想在更多种类的硬件上使用通用OCR产线,请参考[PaddleX多硬件使用指南](../../../other_devices_support/multi_devices_use_guide.md)。
+若您想在更多种类的硬件上使用车辆属性识别产线,请参考[PaddleX多硬件使用指南](../../../other_devices_support/multi_devices_use_guide.md)。