Ver código fonte

Add ovd ovs pipeline (#2852)

* add fast infer for semantic seg; by zzl

* fix sth

* fix sth oh seg

* add platform judge

* add platform judge

* Re-trigger CI

* add inst seg; fix sth

* fix sth

* add docs

* fix sth

* add param for seg

* fix sth

* adapt seg rst to lower version of pillow

* fix sth

* Trigger CI

* fix pil

* fix pil

* add GDINO; add SAM

* Trigger CI

* add pipelines of seg, inst seg, sod, rod

* fix sth

* fix sth

* add ovd & ovs pipeline; add modules for ovd & ovs; fix sth

* add docs

* fix sth
Zhang Zelun 10 meses atrás
pai
commit
27e98c1ebe
31 arquivos alterados com 2362 adições e 36 exclusões
  1. 191 4
      docs/module_usage/tutorials/cv_modules/human_detection.md
  2. 195 2
      docs/module_usage/tutorials/cv_modules/instance_segmentation.md
  3. 191 4
      docs/module_usage/tutorials/cv_modules/mainbody_detection.md
  4. 249 0
      docs/module_usage/tutorials/cv_modules/open_vocabulary_detection.md
  5. 244 0
      docs/module_usage/tutorials/cv_modules/open_vocabulary_segmentation.md
  6. 205 3
      docs/module_usage/tutorials/cv_modules/rotated_object_detection.md
  7. 194 6
      docs/module_usage/tutorials/cv_modules/semantic_segmentation.md
  8. 193 4
      docs/module_usage/tutorials/cv_modules/small_object_detection.md
  9. 192 4
      docs/module_usage/tutorials/cv_modules/vehicle_detection.md
  10. 12 0
      paddlex/configs/pipelines/open_vocabulary_detection.yaml
  11. 13 0
      paddlex/configs/pipelines/open_vocabulary_segmentation.yaml
  12. 17 7
      paddlex/inference/models_new/open_vocabulary_segmentation/results/sam_result.py
  13. 4 2
      paddlex/inference/pipelines_new/__init__.py
  14. 15 0
      paddlex/inference/pipelines_new/open_vocabulary_detection/__init__.py
  15. 74 0
      paddlex/inference/pipelines_new/open_vocabulary_detection/pipeline.py
  16. 15 0
      paddlex/inference/pipelines_new/open_vocabulary_segmentation/__init__.py
  17. 90 0
      paddlex/inference/pipelines_new/open_vocabulary_segmentation/pipeline.py
  18. 0 0
      paddlex/inference/pipelines_new/rotated_object_detection/__init__.py
  19. 0 0
      paddlex/inference/pipelines_new/rotated_object_detection/pipeline.py
  20. 0 0
      paddlex/inference/pipelines_new/small_object_detection/__init__.py
  21. 0 0
      paddlex/inference/pipelines_new/small_object_detection/pipeline.py
  22. 5 0
      paddlex/modules/open_vocabulary_detection/__init__.py
  23. 29 0
      paddlex/modules/open_vocabulary_detection/dataset_checker.py
  24. 29 0
      paddlex/modules/open_vocabulary_detection/evaluator.py
  25. 29 0
      paddlex/modules/open_vocabulary_detection/exportor.py
  26. 42 0
      paddlex/modules/open_vocabulary_detection/trainer.py
  27. 5 0
      paddlex/modules/open_vocabulary_segmentation/__init__.py
  28. 29 0
      paddlex/modules/open_vocabulary_segmentation/dataset_checker.py
  29. 29 0
      paddlex/modules/open_vocabulary_segmentation/evaluator.py
  30. 29 0
      paddlex/modules/open_vocabulary_segmentation/exportor.py
  31. 42 0
      paddlex/modules/open_vocabulary_segmentation/trainer.py

+ 191 - 4
docs/module_usage/tutorials/cv_modules/human_detection.md

@@ -48,18 +48,205 @@ comments: true
 
 ```python
 from paddlex import create_model
-
 model_name = "PP-YOLOE-S_human"
-
 model = create_model(model_name)
 output = model.predict("human_detection.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")
+```
 
+运行后,得到的结果为:
+```bash
+{'res': "{'input_path': 'human_detection.jpg', 'boxes': [{'cls_id': 0, 'label': 'pedestrian', 'score': 0.9085694551467896, 'coordinate': [259.53326, 342.86493, 307.43408, 464.22394]}, {'cls_id': 0, 'label': 'pedestrian', 'score': 0.8818504810333252, 'coordinate': [170.22249, 317.11432, 260.24777, 470.12704]}, {'cls_id': 0, 'label': 'pedestrian', 'score': 0.8622929453849792, 'coordinate': [402.17957, 345.1815, 458.4271, 479.91724]}, {'cls_id': 0, 'label': 'pedestrian', 'score': 0.8577917218208313, 'coordinate': [522.5973, 360.11118, 614.3201, 480]}, {'cls_id': 0, 'label': 'pedestrian', 'score': 0.8485967516899109, 'coordinate': [25.010237, 338.83722, 57.340042, 426.11932]}, ... ]}"}
 ```
+运行结果参数含义如下:
+- `input_path`: 表示输入待预测图像的路径
+- `boxes`: 每个预测出的object的信息
+  - `cls_id`: 类别ID
+  - `label`: 类别名称
+  - `score`: 预测得分
+  - `coordinate`: 预测框的坐标,格式为<code>[xmin, ymin, xmax, ymax]</code>
+
+可视化图片如下:
+
+<img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/human_detection/human_detection_res.jpg">
+
+
+相关方法、参数等说明如下:
+
+* `create_model`实例化行人检测模型(此处以`PP-YOLOE-S_human`为例),具体说明如下:
+<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>无</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>低分object过滤阈值</td>
+<td><code>float/None/dict</code></td>
+<td>无</td>
+<td>None</td>
+</tr>
+</table>
+
+* 其中,`model_name` 必须指定,指定 `model_name` 后,默认使用 PaddleX 内置的模型参数,在此基础上,指定 `model_dir` 时,使用用户自定义的模型。
+* `threshold`为低分object过滤阈值,默认为None,表示使用上一层设置,参数设置的优先级从高到低为:`predict参数传入 > create_model初始化传入 > yaml配置文件设置`。目前支持float和dict两种阈值设置方式:
+  * `float`, 对于所有的类别使用同一个阈值。
+  * `dict`, key为类别ID,value为阈值,对于不同的类别使用不同的阈值。行人检测为单类别检测,无需此设置。
+
+* 调用行人检测模型的 `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>dict</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_instance_segmentation_004.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>低分object过滤阈值</td>
+<td><code>float</code>/<code>dict</code>/<code>None</code></td>
+<td>
+<ul>
+  <li><b>None</b>,表示沿用上一层设置, 参数设置优先级从高到低为: <code>predict参数传入 > create_model初始化传入 > yaml配置文件设置</code></li>
+  <li><b>float</b>,如0.5,表示推理时使用0.5作为低分object过滤阈值</li>
+  <li><b>dict</b>,如<code>{0: 0.5, 1: 0.35}</code>,表示推理时对类别0使用0.5低分过滤阈值,对类别1使用0.35低分过滤阈值。行人检测为单类别检测,无需此设置。</li>
+</ul>
+</td>
+<td>None</td>
+</tr>
+</table>
+
+* 对预测结果进行处理,每个样本的预测结果均为`dict`类型,且支持打印、保存为图片、保存为`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)。
 

+ 195 - 2
docs/module_usage/tutorials/cv_modules/instance_segmentation.md

