Просмотр исходного кода

support inference and wheel, add some docs

cuicheng01 1 год назад
Родитель
Сommit
57e5e5297c
100 измененных файлов с 2079 добавлено и 333 удалено
  1. 20 11
      docs/tutorials/INSTALL.md
  2. 16 1
      docs/tutorials/QUCK_STARTED.md
  3. 26 5
      docs/tutorials/data/README.md
  4. 71 0
      docs/tutorials/data/dataset_check.md
  5. 237 0
      docs/tutorials/data/dataset_format.md
  6. 172 0
      docs/tutorials/pipeline.md
  7. 29 8
      docs/tutorials/train/README.md
  8. 32 0
      docs/tutorials/train/hyperparameters_introduction.md
  9. 47 0
      docs/tutorials/wheel.md
  10. 13 8
      install_pdx.py
  11. 13 8
      main.py
  12. 20 10
      paddlex/__init__.py
  13. 8 2
      paddlex/configs/image_classification/CLIP_vit_base_patch16_224.yaml
  14. 9 3
      paddlex/configs/image_classification/CLIP_vit_large_patch14_224.yaml
  15. 8 2
      paddlex/configs/image_classification/ConvNeXt_tiny.yaml
  16. 8 3
      paddlex/configs/image_classification/MobileNetV2_x0_25.yaml
  17. 8 3
      paddlex/configs/image_classification/MobileNetV2_x0_5.yaml
  18. 8 3
      paddlex/configs/image_classification/MobileNetV2_x1_0.yaml
  19. 8 3
      paddlex/configs/image_classification/MobileNetV2_x1_5.yaml
  20. 8 3
      paddlex/configs/image_classification/MobileNetV2_x2_0.yaml
  21. 8 3
      paddlex/configs/image_classification/MobileNetV3_large_x0_35.yaml
  22. 8 3
      paddlex/configs/image_classification/MobileNetV3_large_x0_5.yaml
  23. 8 3
      paddlex/configs/image_classification/MobileNetV3_large_x0_75.yaml
  24. 8 3
      paddlex/configs/image_classification/MobileNetV3_large_x1_0.yaml
  25. 8 3
      paddlex/configs/image_classification/MobileNetV3_large_x1_25.yaml
  26. 8 3
      paddlex/configs/image_classification/MobileNetV3_small_x0_35.yaml
  27. 8 3
      paddlex/configs/image_classification/MobileNetV3_small_x0_5.yaml
  28. 8 3
      paddlex/configs/image_classification/MobileNetV3_small_x0_75.yaml
  29. 8 3
      paddlex/configs/image_classification/MobileNetV3_small_x1_0.yaml
  30. 8 3
      paddlex/configs/image_classification/MobileNetV3_small_x1_25.yaml
  31. 9 2
      paddlex/configs/image_classification/PP-HGNetV2-B0.yaml
  32. 8 2
      paddlex/configs/image_classification/PP-HGNetV2-B4.yaml
  33. 8 2
      paddlex/configs/image_classification/PP-HGNetV2-B6.yaml
  34. 8 2
      paddlex/configs/image_classification/PP-HGNet_small.yaml
  35. 8 2
      paddlex/configs/image_classification/PP-LCNet_x0_25.yaml
  36. 8 2
      paddlex/configs/image_classification/PP-LCNet_x0_35.yaml
  37. 8 2
      paddlex/configs/image_classification/PP-LCNet_x0_5.yaml
  38. 8 2
      paddlex/configs/image_classification/PP-LCNet_x0_75.yaml
  39. 8 2
      paddlex/configs/image_classification/PP-LCNet_x1_0.yaml
  40. 8 2
      paddlex/configs/image_classification/PP-LCNet_x1_5.yaml
  41. 8 2
      paddlex/configs/image_classification/PP-LCNet_x2_0.yaml
  42. 8 2
      paddlex/configs/image_classification/PP-LCNet_x2_5.yaml
  43. 8 2
      paddlex/configs/image_classification/ResNet101.yaml
  44. 8 2
      paddlex/configs/image_classification/ResNet152.yaml
  45. 8 2
      paddlex/configs/image_classification/ResNet18.yaml
  46. 8 2
      paddlex/configs/image_classification/ResNet34.yaml
  47. 8 2
      paddlex/configs/image_classification/ResNet50.yaml
  48. 8 2
      paddlex/configs/image_classification/SwinTransformer_base_patch4_window7_224.yaml
  49. 10 4
      paddlex/configs/instance_segmentation/Mask-RT-DETR-H.yaml
  50. 8 2
      paddlex/configs/instance_segmentation/Mask-RT-DETR-L.yaml
  51. 8 3
      paddlex/configs/object_detection/PP-YOLOE_plus-L.yaml
  52. 8 3
      paddlex/configs/object_detection/PP-YOLOE_plus-M.yaml
  53. 8 3
      paddlex/configs/object_detection/PP-YOLOE_plus-S.yaml
  54. 8 3
      paddlex/configs/object_detection/PP-YOLOE_plus-X.yaml
  55. 8 2
      paddlex/configs/object_detection/PicoDet-L.yaml
  56. 8 3
      paddlex/configs/object_detection/PicoDet-S.yaml
  57. 8 2
      paddlex/configs/object_detection/RT-DETR-H.yaml
  58. 8 2
      paddlex/configs/object_detection/RT-DETR-L.yaml
  59. 8 2
      paddlex/configs/object_detection/RT-DETR-R18.yaml
  60. 8 2
      paddlex/configs/object_detection/RT-DETR-R50.yaml
  61. 8 2
      paddlex/configs/object_detection/RT-DETR-X.yaml
  62. 8 2
      paddlex/configs/semantic_segmentation/Deeplabv3-R101.yaml
  63. 8 2
      paddlex/configs/semantic_segmentation/Deeplabv3-R50.yaml
  64. 8 2
      paddlex/configs/semantic_segmentation/Deeplabv3_Plus-R101.yaml
  65. 8 2
      paddlex/configs/semantic_segmentation/Deeplabv3_Plus-R50.yaml
  66. 8 2
      paddlex/configs/semantic_segmentation/OCRNet_HRNet-W48.yaml
  67. 8 2
      paddlex/configs/semantic_segmentation/PP-LiteSeg-T.yaml
  68. 8 2
      paddlex/configs/structure_analysis/PicoDet_layout_1x.yaml
  69. 9 3
      paddlex/configs/table_recognition/SLANet.yaml
  70. 8 2
      paddlex/configs/text_detection/PP-OCRv4_mobile_det.yaml
  71. 8 2
      paddlex/configs/text_detection/PP-OCRv4_server_det.yaml
  72. 8 2
      paddlex/configs/text_recognition/PP-OCRv4_mobile_rec.yaml
  73. 8 2
      paddlex/configs/text_recognition/PP-OCRv4_server_rec.yaml
  74. 5 2
      paddlex/configs/ts_anomaly_detection/AutoEncoder_ad.yaml
  75. 5 3
      paddlex/configs/ts_anomaly_detection/DLinear_ad.yaml
  76. 5 3
      paddlex/configs/ts_anomaly_detection/Nonstationary_ad.yaml
  77. 5 3
      paddlex/configs/ts_anomaly_detection/PatchTST_ad.yaml
  78. 5 3
      paddlex/configs/ts_anomaly_detection/TimesNet_ad.yaml
  79. 5 2
      paddlex/configs/ts_classification/TimesNet_cls.yaml
  80. 5 2
      paddlex/configs/ts_forecast/DLinear.yaml
  81. 5 2
      paddlex/configs/ts_forecast/NLinear.yaml
  82. 5 2
      paddlex/configs/ts_forecast/Nonstationary.yaml
  83. 5 2
      paddlex/configs/ts_forecast/PatchTST.yaml
  84. 5 2
      paddlex/configs/ts_forecast/RLinear.yaml
  85. 5 2
      paddlex/configs/ts_forecast/TiDE.yaml
  86. 5 2
      paddlex/configs/ts_forecast/TimesNet.yaml
  87. 18 10
      paddlex/engine.py
  88. 27 20
      paddlex/modules/__init__.py
  89. 18 11
      paddlex/modules/base/__init__.py
  90. 18 18
      paddlex/modules/base/build_model.py
  91. 25 25
      paddlex/modules/base/dataset_checker/__init__.py
  92. 13 8
      paddlex/modules/base/dataset_checker/utils.py
  93. 19 14
      paddlex/modules/base/evaluator.py
  94. 19 0
      paddlex/modules/base/predictor/__init__.py
  95. 18 0
      paddlex/modules/base/predictor/io/__init__.py
  96. 217 0
      paddlex/modules/base/predictor/io/readers.py
  97. 176 0
      paddlex/modules/base/predictor/io/writers.py
  98. 203 0
      paddlex/modules/base/predictor/predictor.py
  99. 37 0
      paddlex/modules/base/predictor/transform.py
  100. 17 0
      paddlex/modules/base/predictor/transforms/__init__.py

+ 20 - 11
docs/tutorials/INSTALL.md

@@ -8,14 +8,14 @@
 
 #### 【推荐】使用 Docker 安装
 
-参考下述命令,使用飞桨官方 Docker 镜像,创建一个名为 `paddlx` 的容器,并将当前工作目录映射到容器内的 `/paddle` 目录。
+参考下述命令,使用飞桨官方 Docker 镜像,创建一个名为 `paddlex` 的容器,并将当前工作目录映射到容器内的 `/paddle` 目录。
 
 ```shell
 # 对于 GPU 用户
-sudo nvidia-docker run --name paddlx -v $PWD:/paddle --shm-size=8G --network=host -it registry.baidubce.com/paddlepaddle/paddle:2.6.1-gpu-cuda12.0-cudnn8.9-trt8.6 /bin/bash
+sudo nvidia-docker run --name paddlex -v $PWD:/paddle --shm-size=8G --network=host -it registry.baidubce.com/paddlepaddle/paddle:2.6.1-gpu-cuda12.0-cudnn8.9-trt8.6 /bin/bash
 
 # 对于 CPU 用户
-sudo docker run --name paddlx -v $PWD:/paddle --shm-size=8G --network=host -it registry.baidubce.com/paddlepaddle/paddle:2.6.1 /bin/bash
+sudo docker run --name paddlex -v $PWD:/paddle --shm-size=8G --network=host -it registry.baidubce.com/paddlepaddle/paddle:2.6.1 /bin/bash
 ```
 
 更多飞桨官方 docker 镜像请参考[飞桨官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/docker/linux-docker.html)。
@@ -23,29 +23,30 @@ sudo docker run --name paddlx -v $PWD:/paddle --shm-size=8G --network=host -it r
 **注意**:
 * 首次使用该镜像时,下述命令会自动下载该镜像文件,下载需要一定的时间,请耐心等待;
 * 请使用 **2.5.2** 及更高版本的 PaddlePaddle;
-* 上述命令会创建一个名为 paddlx 的 Docker 容器,之后再次使用该容器时无需再次运行该命令;
+* 上述命令会创建一个名为 paddlex 的 Docker 容器,之后再次使用该容器时无需再次运行该命令;
 * 参数 `--shm-size=8G` 将设置容器的共享内存为 8G,如机器环境允许,建议将该参数设置较大,如 `64G`;
 
-#### 使用 Pip 或 Conda 安装
+#### 使用 pip 安装
 
-参考下述命令,用 pip 或 conda 在当前环境中安装飞桨 PaddlePaddle。
+参考下述命令,用 pip 在当前环境中安装飞桨 PaddlePaddle。
 
+<!-- 这里需要指定 paddle3.0 版本 -->
 ```bash
-# pip
+# GPU,该命令仅适用于 CUDA 版本为 12 的机器环境,对于其他 CUDA 版本的支持请参考飞桨官网
 python -m pip install paddlepaddle-gpu==2.6.1.post120 -f https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html
 
-pip install paddlepaddle==2.6.1 -f https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html
-
-# conda
-conda install paddlepaddle==2.6.1 --channel https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/
+# CPU
+python -m pip install paddlepaddle==2.6.1 -f https://www.paddlepaddle.org.cn/whl/linux/mkl/avx/stable.html
 ```
 
 更多飞桨 Wheel 版本请参考[飞桨官网](https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/linux-pip.html)。
 
 #### 更多安装方式
 
