فهرست منبع

add docs for SOD practical tutorial (#2704)

Zhang Zelun 10 ماه پیش
والد
کامیت
a1da2a8a75

+ 303 - 0
docs/practical_tutorials/small_object_detection_tutorial.en.md

@@ -0,0 +1,303 @@
+
+# PaddleX 3.0 Small Object Detection Pipeline——Remote Sensing Image Small Object Detection
+
+PaddleX provides a rich set of model pipelines, which are implemented by combining one or more models. Each model pipeline can solve specific task problems in different scenarios. The model pipelines provided by PaddleX all support quick experience. If the effect does not meet expectations, it also supports fine-tuning the model with private data. Moreover, PaddleX provides a Python API, making it convenient to integrate the pipeline into individual projects. Before using it, you first need to install PaddleX. Please refer to [PaddleX Installation](../installation/installation.md) for installation methods. Here, we take a remote sensing small object detection task as an example to introduce the usage process of the model pipeline tool.
+
+## 1. Select Pipeline
+
+First, you need to choose the corresponding PaddleX pipeline based on your task scenario. Here, for remote sensing small object detection, you need to understand that this task belongs to small object detection, corresponding to the small object detection pipeline of PaddleX. If you cannot determine the correspondence between the task and the pipeline, you can learn about the capabilities of related pipelines in the [Model Pipeline List](../support_list/pipelines_list.md) supported by PaddleX.
+
+## 2. Quick Experience
+
+PaddleX provides the following quick experience methods, which can be directly experienced locally through the PaddleX wheel package.
+
+  - Local experience method:
+    ```python
+    import paddlex
+    from paddlex import create_model
+
+    model = create_model("PP-YOLOE_plus_SOD-largesize-L")
+    image_url = "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/remote-scene-det_example.png"
+    rst_save_dir = "./output"
+    output = model.predict([image_url], batch_size=1)
+
+    for res in output:
+        res.print(json_format=False)
+        res.save_to_img(rst_save_dir)
+        res.save_to_json(rst_save_dir)
+    ```
+
+  The quick experience produces the following inference result example:
+  <center>
+
+  <img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/small_obj_det/01.png" width=600>
+
+  </center>
+
+After experiencing the pipeline, you need to determine whether the pipeline meets expectations (including accuracy, speed, etc.), and whether the models included in the pipeline need to be further fine-tuned. If the speed or accuracy of the model does not meet expectations, you need to choose a replaceable model based on the model selection to continue testing and determine whether the effect is satisfactory. If the final effect is not satisfactory, you need to fine-tune the model. This tutorial aims to produce a small object detection model in the field of remote sensing. Obviously, the default weights (weights produced by training on the UAV aerial photography dataset) cannot meet the requirements. You need to collect and annotate data, and then train and fine-tune.
+
+## 3. Select Model
+
+PaddleX provides 3 high-precision and high-efficiency end-to-end small object detection models. For details, please refer to the [Model List](../support_list/models_list.md). The benchmarks of some models are as follows:
+
+<table>
+<tr>
+<th>Model</th><th>Model Download Link</th>
+<th>mAP(0.5:0.95)</th>
+<th>mAP(0.5)</th>
+<th>GPU Inference Time (ms)</th>
+<th>CPU Inference Time (ms)</th>
+<th>Model Storage Size (M)</th>
+<th>Description</th>
+</tr>
+<tr>
+<td>PP-YOLOE_plus_SOD-L</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/PP-YOLOE_plus_SOD-L_infer.tar">Inference Model</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/PP-YOLOE_plus_SOD-L_pretrained.pdparams">Training Model</a></td>
+<td>31.9</td>
+<td>52.1</td>
+<td>57.1</td>
+<td>1007.0</td>
+<td>324.93</td>
+<td rowspan="3">PP-YOLOE_plus small object detection model trained based on VisDrone. VisDrone is a benchmark dataset for UAV vision data, which is used for training and evaluation of small object detection tasks due to its small targets and certain challenges.</td>
+</tr>
+<tr>
+<td>PP-YOLOE_plus_SOD-S</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/PP-YOLOE_plus_SOD-S_infer.tar">Inference Model</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/PP-YOLOE_plus_SOD-S_pretrained.pdparams">Training Model</a></td>
+<td>25.1</td>
+<td>42.8</td>
+<td>65.5</td>
+<td>324.4</td>
+<td>77.29</td>
+</tr>
+<tr>
+<td>PP-YOLOE_plus_SOD-largesize-L</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/PP-YOLOE_plus_SOD-largesize-L_infer.tar">Inference Model</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/PP-YOLOE_plus_SOD-largesize-L_pretrained.pdparams">Training Model</a></td>
+<td>42.7</td>
+<td>65.9</td>
+<td>458.5</td>
+<td>11172.7</td>
+<td>340.42</td>
+</tr>
+</table>
+
+**Note: The above accuracy metrics are mAP(0.5:0.95) on VisDrone-DET validation set. All models' GPU inference time is based on NVIDIA Tesla T4 machine with FP32 precision, CPU inference speed is based on Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz with 8 threads, and FP32 precision.**
+
+## 4. Data Preparation and Validation
+### 4.1 Data Preparation
+
+In this tutorial, the `Remote Sensing Small Object Detection Dataset` is used as an example dataset, which can be obtained through the following commands. If you are using your own annotated dataset, you need to adjust your dataset according to PaddleX's format requirements to meet PaddleX's data format requirements. For data format introduction, you can refer to [PaddleX Detection Task Module Data Annotation Tutorial](../data_annotations/cv_modules/object_detection.md).
+
+Dataset acquisition command:
+```bash
+cd /path/to/paddlex
+wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/remote_scene_object_detection.tar -P ./dataset
+tar -xf ./dataset/remote_scene_object_detection.tar -C ./dataset/
+```
+
+### 4.2 Dataset Validation
+
+When validating the dataset, you only need one line of command:
+
+```bash
+python main.py -c paddlex/configs/small_object_detection/PP-YOLOE_plus_SOD-largesize-L.yaml \
+    -o Global.mode=check_dataset \
+    -o Global.dataset_dir=./dataset/remote_scene_object_detection
+```
+
+After executing the above command, PaddleX will validate the dataset and count the basic information of the dataset. After the command runs successfully, `Check dataset passed!` message will be printed in the log, and the related outputs will be saved in the `./output/check_dataset` directory in the current directory. The output directory includes visualized sample images and sample distribution histograms. The validation result file is saved in `./output/check_dataset_result.json`, the specific content of the validation result file is
+```
+{
+  "done_flag": true,
+  "check_pass": true,
+  "attributes": {
+    "num_classes": 15,
+    "train_samples": 172,
+    "train_sample_paths": [
+      "check_dataset\/demo_img\/P1751__1.0__824___824.png",
+      "check_dataset\/demo_img\/P1560__1.0__0___0.png",
+      "check_dataset\/demo_img\/P1051__1.0__0___0.png",
+      "check_dataset\/demo_img\/P1751__1.0__1648___0.png",
+      "check_dataset\/demo_img\/P0117__1.0__0___0.png",
+      "check_dataset\/demo_img\/P2365__1.0__1648___824.png",
+      "check_dataset\/demo_img\/P1750__1.0__0___1648.png",
+      "check_dataset\/demo_img\/P1560__1.0__824___1648.png",
+      "check_dataset\/demo_img\/P2152__1.0__0___0.png",
+      "check_dataset\/demo_img\/P0047__1.0__102___1143.png"
+    ],
+    "val_samples": 80,
+    "val_sample_paths": [
+      "check_dataset\/demo_img\/P0551__1.0__288___354.png",
+      "check_dataset\/demo_img\/P0858__1.0__1360___441.png",
+      "check_dataset\/demo_img\/P1560__1.0__1648___2472.png",
+      "check_dataset\/demo_img\/P2722__1.0__1648___0.png",
+      "check_dataset\/demo_img\/P2462__1.0__824___824.png",
+      "check_dataset\/demo_img\/P0262__1.0__824___0.png",
+      "check_dataset\/demo_img\/P0047__1.0__0___0.png",
+      "check_dataset\/demo_img\/P2722__1.0__1648___1422.png",
+      "check_dataset\/demo_img\/P2645__1.0__0___1648.png",
+      "check_dataset\/demo_img\/P0858__1.0__0___441.png"
+    ]
+  },
+  "analysis": {
+    "histogram": "check_dataset\/histogram.png"
+  },
+  "dataset_path": "\/git_commit\/final_commit_dev\/PaddleX\/_zzl_sod\/rdet_dota_examples",
+  "show_type": "image",
+  "dataset_type": "COCODetDataset"
+}
+```
+In the above validation result, `check_pass` being `True` indicates that the dataset format meets the requirements. The explanations of other indicators are as follows:
+
+- `attributes.num_classes`: The number of classes in the dataset is 15, which is the number of categories to be passed in for subsequent training;
+- `attributes.train_samples`: The number of training samples in the dataset is 172;
+- `attributes.val_samples`: The number of validation samples in the dataset is 80;
+- `attributes.train_sample_paths`: The relative path list of visualized images of training samples in the dataset;
+- `attributes.val_sample_paths`: The relative path list of visualized images of validation samples in the dataset;
+
+In addition, the dataset validation also analyzed the sample number distribution of all categories in the dataset and plotted the distribution histogram (`histogram.png`):
+<center>
+
+<img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/small_obj_det/02.png" width=600>
+
+</center>
+
+**Note**: Only datasets that pass validation can be trained and evaluated.
+
+### 4.3 Dataset Format Conversion/Dataset Splitting (Optional)
+
+If you need to convert the dataset format or re-split the dataset, you can set it by modifying the configuration file or adding hyperparameters.
+
+Dataset validation related parameters can be set by modifying the fields under `CheckDataset` in the configuration file. The example descriptions of some parameters in the configuration file are as follows:
+
+* `CheckDataset`:
+    * `convert`:
+        * `enable`: Whether to perform dataset format conversion. When set to `True`, perform dataset format conversion. The default is `False`;
+        * `src_dataset_type`: If performing dataset format conversion, you need to set the source dataset format. The selectable source formats are `LabelMe` and `VOC`;
+    * `split`:
+        * `enable`: Whether to re-split the dataset. When set to `True`, perform dataset splitting. The default is `False`;
+        * `train_percent`: If re-splitting the dataset, you need to set the percentage of the training set. The type is any integer between 0-100, and needs to ensure that the sum with `val_percent` is 100;
+        * `val_percent`: If re-splitting the dataset, you need to set the percentage of the validation set. The type is any integer between 0-100, and needs to ensure that the sum with `train_percent` is 100;
+
+Dataset conversion and dataset splitting support being enabled at the same time. For dataset splitting, the original annotation files will be renamed as `xxx.bak` in the original path. The above parameters also support being set by adding command line parameters, such as re-splitting the dataset and setting the ratio of training set to validation set: `-o CheckDataset.split.enable=True -o CheckDataset.split.train_percent=80 -o CheckDataset.split.val_percent=20`.
+
+## 5. Model Training and Evaluation
+### 5.1 Model Training
+
+Before training, please ensure that you have validated the dataset. To complete the training of the PaddleX model, you only need the following command:
+
+```bash
+python main.py -c paddlex/configs/small_object_detection/PP-YOLOE_plus_SOD-largesize-L.yaml \
+    -o Global.mode=train \
+    -o Global.dataset_dir=./dataset/remote_scene_object_detection \
+    -o Train.epochs_iters=80
+```
+
+In PaddleX, model training supports modifying training hyperparameters, single-machine single-card/multi-card training, etc., by modifying the configuration file or adding command line parameters.
+
+Each model in PaddleX provides a configuration file for model development, which is used to set related parameters. Model training related parameters can be set by modifying the fields under `Train` in the configuration file. The example descriptions of some parameters in the configuration file are as follows:
+
+* `Global`:
+    * `mode`: Mode, supports dataset validation (`check_dataset`), model training (`train`), model evaluation (`evaluate`);
+    * `device`: Training device, optional `cpu`, `gpu`, `xpu`, `npu`, `mlu`. Except for `cpu`, multi-card training can specify card numbers, such as `gpu:0,1,2,3`;
+* `Train`: Training hyperparameter settings;
+    * `epochs_iters`: Setting of the number of training iterations;
+    * `learning_rate`: Setting of the training learning rate;
+
+For more hyperparameter introductions, please refer to [PaddleX Universal Model Configuration File Parameter Description](../module_usage/instructions/config_parameters_common.md).
+
+**Note:**
+- The above parameters can be set by adding command line parameters, such as specifying the mode to model training: `-o Global.mode=train`; specifying the first 2 GPUs for training: `-o Global.device=gpu:0,1`; setting the number of training iterations to 80: `-o Train.epochs_iters=80`.
+- During model training, PaddleX will automatically save the model weight files. The default is `output`. If you need to specify the save path, you can do so through the field `-o Global.output` in the configuration file.
+- PaddleX shields you from the concepts of dynamic graph weights and static graph weights. During the model training process, both dynamic graph and static graph weights will be produced. When model inference, static graph weights are selected by default.
+
+**Explanation of Training Output:**
+
+After completing the model training, all outputs are saved under the specified output directory (default is `./output/`), usually including the following outputs:
+
+* `train_result.json`: Training result record file, records whether the training task was completed normally, as well as the indicators of the produced weights, related file paths, etc.;
+* `train.log`: Training log file, records the changes in model indicators during training, loss changes, etc.;
+* `config.yaml`: Training configuration file, records the configuration of hyperparameters in this training;
+* `.pdparams`, `.pdema`, `.pdopt`, `.pdstate`, `.pdiparams`, `.pdmodel`: Model weight related files, including network parameters, optimizer, EMA, static graph network parameters, static graph network structure, etc.;
+
+### 5.2 Model Evaluation
+
+After completing the model training, you can evaluate the specified model weight file on the validation set to verify the model accuracy. Using PaddleX for model evaluation requires only one command:
+
+```bash
+python main.py -c paddlex/configs/small_object_detection/PP-YOLOE_plus_SOD-largesize-L.yaml \
+    -o Global.mode=evaluate \
+    -o Global.dataset_dir=./dataset/remote_scene_object_detection
+```
+
+Similar to model training, model evaluation supports setting by modifying the configuration file or adding command line parameters.
+
+**Note:** When evaluating the model, you need to specify the model weight file path. Each configuration file has a default weight save path built-in. If you need to change it, you only need to set it by adding command line parameters, such as `-o Evaluate.weight_path=./output/best_model/model.pdparams`.
+
+### 5.3 Model Tuning
+
+After learning model training and evaluation, we can improve the model accuracy by adjusting hyperparameters. By properly adjusting the number of training epochs, you can control the training depth of the model and avoid overfitting or underfitting; the setting of the learning rate is related to the speed and stability of model convergence. Therefore, when optimizing model performance, it is necessary to carefully consider the values of these two parameters and adjust flexibly according to the actual situation to obtain the best training effect.
+
+It is recommended to follow the controlled variable method when debugging parameters:
+
+1. First, fix the number of training iterations to 40, and batch size to 1.
+2. Start three experiments based on the PP-YOLOE+ SOD model, with learning rates of 0.000625, 0.00125, and 0.0125 respectively.
+3. It can be found that the configuration with the highest accuracy in Experiment Three is the learning rate of 0.0125. Based on this training hyperparameter, increasing the number of training epochs to 80 can see better accuracy.
+
+Learning rate exploration experiment results:
+<center>
+
+| Experiment  | Number of Epochs | Learning Rate | batch\_size | Training Environment | mAP(0.5:0.95) |
+|-------|------|--------|----------|-------|----------|
+| Experiment One | 40 | 0.000625 | 1        | 4 cards   | 0.476   |
+| Experiment Two | 40 | 0.00125 | 1        | 4 cards   |0.412|
+| Experiment Three | 40 | 0.0125  | 1        | 4 cards   | **0.501**   |
+
+</center>
+
+Experiment results after changing epoch:
+<center>
+
+| Experiment                | Number of Epochs | Learning Rate | batch\_size| Training Environment | mAP(0.5:0.95) |
+|--------------------|---------|-------|------------|------|----------|
+| Experiment Three              | 40    | 0.0125 | 1         | 4 cards   | 0.501   |
+| Experiment Three with increased training iterations | 80   | 0.0125 | 1         | 4 cards   | **0.512**|
+</center>
+
+**Note: This tutorial is an 8-card tutorial. If you have only one GPU, you can complete this experiment by adjusting the number of training cards, but the final indicator may not align with the above indicators, which is normal.**
+
+## 6. Pipeline Testing
+
+Replace the model in the pipeline with the fine-tuned model for testing, such as:
+
+```bash
+python main.py -c paddlex/configs/small_object_detection/PP-YOLOE_plus_SOD-largesize-L.yaml \
+    -o Global.mode=predict \
+    -o Predict.model_dir="output/best_model/inference" \
+    -o Predict.input="https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/remote-scene-det_example.png"
+```
+
+Through the above, the prediction results can be generated under `./output`, as follows:
+<center>
+
+<img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/small_obj_det/03.png" width="600"/>
+
+</center>
+
+## 7. Development Integration/Deployment
+If the small object detection pipeline can meet your requirements for pipeline inference speed and accuracy, you can directly proceed with development integration/deployment.
+1. Directly apply the trained model in your Python project. You can refer to the following sample code, and modify `Pipeline.model` in `paddlex/pipelines/small_object_detection.yaml` configuration file to your own model path `output/best_model/inference`:
+```python
+from paddlex import create_pipeline
+pipeline = create_pipeline(pipeline="paddlex/pipelines/small_object_detection.yaml")
+output = pipeline.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/remote-scene-det_example.png")
+for res in output:
+    res.print() # Print the structured output of the prediction
+    res.save_to_img("./output/") # Save the result visualization image
+    res.save_to_json("./output/") # Save the structured output of the prediction
+```
+For more parameters, please refer to [Small Object Detection Pipeline Usage Tutorial](../pipeline_usage/tutorials/cv_pipelines/small_object_detection.md).
+
+2. In addition, PaddleX also provides three other deployment methods, detailed explanations are as follows:
+
+* High-performance deployment: In actual production environments, many applications have strict standards for the performance indicators of deployment strategies (especially response speed) to ensure the efficient operation of the system and the smooth user experience. For this reason, PaddleX provides a high-performance inference plugin, aiming to deeply optimize the performance of model inference and pre/post-processing, achieving significant acceleration of the end-to-end process. For detailed high-performance deployment processes, please refer to [PaddleX High-Performance Inference Guide](../pipeline_deploy/high_performance_inference.md).
+* Service deployment: Service deployment is a common deployment form in actual production environments. By encapsulating inference functions into services, clients can access these services through network requests to obtain inference results. PaddleX supports users to achieve service deployment of the pipeline at a low cost. For detailed service deployment processes, please refer to [PaddleX Service Deployment Guide](../pipeline_deploy/service_deploy.md).
+* Edge deployment: Edge deployment is a way of placing computing and data processing functions on user devices themselves, where devices can directly process data without relying on remote servers. PaddleX supports deploying models on edge devices such as Android. For detailed edge deployment processes, please refer to [PaddleX Edge Deployment Guide](../pipeline_deploy/edge_deploy.md).
+
+You can choose an appropriate method to deploy the model pipeline according to your needs and proceed with subsequent AI application integration.

+ 310 - 0
docs/practical_tutorials/small_object_detection_tutorial.md

@@ -0,0 +1,310 @@
+---
+comments: true
+---
+
+# PaddleX 3.0 小目标检测产线———遥感图像小目标检测
+
+PaddleX 提供了丰富的模型产线,模型产线由一个或多个模型组合实现,每个模型产线都能够解决特定的场景任务问题。PaddleX 所提供的模型产线均支持快速体验,如果效果不及预期,也同样支持使用私有数据微调模型,并且 PaddleX 提供了 Python API,方便将产线集成到个人项目中。在使用之前,您首先需要安装 PaddleX, 安装方式请参考[ PaddleX 安装](../installation/installation.md)。此处以一个遥感小目标检测的任务为例子,介绍模型产线工具的使用流程。
+
+## 1. 选择产线
+
+首先,需要根据您的任务场景,选择对应的 PaddleX 产线,此处为遥感小目标检测,需要了解到这个任务属于小目标检测任务,对应 PaddleX 的小目标检测产线。如果无法确定任务和产线的对应关系,您可以在 PaddleX 支持的[模型产线列表](../support_list/pipelines_list.md)中了解相关产线的能力介绍。
+
+
+## 2. 快速体验
+
+PaddleX 提供了以下快速体验的方式,可以直接通过 PaddleX wheel 包在本地体验。
+
+  - 本地体验方式:
+    ```python
+    import paddlex
+    from paddlex import create_model
+
+    model = create_model("PP-YOLOE_plus_SOD-largesize-L")
+    image_url = "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/remote-scene-det_example.png"
+    rst_save_dir = "./output"
+    output = model.predict([image_url], batch_size=1)
+
+    for res in output:
+        res.print(json_format=False)
+        res.save_to_img(rst_save_dir)
+        res.save_to_json(rst_save_dir)
+    ```
+
+
+  快速体验产出推理结果示例:
+  <center>
+
+  <img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/small_obj_det/01.png" width=600>
+
+  </center>
+
+当体验完该产线之后,需要确定产线是否符合预期(包含精度、速度等),产线包含的模型是否需要继续微调,如果模型的速度或者精度不符合预期,则需要根据模型选择选择可替换的模型继续测试,确定效果是否满意。如果最终效果均不满意,则需要微调模型。本教程希望产出遥感领域的小目标检测模型,显然默认的权重(无人机航拍 数据集训练产出的权重)无法满足要求,需要采集和标注数据,然后进行训练微调。
+
+## 3. 选择模型
+
+PaddleX 提供了 3 个端到端的高精度高效率小目标检测模型,具体可参考 [模型列表](../support_list/models_list.md),其中部分模型的benchmark如下:
+
+<table>
+<tr>
+<th>模型</th><th>模型下载链接</th>
+<th>mAP(0.5:0.95)</th>
+<th>mAP(0.5)</th>
+<th>GPU推理耗时(ms)</th>
+<th>CPU推理耗时 (ms)</th>
+<th>模型存储大小(M)</th>
+<th>介绍</th>
+</tr>
+<tr>
+<td>PP-YOLOE_plus_SOD-L</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/PP-YOLOE_plus_SOD-L_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/PP-YOLOE_plus_SOD-L_pretrained.pdparams">训练模型</a></td>
+<td>31.9</td>
+<td>52.1</td>
+<td>57.1</td>
+<td>1007.0</td>
+<td>324.93</td>
+<td rowspan="3">基于VisDrone训练的PP-YOLOE_plus小目标检测模型。VisDrone是针对无人机视觉数据的基准数据集,由于目标较小同时具有一定的挑战性而被用于小目标检测任务的训练和评测</td>
+</tr>
+<tr>
+<td>PP-YOLOE_plus_SOD-S</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/PP-YOLOE_plus_SOD-S_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/PP-YOLOE_plus_SOD-S_pretrained.pdparams">训练模型</a></td>
+<td>25.1</td>
+<td>42.8</td>
+<td>65.5</td>
+<td>324.4</td>
+<td>77.29</td>
+</tr>
+<tr>
+<td>PP-YOLOE_plus_SOD-largesize-L</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/PP-YOLOE_plus_SOD-largesize-L_infer.tar">推理模型</a>/<a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_pretrained_model/PP-YOLOE_plus_SOD-largesize-L_pretrained.pdparams">训练模型</a></td>
+<td>42.7</td>
+<td>65.9</td>
+<td>458.5</td>
+<td>11172.7</td>
+<td>340.42</td>
+</tr>
+</table>
+
+<b>注:以上精度指标为 VisDrone-DET 验证集 mAP(0.5:0.95)。所有模型 GPU 推理耗时基于 NVIDIA Tesla T4 机器,精度类型为 FP32, CPU 推理速度基于 Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz,线程数为8,精度类型为 FP32</b>。
+
+
+## 4. 数据准备和校验
+### 4.1 数据准备
+
+本教程采用 `遥感小目标检测数据集` 作为示例数据集,可通过以下命令获取示例数据集。如果您使用自备的已标注数据集,需要按照 PaddleX 的格式要求对自备数据集进行调整,以满足 PaddleX 的数据格式要求。关于数据格式介绍,您可以参考 [PaddleX 检测任务模块数据标注教程](../data_annotations/cv_modules/object_detection.md)。
+
+数据集获取命令:
+```bash
+cd /path/to/paddlex
+wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/remote_scene_object_detection.tar -P ./dataset
+tar -xf ./dataset/remote_scene_object_detection.tar -C ./dataset/
+```
+
+### 4.2 数据集校验
+
+在对数据集校验时,只需一行命令:
+
+```bash
+python main.py -c paddlex/configs/small_object_detection/PP-YOLOE_plus_SOD-largesize-L.yaml \
+    -o Global.mode=check_dataset \
+    -o Global.dataset_dir=./dataset/remote_scene_object_detection
+```
+
+执行上述命令后,PaddleX 会对数据集进行校验,并统计数据集的基本信息。命令运行成功后会在 log 中打印出 `Check dataset passed !` 信息,同时相关产出会保存在当前目录的 `./output/check_dataset` 目录下,产出目录中包括可视化的示例样本图片和样本分布直方图。校验结果文件保存在 `./output/check_dataset_result.json`,校验结果文件具体内容为
+```
+{
+  "done_flag": true,
+  "check_pass": true,
+  "attributes": {
+    "num_classes": 15,
+    "train_samples": 172,
+    "train_sample_paths": [
+      "check_dataset\/demo_img\/P1751__1.0__824___824.png",
+      "check_dataset\/demo_img\/P1560__1.0__0___0.png",
+      "check_dataset\/demo_img\/P1051__1.0__0___0.png",
+      "check_dataset\/demo_img\/P1751__1.0__1648___0.png",
+      "check_dataset\/demo_img\/P0117__1.0__0___0.png",
+      "check_dataset\/demo_img\/P2365__1.0__1648___824.png",
+      "check_dataset\/demo_img\/P1750__1.0__0___1648.png",
+      "check_dataset\/demo_img\/P1560__1.0__824___1648.png",
+      "check_dataset\/demo_img\/P2152__1.0__0___0.png",
+      "check_dataset\/demo_img\/P0047__1.0__102___1143.png"
+    ],
+    "val_samples": 80,
+    "val_sample_paths": [
+      "check_dataset\/demo_img\/P0551__1.0__288___354.png",
+      "check_dataset\/demo_img\/P0858__1.0__1360___441.png",
+      "check_dataset\/demo_img\/P1560__1.0__1648___2472.png",
+      "check_dataset\/demo_img\/P2722__1.0__1648___0.png",
+      "check_dataset\/demo_img\/P2462__1.0__824___824.png",
+      "check_dataset\/demo_img\/P0262__1.0__824___0.png",
+      "check_dataset\/demo_img\/P0047__1.0__0___0.png",
+      "check_dataset\/demo_img\/P2722__1.0__1648___1422.png",
+      "check_dataset\/demo_img\/P2645__1.0__0___1648.png",
+      "check_dataset\/demo_img\/P0858__1.0__0___441.png"
+    ]
+  },
+  "analysis": {
+    "histogram": "check_dataset\/histogram.png"
+  },
+  "dataset_path": "\/git_commit\/final_commit_dev\/PaddleX\/_zzl_sod\/rdet_dota_examples",
+  "show_type": "image",
+  "dataset_type": "COCODetDataset"
+}
+```
+上述校验结果中,check_pass 为 True 表示数据集格式符合要求,其他部分指标的说明如下:
+
+- attributes.num_classes:该数据集类别数为 15,此处类别数量为后续训练需要传入的类别数量;
+- attributes.train_samples:该数据集训练集样本数量为 172;
+- attributes.val_samples:该数据集验证集样本数量为 80;
+- attributes.train_sample_paths:该数据集训练集样本可视化图片相对路径列表;
+- attributes.val_sample_paths:该数据集验证集样本可视化图片相对路径列表;
+
+另外,数据集校验还对数据集中所有类别的样本数量分布情况进行了分析,并绘制了分布直方图(histogram.png):
+<center>
+
+<img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/small_obj_det/02.png" width=600>
+
+</center>
+
+**注**:只有通过数据校验的数据才可以训练和评估。
+
+
+### 4.3 数据集格式转换/数据集划分(非必选)
+
+如需对数据集格式进行转换或是重新划分数据集,可通过修改配置文件或是追加超参数的方式进行设置。
+
+数据集校验相关的参数可以通过修改配置文件中 `CheckDataset` 下的字段进行设置,配置文件中部分参数的示例说明如下:
+
+* `CheckDataset`:
+    * `convert`:
+        * `enable`: 是否进行数据集格式转换,为 `True` 时进行数据集格式转换,默认为 `False`;
+        * `src_dataset_type`: 如果进行数据集格式转换,则需设置源数据集格式,数据可选源格式为 `LabelMe` 和 `VOC`;
+    * `split`:
+        * `enable`: 是否进行重新划分数据集,为 `True` 时进行数据集格式转换,默认为 `False`;
+        * `train_percent`: 如果重新划分数据集,则需要设置训练集的百分比,类型为 0-100 之间的任意整数,需要保证和 `val_percent` 值加和为 100;
+        * `val_percent`: 如果重新划分数据集,则需要设置验证集的百分比,类型为 0-100 之间的任意整数,需要保证和 `train_percent` 值加和为 100;
+
+数据转换和数据划分支持同时开启,对于数据划分原有标注文件会被在原路径下重命名为 `xxx.bak`,以上参数同样支持通过追加命令行参数的方式进行设置,例如重新划分数据集并设置训练集与验证集比例:`-o CheckDataset.split.enable=True -o CheckDataset.split.train_percent=80 -o CheckDataset.split.val_percent=20`。
+
+## 5. 模型训练和评估
+### 5.1 模型训练
+
+在训练之前,请确保您已经对数据集进行了校验。完成 PaddleX 模型的训练,只需如下一条命令:
+
+```bash
+python main.py -c paddlex/configs/small_object_detection/PP-YOLOE_plus_SOD-largesize-L.yaml \
+    -o Global.mode=train \
+    -o Global.dataset_dir=./dataset/remote_scene_object_detection \
+    -o Train.epochs_iters=80
+```
+
+在 PaddleX 中模型训练支持:修改训练超参数、单机单卡/多卡训练等功能,只需修改配置文件或追加命令行参数。
+
+PaddleX 中每个模型都提供了模型开发的配置文件,用于设置相关参数。模型训练相关的参数可以通过修改配置文件中 `Train` 下的字段进行设置,配置文件中部分参数的示例说明如下:
+
+* `Global`:
+    * `mode`:模式,支持数据校验(`check_dataset`)、模型训练(`train`)、模型评估(`evaluate`);
+    * `device`:训练设备,可选`cpu`、`gpu`、`xpu`、`npu`、`mlu`,除 cpu 外,多卡训练可指定卡号,如:`gpu:0,1,2,3`;
+* `Train`:训练超参数设置;
+    * `epochs_iters`:训练迭代次数数设置;
+    * `learning_rate`:训练学习率设置;
+
+更多超参数介绍,请参考 [PaddleX 通用模型配置文件参数说明](../module_usage/instructions/config_parameters_common.md)。
+
+**注:**
+- 以上参数可以通过追加令行参数的形式进行设置,如指定模式为模型训练:`-o Global.mode=train`;指定前 2 卡 gpu 训练:`-o Global.device=gpu:0,1`;设置训练迭代次数为 80:`-o Train.epochs_iters=80`。
+- 模型训练过程中,PaddleX 会自动保存模型权重文件,默认为`output`,如需指定保存路径,可通过配置文件中 `-o Global.output` 字段
+- PaddleX 对您屏蔽了动态图权重和静态图权重的概念。在模型训练的过程中,会同时产出动态图和静态图的权重,在模型推理时,默认选择静态图权重推理。
+
+**训练产出解释:**
+
+在完成模型训练后,所有产出保存在指定的输出目录(默认为`./output/`)下,通常有以下产出:
+
+* train_result.json:训练结果记录文件,记录了训练任务是否正常完成,以及产出的权重指标、相关文件路径等;
+* train.log:训练日志文件,记录了训练过程中的模型指标变化、loss 变化等;
+* config.yaml:训练配置文件,记录了本次训练的超参数的配置;
+* .pdparams、.pdema、.pdopt、.pdstate、.pdiparams、.pdmodel:模型权重相关文件,包括网络参数、优化器、EMA、静态图网络参数、静态图网络结构等;
+
+### 5.2 模型评估
+
+在完成模型训练后,可以对指定的模型权重文件在验证集上进行评估,验证模型精度。使用 PaddleX 进行模型评估,只需一行命令:
+
+```bash
+python main.py -c paddlex/configs/small_object_detection/PP-YOLOE_plus_SOD-largesize-L.yaml \
+    -o Global.mode=evaluate \
+    -o Global.dataset_dir=./dataset/remote_scene_object_detection
+```
+
+与模型训练类似,模型评估支持修改配置文件或追加命令行参数的方式设置。
+
+**注:** 在模型评估时,需要指定模型权重文件路径,每个配置文件中都内置了默认的权重保存路径,如需要改变,只需要通过追加命令行参数的形式进行设置即可,如`-o Evaluate.weight_path=./output/best_model/model.pdparams`。
+
+### 5.3 模型调优
+
+在学习了模型训练和评估后,我们可以通过调整超参数来提升模型的精度。通过合理调整训练轮数,您可以控制模型的训练深度,避免过拟合或欠拟合;而学习率的设置则关乎模型收敛的速度和稳定性。因此,在优化模型性能时,务必审慎考虑这两个参数的取值,并根据实际情况进行灵活调整,以获得最佳的训练效果。
+
+推荐在调试参数时遵循控制变量法:
+
+1. 首先固定训练迭代次数为 40,批大小为 1。
+2. 基于 PP-YOLOE+ SOD 模型启动三个实验,学习率分别为:0.000625,0.00125,0.0125。
+3. 可以发现实验三精度最高的配置为学习率为 0.00125,在该训练超参数基础上,增加训练轮次数到80,可以看到达到更优的精度。
+
+学习率探寻实验结果:
+<center>
+
+| 实验  | 迭代轮数 | 学习率 | batch\_size | 训练环境 | mAP(0.5:0.95) |
+|-------|------|--------|----------|-------|----------|
+| 实验一 | 40 | 0\.000625 | 1        | 4卡   | 0\.476   |
+| 实验二 | 40 | 0\.00125 | 1        | 4卡   |0\.412|
+| 实验三 | 40 | 0\.0125  | 1        | 4卡   | **0\.501**   |
+
+</center>
+
+改变 epoch 实验结果:
+<center>
+
+| 实验                | 迭代轮数 | 学习率 | batch\_size| 训练环境 | mAP(0.5:0.95) |
+|--------------------|---------|-------|------------|------|----------|
+| 实验三              | 40    | 0\.4 | 1         | 4卡   | 0\.501   |
+| 实验三增大训练迭代次数 | 80   | 0\.4 | 1         | 4卡   | **0\.512**|
+</center>
+
+**注:本教程为8卡教程,如果您只有1张GPU,可通过调整训练卡数完成本次实验,但最终指标未必和上述指标对齐,属正常情况。**
+
+## 6. 产线测试
+
+将产线中的模型替换为微调后的模型进行测试,如:
+
+```bash
+python main.py -c paddlex/configs/small_object_detection/PP-YOLOE_plus_SOD-largesize-L.yaml \
+    -o Global.mode=predict \
+    -o Predict.model_dir="output/best_model/inference" \
+    -o Predict.input="https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/remote-scene-det_example.png"
+```
+
+通过上述可在`./output`下生成预测结果,预测结果如下:
+<center>
+
+<img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/small_obj_det/03.png" width="600"/>
+
+</center>
+
+## 7. 开发集成/部署
+如果小目标检测产线可以达到您对产线推理速度和精度的要求,您可以直接进行开发集成/部署。
+1. 直接将训练好的模型应用在您的 Python 项目中,可以参考如下示例代码,并将`paddlex/pipelines/small_object_detection.yaml`配置文件中的`Pipeline.model`修改为自己的模型路径`output/best_model/inference`:
+```python
+from paddlex import create_pipeline
+pipeline = create_pipeline(pipeline="paddlex/pipelines/small_object_detection.yaml")
+output = pipeline.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/remote-scene-det_example.png")
+for res in output:
+    res.print() # 打印预测的结构化输出
+    res.save_to_img("./output/") # 保存结果可视化图像
+    res.save_to_json("./output/") # 保存预测的结构化输出
+```
+更多参数请参考 [小目标检测产线使用教程](../pipeline_usage/tutorials/cv_pipelines/small_object_detection.md)。
+
+1. 此外,PaddleX 也提供了其他三种部署方式,详细说明如下:
+
+* 高性能部署:在实际生产环境中,许多应用对部署策略的性能指标(尤其是响应速度)有着较严苛的标准,以确保系统的高效运行与用户体验的流畅性。为此,PaddleX 提供高性能推理插件,旨在对模型推理及前后处理进行深度性能优化,实现端到端流程的显著提速,详细的高性能部署流程请参考 [PaddleX 高性能推理指南](../pipeline_deploy/high_performance_inference.md)。
+* 服务化部署:服务化部署是实际生产环境中常见的一种部署形式。通过将推理功能封装为服务,客户端可以通过网络请求来访问这些服务,以获取推理结果。PaddleX 支持用户以低成本实现产线的服务化部署,详细的服务化部署流程请参考 [PaddleX 服务化部署指南](../pipeline_deploy/service_deploy.md)。
+* 端侧部署:端侧部署是一种将计算和数据处理功能放在用户设备本身上的方式,设备可以直接处理数据,而不需要依赖远程的服务器。PaddleX 支持将模型部署在 Android 等端侧设备上,详细的端侧部署流程请参考 [PaddleX端侧部署指南](../pipeline_deploy/edge_deploy.md)。
+
+您可以根据需要选择合适的方式部署模型产线,进而进行后续的 AI 应用集成。