@@ -170,16 +170,209 @@ comments: true
 
 ```python
 from paddlex import create_model
-model = create_model("Mask-RT-DETR-L")
+model = create_model("PP-YOLOE_seg-S")
 output = model.predict("general_instance_segmentation_004.png", 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")
 ```
 
 关于更多 PaddleX 的单模型推理的 API 的使用方法,可以参考[PaddleX单模型Python脚本使用说明](../../instructions/model_python_API.md)。
 
+运行后,得到的结果为:
+```bash
+{'res': "{'input_path': 'general_instance_segmentation_004.png', 'boxes': [{'cls_id': 0, 'label': 'person', 'score': 0.8723232746124268, 'coordinate': [88.34339, 109.87673, 401.85236, 575.59576]}, {'cls_id': 0, 'label': 'person', 'score': 0.8711188435554504, 'coordinate': [325.114, 1.1152496, 644.10266, 575.359]}, {'cls_id': 0, 'label': 'person', 'score': 0.842758297920227, 'coordinate': [514.18964, 21.760618, 768, 576]}, {'cls_id': 0, 'label': 'person', 'score': 0.8332827091217041, 'coordinate': [0.105075076, 0, 189.23515, 575.9612]}], 'masks': '...'}"}
+```
+运行结果参数含义如下:
+- `input_path`: 表示输入待预测图像的路径
+- `boxes`: 每个预测出的object的信息
+  - `cls_id`: 类别ID
+  - `label`: 类别名称
+  - `score`: 预测得分
+  - `coordinate`: 预测框的坐标,格式为<code>[xmin, ymin, xmax, ymax]</code>
+- `pred`: 实例分割模型实际预测的mask,由于数据过大不便于直接print,所以此处用`...`替换,可以通过`res.save_to_img()`将预测结果保存为图片,通过`res.save_to_json()`将预测结果保存为json文件。
+
+可视化图片如下:
+
+<img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/instance_segmentation/general_instance_segmentation_004_res.png">
+
+
+相关方法、参数等说明如下:
+
+* `create_model`实例化通用实例分割模型(此处以`PP-YOLOE_seg-S`为例),具体说明如下:
+<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>无</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>低分object过滤阈值</td>
+<td><code>float/None</code></td>
+<td>无</td>
+<td>None</td>
+</tr>
+</table>
+
+* 其中,`model_name` 必须指定,指定 `model_name` 后,默认使用 PaddleX 内置的模型参数,在此基础上,指定 `model_dir` 时,使用用户自定义的模型。
+* `threshold`为低分object过滤阈值,默认为None,表示使用上一层设置,参数设置的优先级从高到低为:`predict参数传入 > create_model初始化传入 > yaml配置文件设置`。
+
+* 调用通用实例分割模型的 `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>dict</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_instance_segmentation_004.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>低分object过滤阈值</td>
+<td><code>float</code>/<code>None</code></td>
+<td>
+<ul>
+  <li><b>None</b>,表示沿用上一层设置, 参数设置优先级从高到低为: <code>predict参数传入 > create_model初始化传入 > yaml配置文件设置</code></li>
+  <li><b>float</b>,如0.5,表示推理时使用<code>0.5</code>作为低分object过滤阈值</li>
+</ul>
+</td>
+<td>None</td>
+</tr>
+</table>
+
+* 对预测结果进行处理,每个样本的预测结果均为`dict`类型,且支持打印、保存为图片、保存为`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)中的二次开发部分。
 

+ 191 - 4
docs/module_usage/tutorials/cv_modules/mainbody_detection.md

@@ -40,18 +40,205 @@ comments: true
 
 ```python
 from paddlex import create_model
-
 model_name = "PP-ShiTuV2_det"
-
 model = create_model(model_name)
 output = model.predict("general_object_detection_002.png", 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")
 ```
 
+运行后,得到的结果为:
+```bash
+{'res': "{'input_path': 'general_object_detection_002.png', 'boxes': [{'cls_id': 0, 'label': 'mainbody', 'score': 0.8161919713020325, 'coordinate': [76.07117, 272.83017, 329.5627, 519.48236]}, {'cls_id': 0, 'label': 'mainbody', 'score': 0.8071584701538086, 'coordinate': [662.7539, 92.804276, 874.7139, 308.21216]}, {'cls_id': 0, 'label': 'mainbody', 'score': 0.754974365234375, 'coordinate': [284.4833, 93.76895, 476.6789, 297.27588]}, {'cls_id': 0, 'label': 'mainbody', 'score': 0.6657832860946655, 'coordinate': [732.1591, 0, 1035.9547, 168.45923]}, {'cls_id': 0, 'label': 'mainbody', 'score': 0.614763081073761, 'coordinate': [763.9127, 280.74258, 925.48065, 439.444]}, ... ]}"}
+```
+运行结果参数含义如下:
+- `input_path`: 表示输入待预测图像的路径
+- `boxes`: 每个预测出的object的信息
+  - `cls_id`: 类别ID
+  - `label`: 类别名称
+  - `score`: 预测得分
+  - `coordinate`: 预测框的坐标,格式为<code>[xmin, ymin, xmax, ymax]</code>
+
+可视化图片如下:
+
+<img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/mainbody_detection/general_object_detection_002_res.png">
+
+
+相关方法、参数等说明如下:
+
+* `create_model`实例化主体检测模型(此处以`PP-ShiTuV2_det`为例),具体说明如下:
+<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>无</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>低分object过滤阈值</td>
+<td><code>float/None/dict</code></td>
+<td>无</td>
+<td>None</td>
+</tr>
+</table>
+
+* 其中,`model_name` 必须指定,指定 `model_name` 后,默认使用 PaddleX 内置的模型参数,在此基础上,指定 `model_dir` 时,使用用户自定义的模型。
+* `threshold`为低分object过滤阈值,默认为None,表示使用上一层设置,参数设置的优先级从高到低为:`predict参数传入 > create_model初始化传入 > yaml配置文件设置`。目前支持float和dict两种阈值设置方式:
+  * `float`, 对于所有的类别使用同一个阈值。
+  * `dict`, key为类别ID,value为阈值,对于不同的类别使用不同的阈值。主体检测为单类别检测,无需此设置。
+
+* 调用主体检测模型的 `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>dict</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_instance_segmentation_004.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>低分object过滤阈值</td>
+<td><code>float</code>/<code>dict</code>/<code>None</code></td>
+<td>
+<ul>
+  <li><b>None</b>,表示沿用上一层设置, 参数设置优先级从高到低为: <code>predict参数传入 > create_model初始化传入 > yaml配置文件设置</code></li>
+  <li><b>float</b>,如0.5,表示推理时使用<code>0.5</code>作为低分object过滤阈值</li>
+  <li><b>dict</b>,如<code>{0: 0.5, 1: 0.35}</code>,表示推理时对类别0使用0.5低分过滤阈值,对类别1使用0.35低分过滤阈值。主体检测为单类别检测,无需此设置。</li>
+</ul>
+</td>
+<td>None</td>
+</tr>
+</table>
+
+* 对预测结果进行处理,每个样本的预测结果均为`dict`类型,且支持打印、保存为图片、保存为`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)。
 
 ## 四、二次开发

+ 249 - 0
docs/module_usage/tutorials/cv_modules/open_vocabulary_detection.md