+<!-- 这里需要指定内多硬件安装的文档 -->
 关于**源码编译**安装等更多安装方式,及**昆仑芯**、**海光**、**寒武纪**、**昇腾**等飞桨版本,请参考[飞桨官网](https://www.paddlepaddle.org.cn/install/quick?docurl=undefined)。
 
+
 ### 1.2 验证
 
 使用以下命令可以验证 PaddlePaddle 是否安装成功。
@@ -60,6 +61,9 @@ python -c "import paddle; paddle.utils.run_check()"
 python -c "import paddle; print(paddle.__version__)"
 ```
 
+<!-- 这里需要指明输出什么内容则表示正确 -->
+
+
 ## 2. 安装 PaddleX
 
 ### 2.1 获取源码
@@ -84,7 +88,12 @@ git clone https://gitee.com/paddlepaddle/PaddleX.git
 
 参考下述命令,按提示操作,完成 PaddleX 依赖的安装。
 
+<!-- 这里需要指明安装成功的状态 -->
 ```bash
 cd PaddleX
+# 安装第三方依赖
+pip install -r requirements.txt
+
+# 获取并安装飞桨开发套件
 python install_pdx.py
 ```

+ 16 - 1
docs/tutorials/QUCK_STARTED.md

@@ -156,4 +156,19 @@ python main.py -c paddlex/configs/image_classification/PP-LCNet_x1_0.yaml -o Glo
 
 ### 5. 模型推理
 
-模型推理功能正在开发中,敬请期待……
+在训练得到满意的模型后,可以使用训练好的模型进行推理预测:
+
+```bash
+python main.py -c paddlex/configs/image_classification/PP-LCNet_x1_0.yaml -o Global.mode=predict -o Predict.model_dir="output/best_model" -o Predict.input_path="/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+```
+
+上述命令中,可以通过修改配置文件(`paddlex/configs/image_classification/PP-LCNet_x1_0.yaml`)或`-o`追加参数的方式设置模型推理相关参数:
+
+* `Predict.model_dir`:使用的推理模型文件所在目录,在完成模型训练后,最佳模型的推理文件默认保存在`output/best_model`中,推理模型文件为`inference.pdparams`、`inference.pdmodel`等;
+* `Predict.input_path`:待预测图像路径;
+
+在执行上述命令进行推理后,可以在控制台输出预测结果,如下所示:
+
+```bash
+[{'class_ids': [76], 'scores': [0.66833], 'label_names': ['西番莲']}]
+```

+ 26 - 5
docs/tutorials/data/README.md

@@ -1,23 +1,44 @@
 # 数据校验
 
-PaddleX 支持对数据集进行校验,确保数据集内容符合 PaddleX 的相关要求。同时在数据校验时,能够对数据集进行分析,统计数据集的基本信息。此外,PaddleX 支持将其他常见数据集类型转换为 PaddleX 规定的数据集格式,以及对数据集按比例重新划分训练集、验证集。
+PaddleX 支持对数据集进行校验,确保数据集格式符合 PaddleX 的相关要求。同时在数据校验时,能够对数据集进行分析,统计数据集的基本信息。此外,PaddleX 支持将其他常见数据集类型转换为 PaddleX 规定的数据集格式,以及对数据集按比例重新划分训练集、验证集。本文档提供了图像分类的示例,其他任务的数据校验与图像分类类似。详情[PaddleX 数据校验](./dataset_check.md)。
 
-## 1. 数据集校验
+
+## 1. 数据准备
+您需要按照 PaddleX 支持的数据格式要求准备数据,关于数据标注,您可以参考[PaddleX 数据标注](./annotation/README.md),关于数据格式介绍,您可以参考[PaddleX 数据格式介绍](./dataset_format.md),此处我们准备了图像分类 Demo 数据供您使用。
+
+```bash
+cd /path/to/paddlex
+wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/cls_flowers_examples.tar -P ./dataset
+tar -xf ./dataset/cls_flowers_examples.tar -C ./dataset/
+```
+
+## 2. 数据集校验
 
 在对数据集校验时,只需一行命令:
 
 ```bash
-python main.py -c paddlex/configs/image_classification/PP-LCNet_x1_0.yaml -o Global.mode=check_dataset
+python main.py -c paddlex/configs/image_classification/PP-LCNet_x1_0.yaml \
+    -o Global.mode=check_dataset \
+    -o Global.dataset_dir=./dataset/cls_flowers_examples
 ```
 
-## 2. 数据集格式转换\数据集划分
+执行上述命令后,PaddleX 会对数据集进行校验,并统计数据集的基本信息。相关信息会保存在当前目录的 `./output/check_dataset` 目录下。
+
+<!-- 这里需要增加输出的说明,以及产出的说明,畅达 -->
+
+**注**:只有通过数据校验的数据才可以训练和评估。
+
+
+## 3. 数据集格式转换/数据集划分(非必选)
 
 如需对数据集格式进行转换或是重新划分数据集,可通过修改配置文件或是追加超参数的方式进行设置。
 
 数据集校验相关的参数可以通过修改配置文件中 `CheckDataset` 下的字段进行设置,配置文件中部分参数的示例说明如下:
 
 * `CheckDataset`:
+    <!-- 这里需要增加详细的说明,比如图像分类这里不支持转换,也需要说明,畅达 -->
     * `dst_dataset_name`: 生成的数据集目录名,PaddleX 在数据校验时,会产生一个新的数据集;
+
     * `convert`:
         * `enable`: 是否进行数据集格式转换;
         * `src_dataset_type`: 如果进行数据集格式转换,则需设置源数据集格式;
@@ -26,4 +47,4 @@ python main.py -c paddlex/configs/image_classification/PP-LCNet_x1_0.yaml -o Glo
         * `train_percent`: 如果重新划分数据集,则需要设置训练集的百分比;
         * `val_percent`: 如果重新划分数据集,则需要设置验证集的百分比;
 
-以上参数同样支持通过追加命令行参数的方式进行设置,如重新划分数据集并设置训练集与验证集比例:`-o CheckDataset.split=True -o CheckDataset.train_percent=True -o CheckDataset.val_percent=True`。
+以上参数同样支持通过追加命令行参数的方式进行设置,如重新划分数据集并设置训练集与验证集比例:`-o CheckDataset.split=True -o CheckDataset.train_percent=0.8 -o CheckDataset.val_percent=0.2`。

+ 71 - 0
docs/tutorials/data/dataset_check.md

@@ -0,0 +1,71 @@
+# PaddleX 数据集校验
+
+PaddleX 针对常见 AI 任务模块,给出通用简明的数据集规范,涵盖数据集名称、组织结构、标注格式。您可以参考下面不同任务的说明准备数据,进而可以通过 PaddleX 的数据校验,最后完成全流程任务开发。在数据校验过程中,PaddleX 支持额外的功能,如数据集格式转换、数据集划分等,您可以根据自己的需求选择使用。
+
+## 1. 图像分类任务模块数据校验
+
+### 1.1 数据准备
+
+您需要按照 PaddleX 支持的数据格式要求准备数据,关于数据标注,您可以参考[PaddleX 数据标注](./annotation/README.md),关于数据格式介绍,您可以参考[PaddleX 数据格式介绍](./dataset_format.md),此处我们准备了图像分类 Demo 数据供您使用。
+
+```bash
+cd /path/to/paddlex
+wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/cls_flowers_examples.tar -P ./dataset
+tar -xf ./dataset/cls_flowers_examples.tar -C ./dataset/
+```
+
+### 1.2 数据集校验
+
+在对数据集校验时,只需一行命令:
+
+```bash
+python main.py -c paddlex/configs/image_classification/PP-LCNet_x1_0.yaml \
+    -o Global.mode=check_dataset \
+    -o Global.dataset_dir=./dataset/cls_flowers_examples
+```
+
+执行上述命令后,PaddleX 会对数据集进行校验,并统计数据集的基本信息。相关信息会保存在当前目录的 `./output/check_dataset` 目录下。
+
+<!-- 这里需要增加输出的说明,以及产出的说明,畅达 -->
+
+**注**:只有通过数据校验的数据才可以训练和评估。
+
+
+### 1.3 数据集格式转换/数据集划分(非必选)
+
+如需对数据集格式进行转换或是重新划分数据集,可通过修改配置文件或是追加超参数的方式进行设置。
+
+数据集校验相关的参数可以通过修改配置文件中 `CheckDataset` 下的字段进行设置,配置文件中部分参数的示例说明如下:
+
+* `CheckDataset`:
+    <!-- 这里需要增加详细的说明,廷权 -->
+    * `dst_dataset_name`: 生成的数据集目录名,PaddleX 在数据校验时,会产生一个新的数据集;
+
+    * `convert`:
+        * `enable`: 是否进行数据集格式转换;
+        * `src_dataset_type`: 如果进行数据集格式转换,则需设置源数据集格式;
+    * `split`:
+        * `enable`: 是否进行重新划分数据集;
+        * `train_percent`: 如果重新划分数据集,则需要设置训练集的百分比;
+        * `val_percent`: 如果重新划分数据集,则需要设置验证集的百分比;
+
+以上参数同样支持通过追加命令行参数的方式进行设置,如重新划分数据集并设置训练集与验证集比例:`-o CheckDataset.split=True -o CheckDataset.train_percent=0.8 -o CheckDataset.val_percent=0.2`。
+
+
+## 目标检测任务模块数据校验
+
+## 语义分割任务模块数据校验
+
+## 实例分割任务模块数据校验
+
+## 文本检测任务模块数据校验
+
+## 文本识别任务模块数据校验
+
+## 表格识别任务模块数据校验
+
+## 时序预测任务模块数据校验
+
+## 时序异常检测任务模块数据校验
+
+## 时序分类任务模块数据校验

+ 237 - 0
docs/tutorials/data/dataset_format.md

@@ -0,0 +1,237 @@
+# PaddleX 数据格式说明
+
+众所周知,数据准备是AI任务开发流程中的重要一步,但是不同 AI 任务对数据准备的要求不尽相同,而且单个 AI 任务具有多种数据集,经常给大家带来困惑。
+
+因此,PaddleX 针对常见 AI 任务,给出通用简明的数据集规范说明,涵盖数据集名称、组织结构、标注格式。
+
+**请您在下面找到特定 AI 任务,参考说明准备数据,进而可以通过 PaddleX 的数据校验,最后完成全流程任务开发。**
+
+请注意:
+
+- 如果已有数据集不符合 PaddleX 的规范说明,请大家进行相应转换。
+
+## 1. 图像分类任务模块
+
+PaddleX 针对图像分类任务定义的数据集,名称是 **ClsDataset**,组织结构和标注格式如下。 
+
+```plain
+dataset_dir    # 数据集根目录,目录名称可以改变
+├── images     # 图像的保存目录,目录名称可以改变,但要注意与train.txt、val.txt的内容对应
+├── label.txt  # 标注id和类别名称的对应关系,文件名称不可改变。每行给出类别id和类别名称,内容举例:45 wallflower
+├── train.txt  # 训练集标注文件,文件名称不可改变。每行给出图像路径和图像类别id,使用空格分隔,内容举例:images/image_06765.jpg 0
+└── val.txt    # 验证集标注文件,文件名称不可改变。每行给出图像路径和图像类别id,使用空格分隔,内容举例:images/image_06767.jpg 10
+```
+
+请大家参考上述规范准备数据,此外可以参考:[示例数据集](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/cls_flowers_examples.tar) 和 [图像分类任务数据集说明](https://github.com/PaddlePaddle/PaddleClas/blob/develop/docs/zh_CN/training/single_label_classification/dataset.md)。
+
+如果您已有数据集且数据集格式为如下格式,但是没有标注文件,可以使用[脚本](https://paddleclas.bj.bcebos.com/tools/create_cls_trainval_lists.py)将已有的数据集生成标注文件。
+
+```plain
+dataset_dir          # 数据集根目录,目录名称可以改变      
+├── images           # 图像的保存目录,目录名称可以改变
+   ├── train         # 训练集目录,目录名称可以改变
+      ├── class0     # 类名字,最好是有意义的名字,否则生成的类别映射文件label.txt无意义
+         ├── xxx.jpg # 图片,此处支持层级嵌套
+         ├── xxx.jpg # 图片,此处支持层级嵌套
+         ...      
+      ├── class1     # 类名字,最好是有意义的名字,否则生成的类别映射文件label.txt无意义
+      ...
+   ├── val           # 验证集目录,目录名称可以改变
+```
+
+如果您使用的是 PaddleX 2.x版本的图像分类数据集,在经过训练集/验证集/测试集切分后,手动将 train_list.txt、val_list.txt、test_list.txt修改为train.txt、val.txt、test.txt,并且按照规则修改 label.txt 即可。
+
+原版label.txt
+
+```python
+classname1
+classname2
+classname3
+...
+```
+
+修改后的label.txt
+
+```python
+0 classname1
+1 classname2
+2 classname3
+...
+```
+
+## 2. 目标检测任务模块
+
+PaddleX 针对目标检测任务定义的数据集,名称是 **COCODetDataset**,组织结构和标注格式如下。
+
+```plain
+dataset_dir                  # 数据集根目录,目录名称可以改变
+├── annotations              # 标注文件的保存目录,目录名称不可改变
+│   ├── instance_train.json  # 训练集标注文件,文件名称不可改变,采用COCO标注格式
+│   └── instance_val.json    # 验证集标注文件,文件名称不可改变,采用COCO标注格式
+└── images                   # 图像的保存目录,目录名称不可改变
+```
+
+标注文件采用 COCO 格式。请大家参考上述规范准备数据,此外可以参考:[示例数据集](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/det_coco_examples.tar) 和 [目标检测数据准备](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/data/PrepareDetDataSet.md)。
+
+
+当大家使用的是 PaddleX 2.x 版本时的目标检测数据集时,请参考[数据格式转换](),将 VOC 格式数据集转换为 COCO 数据集。
+
+## 3. 实例分割任务模块
+
+PaddleX 针对实例分割任务定义的数据集,名称是 **COCOInstSegDataset**,组织结构和标注格式如下。
+
+```plain
+dataset_dir                  # 数据集根目录,目录名称可以改变
+├── annotations              # 标注文件的保存目录,目录名称不可改变
+│   ├── instance_train.json  # 训练集标注文件,文件名称不可改变,采用COCO标注格式
+│   └── instance_val.json    # 验证集标注文件,文件名称不可改变,采用COCO标注格式
+└── images                   # 图像的保存目录,目录名称不可改变
+```
+
+标注文件采用 COCO 格式。请大家参考上述规范准备数据,此外可以参考:[示例数据集](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/det_coco_examples.tar) 和 [目标检测数据准备](https://github.com/PaddlePaddle/PaddleDetection/blob/develop/docs/tutorials/data/PrepareDetDataSet.md)。
+
+
+当大家使用的是 PaddleX 2.x 版本时的实例分割数据集时,请参考[数据格式转换](),将 VOC 格式数据集转换为 COCO 数据集。
+
+**注:格式标注要求**
+
+- 实例分割数据要求采用 COCO 数据格式标注出数据集中每张图像各个目标区域的像素边界和类别,采用 [x1,y1,x2,y2,...,xn,yn] 表示物体的多边形边界(segmentation)。其中,(xn,yn) 多边形各个角点坐标。标注信息存放到 annotations 目录下的 json 文件中,训练集 instance_train.json 和验证集 instance_val.json 分开存放。
+
+- 如果你有一批未标注数据,我们推荐使用 LabelMe 进行数据标注。对于使用 LabelMe 标注的数据集,产线支持进行数据格式转换,请选择对应的格式后,点击「开始校验」按钮。
+
+- 为确保格式转换顺利完成,请严格遵循示例数据集的文件命名和组织方式: [LabelMe 示例数据集](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/instance_seg_labelme_examples.tar)。
+
+
+## 4. 语义分割任务模块
+
+PaddleX 针对图像分割任务定义的数据集,名称是**SegDataset**,组织结构和标注格式如下。
+
+```plain
+dataset_dir         # 数据集根目录,目录名称可以改变
+├── annotations     # 存放标注图像的目录,目录名称可以改变,注意与标识文件的内容相对应
+├── images          # 存放原始图像的目录,目录名称可以改变,注意与标识文件的内容相对应
+├── train.txt       # 训练集标注文件,文件名称不可改变。每行是原始图像路径和标注图像路径,使用空格分隔,内容举例:images/P0005.jpg annotations/P0005.png
+└── val.txt         # 验证集标注文件,文件名称不可改变。每行是原始图像路径和标注图像路径,使用空格分隔,内容举例:images/N0139.jpg annotations/N0139.png
+```
+
+标注图像是单通道灰度图或者单通道伪彩色图,建议使用PNG格式保存。标注图像中每种像素值代表一个类别,类别必须从0开始依次递增,例如0、1、2、3表示4种类别。标注图像的像素存储是8bit,所以标注类别最多支持256类。
+
+请大家参考上述规范准备数据,此外可以参考:[示例数据集](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/seg_optic_examples.tar) 和 [图像语义分割数据准备](https://github.com/PaddlePaddle/PaddleSeg/blob/release/2.8/docs/data/marker/marker_cn.md)。
+
+**注:格式标注要求**
+
+语义分割数据要求标注出数据集中每张图像不同类别所在的不同区域,产线要求的 Seg 格式数据集使用单通道的标注图片,每一种 `像素值` 代表一种类别,像素标注类别需要从0开始递增,例如0,1,2,3表示有4种类别。建议标注图像使用PNG无损压缩格式的图片,支持的标注类别最多为256类。在 `train.txt` 与 `val.txt` 中每行给出图像路径和标注图像路径,使用空格分隔。对于自定义标注的数据集,只需要标注前景目标并设置标注类别即可,其他像素默认作为背景。如需要手动标注背景区域,类别必须设置为 `_background_`,否则格式转换数据集会出现错误。对于图片中的噪声部分或不参与模型训练的部分,可以使用 `__ignore__` 类,模型训练时会自动跳过对应部分。
+
+如果你有一批未标注数据,我们推荐使用 <a href="https://github.com/labelmeai/labelme" target="_blank">LabelMe</a> 进行数据标注。为确保格式转换顺利完成,请严格遵循示例数据集的文件命名和组织方式:
+[LabelMe 示例数据集](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/seg_dataset_to_convert.tar)
+
+
+## 5. 文本检测任务模块
+
+PaddleX针对文本检测任务定义的数据集,名称是**TextDetDataset**,组织结构和标注格式如下。
+
+```plain
+dataset_dir     # 数据集根目录,目录名称可以改变
+├── images      # 存放图像的目录,目录名称可以改变,但要注意和train.txt val.txt的内容对应
+├── train.txt   # 训练集标注文件,文件名称不可改变,内容举例:images/img_0.jpg \t [{"transcription": "MASA", "points": [[310, 104], [416, 141], [418, 216], [312, 179]]}, {...}]
+└── val.txt     # 验证集标注文件,文件名称不可改变,内容举例:images/img_61.jpg \t [{"transcription": "TEXT", "points": [[31, 10], [310, 140], [420, 220], [310, 170]]}, {...}]
+```
+
+标注文件的每行内容是一张图像的路径和一个组成元素是字典的列表,路径和列表必须使用制表符’\t‘进行分隔,不可使用空格进行分隔。
+
+对于组成元素是字典的列表,字典中 points 表示文本框的四个顶点的坐标(x, y),从左上角的顶点开始顺时针排;字典中`transcription`表示该文本框的文字,若`transcription 的`内容为“###”时,表示该文本框无效,不参与训练。
+
+如果您使用了[PPOCRLabel](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.7/PPOCRLabel/README_ch.md)标注数据,只需要在完成数据集划分后将文字检测(det)目录中的`det_gt_train.txt`改名为`train.txt`、`det_gt_test.txt`改名为`val.txt`即可。
+
+请大家参考上述规范准备数据,此外可以参考:[示例数据集](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/ocr_det_dataset_examples.tar) 和 [文本检测数据准备](https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_ch/dataset/ocr_datasets.md)。
+
+## 6. 文本识别任务模块
+
+PaddleX针对文字识别任务定义的数据集,名称是**MSTextRecDataset**,组织结构和标注格式如下。
+
+```plain
+dataset_dir      # 数据集根目录,目录名称可以改变
+├── images       # 存放图像的目录,目录名称可以改变,但要注意和train.txt val.txt的内容对应
+├── train.txt    # 训练集标注文件,文件名称不可改变,内容举例:images/111085122871_0.JPG \t 百度
+├── val.txt      # 验证集标注文件,文件名称不可改变,内容举例:images/111085122871_0.JPG \t 百度
+└── dict.txt     # 字典文件,文件名称不可改变。字典文件将所有出现的字符映射为字典的索引,每行为一个单字,内容举例:百
+```
+
+标注文件的每行内容是图像路径和文本内容,两者必须使用制表符’\t‘进行分隔,不可使用空格进行分隔。
+
+如果您使用了[PPOCRLabel](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.7/PPOCRLabel/README_ch.md)标注数据,只需要在完成数据集划分后将文字识别(rec)目录中的`rec_gt_train.txt`改名为`train.txt`、`rec_gt_test.txt`改名为`val.txt`即可。
+
+字典文件dict.txt的每行是一个单字,如"a"、"度"、"3"等,如下所示:
+
+```plain
+a
+度
+3
+```
+
+推荐使用 PP-OCR [默认字典](https://raw.githubusercontent.com/PaddlePaddle/PaddleOCR/release/2.7/ppocr/utils/ppocr_keys_v1.txt)(右击链接下载即可) 并重命名为 `dict.txt` ,也可使用脚本 [gen_dict.py](https://paddleocr.bj.bcebos.com/script/gen_dict.py) 根据训练/评估数据自动生成字典:
+
+```python
+# 将脚本下载至 {dataset_dir} 目录下
+wget https://paddleocr.bj.bcebos.com/script/gen_dict.py
+# 执行转化,默认训练集标注文件为"train.txt", 验证集标注文件为"val.txt", 生成的字典文件为"dict.txt"
+python gen_dict.py
+```
+
+请大家参考上述规范准备数据,此外可以参考:[示例数据集](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/ocr_rec_dataset_examples.tar) 和 [文本识别数据准备](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.6/doc/doc_ch/recognition.md#12-自定义数据集)。
+
+
+## 7. 表格识别任务模块
+
+PaddleX 针对表格识别任务定义的数据集,名称是 **PubTabTableRecDataset**,组织结构和标注格式如下。
+
+```plain
+dataset_dir    # 数据集根目录,目录名称可以改变
+├── images     # 图像的保存目录,目录名称可以改变,但要注意和train.txt val.txt的内容对应
+├── train.txt  # 训练集标注文件,文件名称不可改变,内容举例:{"filename": "images/border.jpg", "html": {"structure": {"tokens": ["<tr>", "<td", " colspan=\"3\"", ">", "</td>", "</tr>", "<tr>", "<td>", "</td>", "<td>", "</td>", "<td>", "</td>", "</tr>", "<tr>", "<td>", "</td>", "<td>", "</td>", "<td>", "</td>", "</tr>"]}, "cells": [{"tokens": ["、", "自", "我"], "bbox": [[[5, 2], [231, 2], [231, 35], [5, 35]]]}, {"tokens": ["9"], "bbox": [[[168, 68], [231, 68], [231, 98], [168, 98]]]}]}, "gt": "<html><body><table><tr><td colspan=\"3\">、自我</td></tr><tr><td>Aghas</td><td>失吴</td><td>月,</td></tr><tr><td>lonwyCau</td><td></td><td>9</td></tr></table></body></html>"}
+└── val.txt    # 验证集标注文件,文件名称不可改变,内容举例:{"filename": "images/no_border.jpg", "html": {"structure": {"tokens": ["<tr>", "<td", " colspan=\"2\"", ">", "</td>", "<td", " rowspan=\"2\"", ">", "</td>", "<td", " rowspan=\"2\"", ">", "</td>", "</tr>", "<tr>", "<td>", "</td>", "<td>", "</td>", "</tr>", "<tr>", "<td>", "</td>", "<td>", "</td>", "<td>", "</td>", "<td>", "</td>", "</tr>"]}, "cells": [{"tokens": ["a", "d", "e", "s"], "bbox": [[[0, 4], [284, 4], [284, 34], [0, 34]]]}, {"tokens": ["$", "7", "5", "1", "8", ".", "8", "3"], "bbox": [[[442, 67], [616, 67], [616, 100], [442, 100]]]}]}, "gt": "<html><body><table><tr><td colspan=\"2\">ades</td><td rowspan=\"2\">研究中心主任滕建</td><td rowspan=\"2\">品、家居用品位居商</td></tr><tr><td>naut</td><td>则是创办思</td></tr><tr><td>各方意见建议,确保</td><td>9.66</td><td>道开业,负责</td><td>$7518.83</td></tr></table></body></html>"}
+```
+
+标注文件采用 PubTabNet 数据集格式进行标注,每行内容都是一个字典。
+
+请大家参考上述规范准备数据,此外可以参考:[示例数据集](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/table_rec_dataset_examples.tar) 和 [表格识别数据准备](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.6/doc/doc_ch/table_recognition.md#1-数据准备)。
+
+## 8. 时序预测任务模块
+
+PaddleX 针对长时序预测任务定义的数据集,名称是**TSDataset**,组织结构和标注格式如下。
+
+```plain
+dataset_dir         # 数据集根目录,目录名称可以改变     
+├── train.csv       # 训练集标注文件,文件名称不可改变。表头是每列的列名称,每一行是某一个时间点采集的数据。
+├── val.csv         # 验证集标注文件,文件名称不可改变。表头是每列的列名称,每一行是某一个时间点采集的数据。
+└── test.csv        # 测试集标注文件(可选),文件名称不可改变。表头是每列的列名称,每一行是某一个时间点采集的数据。
+```
+
+请大家参考上述规范准备数据,此外可以参考: [示例数据集](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/ts_dataset_examples.tar)和[TS数据准备](https://paddlets.readthedocs.io/zh_CN/latest/source/get_started/get_started.html#built-in-tsdataset)。
+
+
+## 9. 时序异常检测任务模块
+
+PaddleX 针对时序异常检测任务定义的数据集,名称是**TSADDataset**,组织结构和标注格式如下。
+
+```shell
+dataset_dir     # 数据集根目录,目录名称可以改变
+├── train.csv   # 训练集文件,文件名称不可改变
+├── val.csv     # 验证集文件,文件名称不可改变
+└── test.csv    # 测试集文件,文件名称不可改变
+```
+
+时序异常检测和多模型融合时序异常检测要求的数据集格式,支持 xls、xlsx 格式的数据集转换为 csv 格式。你可以参考:[示例数据集](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/ts_anomaly_examples.tar)。
+
+## 10. 时序分类任务模块
+
+PaddleX 针对时序异常检测任务定义的数据集,名称是**TSCLSataset**,组织结构和标注格式如下。
+
+```shell
+dataset_dir     # 数据集根目录,目录名称可以改变
+├── train.csv   # 训练集文件,文件名称不可改变,群组编号名称固定为"group_id",标签变量名称固定为"label"
+├── val.csv     # 验证集文件,文件名称不可改变,群组编号名称固定为"group_id",标签变量名称固定为"label"
+└── test.csv    # 测试集文件,文件名称不可改变,群组编号名称固定为"group_id",标签变量(可不包含)名称固定为"label"
+```
+
+时序分类要求的数据集格式,支持 xls、xlsx 格式的数据集转换为 csv 格式。你可以参考:[示例数据集](https://paddle-model-ecology.bj.bcebos.com/paddlex/data/ts_classify_examples.tar)。

+ 172 - 0
docs/tutorials/pipeline.md

@@ -0,0 +1,172 @@
+# PaddleX 产线(Pipeline)推理
+
+PaddleX 中提供了多个产线,包括:OCR、图像分类、目标检测、实例分割、语义分割等,每个产线有多个模型可供选择,并均提供了官方预训练权重,支持通过 Python API、命令行方式直接推理预测。各产线使用方式可参考以下代码。
+
+## OCR
+
+```python
+import cv2
+from paddlex import OCRPipeline
+from paddlex import PaddleInferenceOption
+from paddle.pipelines.PPOCR.utils import draw_ocr_box_txt
+
+pipeline = OCRPipeline(
+    'PP-OCRv4_mobile_det',
+    'PP-OCRv4_mobile_rec',
+    text_det_kernel_option=PaddleInferenceOption(),
+    text_rec_kernel_option=PaddleInferenceOption(),)
+result = pipeline(
+    "/paddle/dataset/paddlex/ocr_det/ocr_det_dataset_examples/images/train_img_100.jpg",
+)
+
+draw_img = draw_ocr_box_txt(result['original_image'],result['dt_polys'], result["rec_text"])
+cv2.imwrite("ocr_result.jpg", draw_img[:, :, ::-1], )
+```
+
+## 图像分类
+
+```python
+from paddlex import ClsPipeline
+from paddlex import PaddleInferenceOption
+
+models = [
+    "ResNet18",
+    "ResNet34",
+    "ResNet50",
+    "ResNet101",
+    "ResNet152",
+    "PP-LCNet_x0_25",
+    "PP-LCNet_x0_35",
+    "PP-LCNet_x0_5",
+    "PP-LCNet_x0_75",
+    "PP-LCNet_x1_0",
+    "PP-LCNet_x1_5",
+    "PP-LCNet_x2_5",
+    "PP-LCNet_x2_0",
+    "MobileNetV3_large_x0_35",
+    "MobileNetV3_large_x0_5",
+    "MobileNetV3_large_x0_75",
+    "MobileNetV3_large_x1_0",
+    "MobileNetV3_large_x1_25",
+    "MobileNetV3_small_x0_35",
+    "MobileNetV3_small_x0_5",
+    "MobileNetV3_small_x0_75",
+    "MobileNetV3_small_x1_0",
+    "MobileNetV3_small_x1_25",
+    "ConvNeXt_tiny",
+    "MobileNetV2_x0_25",
+    "MobileNetV2_x0_5",
+    "MobileNetV2_x1_0",
+    "MobileNetV2_x1_5",
+    "MobileNetV2_x2_0",
+    "SwinTransformer_base_patch4_window7_224",
+    "PP-HGNet_small",
+    "PP-HGNetV2-B0",
+    "PP-HGNetV2-B4",
+    "PP-HGNetV2-B6",
+    "CLIP_vit_base_patch16_224",
+    "CLIP_vit_large_patch14_224",
+]
+
+for model_name in models:
+    try:
+        pipeline = ClsPipeline(model_name, kernel_option=PaddleInferenceOption())
+        result = pipeline(
+            "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00006.jpg"
+        )
+        print(result["cls_result"])
+    except Exception as e:
+        print(f"[ERROR] model: {model_name}; err: {e}")
+    print(f"[INFO] model: {model_name} done!")
+```
+
+## 目标检测
+
+```python
+from pathlib import Path
+from paddlex import DetPipeline
+from paddlex import PaddleInferenceOption
+
+models = [
+    "PicoDet-L",
+    "PicoDet-S",
+    "PP-YOLOE_plus-L",
+    "PP-YOLOE_plus-M",
+    "PP-YOLOE_plus-S",
+    "PP-YOLOE_plus-X",
+    "RT-DETR-H",
+    "RT-DETR-L",
+    "RT-DETR-R18",
+    "RT-DETR-R50",
+    "RT-DETR-X",
+]
+output_base = Path("output")
+
+for model_name in models:
+    output_dir = output_base / model_name
+    try:
+        pipeline = DetPipeline(model_name, output_dir=output_dir, kernel_option=PaddleInferenceOption())
+        result = pipeline(
+            "/paddle/dataset/paddlex/det/det_coco_examples/images/road0.png")
+        print(result["boxes"])
+    except Exception as e:
+        print(f"[ERROR] model: {model_name}; err: {e}")
+    print(f"[INFO] model: {model_name} done!")
+```
+
+
+## 实例分割
+
+```python
+from pathlib import Path
+from paddlex import InstanceSegPipeline
+from paddlex import PaddleInferenceOption
+
+models = ["Mask-RT-DETR-H", "Mask-RT-DETR-L"]
+output_base = Path("output")
+
+for model_name in models:
+    output_dir = output_base / model_name
+    try:
+        pipeline = InstanceSegPipeline(model_name, output_dir=output_dir, kernel_option=PaddleInferenceOption())
+        result = pipeline(
+            "/paddle/dataset/paddlex/instance_seg/instance_seg_coco_examples/images/aircraft-women-fashion-pilot-48797.png"
+        )
+        print(result["masks"])
+    except Exception as e:
+        print(f"[ERROR] model: {model_name}; err: {e}")
+    print(f"[INFO] model: {model_name} done!")
+```
+
+## 语义分割
+
+
+```python
+from pathlib import Path
+from paddlex import SegPipeline
+from paddlex import PaddleInferenceOption
+
+
+models = [
+    "Deeplabv3-R50",
+    "Deeplabv3-R101",
+    "Deeplabv3_Plus-R50",
+    "Deeplabv3_Plus-R101",
+    "PP-LiteSeg-T",
+    "OCRNet_HRNet-W48",
+]
+
+output_base = Path("output")
+
+for model_name in models:
+    output_dir = output_base / model_name
+    try:
+        pipeline = SegPipeline(model_name, output_dir=output_dir, kernel_option=PaddleInferenceOption())
+        result = pipeline(
+            "/paddle/dataset/paddlex/seg/seg_optic_examples/images/H0002.jpg"
+        )
+        print(result["seg_map"])
+    except Exception as e:
+        print(f"[ERROR] model: {model_name}; err: {e}")
+    print(f"[INFO] model: {model_name} done!")
+```

+ 29 - 8
docs/tutorials/train/README.md

@@ -1,11 +1,15 @@
-# 模型训练
+# PaddleX 模型训练和评估
 
-## 1. 训练
+在训练之前,请确保您的数据集已经经过了[数据校验](../data/README.md)。经过数据校验的数据集才可以进行训练。PaddleX 提供了很多不同的任务模块,不同的模块下又内置了很多被广泛验证的高精度、高效率、精度效率均衡的模型。训练模型时,您只需要一行命令,即可发起相应任务的训练。本文档提供了图像分类任务模块的 `PP-LCNet_x1_0` 模型的训练和评估示例,其他任务模块的训练与图像分类类似。当您按照[PaddleX 数据集标注](../data/annotation/README.md)和 [PaddleX 数据集校验](../data/dataset_check.md)准备好训练数据后,即可参考本文档完成所有 PaddleX 支持的模型训练。
 
-PaddleX 预置了大量优秀的模型,使用 PaddleX 进行模型训练,只需一行命令:
+## 1. 模型训练
+
+完成 PaddleX 模型的训练,只需如下一条命令:
 
 ```bash
-python main.py -c paddlex/configs/image_classification/PP-LCNet_x1_0.yaml -o Global.mode=train
+python main.py -c paddlex/configs/image_classification/PP-LCNet_x1_0.yaml \
+    -o Global.mode=train \
+    -o Global.dataset_dir=./dataset/cls_flowers_examples
 ```
 
 在 PaddleX 中模型训练支持:修改训练超参数、单机单卡/多卡训练等功能,只需修改配置文件或追加命令行参数。
@@ -14,19 +18,36 @@ PaddleX 中每个模型都提供了模型开发的配置文件,用于设置相
 
 * `Global`:
     * `mode`:模式,支持数据校验(`check_dataset`)、模型训练(`train`)、模型评估(`evaluate`);
-    * `device`:训练设备,可选`cpu`、`gpu`,GPU 多卡训练可指定卡号,如:`gpu:0,1,2,3`;
+    * `device`:训练设备,可选`cpu`、`gpu`、`xpu`、`npu`、`mlu`,除 CPU 外,多卡训练可指定卡号,如:`gpu:0,1,2,3`;
 * `Train`:训练超参数设置;
     * `epochs_iters`:训练轮次数设置;
     * `learning_rate`:训练学习率设置;
 
-以上参数通过可以通过追加令行参数的形式进行设置,如指定模式为模型训练:`-o Global.mode=train`;指定 2 卡 GPU 训练:`-o Global.device=gpu:0,1`;设置训练轮次数为 10:`-o Train.epochs_iters=10`。
+更多超参数介绍,请参考 [PaddleX 超参数介绍](./hyperparameters_introduction.md)。
+
+**注:** 
+- 以上参数可以通过追加令行参数的形式进行设置,如指定模式为模型训练:`-o Global.mode=train`;指定前 2 卡 GPU 训练:`-o Global.device=gpu:0,1`;设置训练轮次数为 10:`-o Train.epochs_iters=10`。
+- 模型训练过程中,PaddleX 会自动保存模型权重文件,默认为`output`,如需指定保存路径,可通过配置文件中 `-o Global.output` 字段进行设置。
+- 在 OCR 和语义分割任务模块中,参数 `epochs_iters` 对应训练 Step 数,在其他任务模块中,参数 `epochs_iters` 对应训练 Epoch 数。
 
-## 2. 评估
+## 2. 模型评估
 
 在完成模型训练后,可以对指定的模型权重文件在验证集上进行评估,验证模型精度。使用 PaddleX 进行模型评估,只需一行命令:
 
 ```bash
-python main.py -c paddlex/configs/image_classification/PP-LCNet_x1_0.yaml -o Global.mode=evaluate
+python main.py -c paddlex/configs/image_classification/PP-LCNet_x1_0.yaml \
+    -o Global.mode=evaluate \
+    -o Global.dataset_dir=./dataset/cls_flowers_examples
 ```
 
 与模型训练类似,模型评估支持修改配置文件或追加命令行参数的方式设置。
+
+**注:** 在模型评估时,需要指定模型权重文件路径,每个配置文件中都内置了默认的权重保存路径,如需要改变,只需要通过追加命令行参数的形式进行设置即可,如`-o Evaluate.weight_path=./output/best_model.pdparams`。
+
+## 3. 须知事项
+### 3.1 训练须知事项
+- 训练其他模型时,需要的指定相应的配置文件,模型和配置的文件的对应关系,可以详情[模型库](../models/support_model_list.md)。
+- PaddleX 对您屏蔽了动态图权重和静态图权重的概念,在模型训练的过程中,会同时产出动态图和静态图的权重,在模型推理时,默认选择静态图权重推理。
+<!-- 这里需要补充说明,廷权 -->
+### 3.2 训练产出解释
+<!-- 这里需要补充说明,廷权 -->

+ 32 - 0
docs/tutorials/train/hyperparameters_introduction.md

@@ -0,0 +1,32 @@
+# PaddleX 超参数介绍
+PaddleX 暴露了模型迭代中最常修改的参数,方便您在配置文件中或者命令行中进行修改。训练模型的基础配置和高级配置参数如下:
+
+## 1. 基础参数
+对于非时序任务模块,基础参数包括`epochs_iters`,`batch_size`,`class_num`,`learning_rate`,相关的参数解释如下:
+- `epochs_iters`:Epochs 或者 Steps,模型对训练数据的重复学习次数,一般来说,轮次越大,模型训练时间越长,模型精度越高,但是如果设置特别大,可能会导致模型过拟合。如果对轮次没有特别的要求,可以使用默认值进行训练。
+- `batch_size`:批大小,由于训练数据量一般较大,模型每轮次的训练是分批读取数据的,批大小是每一批数据的数据量,和显存直接相关,批大小越大模型训练的速度越快,显存占用越高。
+- `class_num`:类别数量,数据集中的类别数(若有类别概念),由于类别数量和数据集直接相关,我们无法填充默认值,请根据数据校验的结果进行填写,类别数量需要准确,否则可能引起训练失败。
+- `learning_rate`:学习率,模型训练过程中梯度调整的步长,通常与批大小成正比例关系,学习率设置过大可能会导致模型训练不收敛,设置过小可能会导致模型收敛速度过慢。在不同的数据集上学习率可能不同,对结果影响较大,需要不断调试。
+
+对于时序任务模块,基础参数包括`time_col`,`target_cols`,`group_id`,`static_cov_cols`,`freq`,`seq_len`。相关的参数解释如下:
+- `time_col`:时间列,须结合自己的数据设置时间序列数据集的时间列的列名称。
+- `target_cols`:目标变量列,须结合自己的数据设置时间序列数据集的目标变量的列名称,可以为多个,多个之间用','分隔。
+- `group_id`:分组列名,时序数据中表示分组标识的列名称。
+-  `static_cov_cols`:标签变量,代表时序的类别,须结合自己的数据设置类别的列名称,如:label。
+- `freq`:频率,须结合自己的数据设置时间频率,如:1min、5min、1h。
+- `seq_len`:群组编号,须结合自己的数据设置指定群组编号的列名称, 如:group_id, 群组编号表示的是每个时序样本。
+
+## 2. 进阶参数
+- `resune_path`:断点训练权重:在模型训练过程中发生人为或意外终止的情况时,加载训练中断之前保存的断点权重路径,完成继续训练,避免算力资源浪费。
+- `pretrain_weight_path`:预训练权重:基于已经在大数据集上训练好的模型权重进行微调训练,可提高模型训练开始前的初始经验,提高训练效率。
+- `warmup_steps`:热启动步数(WarmUp Steps):在训练初始阶段以较小学习率缓慢增加到设置学习率的批次数量,该值的设置可以避免模型在初始阶段以较大学习率迭代模型最终破坏预训练权重,一定程度上提升模型的精度。
+- `log_inteval`:log 打印间隔,训练日志中打印日志信息的批次数量间隔。
+- `eval_inteval`:评估间隔,训练过程中对验证集进行评估的轮数间隔。
+- `save_inteval`:保存权重间隔,训练过程中保存权重的轮数间隔。
+
+**注:** 在**目标检测**和**实例分割**任务模块中,评估、保存间隔为统一参数 `eval_interval`。
+
+## 3. 更多参数
+在 PaddleX 中,除了常见的参数修改之外,也支持您修改更多的参数。
+<!-- 这里简单解释不同config的逻辑,以及参数覆盖逻辑,廷权 -->
+

+ 47 - 0
docs/tutorials/wheel.md

@@ -0,0 +1,47 @@
+# 使用 PaddleX wheel 进行推理预测
+
+## 1. 安装
+
+### 1.1 安装 PaddleX whl
+
+1. 安装官方版本
+
+```bash
+pip install paddlex
+```
+
+2. 从源码编译安装
+
+```bash
+cd PaddleX
+python setup.py install
+```
+
+### 1.2 安装 PaddleX 相关依赖
+
+```bash
+paddlex --install
+```
+
+## 2. 推理预测
+
+### 2.1 使用 CLI 进行推理预测
+
+以图像分类模型 `PP-LCNet_x1_0` 为例,使用inference模型文件(`output/best_model`)对图像(`/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg`)进行预测,命令如下:
+
+```bash
+paddlex --model_name PP-LCNet_x1_0 --model output/best_model --device gpu:0 --input_path /paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg --output
+```
+
+可以得到预测结果:
+
+```
+image_00002.jpg:        class id(s): [76, 24, 70, 18, 14], score(s): [0.66, 0.05, 0.02, 0.02, 0.01], label_name(s): ['tarantula', 'great grey owl, great gray owl, Strix nebulosa', 'harvestman, daddy longlegs, Phalangium opilio', 'magpie', 'indigo bunting, indigo finch, indigo bird, Passerina cyanea']
+```
+
+### 2.2 使用 Python 进行推理预测
+
+```python
+import paddlex
+paddlex.predict("PP-LCNet_x1_0", "output/best_model", "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg", "gpu", "./output")
+```

+ 13 - 8
install_pdx.py

@@ -1,13 +1,18 @@
-# !/usr/bin/env python3
-# -*- coding: UTF-8 -*-
-################################################################################
+# 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
 #
-# Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved
+#    http://www.apache.org/licenses/LICENSE-2.0
 #
-################################################################################
-"""
-Author: PaddlePaddle Authors
-"""
+# 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.
+
+
 import os
 import argparse
 from paddlex.repo_manager import setup, get_all_supported_repo_names

+ 13 - 8
main.py

@@ -1,13 +1,18 @@
-# !/usr/bin/env python3
-# -*- coding: UTF-8 -*-
-################################################################################
+# 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
 #
-# Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved
+#    http://www.apache.org/licenses/LICENSE-2.0
 #
-################################################################################
-"""
-Author: PaddlePaddle Authors
-"""
+# 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 paddlex.engine import Engine
 
 if __name__ == "__main__":

+ 20 - 10
paddlex/__init__.py

@@ -1,21 +1,31 @@
-# !/usr/bin/env python3
-# -*- coding: UTF-8 -*-
-################################################################################
+# 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
 #
-# Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved
+#    http://www.apache.org/licenses/LICENSE-2.0
 #
-################################################################################
-"""
-Author: PaddlePaddle Authors
-"""
+# 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.
+
+
 
 import os
 
-from .utils import flags
 from . import version
+from .paddlex import predict
+from .modules import build_dataset_checker, build_trainer, build_evaluater, build_predictor
+from .pipelines import *
+from .modules.base.predictor.utils.paddle_inference_predictor import PaddleInferenceOption
 
 
 def _initialize():
+    from .utils.logging import setup_logging
+    from .utils import flags
     from . import repo_manager
     from . import repo_apis
 
@@ -23,7 +33,7 @@ def _initialize():
     repo_manager.set_parent_dirs(
         os.path.join(__DIR__, 'repo_manager', 'repos'), repo_apis)
 
-    # setup_logging()
+    setup_logging()
 
     if flags.EAGER_INITIALIZATION:
         repo_manager.initialize()

+ 8 - 2
paddlex/configs/image_classification/CLIP_vit_base_patch16_224.yaml

@@ -1,12 +1,11 @@
 Global:
   model: CLIP_vit_base_patch16_224
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 9 - 3
paddlex/configs/image_classification/CLIP_vit_large_patch14_224.yaml

@@ -1,12 +1,11 @@
 Global:
   model: CLIP_vit_large_patch14_224
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -18,7 +17,7 @@ CheckDataset:
 Train:
   num_classes: 102
   epochs_iters: 20
-  batch_size: 64
+  batch_size: 32
   learning_rate: 0.0003
   pretrain_weight_path: null
   warmup_steps: 5
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/ConvNeXt_tiny.yaml

@@ -1,12 +1,11 @@
 Global:
   model: ConvNeXt_tiny
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/image_classification/MobileNetV2_x0_25.yaml

@@ -1,12 +1,11 @@
 Global:
   model: MobileNetV2_x0_25
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -27,7 +26,13 @@ Train:
   eval_interval: 1
   save_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/image_classification/MobileNetV2_x0_5.yaml

@@ -1,12 +1,11 @@
 Global:
   model: MobileNetV2_x0_5
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -27,7 +26,13 @@ Train:
   eval_interval: 1
   save_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/image_classification/MobileNetV2_x1_0.yaml

@@ -1,12 +1,11 @@
 Global:
   model: MobileNetV2_x1_0
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -27,7 +26,13 @@ Train:
   eval_interval: 1
   save_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/image_classification/MobileNetV2_x1_5.yaml

@@ -1,12 +1,11 @@
 Global:
   model: MobileNetV2_x1_5
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -27,7 +26,13 @@ Train:
   eval_interval: 1
   save_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/image_classification/MobileNetV2_x2_0.yaml

@@ -1,12 +1,11 @@
 Global:
   model: MobileNetV2_x2_0
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -27,7 +26,13 @@ Train:
   eval_interval: 1
   save_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/image_classification/MobileNetV3_large_x0_35.yaml

@@ -1,12 +1,11 @@
 Global:
   model: MobileNetV3_large_x0_35
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -27,7 +26,13 @@ Train:
   eval_interval: 1
   save_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/image_classification/MobileNetV3_large_x0_5.yaml

@@ -1,12 +1,11 @@
 Global:
   model: MobileNetV3_large_x0_5
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -27,7 +26,13 @@ Train:
   eval_interval: 1
   save_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/image_classification/MobileNetV3_large_x0_75.yaml

@@ -1,12 +1,11 @@
 Global:
   model: MobileNetV3_large_x0_75
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -27,7 +26,13 @@ Train:
   eval_interval: 1
   save_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/image_classification/MobileNetV3_large_x1_0.yaml

@@ -1,12 +1,11 @@
 Global:
   model: MobileNetV3_large_x1_0
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -27,7 +26,13 @@ Train:
   eval_interval: 1
   save_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/image_classification/MobileNetV3_large_x1_25.yaml

@@ -1,12 +1,11 @@
 Global:
   model: MobileNetV3_large_x1_25
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -27,7 +26,13 @@ Train:
   eval_interval: 1
   save_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/image_classification/MobileNetV3_small_x0_35.yaml

@@ -1,12 +1,11 @@
 Global:
   model: MobileNetV3_small_x0_35
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -27,7 +26,13 @@ Train:
   eval_interval: 1
   save_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/image_classification/MobileNetV3_small_x0_5.yaml

@@ -1,12 +1,11 @@
 Global:
   model: MobileNetV3_small_x0_5
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -27,7 +26,13 @@ Train:
   eval_interval: 1
   save_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/image_classification/MobileNetV3_small_x0_75.yaml

@@ -1,12 +1,11 @@
 Global:
   model: MobileNetV3_small_x0_75
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -27,7 +26,13 @@ Train:
   eval_interval: 1
   save_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/image_classification/MobileNetV3_small_x1_0.yaml

@@ -1,12 +1,11 @@
 Global:
   model: MobileNetV3_small_x1_0
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -27,7 +26,13 @@ Train:
   eval_interval: 1
   save_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/image_classification/MobileNetV3_small_x1_25.yaml

@@ -1,12 +1,11 @@
 Global:
   model: MobileNetV3_small_x1_25
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -27,7 +26,13 @@ Train:
   eval_interval: 1
   save_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 9 - 2
paddlex/configs/image_classification/PP-HGNetV2-B0.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-HGNetV2-B0
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -26,6 +25,14 @@ Train:
   log_interval: 1
   eval_interval: 1
   save_interval: 1
+
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/PP-HGNetV2-B4.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-HGNetV2-B4
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/PP-HGNetV2-B6.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-HGNetV2-B6
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/PP-HGNet_small.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-HGNet_small
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/PP-LCNet_x0_25.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-LCNet_x0_25
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/PP-LCNet_x0_35.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-LCNet_x0_35
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/PP-LCNet_x0_5.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-LCNet_x0_5
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/PP-LCNet_x0_75.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-LCNet_x0_75
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/PP-LCNet_x1_0.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-LCNet_x1_0
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/PP-LCNet_x1_5.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-LCNet_x1_5
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/PP-LCNet_x2_0.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-LCNet_x2_0
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/PP-LCNet_x2_5.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-LCNet_x2_5
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/ResNet101.yaml

@@ -1,12 +1,11 @@
 Global:
   model: ResNet101
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/ResNet152.yaml

@@ -1,12 +1,11 @@
 Global:
   model: ResNet152
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/ResNet18.yaml

@@ -1,12 +1,11 @@
 Global:
   model: ResNet18
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/ResNet34.yaml

@@ -1,12 +1,11 @@
 Global:
   model: ResNet34
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/ResNet50.yaml

@@ -1,12 +1,11 @@
 Global:
   model: ResNet50
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/image_classification/SwinTransformer_base_patch4_window7_224.yaml

@@ -1,12 +1,11 @@
 Global:
   model: SwinTransformer_base_patch4_window7_224
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/cls/cls_flowers_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -30,3 +29,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/cls/cls_flowers_examples/images/image_00002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 10 - 4
paddlex/configs/instance_segmentation/Mask-RT-DETR-H.yaml

@@ -1,12 +1,11 @@
 Global:
   model: Mask-RT-DETR-H
-  mode: check_dataset # check_dataset/train/evaluate
-  dataset_dir: "/paddle/dataset/paddlex/instance_seg"
+  mode: check_dataset # check_dataset/train/evaluate/predict
+  dataset_dir: "/paddle/dataset/paddlex/instance_seg/instance_seg_coco_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: nul
@@ -28,4 +27,11 @@ Train:
 
 Evaluate:
   weight_path: "output/best_model.pdparams"
-  log_interval: 10
+  log_interval: 10
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/instance_seg/instance_seg_coco_examples/images/aircraft-women-fashion-pilot-48797.png"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/instance_segmentation/Mask-RT-DETR-L.yaml

@@ -1,12 +1,11 @@
 Global:
   model: Mask-RT-DETR-L
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/instance_seg/instance_seg_coco_examples/"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: nul
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/instance_seg/instance_seg_coco_examples/images/aircraft-women-fashion-pilot-48797.png"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/object_detection/PP-YOLOE_plus-L.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-YOLOE_plus-L
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/det/det_coco_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert:
     enable: False
     src_dataset_type: nul
@@ -26,7 +25,13 @@ Train:
   log_interval: 10
   eval_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/det/det_coco_examples/images/road0.png"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/object_detection/PP-YOLOE_plus-M.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-YOLOE_plus-M
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/det/det_coco_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert:
     enable: False
     src_dataset_type: nul
@@ -26,7 +25,13 @@ Train:
   log_interval: 10
   eval_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/det/det_coco_examples/images/road0.png"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/object_detection/PP-YOLOE_plus-S.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-YOLOE_plus-S
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/det/det_coco_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert:
     enable: False
     src_dataset_type: nul
@@ -26,7 +25,13 @@ Train:
   log_interval: 10
   eval_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/det/det_coco_examples/images/road0.png"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/object_detection/PP-YOLOE_plus-X.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-YOLOE_plus-X
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/det/det_coco_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert:
     enable: False
     src_dataset_type: nul
@@ -26,7 +25,13 @@ Train:
   log_interval: 10
   eval_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/det/det_coco_examples/images/road0.png"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/object_detection/PicoDet-L.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PicoDet-L
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/det/det_coco_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert:
     enable: False
     src_dataset_type: nul
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/det/det_coco_examples/images/road0.png"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 3
paddlex/configs/object_detection/PicoDet-S.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PicoDet-S
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/det/det_coco_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert:
     enable: False
     src_dataset_type: nul
@@ -26,7 +25,13 @@ Train:
   log_interval: 10
   eval_interval: 1
 
-
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/det/det_coco_examples/images/road0.png"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/object_detection/RT-DETR-H.yaml

@@ -1,12 +1,11 @@
 Global:
   model: RT-DETR-H
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/det/det_coco_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert:
     enable: False
     src_dataset_type: nul
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/det/det_coco_examples/images/road0.png"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/object_detection/RT-DETR-L.yaml

@@ -1,12 +1,11 @@
 Global:
   model: RT-DETR-L
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/det/det_coco_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert:
     enable: False
     src_dataset_type: nul
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/det/det_coco_examples/images/road0.png"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/object_detection/RT-DETR-R18.yaml

@@ -1,12 +1,11 @@
 Global:
   model: RT-DETR-R18
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/det/det_coco_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert:
     enable: False
     src_dataset_type: nul
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/det/det_coco_examples/images/road0.png"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/object_detection/RT-DETR-R50.yaml

@@ -1,12 +1,11 @@
 Global:
   model: RT-DETR-R50
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/det/det_coco_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert:
     enable: False
     src_dataset_type: nul
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/det/det_coco_examples/images/road0.png"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/object_detection/RT-DETR-X.yaml

@@ -1,12 +1,11 @@
 Global:
   model: RT-DETR-X
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/det/det_coco_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert:
     enable: False
     src_dataset_type: nul
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/det/det_coco_examples/images/road0.png"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/semantic_segmentation/Deeplabv3-R101.yaml

@@ -1,12 +1,11 @@
 Global:
   model: Deeplabv3-R101
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/seg/seg_optic_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model/model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model/model"
+  input_path: "/paddle/dataset/paddlex/seg/seg_optic_examples/images/H0002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/semantic_segmentation/Deeplabv3-R50.yaml

@@ -1,12 +1,11 @@
 Global:
   model: Deeplabv3-R50
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/seg/seg_optic_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model/model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model/model"
+  input_path: "/paddle/dataset/paddlex/seg/seg_optic_examples/images/H0002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/semantic_segmentation/Deeplabv3_Plus-R101.yaml

@@ -1,12 +1,11 @@
 Global:
   model: Deeplabv3_Plus-R101
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/seg/seg_optic_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model/model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model/model"
+  input_path: "/paddle/dataset/paddlex/seg/seg_optic_examples/images/H0002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/semantic_segmentation/Deeplabv3_Plus-R50.yaml

@@ -1,12 +1,11 @@
 Global:
   model: Deeplabv3_Plus-R50
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/seg/seg_optic_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model/model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model/model"
+  input_path: "/paddle/dataset/paddlex/seg/seg_optic_examples/images/H0002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/semantic_segmentation/OCRNet_HRNet-W48.yaml

@@ -1,12 +1,11 @@
 Global:
   model: OCRNet_HRNet-W48
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/seg/seg_optic_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model/model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model/model"
+  input_path: "/paddle/dataset/paddlex/seg/seg_optic_examples/images/H0002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/semantic_segmentation/PP-LiteSeg-T.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-LiteSeg-T
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/seg/seg_optic_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model/model.pdparams"
   log_interval: 10
+
+Predict:
+  model_dir: "output/best_model/model"
+  input_path: "/paddle/dataset/paddlex/seg/seg_optic_examples/images/H0002.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/structure_analysis/PicoDet_layout_1x.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PicoDet_layout_1x
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/layout/det_layout_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert:
     enable: False
     src_dataset_type: nul
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_model.pdparams"
   log_interval: 10
+
+Predict:
+  model: "output/best_model"
+  input_path: "/paddle/dataset/paddlex/layout/det_layout_examples/images/JPEGImages/train_0001.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 9 - 3
paddlex/configs/table_recognition/SLANet.yaml

@@ -1,12 +1,11 @@
 Global:
   model: SLANet
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/table_rec/table_rec_dataset_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert:
     enable: False
     src_dataset_type: null
@@ -27,4 +26,11 @@ Train:
 
 Evaluate:
   weight_path: "output/best_accuracy.pdparams"
-  log_interval: 1
+  log_interval: 1
+
+Predict:
+  model_dir: "output/best_accuracy"
+  input_path: "/paddle/dataset/paddlex/table_rec/table_rec_dataset_examples/images/border_10368_GBUAFQNHRKR5FUQ6ZE50.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/text_detection/PP-OCRv4_mobile_det.yaml

@@ -1,13 +1,12 @@
 Global:
   model: PP-OCRv4_mobile_det
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   module: text_det
   dataset_dir: "/paddle/dataset/paddlex/ocr_det/ocr_det_dataset_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert:
     enable: False
     src_dataset_type: null
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_accuracy.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_accuracy"
+  input_path: "/paddle/dataset/paddlex/ocr_det/ocr_det_dataset_examples/images/train_img_100.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/text_detection/PP-OCRv4_server_det.yaml

@@ -1,13 +1,12 @@
 Global:
   model: PP-OCRv4_server_det
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   module: text_det
   dataset_dir: "/paddle/dataset/paddlex/ocr_det/ocr_det_dataset_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert:
     enable: False
     src_dataset_type: null
@@ -29,3 +28,10 @@ Train:
 Evaluate:
   weight_path: "output/best_accuracy.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_accuracy"
+  input_path: "/paddle/dataset/paddlex/ocr_det/ocr_det_dataset_examples/images/train_img_100.jpg"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/text_recognition/PP-OCRv4_mobile_rec.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-OCRv4_mobile_rec
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/ocr_rec/ocr_rec_dataset_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -28,3 +27,10 @@ Train:
 Evaluate:
   weight_path: "output/best_accuracy.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_accuracy"
+  input_path: "/paddle/dataset/paddlex/ocr_rec/ocr_rec_dataset_examples/images/train_word_1003.png"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 8 - 2
paddlex/configs/text_recognition/PP-OCRv4_server_rec.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PP-OCRv4_server_rec
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/ocr_rec/ocr_rec_dataset_examples"
   device: gpu:0,1,2,3
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: null
@@ -28,3 +27,10 @@ Train:
 Evaluate:
   weight_path: "output/best_accuracy.pdparams"
   log_interval: 1
+
+Predict:
+  model_dir: "output/best_accuracy"
+  input_path: "/paddle/dataset/paddlex/ocr_rec/ocr_rec_dataset_examples/images/train_word_1003.png"
+  kernel_option:
+    run_mode: paddle
+    batch_size: 1

+ 5 - 2
paddlex/configs/ts_anomaly_detection/AutoEncoder_ad.yaml

@@ -1,12 +1,11 @@
 Global:
   model: AutoEncoder_ad
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/ts_ad/ts_anomaly_examples/"
   device: gpu:0
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: nul
@@ -27,3 +26,7 @@ Train:
 
 Evaluate:
   weight_path: "output/best_accuracy.pdparams.tar"
+
+Predict:
+  model_dir: "output/best_model/model.pdparams"
+  input_path: "/paddle/dataset/paddlex/ts_ad/ts_anomaly_examples/test.csv"

+ 5 - 3
paddlex/configs/ts_anomaly_detection/DLinear_ad.yaml

@@ -1,12 +1,11 @@
 Global:
   model: DLinear_ad
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/ts_ad/ts_anomaly_examples/"
   device: gpu:0
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: nul
@@ -25,6 +24,9 @@ Train:
   batch_size: 16
   learning_rate: 0.0005
 
-
 Evaluate:
   weight_path: "output/best_accuracy.pdparams.tar"
+
+Predict:
+  model_dir: "output/best_model/model.pdparams"
+  input_path: "/paddle/dataset/paddlex/ts_ad/ts_anomaly_examples/test.csv"

+ 5 - 3
paddlex/configs/ts_anomaly_detection/Nonstationary_ad.yaml

@@ -1,12 +1,11 @@
 Global:
   model: Nonstationary_ad
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/ts_ad/ts_anomaly_examples/"
   device: gpu:0
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: nul
@@ -25,6 +24,9 @@ Train:
   batch_size: 16
   learning_rate: 0.0005
 
-
 Evaluate:
   weight_path: "output/best_accuracy.pdparams.tar"
+
+Predict:
+  model_dir: "output/best_model/model.pdparams"
+  input_path: "/paddle/dataset/paddlex/ts_ad/ts_anomaly_examples/test.csv"

+ 5 - 3
paddlex/configs/ts_anomaly_detection/PatchTST_ad.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PatchTST_ad
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/ts_ad/ts_anomaly_examples/"
   device: gpu:0
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: nul
@@ -25,6 +24,9 @@ Train:
   batch_size: 16
   learning_rate: 0.0005
 
-
 Evaluate:
   weight_path: "output/best_accuracy.pdparams.tar"
+
+Predict:
+  model_dir: "output/best_model/model.pdparams"
+  input_path: "/paddle/dataset/paddlex/ts_ad/ts_anomaly_examples/test.csv"

+ 5 - 3
paddlex/configs/ts_anomaly_detection/TimesNet_ad.yaml

@@ -1,12 +1,11 @@
 Global:
   model: TimesNet_ad
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/ts_ad/ts_anomaly_examples/"
   device: gpu:0
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: nul
@@ -25,6 +24,9 @@ Train:
   batch_size: 16
   learning_rate: 0.0005
 
-
 Evaluate:
   weight_path: "output/best_accuracy.pdparams.tar"
+
+Predict:
+  model_dir: "output/best_model/model.pdparams"
+  input_path: "/paddle/dataset/paddlex/ts_ad/ts_anomaly_examples/test.csv"

+ 5 - 2
paddlex/configs/ts_classification/TimesNet_cls.yaml

@@ -1,12 +1,11 @@
 Global:
   model: TimesNet_cls
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/ts_cls/ts_classify_examples"
   device: gpu:0
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: nul
@@ -27,3 +26,7 @@ Train:
 
 Evaluate:
   weight_path: "output/best_accuracy.pdparams.tar"
+
+Predict:
+  model_dir: "output/best_model/model.pdparams"
+  input_path: "/paddle/dataset/paddlex/ts_cls/ts_classify_examples/test.csv"

+ 5 - 2
paddlex/configs/ts_forecast/DLinear.yaml

@@ -1,12 +1,11 @@
 Global:
   model: DLinear
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/ts_fc/ts_dataset_examples"
   device: gpu:0
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: nul
@@ -28,3 +27,7 @@ Train:
 
 Evaluate:
   weight_path: "output/best_accuracy.pdparams.tar"
+
+Predict:
+  model_dir: "output/best_model/model.pdparams"
+  input_path: "/paddle/dataset/paddlex/ts_fc/ts_dataset_examples/test.csv"

+ 5 - 2
paddlex/configs/ts_forecast/NLinear.yaml

@@ -1,12 +1,11 @@
 Global:
   model: NLinear
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/ts_fc/ts_dataset_examples"
   device: gpu:0
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: nul
@@ -28,3 +27,7 @@ Train:
 
 Evaluate:
   weight_path: "output/best_accuracy.pdparams.tar"
+
+Predict:
+  model_dir: "output/best_model/model.pdparams"
+  input_path: "/paddle/dataset/paddlex/ts_fc/ts_dataset_examples/test.csv"

+ 5 - 2
paddlex/configs/ts_forecast/Nonstationary.yaml

@@ -1,12 +1,11 @@
 Global:
   model: Nonstationary
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/ts_fc/ts_dataset_examples"
   device: gpu:0
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: nul
@@ -28,3 +27,7 @@ Train:
 
 Evaluate:
   weight_path: "output/best_accuracy.pdparams.tar"
+
+Predict:
+  model_dir: "output/best_model/model.pdparams"
+  input_path: "/paddle/dataset/paddlex/ts_fc/ts_dataset_examples/test.csv"

+ 5 - 2
paddlex/configs/ts_forecast/PatchTST.yaml

@@ -1,12 +1,11 @@
 Global:
   model: PatchTST
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/ts_fc/ts_dataset_examples"
   device: gpu:0
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: nul
@@ -28,3 +27,7 @@ Train:
 
 Evaluate:
   weight_path: "output/best_accuracy.pdparams.tar"
+
+Predict:
+  model_dir: "output/best_model/model.pdparams"
+  input_path: "/paddle/dataset/paddlex/ts_fc/ts_dataset_examples/test.csv"

+ 5 - 2
paddlex/configs/ts_forecast/RLinear.yaml

@@ -1,12 +1,11 @@
 Global:
   model: RLinear
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/ts_fc/ts_dataset_examples"
   device: gpu:0
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: nul
@@ -28,3 +27,7 @@ Train:
 
 Evaluate:
   weight_path: "output/best_accuracy.pdparams.tar"
+
+Predict:
+  model_dir: "output/best_model/model.pdparams"
+  input_path: "/paddle/dataset/paddlex/ts_fc/ts_dataset_examples/test.csv"

+ 5 - 2
paddlex/configs/ts_forecast/TiDE.yaml

@@ -1,12 +1,11 @@
 Global:
   model: TiDE
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/ts_fc/ts_dataset_examples"
   device: gpu:0
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: nul
@@ -28,3 +27,7 @@ Train:
 
 Evaluate:
   weight_path: "output/best_accuracy.pdparams.tar"
+
+Predict:
+  model_dir: "output/best_model/model.pdparams"
+  input_path: "/paddle/dataset/paddlex/ts_fc/ts_dataset_examples/test.csv"

+ 5 - 2
paddlex/configs/ts_forecast/TimesNet.yaml

@@ -1,12 +1,11 @@
 Global:
   model: TimesNet
-  mode: check_dataset # check_dataset/train/evaluate
+  mode: check_dataset # check_dataset/train/evaluate/predict
   dataset_dir: "/paddle/dataset/paddlex/ts_fc/ts_dataset_examples"
   device: gpu:0
   output: "output"
 
 CheckDataset:
-  dst_dataset_name: dataset
   convert: 
     enable: False
     src_dataset_type: nul
@@ -28,3 +27,7 @@ Train:
 
 Evaluate:
   weight_path: "output/best_accuracy.pdparams.tar"
+
+Predict:
+  model_dir: "output/best_model/model.pdparams"
+  input_path: "/paddle/dataset/paddlex/ts_fc/ts_dataset_examples/test.csv"

+ 18 - 10
paddlex/engine.py

@@ -1,16 +1,21 @@
-# !/usr/bin/env python3
-# -*- coding: UTF-8 -*-
-################################################################################
+# 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
 #
-# Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved
+#    http://www.apache.org/licenses/LICENSE-2.0
 #
-################################################################################
-"""
-Author: PaddlePaddle Authors
-"""
+# 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.
+
+
 import os
 
-from .modules.base import build_dataset_checker, build_trainer, build_evaluater
+from .modules.base import build_dataset_checker, build_trainer, build_evaluater, build_predictor
 from .utils.result_saver import try_except_decorator
 from .utils import config
 from .utils.errors import raise_unsupported_api_error
@@ -40,6 +45,9 @@ class Engine(object):
             return evaluate()
         elif self.config.Global.mode == "export":
             raise_unsupported_api_error("export", self.__class__)
+        elif self.config.Global.mode == "predict":
+            predict = build_predictor(self.config)
+            return predict()
         else:
             raise_unsupported_api_error(f"{self.config.Global.mode}",
-                                        self.__class__)
+                                        self.__class__)

+ 27 - 20
paddlex/modules/__init__.py

@@ -1,20 +1,27 @@
-# !/usr/bin/env python3
-# -*- coding: UTF-8 -*-
-################################################################################
-#
-# Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved
-#
-################################################################################
-"""
-Author: PaddlePaddle Authors
-"""
-from .image_classification import ClsDatasetChecker, ClsTrainer, ClsEvaluator
-from .object_detection import COCODatasetChecker, DetTrainer, DetEvaluator
-from .text_detection import TextDetDatasetChecker, TextDetTrainer, TextDetEvaluator
-from .text_recognition import TextRecDatasetChecker, TextRecTrainer, TextRecEvaluator
-from .table_recognition import TableRecDatasetChecker, TableRecTrainer, TableRecEvaluator
-from .semantic_segmentation import SegDatasetChecker, SegTrainer, SegEvaluator
-from .instance_segmentation import COCOInstSegDatasetChecker, InstanceSegTrainer, InstanceSegEvaluator
-from .ts_anomaly_detection import TSADDatasetChecker, TSADTrainer, TSADEvaluator
-from .ts_classification import TSCLSDatasetChecker, TSCLSTrainer, TSCLSEvaluator
-from .ts_forecast import TSFCDatasetChecker, TSFCTrainer, TSFCEvaluator
+# 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 .base import build_dataset_checker, build_trainer, build_evaluater, build_predictor, create_model
+from .image_classification import ClsDatasetChecker, ClsTrainer, ClsEvaluator, ClsPredictor
+from .object_detection import COCODatasetChecker, DetTrainer, DetEvaluator, DetPredictor
+from .text_detection import TextDetDatasetChecker, TextDetTrainer, TextDetEvaluator, TextDetPredictor
+from .text_recognition import TextRecDatasetChecker, TextRecTrainer, TextRecEvaluator, TextRecPredictor
+from .table_recognition import TableRecDatasetChecker, TableRecTrainer, TableRecEvaluator, TableRecPredictor
+from .semantic_segmentation import SegDatasetChecker, SegTrainer, SegEvaluator, SegPredictor
+from .instance_segmentation import COCOInstSegDatasetChecker, InstanceSegTrainer, InstanceSegEvaluator, \
+InstanceSegPredictor
+from .ts_anomaly_detection import TSADDatasetChecker, TSADTrainer, TSADEvaluator, TSADPredictor
+from .ts_classification import TSCLSDatasetChecker, TSCLSTrainer, TSCLSEvaluator, TSCLSPredictor
+from .ts_forecast import TSFCDatasetChecker, TSFCTrainer, TSFCEvaluator, TSFCPredictor

+ 18 - 11
paddlex/modules/base/__init__.py

@@ -1,14 +1,21 @@
-# !/usr/bin/env python3
-# -*- coding: UTF-8 -*-
-################################################################################
+# 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
 #
-# Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved
+#    http://www.apache.org/licenses/LICENSE-2.0
 #
-################################################################################
-"""
-Author: PaddlePaddle Authors
-"""
+# 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 .dataset_checker import build_dataset_checker
-from .trainer import build_trainer
-from .evaluator import build_evaluater
+
+
+from .dataset_checker import build_dataset_checker, BaseDatasetChecker
+from .trainer import build_trainer, BaseTrainer
+from .evaluator import build_evaluater, BaseEvaluator
+from .predictor import BasePredictor, BaseTransform, PaddleInferenceOption, build_predictor, create_model
+from .train_deamon import BaseTrainDeamon

+ 18 - 18
paddlex/modules/base/build_model.py

@@ -1,22 +1,30 @@
-# !/usr/bin/env python3
-# -*- coding: UTF-8 -*-
-################################################################################
+# 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
 #
-# Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved
+#    http://www.apache.org/licenses/LICENSE-2.0
 #
-################################################################################
-"""
-Author: PaddlePaddle Authors
-"""
+# 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.
+
+
 import os
 from ...repo_apis.base import Config, PaddleModel
+from ...utils.device import get_device
 
 
-def build_model(model_name: str, config_path: str=None) -> tuple:
+def build_model(model_name: str, device: str=None,
+                config_path: str=None) -> tuple:
     """build Config and PaddleModel
 
     Args:
         model_name (str): model name
+        device (str): device, such as gpu, cpu, npu, xpu, mlu
         config_path (str, optional): path to the PaddleX config yaml file.
             Defaults to None, i.e. using the default config file.
 
@@ -25,15 +33,7 @@ def build_model(model_name: str, config_path: str=None) -> tuple:
     """
     config = Config(model_name, config_path)
 
-    # NOTE(gaotingquan): aistudio can only support 4GB shm when single gpu can be used.
-    device = os.environ.get("DEVICE", None)
     if device:
-        if device.lower() == "cpu" or (
-                device.lower() == "gpu" and
-                os.environ.get("GPU_NUMBER", None) == "1"):
-            if hasattr(config, "disable_shared_memory"):
-                config.disable_shared_memory()
-            if hasattr(config, "update_num_workers"):
-                config.update_num_workers(2)
+        config.update_device(get_device(device).split(":")[0])
     model = PaddleModel(config=config)
     return config, model

+ 25 - 25
paddlex/modules/base/dataset_checker/__init__.py

@@ -1,24 +1,25 @@
-# !/usr/bin/env python3
-# -*- coding: UTF-8 -*-
-################################################################################
+# 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
 #
-# Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved
+#    http://www.apache.org/licenses/LICENSE-2.0
 #
-################################################################################
-"""
-Author: PaddlePaddle Authors
-"""
+# 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.
+
+
 import os
-import shutil
-import json
-import argparse
-from pathlib import Path
 from abc import ABC, abstractmethod
 
 from .utils import build_res_dict
-from ....utils.file_interface import custom_open
 from ....utils.misc import AutoRegisterABCMetaClass
 from ....utils.config import AttrDict
+from ....utils.logging import info
 
 
 def build_dataset_checker(config: AttrDict) -> "BaseDatasetChecker":
@@ -47,6 +48,8 @@ class BaseDatasetChecker(ABC, metaclass=AutoRegisterABCMetaClass):
         """
         self.global_config = config.Global
         self.check_dataset_config = config.CheckDataset
+        self.output_dir = os.path.join(self.global_config.output,
+                                       "check_dataset")
 
     def __call__(self) -> dict:
         """execute dataset checking
@@ -56,21 +59,18 @@ class BaseDatasetChecker(ABC, metaclass=AutoRegisterABCMetaClass):
         """
         dataset_dir = self.get_dataset_root(self.global_config.dataset_dir)
 
+        if not os.path.exists(self.output_dir):
+            os.makedirs(self.output_dir)
+
         if self.check_dataset_config.get("convert", None):
             if self.check_dataset_config.convert.get("enable", False):
-                dataset_dir = self.convert_dataset(dataset_dir)
+                self.convert_dataset(dataset_dir)
+                info("Convert dataset successfully !")
 
         if self.check_dataset_config.get("split", None):
             if self.check_dataset_config.split.get("enable", False):
-                dataset_dir = self.split_dataset(dataset_dir)
-
-        dst_dataset_path = os.path.join(
-            self.global_config.output,
-            self.check_dataset_config.dst_dataset_name)
-        if os.path.exists(dst_dataset_path):
-            shutil.rmtree(dst_dataset_path)
-        shutil.copytree(dataset_dir, dst_dataset_path)
-        dataset_dir = dst_dataset_path
+                self.split_dataset(dataset_dir)
+                info("Split dataset successfully !")
 
         attrs = self.check_dataset(dataset_dir)
         analysis = self.analyse(dataset_dir)
@@ -78,10 +78,10 @@ class BaseDatasetChecker(ABC, metaclass=AutoRegisterABCMetaClass):
         check_result = build_res_dict(True)
         check_result["attributes"] = attrs
         check_result["analysis"] = analysis
-        check_result[
-            "dataset_path"] = self.check_dataset_config.dst_dataset_name
+        check_result["dataset_path"] = self.global_config.dataset_dir
         check_result["show_type"] = self.get_show_type()
         check_result["dataset_type"] = self.get_dataset_type()
+        info("Check dataset passed !")
         return check_result
 
     def get_dataset_root(self, dataset_dir: str) -> str:

+ 13 - 8
paddlex/modules/base/dataset_checker/utils.py

@@ -1,13 +1,18 @@
-# !/usr/bin/env python3
-# -*- coding: UTF-8 -*-
-################################################################################
+# 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
 #
-# Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved
+#    http://www.apache.org/licenses/LICENSE-2.0
 #
-################################################################################
-"""
-Author: PaddlePaddle Authors
-"""
+# 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.
+
+
 import os
 
 __all__ = [

+ 19 - 14
paddlex/modules/base/evaluator.py

@@ -1,19 +1,24 @@
-# !/usr/bin/env python3
-# -*- coding: UTF-8 -*-
-################################################################################
+# 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
 #
-# Copyright (c) 2024 Baidu.com, Inc. All Rights Reserved
+#    http://www.apache.org/licenses/LICENSE-2.0
 #
-################################################################################
-"""
-Author: PaddlePaddle Authors
-"""
+# 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.
+
+
 import os
 from pathlib import Path
 from abc import ABC, abstractmethod
 
 from .build_model import build_model
-from .utils.device import get_device
+from ...utils.device import get_device
 from ...utils.misc import AutoRegisterABCMetaClass
 from ...utils.config import AttrDict
 from ...utils.logging import *
@@ -58,7 +63,7 @@ class BaseEvaluator(ABC, metaclass=AutoRegisterABCMetaClass):
     def get_config_path(self, weight_path):
         """
         get config path
-        
+
         Args:
             weight_path (str): The path to the weight
 
@@ -123,18 +128,18 @@ evaling!"
 
         return evaluate_result.metrics
 
-    def get_device(self, using_gpu_number: int=None) -> str:
+    def get_device(self, using_device_number: int=None) -> str:
         """get device setting from config
 
         Args:
-            using_gpu_number (int, optional): specify GPU number to use.
+            using_device_number (int, optional): specify device number to use.
                 Defaults to None, means that base on config setting.
 
         Returns:
-            str: device setting, such as: `gpu:0,1`, `cpu`.
+            str: device setting, such as: `gpu:0,1`, `npu:0,1`, `cpu`.
         """
         return get_device(
-            self.global_config.device, using_gpu_number=using_gpu_number)
+            self.global_config.device, using_device_number=using_device_number)
 
     @abstractmethod
     def update_config(self):

+ 19 - 0
paddlex/modules/base/predictor/__init__.py

@@ -0,0 +1,19 @@
+# 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 .predictor import BasePredictor, build_predictor, create_model
+from .transform import BaseTransform
+from .utils.paddle_inference_predictor import PaddleInferenceOption

+ 18 - 0
paddlex/modules/base/predictor/io/__init__.py

@@ -0,0 +1,18 @@
+# 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 .readers import (ImageReader, VideoReader, ReaderType)
+from .writers import (ImageWriter, TextWriter, WriterType)

+ 217 - 0
paddlex/modules/base/predictor/io/readers.py

@@ -0,0 +1,217 @@
+# 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.
+
+
+
+import enum
+import itertools
+
+import cv2
+
+__all__ = ['ImageReader', 'VideoReader', 'ReaderType']
+
+
+class ReaderType(enum.Enum):
+    """ ReaderType """
+    IMAGE = 1
+    GENERATIVE = 2
+    POINT_CLOUD = 3
+
+
+class _BaseReader(object):
+    """ _BaseReader """
+
+    def __init__(self, backend, **bk_args):
+        super().__init__()
+        if len(bk_args) == 0:
+            bk_args = self.get_default_backend_args()
+        self.bk_type = backend
+        self.bk_args = bk_args
+        self._backend = self.get_backend()
+
+    def read(self, in_path):
+        """ read file from path """
+        raise NotImplementedError
+
+    def get_backend(self, bk_args=None):
+        """ get the backend """
+        if bk_args is None:
+            bk_args = self.bk_args
+        return self._init_backend(self.bk_type, bk_args)
+
+    def _init_backend(self, bk_type, bk_args):
+        """ init backend """
+        raise NotImplementedError
+
+    def get_type(self):
+        """ get type """
+        raise NotImplementedError
+
+    def get_default_backend_args(self):
+        """ get default backend arguments """
+        return {}
+
+
+class ImageReader(_BaseReader):
+    """ ImageReader """
+
+    def __init__(self, backend='opencv', **bk_args):
+        super().__init__(backend=backend, **bk_args)
+
+    def read(self, in_path):
+        """ read the image file from path """
+        arr = self._backend.read_file(in_path)
+        return arr
+
+    def _init_backend(self, bk_type, bk_args):
+        """ init backend """
+        if bk_type == 'opencv':
+            return OpenCVImageReaderBackend(**bk_args)
+        else:
+            raise ValueError("Unsupported backend type")
+
+    def get_type(self):
+        """ get type """
+        return ReaderType.IMAGE
+
+
+class _GenerativeReader(_BaseReader):
+    """ _GenerativeReader """
+
+    def get_type(self):
+        """ get type """
+        return ReaderType.GENERATIVE
+
+
+def is_generative_reader(reader):
+    """ is_generative_reader """
+    return isinstance(reader, _GenerativeReader)
+
+
+class VideoReader(_GenerativeReader):
+    """ VideoReader """
+
+    def __init__(self,
+                 backend='opencv',
+                 st_frame_id=0,
+                 max_num_frames=None,
+                 auto_close=True,
+                 **bk_args):
+        super().__init__(backend=backend, **bk_args)
+        self.st_frame_id = st_frame_id
+        self.max_num_frames = max_num_frames
+        self.auto_close = auto_close
+
+    def read(self, in_path):
+        """ read vide file from path """
+        self._backend.set_pos(self.st_frame_id)
+        gen = self._backend.read_file(in_path)
+        if self.num_frames is not None:
+            gen = itertools.islice(gen, self.num_frames)
+        yield from gen
+        if self.auto_close:
+            self._backend.close()
+
+    def _init_backend(self, bk_type, bk_args):
+        """ init backend """
+        if bk_type == 'opencv':
+            return OpenCVVideoReaderBackend(**bk_args)
+        else:
+            raise ValueError("Unsupported backend type")
+
+
+class _BaseReaderBackend(object):
+    """ _BaseReaderBackend """
+
+    def read_file(self, in_path):
+        """ read file from path """
+        raise NotImplementedError
+
+
+class _ImageReaderBackend(_BaseReaderBackend):
+    """ _ImageReaderBackend """
+    pass
+
+
+class OpenCVImageReaderBackend(_ImageReaderBackend):
+    """ OpenCVImageReaderBackend """
+
+    def __init__(self, flags=cv2.IMREAD_COLOR):
+        super().__init__()
+        self.flags = flags
+
+    def read_file(self, in_path):
+        """ read image file from path by OpenCV """
+        return cv2.imread(in_path, flags=self.flags)
+
+
+class _VideoReaderBackend(_BaseReaderBackend):
+    """ _VideoReaderBackend """
+
+    def set_pos(self, pos):
+        """ set pos """
+        raise NotImplementedError
+
+    def close(self):
+        """ close io """
+        raise NotImplementedError
+
+
+class OpenCVVideoReaderBackend(_VideoReaderBackend):
+    """ OpenCVVideoReaderBackend """
+
+    def __init__(self, **bk_args):
+        super().__init__()
+        self.cap_init_args = bk_args
+        self._cap = None
+        self._pos = 0
+        self._max_num_frames = None
+
+    def read_file(self, in_path):
+        """ read vidio file from path """
+        if self._cap is not None:
+            self._cap_release()
+        self._cap = self._cap_open(in_path)
+        if self._pos is not None:
+            self._cap_set_pos()
+        return self._read_frames(self._cap)
+
+    def _read_frames(self, cap):
+        """ read frames """
+        while True:
+            ret, frame = cap.read()
+            if not ret:
+                break
+            yield frame
+        self._cap_release()
+
+    def _cap_open(self, video_path):
+        self._cap = cv2.VideoCapture(video_path, **self.cap_init_args)
+        if not self._cap.isOpened():
+            raise RuntimeError(f"Failed to open {video_path}")
+        return self._cap
+
+    def _cap_release(self):
+        self._cap.release()
+
+    def _cap_set_pos(self):
+        self._cap.set(cv2.CAP_PROP_POS_FRAMES, self._pos)
+
+    def set_pos(self, pos):
+        self._pos = pos
+
+    def close(self):
+        if self._cap is not None:
+            self._cap_release()
+            self._cap = None

+ 176 - 0
paddlex/modules/base/predictor/io/writers.py

@@ -0,0 +1,176 @@
+# 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.
+
+
+
+import os
+import enum
+
+import cv2
+import numpy as np
+from PIL import Image
+
+__all__ = ['ImageWriter', 'TextWriter', 'WriterType']
+
+
+class WriterType(enum.Enum):
+    """ WriterType """
+    IMAGE = 1
+    VIDEO = 2
+    TEXT = 3
+
+
+class _BaseWriter(object):
+    """ _BaseWriter """
+
+    def __init__(self, backend, **bk_args):
+        super().__init__()
+        if len(bk_args) == 0:
+            bk_args = self.get_default_backend_args()
+        self.bk_type = backend
+        self.bk_args = bk_args
+        self._backend = self.get_backend()
+
+    def write(self, out_path, obj):
+        """ write """
+        raise NotImplementedError
+
+    def get_backend(self, bk_args=None):
+        """ get backend """
+        if bk_args is None:
+            bk_args = self.bk_args
+        return self._init_backend(self.bk_type, bk_args)
+
+    def _init_backend(self, bk_type, bk_args):
+        """ init backend """
+        raise NotImplementedError
+
+    def get_type(self):
+        """ get type """
+        raise NotImplementedError
+
+    def get_default_backend_args(self):
+        """ get default backend arguments """
+        return {}
+
+
+class ImageWriter(_BaseWriter):
+    """ ImageWriter """
+
+    def __init__(self, backend='opencv', **bk_args):
+        super().__init__(backend=backend, **bk_args)
+
+    def write(self, out_path, obj):
+        """ write """
+        return self._backend.write_obj(out_path, obj)
+
+    def _init_backend(self, bk_type, bk_args):
+        """ init backend """
+        if bk_type == 'opencv':
+            return OpenCVImageWriterBackend(**bk_args)
+        elif bk_type == 'pillow':
+            return PILImageWriterBackend(**bk_args)
+        else:
+            raise ValueError("Unsupported backend type")
+
+    def get_type(self):
+        """ get type """
+        return WriterType.IMAGE
+
+
+class TextWriter(_BaseWriter):
+    """ TextWriter """
+
+    def __init__(self, backend='python', **bk_args):
+        super().__init__(backend=backend, **bk_args)
+
+    def write(self, out_path, obj):
+        """ write """
+        return self._backend.write_obj(out_path, obj)
+
+    def _init_backend(self, bk_type, bk_args):
+        """ init backend """
+        if bk_type == 'python':
+            return TextWriterBackend(**bk_args)
+        else:
+            raise ValueError("Unsupported backend type")
+
+    def get_type(self):
+        """ get type """
+        return WriterType.TEXT
+
+
+class _BaseWriterBackend(object):
+    """ _BaseWriterBackend """
+
+    def write_obj(self, out_path, obj):
+        """ write object """
+        out_dir = os.path.dirname(out_path)
+        os.makedirs(out_dir, exist_ok=True)
+        return self._write_obj(out_path, obj)
+
+    def _write_obj(self, out_path, obj):
+        """ write object """
+        raise NotImplementedError
+
+
+class TextWriterBackend(_BaseWriterBackend):
+    """ TextWriterBackend """
+
+    def __init__(self, mode='w', encoding='utf-8'):
+        super().__init__()
+        self.mode = mode
+        self.encoding = encoding
+
+    def _write_obj(self, out_path, obj):
+        """ write text object """
+        with open(out_path, mode=self.mode, encoding=self.encoding) as f:
+            f.write(obj)
+
+
+class _ImageWriterBackend(_BaseWriterBackend):
+    """ _ImageWriterBackend """
+    pass
+
+
+class OpenCVImageWriterBackend(_ImageWriterBackend):
+    """ OpenCVImageWriterBackend """
+
+    def _write_obj(self, out_path, obj):
+        """ write image object by OpenCV """
+        if isinstance(obj, Image.Image):
+            arr = np.asarray(obj)
+        elif isinstance(obj, np.ndarray):
+            arr = obj
+        else:
+            raise TypeError("Unsupported object type")
+        return cv2.imwrite(out_path, arr)
+
+
+class PILImageWriterBackend(_ImageWriterBackend):
+    """ PILImageWriterBackend """
+
+    def __init__(self, format_=None):
+        super().__init__()
+        self.format = format_
+
+    def _write_obj(self, out_path, obj):
+        """ write image object by PIL """
+        if isinstance(obj, Image.Image):
+            img = obj
+        elif isinstance(obj, np.ndarray):
+            img = Image.fromarray(obj)
+        else:
+            raise TypeError("Unsupported object type")
+        return img.save(out_path, format=self.format)

+ 203 - 0
paddlex/modules/base/predictor/predictor.py

@@ -0,0 +1,203 @@
+# 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.
+
+
+
+import os
+from copy import deepcopy
+from abc import ABC, abstractmethod
+
+from .utils.paddle_inference_predictor import _PaddleInferencePredictor, PaddleInferenceOption
+from .utils.mixin import FromDictMixin
+from .utils.batch import batchable_method, Batcher
+from .utils.node import Node
+from .utils.official_models import official_models
+from ....utils.device import get_device
+from ....utils import logging
+from ....utils.config import AttrDict
+
+
+class BasePredictor(ABC, FromDictMixin, Node):
+    """ Base Predictor """
+    __is_base = True
+
+    MODEL_FILE_TAG = 'inference'
+
+    def __init__(self,
+                 model_dir,
+                 kernel_option,
+                 pre_transforms=None,
+                 post_transforms=None):
+        super().__init__()
+        self.model_dir = model_dir
+        self.pre_transforms = pre_transforms
+        self.post_transforms = post_transforms
+        self.kernel_option = kernel_option
+
+        param_path = os.path.join(model_dir, f"{self.MODEL_FILE_TAG}.pdiparams")
+        model_path = os.path.join(model_dir, f"{self.MODEL_FILE_TAG}.pdmodel")
+        self._predictor = _PaddleInferencePredictor(
+            param_path=param_path, model_path=model_path, option=kernel_option)
+
+        self.other_src = self.load_other_src()
+
+    def predict(self, input, batch_size=1):
+        """ predict """
+        if not isinstance(input, dict) and not (isinstance(input, list) and all(
+                isinstance(ele, dict) for ele in input)):
+            raise TypeError(f"`input` should be a dict or a list of dicts.")
+
+        orig_input = input
+        if isinstance(input, dict):
+            input = [input]
+
+        logging.info(
+            f"Running {self.__class__.__name__}\nModel: {self.model_dir}\nEnv: {self.kernel_option}\n"
+        )
+        data = input[0]
+        if self.pre_transforms is not None:
+            pre_tfs = self.pre_transforms
+        else:
+            pre_tfs = self._get_pre_transforms_for_data(data)
+        logging.info(
+            f"The following transformation operators will be used for data preprocessing:\n\
+{self._format_transforms(pre_tfs)}\n")
+        if self.post_transforms is not None:
+            post_tfs = self.post_transforms
+        else:
+            post_tfs = self._get_post_transforms_for_data(data)
+        logging.info(
+            f"The following transformation operators will be used for postprocessing:\n\
+{self._format_transforms(post_tfs)}\n")
+
+        output = []
+        for mini_batch in Batcher(input, batch_size=batch_size):
+            mini_batch = self._preprocess(mini_batch, pre_transforms=pre_tfs)
+
+            for data in mini_batch:
+                self.check_input_keys(data)
+
+            mini_batch = self._run(batch_input=mini_batch)
+
+            for data in mini_batch:
+                self.check_output_keys(data)
+
+            mini_batch = self._postprocess(mini_batch, post_transforms=post_tfs)
+
+            output.extend(mini_batch)
+
+        if isinstance(orig_input, dict):
+            return output[0]
+        else:
+            return output
+
+    @abstractmethod
+    def _run(self, batch_input):
+        raise NotImplementedError
+
+    @abstractmethod
+    def _get_pre_transforms_for_data(self, data):
+        """ get preprocess transforms """
+        raise NotImplementedError
+
+    @abstractmethod
+    def _get_post_transforms_for_data(self, data):
+        """ get postprocess transforms """
+        raise NotImplementedError
+
+    @batchable_method
+    def _preprocess(self, data, pre_transforms):
+        """ preprocess """
+        for tf in pre_transforms:
+            data = tf(data)
+        return data
+
+    @batchable_method
+    def _postprocess(self, data, post_transforms):
+        """ postprocess """
+        for tf in post_transforms:
+            data = tf(data)
+        return data
+
+    def _format_transforms(self, transforms):
+        """ format transforms """
+        lines = ['[']
+        for tf in transforms:
+            s = '\t'
+            s += str(tf)
+            lines.append(s)
+        lines.append(']')
+        return '\n'.join(lines)
+
+    def load_other_src(self):
+        """ load other source
+        """
+        return None
+
+
+class PredictorBuilderByConfig(object):
+    """build model predictor
+    """
+
+    def __init__(self, config):
+        """
+        Args:
+            config (AttrDict): PaddleX pipeline config, which is loaded from pipeline yaml file.
+        """
+        model_name = config.Global.model
+
+        device = config.Global.device.split(':')[0]
+
+        predict_config = deepcopy(config.Predict)
+        model_dir = predict_config.pop('model_dir')
+        kernel_setting = predict_config.pop('kernel_option', {})
+        kernel_setting.setdefault('device', device)
+        kernel_option = PaddleInferenceOption(**kernel_setting)
+
+        self.input_path = predict_config.pop('input_path')
+
+        self.predictor = BasePredictor.get(model_name)(model_dir, kernel_option,
+                                                       **predict_config)
+        self.output = config.Global.output
+
+    def __call__(self):
+        data = {
+            "input_path": self.input_path,
+            "cli_flag": True,
+            "output_dir": self.output
+        }
+        self.predictor.predict(data)
+
+
+def build_predictor(*args, **kwargs):
+    """build predictor by config for dev
+    """
+    return PredictorBuilderByConfig(*args, **kwargs)
+
+
+def create_model(model_name,
+                 model_dir=None,
+                 kernel_option=None,
+                 pre_transforms=None,
+                 post_transforms=None,
+                 *args,
+                 **kwargs):
+    """create model for predicting using inference model
+    """
+    kernel_option = PaddleInferenceOption(
+    ) if kernel_option is None else kernel_option
+    model_dir = official_models[model_name] if model_dir is None else model_dir
+    return BasePredictor.get(model_name)(model_dir, kernel_option,
+                                         pre_transforms, post_transforms, *args,
+                                         **kwargs)

+ 37 - 0
paddlex/modules/base/predictor/transform.py

@@ -0,0 +1,37 @@
+# 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.
+
+
+
+import abc
+
+from .utils.mixin import FromDictMixin
+from .utils.batch import batchable_method
+from .utils.node import Node
+
+
+class BaseTransform(FromDictMixin, Node):
+    """ BaseTransform """
+
+    @batchable_method
+    def __call__(self, data):
+        self.check_input_keys(data)
+        data = self.apply(data)
+        self.check_output_keys(data)
+        return data
+
+    @abc.abstractmethod
+    def apply(self, data):
+        """ apply """
+        raise NotImplementedError

+ 17 - 0
paddlex/modules/base/predictor/transforms/__init__.py

@@ -0,0 +1,17 @@
+# 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 . import image_common

Некоторые файлы не были показаны из-за большого количества измененных файлов