PaddleX offers a rich set of pipelines, each consisting of one or more models tailored to solve specific scenario tasks. All PaddleX pipelines support quick trials, and if the results are not satisfactory, you can fine-tune the models with your private data. PaddleX also provides Python APIs for easy integration into personal projects. Before proceeding, ensure you have installed PaddleX. For installation instructions, refer to PaddleX Installation. This tutorial introduces the usage of the pipeline tool with an example of pedestrian fall detection.
First, choose the appropriate PaddleX pipeline based on your task scenario. For pedestrian fall detection, this falls under the General Object Detection pipeline in PaddleX. If unsure about the task-pipeline correspondence, consult the Pipeline List for capabilities of each pipeline.
PaddleX offers two ways to experience the pipelines: locally through the PaddleX wheel package or on the Baidu AIStudio Community.
Local Experience:
paddlex --pipeline object_detection \
--input https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/fall.png
AIStudio Community Experience: Navigate to Baidu AIStudio Community, click "Create Pipeline," and create a General Object Detection pipeline for a quick trial.
Quick trial output example:
After the trial, determine if the pipeline meets your expectations (including accuracy, speed, etc.). If the model's speed or accuracy is unsatisfactory, test alternative models or proceed with fine-tuning. Since the default weights (trained on the COCO dataset) are unlikely to meet the requirements for detecting pedestrian falls, you'll need to collect and annotate data for training and fine-tuning.
PaddleX provides 37 end-to-end object detection models. Refer to the Model List for details. Here's a benchmark of some models:
| Model | Model Download Link | mAP(%) | CPU Inference Time (ms) [Normal Mode / High-Performance Mode] |
CPU Inference Time (ms) [Normal Mode / High-Performance Mode] |
Model Storage Size (M) | Description |
|---|---|---|---|---|---|---|
| PicoDet-L | Inference Model/Trained Model | 42.6 | 14.68 / 5.81 | 47.32 / 47.32 | 20.9 M | PP-PicoDet is a lightweight object detection algorithm for full-size, wide-angle targets, considering the computational capacity of mobile devices. Compared to traditional object detection algorithms, PP-PicoDet has a smaller model size and lower computational complexity, achieving higher speed and lower latency while maintaining detection accuracy. |
| PicoDet-S | Inference Model/Trained Model | 29.1 | 7.98 / 2.33 | 14.82 / 5.60 | 4.4 M | |
| PP-YOLOE_plus-L | Inference Model/Trained Model | 52.9 | 33.55 / 10.46 | 189.05 / 189.05 | 185.3 M | PP-YOLOE_plus is an upgraded version of the high-precision cloud-edge integrated model PP-YOLOE, developed by Baidu's PaddlePaddle vision team. By using the large-scale Objects365 dataset and optimizing preprocessing, it significantly enhances the model's end-to-end inference speed. |
| PP-YOLOE_plus-S | Inference Model/Trained Model | 43.7 | 12.16 / 4.58 | 73.86 / 52.90 | 28.3 M | |
| RT-DETR-H | Inference Model/Trained Model | 56.3 | 115.92 / 28.16 | 971.32 / 971.32 | 435.8 M | RT-DETR is the first real-time end-to-end object detector. The model features an efficient hybrid encoder to meet both model performance and throughput requirements, efficiently handling multi-scale features, and proposes an accelerated and optimized query selection mechanism to optimize the dynamics of decoder queries. RT-DETR supports flexible end-to-end inference speeds by using different decoders. |
| RT-DETR-L | Inference Model/Trained Model | 53.0 | 35.00 / 10.45 | 495.51 / 495.51 | 113.7 M |
Note: The above accuracy metrics are based on the mAP(0.5:0.95) of the COCO2017 validation set. GPU inference time is measured on an NVIDIA Tesla T4 machine with FP32 precision. CPU inference speed is based on an Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz with 8 threads and FP32 precision.
In summary, models listed from top to bottom offer faster inference speeds, while those from bottom to top offer higher accuracy. This tutorial uses the PP-YOLOE_plus-S model as an example to complete the full model development process. Choose a suitable model based on your actual usage scenario, train it, evaluate the model weights within the pipeline, and finally deploy
This tutorial uses the "Pedestrian Fall Detection Dataset" as an example dataset. You can obtain the example dataset using the following commands. If you use your own annotated dataset, you need to adjust it according to the PaddleX format requirements to meet PaddleX's data format specifications. For data format introductions, you can refer to the PaddleX Object Detection Task Module Data Preparation Tutorial.
Dataset acquisition commands:
cd /path/to/paddlex
wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/fall_det.tar -P ./dataset
tar -xf ./dataset/fall_det.tar -C ./dataset/
To verify the dataset, simply use the following command:
python main.py -c paddlex/configs/modules/object_detection/PP-YOLOE_plus-S.yaml \
-o Global.mode=check_dataset \
-o Global.dataset_dir=./dataset/fall_det
After executing the above command, PaddleX will verify the dataset and count its basic information. Upon successful execution, the log will print out Check dataset passed ! information, and relevant outputs will be saved in the current directory's ./output/check_dataset folder. The output directory includes visualized example images and sample distribution histograms. The verification result file is saved in ./output/check_dataset_result.json, and the specific content of the verification result file is:
{
"done_flag": true,
"check_pass": true,
"attributes": {
"num_classes": 1,
"train_samples": 1224,
"train_sample_paths": [
"check_dataset/demo_img/fall_1168.jpg",
"check_dataset/demo_img/fall_1113.jpg"
],
"val_samples": 216,
"val_sample_paths": [
"check_dataset/demo_img/fall_349.jpg",
"check_dataset/demo_img/fall_394.jpg"
]
},
"analysis": {
"histogram": "check_dataset/histogram.png"
},
"dataset_path": "./dataset/fall_det",
"show_type": "image",
"dataset_type": "COCODetDataset"
}
The above verification results indicate that the check_pass being True means the dataset format meets the requirements. Explanations for other indicators are as follows:
attributes.num_classes: The number of classes in this dataset is 1, which is the number of classes that need to be passed in for subsequent training.attributes.train_samples: The number of training samples in this dataset is 1224.attributes.val_samples: The number of validation samples in this dataset is 216.attributes.train_sample_paths: A list of relative paths to the visualization images of training samples in this dataset.attributes.val_sample_paths: A list of relative paths to the visualization images of validation samples in this dataset.Additionally, the dataset verification also analyzes the distribution of sample numbers across all classes and generates a histogram (histogram.png) for visualization:
Note: Only data that passes the verification can be used for training and evaluation.
If you need to convert the dataset format or re-split the dataset, you can modify the configuration file or append hyperparameters for settings.
Parameters related to dataset verification can be set by modifying the fields under CheckDataset in the configuration file. Examples of some parameters in the configuration file are as follows:
CheckDataset:
convert:
enable: Whether to convert the dataset format. Set to True to enable dataset format conversion, default is False.src_dataset_type: If dataset format conversion is performed, the source dataset format must be specified. Available source formats are LabelMe and VOC.split:
enable: Whether to re-split the dataset. Set to True to enable dataset splitting, default is False.train_percent: If dataset splitting is performed, the percentage of the training set must be set. The value should be an integer between 0 and 100, and the sum with val_percent must be 100.val_percent: If dataset splitting is performed, the percentage of the validation set must be set. The value should be an integer between 0 and 100, and the sum with train_percent must be 100.Data conversion and data splitting can be enabled simultaneously. For data splitting, the original annotation files will be renamed to xxx.bak in their original paths. The above parameters also support setting through appending command-line arguments, for example, to re-split the dataset and set the training and validation set ratios: -o CheckDataset.split.enable=True -o CheckDataset.split.train_percent=80 -o CheckDataset.split.val_percent=20.
Before training, ensure that you have validated your dataset. To complete the training of a PaddleX model, simply use the following command:
python main.py -c paddlex/configs/modules/object_detection/PP-YOLOE_plus-S.yaml \
-o Global.mode=train \
-o Global.dataset_dir=./dataset/fall_det \
-o Train.num_classes=1
PaddleX supports modifying training hyperparameters, single/multi-GPU training, and more, simply by modifying the configuration file or appending command-line parameters.
Each model in PaddleX provides a configuration file for model development, which is used to set relevant parameters. Model training-related parameters can be set by modifying the Train fields in the configuration file. Some example explanations of parameters in the configuration file are as follows:
Global:
mode: Mode, supporting dataset validation (check_dataset), model training (train), and model evaluation (evaluate);device: Training device, options include cpu, gpu, xpu, npu, mlu. For multi-GPU training, specify card numbers, e.g., gpu:0,1,2,3;Train: Training hyperparameter settings;
epochs_iters: Number of training epochs;learning_rate: Training learning rate;For more hyperparameter introductions, refer to PaddleX General Model Configuration File Parameter Explanation.
Note:
-o Global.mode=train; specifying the first two GPUs for training: -o Global.device=gpu:0,1; setting the number of training epochs to 10: -o Train.epochs_iters=10.output. To specify a save path, use the -o Global.output field in the configuration file.Explanation of Training Outputs:
After completing model training, all outputs are saved in the specified output directory (default is ./output/), typically including the following:
After completing model training, you can evaluate the specified model weight file on the validation set to verify the model's accuracy. To evaluate a model using PaddleX, simply use the following command:
python main.py -c paddlex/configs/modules/object_detection/PP-YOLOE_plus-S.yaml \
-o Global.mode=evaluate \
-o Global.dataset_dir=./dataset/fall_det
Similar to model training, model evaluation supports setting parameters by modifying the configuration file or appending command-line parameters.
Note: When evaluating a model, you need to specify the model weight file path. Each configuration file has a default weight save path. If you need to change it, simply set it by appending a command-line parameter, e.g., -o Evaluate.weight_path=./output/best_model/best_model.pdparams.
After learning about model training and evaluation, we can improve model accuracy by adjusting hyperparameters. By reasonably adjusting the number of training epochs, you can control the depth of model training to avoid overfitting or underfitting. The learning rate setting affects the speed and stability of model convergence. Therefore, when optimizing model performance, carefully consider the values of these two parameters and adjust them flexibly based on actual conditions to achieve the best training results.
It is recommended to follow the control variable method when debugging parameters:
Learning Rate Exploration Results:
| Experiment | Epochs | Learning Rate | batch_size | Training Environment | mAP@0.5 |
|---|---|---|---|---|---|
| Experiment 1 | 10 | 0.00002 | 8 | 4 GPUs | 0.880 |
| Experiment 2 | 10 | 0.0001 | 8 | 4 GPUs | 0.910 |
| Experiment 3 | 10 | 0.0005 | 8 | 4 GPUs | 0.888 |
Changing Epochs Results:
| Experiment | Epochs | Learning Rate | batch_size | Training Environment | mAP@0.5 |
|---|---|---|---|---|---|
| Experiment 2 | 10 | 0.0001 | 8 | 4 GPUs | 0.910 |
| Experiment 2 (Increased Epochs) | 50 | 0.0001 | 8 | 4 GPUs | 0.944 |
| Experiment 2 (Increased Epochs) | 100 | 0.0001 | 8 | 4 GPUs | 0.947 |
Note: The above accuracy metrics are based on the mAP(0.5:0.95) of the COCO2017 validation set. GPU inference time is measured on an NVIDIA Tesla T4 machine with FP32 precision. CPU inference speed is based on an Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz with 8 threads and FP32 precision.
Replace the model in the production line with the fine-tuned model for testing, for example:
python main.py -c paddlex/configs/modules/object_detection/PP-YOLOE_plus-S.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/fall.png"
The prediction results will be generated under ./output, and the prediction result for fall.png is shown below:

If the General Object Detection Pipeline meets your requirements for inference speed and precision in the production line, you can proceed directly with development integration/deployment.
If you need to use the fine-tuned model weights, you can obtain the pipeline configuration file for object detection and load it for prediction. You can execute the following command to save the results in my_path:
paddlex --get_pipeline_config object_detection --save_path ./my_path
Fill in the local path of the fine-tuned model weights in the model_dir of the pipeline configuration file. If you want to directly apply the general object detection pipeline in your Python project, you can refer to the example below:
pipeline_name: object_detection
SubModules:
ObjectDetection:
module_name: object_detection
model_name: PicoDet-S
model_dir: null # Replace this with the local path to your trained model weights
batch_size: 1
img_size: null
threshold: null
Then, in your Python code, you can use the pipeline as follows:
from paddlex import create_pipeline
pipeline = create_pipeline(pipeline="my_path/object_detection.yaml")
output = pipeline.predict("https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/fall.png")
for res in output:
res.print() # Print the structured output of the prediction
res.save_to_img("./output/") # Save the result as a visualized image
res.save_to_json("./output/") # Save the structured output of the prediction
For more parameters, please refer to General Object Detection Pipeline Usage Tutorial.
You can select the appropriate deployment method for your model pipeline according to your needs, and proceed with subsequent AI application integration.