@@ -0,0 +1,249 @@
+---
+comments: true
+---
+
+# 开放词汇目标检测模块使用教程
+
+## 一、概述
+开放词汇目标检测是当前一种先进的目标检测技术,旨在突破传统目标检测的局限性。传统方法仅能识别预定义类别的物体,而开放词汇目标检测允许模型识别未在训练中出现的物体。通过结合自然语言处理技术,利用文本描述来定义新的类别,模型能够识别和定位这些新物体。这使得目标检测更具灵活性和泛化能力,具有重要的应用前景。
+
+## 二、支持模型列表
+
+
+<table>
+<tr>
+<th>模型</th><th>模型下载链接</th>
+<th>mAP(0.5:0.95)</th>
+<th>mAP(0.5)</th>
+<th>GPU推理耗时(ms)</th>
+<th>CPU推理耗时 (ms)</th>
+<th>模型存储大小(M)</th>
+<th>介绍</th>
+</tr>
+<tr>
+<td>GroundingDINO-T</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/GroundingDINO-T_infer.tar">推理模型</a></td>
+<td>49.4</td>
+<td>64.4</td>
+<td>253.72</td>
+<td>1807.4</td>
+<td>658.3</td>
+<td rowspan="3">基于O365,GoldG,Cap4M三个数据集训练的开放词汇目标目标检测模型。文本编码器采用Bert,视觉模型部份整体采用DINO,额外设计了一些跨模态融合模块,在开放词汇目标检测领域取得了较好的效果。</td>
+</tr>
+</table>
+
+<b>注:以上精度指标为 COCO val2017 验证集 mAP(0.5:0.95)。所有模型 GPU 推理耗时基于 NVIDIA Tesla T4 机器,精度类型为 FP32, CPU 推理速度基于 Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz,线程数为8,精度类型为 FP32</b>。
+
+
+## 三、快速集成
+> ❗ 在快速集成前,请先安装 PaddleX 的 wheel 包,详细请参考 [PaddleX本地安装教程](../../../installation/installation.md)
+
+完成whl包的安装后,几行代码即可完成开放词汇目标检测模块的推理,可以任意切换该模块下的模型,您也可以将开放词汇目标检测的模块中的模型推理集成到您的项目中。运行以下代码前,请您下载[示例图片](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/open_vocabulary_detection.jpg)到本地。
+
+```python
+from paddlex import create_model
+model = create_model('GroundingDINO-T')
+results = model.predict('open_vocabulary_detection.jpg', prompt = 'bus . walking man . rearview mirror .')
+for res in results:
+    res.print()
+    res.save_to_img(f"./output/")
+    res.save_to_json(f"./output/res.json")
+```
+
+运行后,得到的结果为:
+```bash
+{'res': "{'input_path': 'open_vocabulary_detection.jpg', 'boxes': [{'coordinate': [112.10542297363281, 117.93667602539062, 514.35693359375, 382.10150146484375], 'label': 'bus', 'score': 0.9348853230476379}, {'coordinate': [264.1828918457031, 162.6674346923828, 286.8844909667969, 201.86187744140625], 'label': 'rearview mirror', 'score': 0.6022508144378662}, {'coordinate': [606.1133422851562, 254.4973907470703, 622.56982421875, 293.7867126464844], 'label': 'walking man', 'score': 0.4384709894657135}, {'coordinate': [591.8192138671875, 260.2451171875, 607.3953247070312, 294.2210388183594], 'label': 'man', 'score': 0.3573091924190521}]}"}
+```
+运行结果参数含义如下:
+- `input_path`: 表示输入待预测图像的路径
+- `boxes`: 每个预测出的object的信息
+  - `label`: 类别名称
+  - `score`: 预测得分
+  - `coordinate`: 预测框的坐标,格式为<code>[xmin, ymin, xmax, ymax]</code>
+
+可视化图片如下:
+
+<img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/open_vocabulary_detection/open_vocabulary_detection_res.jpg">
+
+
+相关方法、参数等说明如下:
+
+* `create_model`实例化开放词汇目标检测模型(此处以`GroundingDINO-T`为例),具体说明如下:
+<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>无</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>thresholds</code></td>
+<td>模型使用的过滤阈值</td>
+<td><code>dict/None</code></td>
+<td>无</td>
+<td>None</td>
+</tr>
+</table>
+
+* 其中,`model_name` 必须指定,指定 `model_name` 后,默认使用 PaddleX 内置的模型参数,在此基础上,指定 `model_dir` 时,使用用户自定义的模型。
+* `thresholds`模型使用的过滤阈值,默认为None,表示使用上一层设置,参数设置的优先级从高到低为:`predict参数传入 > create_model初始化传入 > yaml配置文件设置`。
+  * GroundingDINO系列模型在推理时需要设置两个阈值,分别为box_threshold(默认0.3)和text_threshold(默认0.25),参数传入形式为`{"box_threshold": 0.3, "text_threshold": 0.25}`。
+
+* 调用开放词汇目标目标检测模型的 `predict()` 方法进行推理预测,`predict()` 方法参数有 `input` 、 `batch_size` 、 `thresholds` 和 `prompt`,具体说明如下:
+
+<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>dict</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/open_vocabulary_detection.jpg">示例</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>thresholds</code></td>
+<td>模型使用的过滤阈值</td>
+<td><code>dict</code>/<code>None</code></td>
+<td>
+<ul>
+  <li><b>None</b>,表示沿用上一层设置, 参数设置优先级从高到低为: <code>predict参数传入 > create_model初始化传入 > yaml配置文件设置</code></li>
+  <li><b>dict</b>,如<code>{"box_threshold": 0.3, "text_threshold": 0.25}</code>,表示推理时box_threshold设置为0.3,text_threshold设置为0.25</li>
+</ul>
+</td>
+<td>None</td>
+</tr>
+<tr>
+<td><code>prompt</code></td>
+<td>模型预测使用的提示词</td>
+<td><code>str</code></td>
+<td>任意字符串</td>
+<td>1</td>
+</tr>
+</table>
+
+* 对预测结果进行处理,每个样本的预测结果均为`dict`类型,且支持打印、保存为图片、保存为`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)。
+
+## 四、二次开发
+当前模块暂时不支持微调训练,仅支持推理集成。关于该模块的微调训练,计划在未来支持。

+ 244 - 0
docs/module_usage/tutorials/cv_modules/open_vocabulary_segmentation.md

@@ -0,0 +1,244 @@
+---
+comments: true
+---
+
+# 开放词汇分割模块使用教程
+
+## 一、概述
+开放词汇分割是一项图像分割任务,旨在根据文本描述、边框、关键点等除图像以外的信息作为提示,分割图像中对应的物体。它允许模型处理广泛的对象类别,而无需预定义的类别列表。这项技术结合了视觉和多模态技术,极大地提高了图像处理的灵活性和精度。开放词汇分割在计算机视觉领域具有重要应用价值,尤其在复杂场景下的对象分割任务中表现突出。
+
+## 二、支持模型列表
+
+
+<table>
+<tr>
+<th>模型</th><th>模型下载链接</th>
+<th>GPU推理耗时(ms)</th>
+<th>CPU推理耗时 (ms)</th>
+<th>模型存储大小(M)</th>
+<th>介绍</th>
+</tr>
+<tr>
+<td>SAM-H_box</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/SAM-H_box_infer.tar">推理模型</a></td>
+<td>144.9</td>
+<td>33920.7</td>
+<td>2433.7</td>
+<td rowspan="2">SAM(Segment Anything Model)是一种先进的图像分割模型,能够根据用户提供的简单提示(如点、框或文本)对图像中的任意对象进行分割。基于SA-1B数据集训练,有一千万的图像数据和十一亿掩码标注,在大部分场景均有较好的效果。</td>
+</tr>
+<tr>
+<td>SAM-H_point</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/SAM-H_point_infer.tar">推理模型</a></td>
+<td>144.9</td>
+<td>33920.7</td>
+<td>2433.7</td>
+</tr>
+</table>
+
+<b>注:所有模型 GPU 推理耗时基于 NVIDIA Tesla T4 机器,精度类型为 FP32, CPU 推理速度基于 Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz,线程数为8,精度类型为 FP32</b>。
+
+
+## 三、快速集成
+> ❗ 在快速集成前,请先安装 PaddleX 的 wheel 包,详细请参考 [PaddleX本地安装教程](../../../installation/installation.md)
+
+完成whl包的安装后,几行代码即可完成开放词汇分割模块的推理,可以任意切换该模块下的模型,您也可以将开放词汇分割的模块中的模型推理集成到您的项目中。运行以下代码前,请您下载[示例图片](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/open_vocabulary_segmentation.jpg)到本地。
+
+```python
+from paddlex import create_model
+model = create_model('SAM-H_box')
+results = model.predict(
+    "open_vocabulary_segmentation.jpg",
+    prompts = {
+        "box_prompt": [
+            [112.9239273071289,118.38755798339844,513.7587890625,382.0570068359375],
+            [4.597158432006836,263.5540771484375,92.20092010498047,336.5640869140625],
+            [592.3548583984375,260.8838806152344,607.1813354492188,294.2261962890625]
+        ],
+    }
+)
+for res in results:
+    res.print()
+    res.save_to_img(f"./output/")
+    res.save_to_json(f"./output/res.json")
+```
+
+运行后,得到的结果为:
+```bash
+{'res': "{'input_path': '000000004505.jpg', 'prompts': {'box_prompt': [[112.9239273071289, 118.38755798339844, 513.7587890625, 382.0570068359375], [4.597158432006836, 263.5540771484375, 92.20092010498047, 336.5640869140625], [592.3548583984375, 260.8838806152344, 607.1813354492188, 294.2261962890625]]}, 'masks': '...', 'mask_infos': [{'label': 'box_prompt', 'prompt': [112.9239273071289, 118.38755798339844, 513.7587890625, 382.0570068359375]}, {'label': 'box_prompt', 'prompt': [4.597158432006836, 263.5540771484375, 92.20092010498047, 336.5640869140625]}, {'label': 'box_prompt', 'prompt': [592.3548583984375, 260.8838806152344, 607.1813354492188, 294.2261962890625]}]}"}
+```
+运行结果参数含义如下:
+- `input_path`: 表示输入待预测图像的路径
+- `prompts`: 预测使用的原始prompt信息
+- `masks`: 实际预测的mask,由于数据过大不便于直接print,所以此处用`...`替换,可以通过`res.save_to_img()`将预测结果保存为图片,通过`res.save_to_json()`将预测结果保存为json文件。
+- `mask_infos`: 每个预测的mask对应的prompt信息
+  - `label`: 预测的mask对应的prompt类型
+  - `prompt`: 预测的mask对应的原始prompt输入
+
+可视化图片如下:
+
+<img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/open_vocabulary_segmentation/open_vocabulary_segmentation_res.jpg">
+
+
+相关方法、参数等说明如下:
+
+* `create_model`实例化开放词汇分割模型(此处以`SAM-H_box`为例),具体说明如下:
+<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>无</code></td>
+</tr>
+<tr>
+<td><code>model_dir</code></td>
+<td>模型存储路径</td>
+<td><code>str</code></td>
+<td>无</td>
+<td>无</td>
+</tr>
+</table>
+
+* 其中,`model_name` 必须指定,指定 `model_name` 后,默认使用 PaddleX 内置的模型参数,在此基础上,指定 `model_dir` 时,使用用户自定义的模型。
+
+* 调用开放词汇分割模型的 `predict()` 方法进行推理预测,`predict()` 方法参数有 `input` 、 `batch_size` 和 `prompts`,具体说明如下:
+
+<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>dict</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/open_vocabulary_detection.jpg">示例</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>prompts</code></td>
+<td>模型使用提示词</td>
+<td><code>dict</code></td>
+<td>
+<ul>
+  <li><b>dict</b>,如<code>{"box_prompt": [[float, float, float, foat], ...]}</code>,表示推理时使用的多个bbox作为prompt</li>
+</ul>
+</td>
+<td>无</td>
+</tr>
+</table>
+
+* 对预测结果进行处理,每个样本的预测结果均为`dict`类型,且支持打印、保存为图片、保存为`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)。
+
+## 四、二次开发
+当前模块暂时不支持微调训练,仅支持推理集成。关于该模块的微调训练,计划在未来支持。

+ 205 - 3
docs/module_usage/tutorials/cv_modules/rotated_object_detection.md

@@ -38,13 +38,215 @@ comments: true
 
 ```python
 from paddlex import create_model
-model = create_model("PP-YOLOE-R_L")
-output = model.predict("rotated_object_detection_001.png", batch_size=1)
+model_name = "PP-YOLOE-R_L"
+model = create_model(model_name, img_size = 1024)
+output = model.predict("rotated_object_detection_001.png", batch_size=1, threshold=0.5)
 for res in output:
-    res.print(json_format=False)
+    res.print()
     res.save_to_img("./output/")
     res.save_to_json("./output/res.json")
 ```
+
+运行后,得到的结果为:
+```bash
+{'res': "{'input_path': 'rotated_object_detection_001.png', 'boxes': [{'cls_id': 4, 'label': 'small-vehicle', 'score': 0.7513620853424072, 'coordinate': [92.72234, 763.36676, 84.7699, 749.9725, 116.207375, 731.8547, 124.15982, 745.2489]}, {'cls_id': 4, 'label': 'small-vehicle', 'score': 0.7284387350082397, 'coordinate': [348.60703, 177.85127, 332.80432, 149.83975, 345.37347, 142.95677, 361.17618, 170.96828]}, {'cls_id': 11, 'label': 'roundabout', 'score': 0.7909174561500549, 'coordinate': [535.02216, 697.095, 201.49803, 608.4738, 292.2446, 276.9634, 625.76874, 365.5845]}]}"}
+```
+运行结果参数含义如下:
+- `input_path`: 表示输入待预测图像的路径
+- `boxes`: 每个预测出的object的信息
+  - `cls_id`: 类别ID
+  - `label`: 类别名称
+  - `score`: 预测得分
+  - `coordinate`: 预测框的坐标,格式为<code>[x1, y1, x2, y2, x3, y3, x4, y4]</code>
+
+可视化图片如下:
+
+<img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/robj_det/rotated_object_detection_001_res.png">
+
+
+相关方法、参数等说明如下:
+
+* `create_model`实例化旋转目标检测模型(此处以`PP-YOLOE-R_L`为例),具体说明如下:
+<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>无</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>低分object过滤阈值</td>
+<td><code>float/None/dict</code></td>
+<td>无</td>
+<td>None</td>
+</tr>
+<tr>
+<td><code>img_size</code></td>
+<td>模型实际预测使用的分辨率</td>
+<td><code>int/tuple/None</code></td>
+<td>无</td>
+<td>None</td>
+</tr>
+</table>
+
+* 其中,`model_name` 必须指定,指定 `model_name` 后,默认使用 PaddleX 内置的模型参数,在此基础上,指定 `model_dir` 时,使用用户自定义的模型。
+
+* `threshold`为低分object过滤阈值,默认为None,表示使用上一层设置,参数设置的优先级从高到低为:`predict参数传入 > create_model初始化传入 > yaml配置文件设置`。目前支持float和dict两种阈值设置方式:
+  * `float`, 对于所有的类别使用同一个阈值。
+  * `dict`, key为类别ID,value为阈值,对于不同的类别使用不同的阈值。
+
+* `img_size`为模型实际预测使用的分辨率,默认为None,表示使用上一层设置,参数设置的优先级从高到低为:`create_model初始化 > yaml配置文件设置`。
+
+* 调用旋转目标检测模型的 `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>dict</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_instance_segmentation_004.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>低分object过滤阈值</td>
+<td><code>float</code>/<code>dict</code>/<code>None</code></td>
+<td>
+<ul>
+  <li><b>None</b>,表示沿用上一层设置, 参数设置优先级从高到低为: <code>predict参数传入 > create_model初始化传入 > yaml配置文件设置</code></li>
+  <li><b>float</b>,如0.5,表示推理时使用<code>0.5</code>作为所有类别的低分object过滤阈值</li>
+  <li><b>dict</b>,如<code>{0: 0.5, 1: 0.35}</code>,表示推理时对类别0使用0.5低分过滤阈值,对类别1使用0.35低分过滤阈值。</li>
+</ul>
+</td>
+<td>None</td>
+</tr>
+</table>
+
+* 对预测结果进行处理,每个样本的预测结果均为`dict`类型,且支持打印、保存为图片、保存为`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)。
 
 ## 四、二次开发

+ 194 - 6
docs/module_usage/tutorials/cv_modules/semantic_segmentation.md

@@ -165,28 +165,28 @@ comments: true
 </thead>
 <tbody>
 <tr>
-<td>SeaFormer_base(slice)</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/SeaFormer_base(slice)_infer.tar">Inference Model</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SeaFormer_base(slice)_pretrained.pdparams">Trained Model</a></td>
+<td>SeaFormer_base</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/SeaFormer_base(slice)_infer.tar">Inference Model</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SeaFormer_base(slice)_pretrained.pdparams">Trained Model</a></td>
 <td>40.92</td>
 <td>24.4073</td>
 <td>397.574</td>
 <td>30.8 M</td>
 </tr>
 <tr>
-<td>SeaFormer_large (slice)</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/SeaFormer_large (slice)_infer.tar">Inference Model</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SeaFormer_large (slice)_pretrained.pdparams">Trained Model</a></td>
+<td>SeaFormer_large</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/SeaFormer_large (slice)_infer.tar">Inference Model</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SeaFormer_large (slice)_pretrained.pdparams">Trained Model</a></td>
 <td>43.66</td>
 <td>27.8123</td>
 <td>550.464</td>
 <td>49.8 M</td>
 </tr>
 <tr>
-<td>SeaFormer_small (slice)</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/SeaFormer_small (slice)_infer.tar">Inference Model</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SeaFormer_small (slice)_pretrained.pdparams">Trained Model</a></td>
+<td>SeaFormer_small</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/SeaFormer_small (slice)_infer.tar">Inference Model</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SeaFormer_small (slice)_pretrained.pdparams">Trained Model</a></td>
 <td>38.73</td>
 <td>19.2295</td>
 <td>358.343</td>
 <td>14.3 M</td>
 </tr>
 <tr>
-<td>SeaFormer_tiny (slice)</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/SeaFormer_tiny (slice)_infer.tar">Inference Model</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SeaFormer_tiny (slice)_pretrained.pdparams">Trained Model</a></td>
+<td>SeaFormer_tiny</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/SeaFormer_tiny (slice)_infer.tar">Inference Model</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/SeaFormer_tiny (slice)_pretrained.pdparams">Trained Model</a></td>
 <td>34.58</td>
 <td>13.9496</td>
 <td>330.132</td>
@@ -206,12 +206,200 @@ from paddlex import create_model
 model = create_model("PP-LiteSeg-T")
 output = model.predict("general_semantic_segmentation_002.png", 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")
 ```
+
+运行后,得到的结果为:
+```bash
+{'res': "{'input_path': 'general_semantic_segmentation_002.png', 'pred': '...'}"}
+```
+运行结果参数含义如下:
+- `input_path`: 表示输入待预测图像的路径
+- `pred`: 语义分割模型实际预测的mask,由于数据过大不便于直接print,所以此处用`...`替换,可以通过`res.save_to_img()`将预测结果保存为图片,通过`res.save_to_json()`将预测结果保存为json文件。
+
+可视化图片如下:
+
+<img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/semantic_segmentation/general_semantic_segmentation_002_res.png">
+
+相关方法、参数等说明如下:
+
+* `create_model`实例化通用语义分割模型(此处以`PP-LiteSeg-T`为例),具体说明如下:
+<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>无</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>target_size</code></td>
+<td>模型预测时分辨率</td>
+<td><code>int/tuple</code></td>
+<td><code>None/-1/int/tuple</code></td>
+<td><code>None</code></td>
+</tr>
+</table>
+
+* 其中,`model_name` 必须指定,指定 `model_name` 后,默认使用 PaddleX 内置的模型参数,在此基础上,指定 `model_dir` 时,使用用户自定义的模型。
+
+* `target_size`在初始化时指定模型推理时分辨率,默认为`None`。`-1`表示直接使用原图尺寸推理,`None`表示沿用上一层的设置,参数设置的优先级从高到低为:`predict参数传入 > create_model初始化传入 > yaml配置文件设置`。
+
+* 调用通用语义分割模型的 `predict()` 方法进行推理预测,`predict()` 方法参数有 `input` 、 `batch_size` 和 `target_size`,具体说明如下:
+
+<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>dict</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_semantic_segmentation_001.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>target_size</code></td>
+<td>推理时图像的尺寸(W, H)</td>
+<td><code>int</code>/<code>tuple</code></td>
+<td>
+<ul>
+  <li><b>-1</b>,表示直接原图尺寸推理</li>
+  <li><b>None</b>,表示沿用上一层设置, 参数设置优先级从高到低为: <code>predict参数传入 > create_model初始化传入 > yaml配置文件设置</code></li>
+  <li><b>int</b>,如512,表示推理时使用<code>(512, 512)</code>分辨率</li>
+  <li><b>tuple</b>,如(512, 1024),表示推理时使用<code>(512, 1024)</code>分辨率</li>
+</ul>
+</td>
+<td>None</td>
+</tr>
+</table>
+
+* 对预测结果进行处理,每个样本的预测结果均为`dict`类型,且支持打印、保存为图片、保存为`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)中的二次开发部分。
 
@@ -423,7 +611,7 @@ python main.py -c paddlex/configs/semantic_segmentation/PP-LiteSeg-T.yaml \
 
 1.<b>产线集成</b>
 
-文档图像分类模块可以集成的PaddleX产线有[通用语义分割](../../../pipeline_usage/tutorials/cv_pipelines/semantic_segmentation.md),只需要替换模型路径即可完成文本检测模块的模型更新。在产线集成中,你可以使用高性能部署和服务化部署来部署你得到的模型。
+图像通用语义分割模块可以集成的PaddleX产线有[通用语义分割](../../../pipeline_usage/tutorials/cv_pipelines/semantic_segmentation.md),只需要替换模型路径即可完成图像通用语义分割模块的模型更新。在产线集成中,你可以使用高性能部署和服务化部署来部署你得到的模型。
 
 2.<b>模块集成</b>
 

+ 193 - 4
docs/module_usage/tutorials/cv_modules/small_object_detection.md

@@ -57,17 +57,206 @@ comments: true
 
 ```python
 from paddlex import create_model
-
 model_name = "PP-YOLOE_plus_SOD-S"
-
 model = create_model(model_name)
 output = model.predict("small_object_detection.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")
 ```
+
+运行后,得到的结果为:
+```bash
+{'res': "{'input_path': 'small_object_detection.jpg', 'boxes': [{'cls_id': 0, 'label': 'pedestrian', 'score': 0.8025697469711304, 'coordinate': [184.14276, 709.97455, 203.60669, 745.6286]}, {'cls_id': 0, 'label': 'pedestrian', 'score': 0.7245782017707825, 'coordinate': [203.48488, 700.377, 223.07726, 742.5181]}, {'cls_id': 0, 'label': 'pedestrian', 'score': 0.7014670968055725, 'coordinate': [851.23553, 435.81937, 862.94385, 466.81384]}, ... ]}"}
+```
+运行结果参数含义如下:
+- `input_path`: 表示输入待预测图像的路径
+- `boxes`: 每个预测出的object的信息
+  - `cls_id`: 类别ID
+  - `label`: 类别名称
+  - `score`: 预测得分
+  - `coordinate`: 预测框的坐标,格式为<code>[xmin, ymin, xmax, ymax]</code>
+
+可视化图片如下:
+
+<img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/small_obj_det/small_object_detection_res.jpg">
+
+
+相关方法、参数等说明如下:
+
+* `create_model`实例化小目标检测模型(此处以`PP-YOLOE_plus_SOD-S`为例),具体说明如下:
+<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>无</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>低分object过滤阈值</td>
+<td><code>float/None/dict</code></td>
+<td>无</td>
+<td>None</td>
+</tr>
+</table>
+
+* 其中,`model_name` 必须指定,指定 `model_name` 后,默认使用 PaddleX 内置的模型参数,在此基础上,指定 `model_dir` 时,使用用户自定义的模型。
+
+* `threshold`为低分object过滤阈值,默认为None,表示使用上一层设置,参数设置的优先级从高到低为:`predict参数传入 > create_model初始化传入 > yaml配置文件设置`。目前支持float和dict两种阈值设置方式:
+  * `float`, 对于所有的类别使用同一个阈值。
+  * `dict`, key为类别ID,value为阈值,对于不同的类别使用不同的阈值。
+
+* 调用小目标检测模型的 `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>dict</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_instance_segmentation_004.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>低分object过滤阈值</td>
+<td><code>float</code>/<code>dict</code>/<code>None</code></td>
+<td>
+<ul>
+  <li><b>None</b>,表示沿用上一层设置, 参数设置优先级从高到低为: <code>predict参数传入 > create_model初始化传入 > yaml配置文件设置</code></li>
+  <li><b>float</b>,如0.5,表示推理时使用<code>0.5</code>作为所有类别低分object过滤阈值</li>
+  <li><b>dict</b>,如<code>{0: 0.5, 1: 0.35}</code>,表示推理时对类别0使用0.5低分过滤阈值,对类别1使用0.35低分过滤阈值。</li>
+</ul>
+</td>
+<td>None</td>
+</tr>
+</table>
+
+* 对预测结果进行处理,每个样本的预测结果均为`dict`类型,且支持打印、保存为图片、保存为`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)。
 
 ## 四、二次开发

+ 192 - 4
docs/module_usage/tutorials/cv_modules/vehicle_detection.md

@@ -45,18 +45,206 @@ comments: true
 
 ```python
 from paddlex import create_model
-
 model_name = "PP-YOLOE-S_vehicle"
-
 model = create_model(model_name)
 output = model.predict("vehicle_detection.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")
+```
 
+运行后,得到的结果为:
+```bash
+{'res': "{'input_path': 'vehicle_detection.jpg', 'boxes': [{'cls_id': 0, 'label': 'vehicle', 'score': 0.9574093222618103, 'coordinate': [0.10725308, 323.01917, 272.72037, 472.75375]}, {'cls_id': 0, 'label': 'vehicle', 'score': 0.9449281096458435, 'coordinate': [270.3387, 310.36923, 489.8854, 398.07562]}, {'cls_id': 0, 'label': 'vehicle', 'score': 0.939127504825592, 'coordinate': [896.4249, 292.2338, 1051.9075, 370.41345]}, {'cls_id': 0, 'label': 'vehicle', 'score': 0.9388730525970459, 'coordinate': [1057.6327, 274.0139, 1639.8386, 535.54926]}, {'cls_id': 0, 'label': 'vehicle', 'score': 0.9239683747291565, 'coordinate': [482.28885, 307.33447, 574.6905, 357.82965]}, ... ]}"}
 ```
+运行结果参数含义如下:
+- `input_path`: 表示输入待预测图像的路径
+- `boxes`: 每个预测出的object的信息
+  - `cls_id`: 类别ID
+  - `label`: 类别名称
+  - `score`: 预测得分
+  - `coordinate`: 预测框的坐标,格式为<code>[xmin, ymin, xmax, ymax]</code>
+
+可视化图片如下:
+
+<img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/vehicle_detection/vehicle_detection_res.jpg">
+
+
+相关方法、参数等说明如下:
+
+* `create_model`实例化车辆检测模型(此处以`PP-YOLOE-S_vehicle`为例),具体说明如下:
+<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>无</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>低分object过滤阈值</td>
+<td><code>float/None/dict</code></td>
+<td>无</td>
+<td>None</td>
+</tr>
+</table>
+
+* 其中,`model_name` 必须指定,指定 `model_name` 后,默认使用 PaddleX 内置的模型参数,在此基础上,指定 `model_dir` 时,使用用户自定义的模型。
+
+* `threshold`为低分object过滤阈值,默认为None,表示使用上一层设置,参数设置的优先级从高到低为:`predict参数传入 > create_model初始化传入 > yaml配置文件设置`。目前支持float和dict两种阈值设置方式:
+  * `float`, 对于所有的类别使用同一个阈值。
+  * `dict`, key为类别ID,value为阈值,对于不同的类别使用不同的阈值。车辆检测为单类别检测,无需此设置。
+
+* 调用车辆检测模型的 `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>dict</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_instance_segmentation_004.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>低分object过滤阈值</td>
+<td><code>float</code>/<code>dict</code>/<code>None</code></td>
+<td>
+<ul>
+  <li><b>None</b>,表示沿用上一层设置, 参数设置优先级从高到低为: <code>predict参数传入 > create_model初始化传入 > yaml配置文件设置</code></li>
+  <li><b>float</b>,如0.5,表示推理时使用<code>0.5</code>作为低分object过滤阈值</li>
+  <li><b>dict</b>,如<code>{0: 0.5, 1: 0.35}</code>,表示推理时对类别0使用0.5低分过滤阈值,对类别1使用0.35低分过滤阈值。车辆检测为单类别检测,无需此设置。</li>
+</ul>
+</td>
+<td>None</td>
+</tr>
+</table>
+
+* 对预测结果进行处理,每个样本的预测结果均为`dict`类型,且支持打印、保存为图片、保存为`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)。
 
 ## 四、二次开发

+ 12 - 0
paddlex/configs/pipelines/open_vocabulary_detection.yaml

@@ -0,0 +1,12 @@
+
+pipeline_name: open_vocabulary_detection
+
+SubModules:
+  OpenVocabularyDetection:
+    module_name: open_vocabulary_detection
+    model_name: GroundingDINO-T
+    model_dir: null
+    batch_size: 1
+    thresholds:
+      box_threshold: 0.3
+      text_threshold: 0.25

+ 13 - 0
paddlex/configs/pipelines/open_vocabulary_segmentation.yaml

@@ -0,0 +1,13 @@
+pipeline_name: open_vocabulary_segmentation
+
+SubModules:
+  BoxPromptSegmentation:
+    module_name: box_prompt_segmentation
+    model_name: SAM-H_box
+    model_dir: null
+    batch_size: 1
+  PointPromptSegmentation:
+    module_name: point_prompt_segmentation
+    model_name: SAM-H_point
+    model_dir: null
+    batch_size: 1

+ 17 - 7
paddlex/inference/models_new/open_vocabulary_segmentation/results/sam_result.py

@@ -18,10 +18,12 @@ import numpy as np
 import copy, random
 import PIL
 from PIL import Image, ImageDraw, ImageFont
+from ....common.result import BaseCVResult, StrMixin, JsonMixin
 
 from ....utils.color_map import get_colormap
 from ....common.result import BaseCVResult
 
+
 def draw_segm(im, masks, mask_info, alpha=0.7):
     """
     Draw segmentation on image
@@ -34,7 +36,8 @@ def draw_segm(im, masks, mask_info, alpha=0.7):
     masks = np.array(masks)
     masks = masks.astype(np.uint8)
     for i in range(masks.shape[0]):
-        mask, clsid = masks[i], mask_info[i]["class_id"]
+        mask = masks[i]
+        clsid = random.randint(0, len(get_colormap(rgb=True)) - 1)
 
         if clsid not in clsid2color:
             color_index = i % len(color_list)
@@ -101,19 +104,20 @@ def draw_segm(im, masks, mask_info, alpha=0.7):
             )
     return Image.fromarray(im.astype("uint8"))
 
+
 class SAMSegResult(BaseCVResult):
     """Save Result Transform for SAM"""
+
     def __init__(self, data: dict) -> None:
 
         data["masks"] = [mask.squeeze(0) for mask in list(data["masks"])]
-        
-        prompts = data['prompts']
+
+        prompts = data["prompts"]
         assert isinstance(prompts, dict) and len(prompts) == 1
         prompt_type, prompts = list(prompts.items())[0]
         mask_infos = [
             {
                 "label": prompt_type,
-                "class_id": random.randint(0, len(get_colormap(rgb=True)) - 1),
                 "prompt": p,
             }
             for p in prompts
@@ -129,10 +133,16 @@ class SAMSegResult(BaseCVResult):
         mask_infos = self["mask_infos"]
         masks = self["masks"]
         image = draw_segm(image, masks, mask_infos)
+        return {"res": image}
 
-        return image
+    def _to_str(self, *args, **kwargs):
+        data = copy.deepcopy(self)
+        data["masks"] = "..."
+        data.pop("input_img")
+        return StrMixin._to_str(data, *args, **kwargs)
 
-    def _to_str(self, _, *args, **kwargs):
+    def _to_json(self, *args, **kwargs):
         data = copy.deepcopy(self)
         data["masks"] = "..."
-        return super()._to_str(data, *args, **kwargs)
+        data.pop("input_img")
+        return JsonMixin._to_json(data, *args, **kwargs)

+ 4 - 2
paddlex/inference/pipelines_new/__init__.py

@@ -45,9 +45,11 @@ from .attribute_recognition import (
 
 from .semantic_segmentation import SemanticSegmentationPipeline
 from .instance_segmentation import InstanceSegmentationPipeline
-from .small_object__detection import SmallObjectDetectionPipeline
-from .rotated_object__detection import RotatedObjectDetectionPipeline
+from .small_object_detection import SmallObjectDetectionPipeline
+from .rotated_object_detection import RotatedObjectDetectionPipeline
 from .keypoint_detection import KeypointDetectionPipeline
+from .open_vocabulary_detection import OpenVocabularyDetectionPipeline
+from .open_vocabulary_segmentation import OpenVocabularySegmentationPipeline
 
 
 def get_pipeline_path(pipeline_name: str) -> str:

+ 15 - 0
paddlex/inference/pipelines_new/open_vocabulary_detection/__init__.py

@@ -0,0 +1,15 @@
+# copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from .pipeline import OpenVocabularyDetectionPipeline

+ 74 - 0
paddlex/inference/pipelines_new/open_vocabulary_detection/pipeline.py

@@ -0,0 +1,74 @@
+# copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from typing import Any, Dict, Optional
+import numpy as np
+from ...utils.pp_option import PaddlePredictorOption
+from ..base import BasePipeline
+
+# [TODO] 待更新models_new到models
+from ...models_new.object_detection.result import DetResult
+
+
+class OpenVocabularyDetectionPipeline(BasePipeline):
+    """Open Vocabulary Detection Pipeline"""
+
+    entities = "open_vocabulary_detection"
+
+    def __init__(
+        self,
+        config: Dict,
+        device: str = None,
+        pp_option: PaddlePredictorOption = None,
+        use_hpip: bool = False,
+    ) -> None:
+        """
+        Initializes the class with given configurations and options.
+
+        Args:
+            config (Dict): Configuration dictionary containing model and other parameters.
+            device (str): The device to run the prediction on. Default is None.
+            pp_option (PaddlePredictorOption): Options for PaddlePaddle predictor. Default is None.
+            use_hpip (bool): Whether to use high-performance inference (hpip) for prediction. Defaults to False.
+        """
+        super().__init__(device=device, pp_option=pp_option, use_hpip=use_hpip)
+
+        open_vocabulary_detection_model_config = config.get("SubModules", {}).get(
+            "OpenVocabularyDetection",
+            {"model_config_error": "config error for doc_ori_classify_model!"},
+        )
+        self.open_vocabulary_detection_model = self.create_model(
+            open_vocabulary_detection_model_config
+        )
+        self.thresholds = open_vocabulary_detection_model_config["thresholds"]
+
+    def predict(
+        self,
+        input: str | list[str] | np.ndarray | list[np.ndarray],
+        prompt: str,
+        **kwargs
+    ) -> DetResult:
+        """Predicts open vocabulary detection results for the given input.
+
+        Args:
+            input (str | list[str] | np.ndarray | list[np.ndarray]): The input image(s) or path(s) to the images.
+            prompt (str): The text prompt used to describe the objects.
+            **kwargs: Additional keyword arguments that can be passed to the function.
+
+        Returns:
+            DetResult: The predicted open vocabulary detection results.
+        """
+        yield from self.open_vocabulary_detection_model(
+            input, prompt=prompt, thresholds=self.thresholds
+        )

+ 15 - 0
paddlex/inference/pipelines_new/open_vocabulary_segmentation/__init__.py

@@ -0,0 +1,15 @@
+# copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from .pipeline import OpenVocabularySegmentationPipeline

+ 90 - 0
paddlex/inference/pipelines_new/open_vocabulary_segmentation/pipeline.py

@@ -0,0 +1,90 @@
+# copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from typing import Any, Dict, Optional, Union, Tuple
+import numpy as np
+from ...utils.pp_option import PaddlePredictorOption
+from ..base import BasePipeline
+
+# [TODO] 待更新models_new到models
+from ...models_new.open_vocabulary_segmentation.results import SAMSegResult
+
+Number = Union[int, float]
+
+
+class OpenVocabularySegmentationPipeline(BasePipeline):
+    """Open Vocabulary Segmentation pipeline"""
+
+    entities = "open_vocabulary_segmentation"
+
+    def __init__(
+        self,
+        config: Dict,
+        device: str = None,
+        pp_option: PaddlePredictorOption = None,
+        use_hpip: bool = False,
+    ) -> None:
+        """
+        Initializes the class with given configurations and options.
+
+        Args:
+            config (Dict): Configuration dictionary containing model and other parameters.
+            device (str): The device to run the prediction on. Default is None.
+            pp_option (PaddlePredictorOption): Options for PaddlePaddle predictor. Default is None.
+            use_hpip (bool): Whether to use high-performance inference (hpip) for prediction. Defaults to False.
+        """
+        super().__init__(device=device, pp_option=pp_option, use_hpip=use_hpip)
+
+        # create box-prompted SAM-H
+        box_prompted_model_cfg = config.get("SubModules", {}).get(
+            "BoxPromptSegmentation",
+            {"model_config_error": "config error for doc_ori_classify_model!"},
+        )
+        self.box_prompted_model = self.create_model(box_prompted_model_cfg)
+
+        # create point-prompted SAM-H
+        point_prompted_model_cfg = config.get("SubModules", {}).get(
+            "PointPromptSegmentation",
+            {"model_config_error": "config error for doc_ori_classify_model!"},
+        )
+        self.point_prompted_model = self.create_model(point_prompted_model_cfg)
+
+    def predict(
+        self,
+        input: str | list[str] | np.ndarray | list[np.ndarray],
+        prompt: list[list[float]] | np.ndarray,
+        prompt_type: str = "box",
+        **kwargs
+    ) -> SAMSegResult:
+        """Predicts image segmentation results for the given input.
+
+        Args:
+            input (str | list[str] | np.ndarray | list[np.ndarray]): The input image(s) or path(s) to the images.
+            prompt (list[list[int]] | np.ndarray): The prompt for the input image(s).
+            prompt_type (str): The type of prompt, either 'box' or 'point'. Default is 'box'.
+            **kwargs: Additional keyword arguments that can be passed to the function.
+
+        Returns:
+            SAMSegResult: The predicted SAM segmentation results.
+        """
+        if prompt_type == "box":
+            yield from self.box_prompted_model(input, prompts={"box_prompt": prompt})
+        elif prompt_type == "point":
+            yield from self.point_prompted_model(
+                input, prompts={"point_prompt": prompt}
+            )
+        else:
+            raise ValueError(
+                "Invalid prompt type. Only 'box' and 'point' are supported"
+            )

+ 0 - 0
paddlex/inference/pipelines_new/rotated_object__detection/__init__.py → paddlex/inference/pipelines_new/rotated_object_detection/__init__.py


+ 0 - 0
paddlex/inference/pipelines_new/rotated_object__detection/pipeline.py → paddlex/inference/pipelines_new/rotated_object_detection/pipeline.py


+ 0 - 0
paddlex/inference/pipelines_new/small_object__detection/__init__.py → paddlex/inference/pipelines_new/small_object_detection/__init__.py


+ 0 - 0
paddlex/inference/pipelines_new/small_object__detection/pipeline.py → paddlex/inference/pipelines_new/small_object_detection/pipeline.py


+ 5 - 0
paddlex/modules/open_vocabulary_detection/__init__.py

@@ -11,3 +11,8 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+
+from .dataset_checker import OVDetDatasetChecker
+from .trainer import OVDetTrainer
+from .evaluator import OVDetEvaluator
+from .exportor import OVDetExportor

+ 29 - 0
paddlex/modules/open_vocabulary_detection/dataset_checker.py

@@ -0,0 +1,29 @@
+# copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from .model_list import MODELS
+from ..base import BaseDatasetChecker
+from ...utils.errors import UnsupportedAPIError
+
+
+class OVDetDatasetChecker(BaseDatasetChecker):
+    """Dataset Checker for Open Vocabulary Detection Model"""
+
+    entities = MODELS
+
+    def __init__(self, config):
+        # not support for now
+        raise UnsupportedAPIError(
+            "open vocabulary detection models do not support data check for now."
+        )

+ 29 - 0
paddlex/modules/open_vocabulary_detection/evaluator.py

@@ -0,0 +1,29 @@
+# copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from .model_list import MODELS
+from ..base import BaseEvaluator
+from ...utils.errors import UnsupportedAPIError
+
+
+class OVDetEvaluator(BaseEvaluator):
+    """Open Vocabulary Detection Model Evaluator"""
+
+    entities = MODELS
+
+    def __init__(self, config):
+        # not support for now
+        raise UnsupportedAPIError(
+            "open vocabulary detection models do not support evaluate for now."
+        )

+ 29 - 0
paddlex/modules/open_vocabulary_detection/exportor.py

@@ -0,0 +1,29 @@
+# copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from .model_list import MODELS
+from ..base import BaseExportor
+from ...utils.errors import UnsupportedAPIError
+
+
+class OVDetExportor(BaseExportor):
+    """Open Vocabulary Detection Model Exportor"""
+
+    entities = MODELS
+
+    def __init__(self, config):
+        # not support for now
+        raise UnsupportedAPIError(
+            "open vocabulary detection models do not support export for now."
+        )

+ 42 - 0
paddlex/modules/open_vocabulary_detection/trainer.py

@@ -0,0 +1,42 @@
+# copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from .model_list import MODELS
+from ..base import BaseTrainer
+from ...utils.errors import UnsupportedAPIError
+
+
+class OVDetTrainer(BaseTrainer):
+    """Open Vocabulary Detection Model Trainer"""
+
+    entities = MODELS
+
+    def __init__(self, config):
+        # not support for now
+        raise UnsupportedAPIError(
+            "open vocabulary detection models do not support train for now."
+        )
+
+    def update_config(self):
+        """update training config"""
+        pass
+
+    def get_train_kwargs(self) -> dict:
+        """get key-value arguments of model training function
+
+        Returns:
+            dict: the arguments of training function.
+        """
+        train_args = {"device": self.get_device()}
+        return train_args

+ 5 - 0
paddlex/modules/open_vocabulary_segmentation/__init__.py

@@ -11,3 +11,8 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+
+from .dataset_checker import OVSegDatasetChecker
+from .trainer import OVSegTrainer
+from .evaluator import OVSegEvaluator
+from .exportor import OVSegExportor

+ 29 - 0
paddlex/modules/open_vocabulary_segmentation/dataset_checker.py

@@ -0,0 +1,29 @@
+# copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from .model_list import MODELS
+from ..base import BaseDatasetChecker
+from ...utils.errors import UnsupportedAPIError
+
+
+class OVSegDatasetChecker(BaseDatasetChecker):
+    """Dataset Checker for Open Vocabulary Segmentation Model"""
+
+    entities = MODELS
+
+    def __init__(self, config):
+        # not support for now
+        raise UnsupportedAPIError(
+            "open vocabulary segmentation models do not support data check for now."
+        )

+ 29 - 0
paddlex/modules/open_vocabulary_segmentation/evaluator.py

@@ -0,0 +1,29 @@
+# copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from .model_list import MODELS
+from ..base import BaseEvaluator
+from ...utils.errors import UnsupportedAPIError
+
+
+class OVSegEvaluator(BaseEvaluator):
+    """Open Vocabulary Segmentation Model Evaluator"""
+
+    entities = MODELS
+
+    def __init__(self, config):
+        # not support for now
+        raise UnsupportedAPIError(
+            "open vocabulary segmentation models do not support evaluate for now."
+        )

+ 29 - 0
paddlex/modules/open_vocabulary_segmentation/exportor.py

@@ -0,0 +1,29 @@
+# copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from .model_list import MODELS
+from ..base import BaseExportor
+from ...utils.errors import UnsupportedAPIError
+
+
+class OVSegExportor(BaseExportor):
+    """Open Vocabulary Segmentation Model Exportor"""
+
+    entities = MODELS
+
+    def __init__(self, config):
+        # not support for now
+        raise UnsupportedAPIError(
+            "open vocabulary segmentation models do not support export for now."
+        )

+ 42 - 0
paddlex/modules/open_vocabulary_segmentation/trainer.py

@@ -0,0 +1,42 @@
+# copyright (c) 2024 PaddlePaddle Authors. All Rights Reserve.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from .model_list import MODELS
+from ..base import BaseTrainer
+from ...utils.errors import UnsupportedAPIError
+
+
+class OVSegTrainer(BaseTrainer):
+    """Open Vocabulary Segmentation Model Trainer"""
+
+    entities = MODELS
+
+    def __init__(self, config):
+        # not support for now
+        raise UnsupportedAPIError(
+            "open vocabulary segmentation models do not support train for now."
+        )
+
+    def update_config(self):
+        """update training config"""
+        pass
+
+    def get_train_kwargs(self) -> dict:
+        """get key-value arguments of model training function
+
+        Returns:
+            dict: the arguments of training function.
+        """
+        train_args = {"device": self.get_device()}
+        return train_args