浏览代码

add rotated object detection model: PP-YOLOE-R_L (#2552)

* add rotated object detection model: PP-YOLOE-R_L

* add en doc;reorg config dir; fix cn doc

* fix ext_op install
Zhang Zelun 11 月之前
父节点
当前提交
a882280fef

+ 258 - 0
docs/module_usage/tutorials/cv_modules/rotated_object_detection.en.md

@@ -0,0 +1,258 @@
+---
+comments: true
+---
+
+# Rotated Object Detection Module Usage Tutorial
+
+## I. Overview
+Rotated object detection is a derivative of the object detection module, specifically designed for detecting rotated objects. Rotated bounding boxes (Rotated Bounding Boxes) are commonly used for detecting rectangles with angle information, where the width and height of the rectangle are no longer parallel to the image coordinate axes. Compared to horizontal bounding boxes, rotated bounding boxes generally include less background information. Rotated box detection is often used in scenarios such as remote sensing.
+
+## II. Supported Model List
+
+<table>
+<tr>
+<th>Model</th><th>Model Download Link</th>
+<th>mAP(%)</th>
+<th>GPU Inference Time (ms)</th>
+<th>CPU Inference Time (ms)</th>
+<th>Model Storage Size (M)</th>
+<th>Introduction</th>
+</tr>
+<tr>
+<td>PP-YOLOE-R_L</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b1_v2/PP-YOLOE-R_L_infer.tar">Inference Model</a>/<a href="https://paddledet.bj.bcebos.com/models/ppyoloe_r_crn_l_3x_dota.pdparams">Training Model</a></td>
+<td>78.14</td>
+<td>20.7039</td>
+<td>157.942</td>
+<td>211.0 M</td>
+<td rowspan="1">PP-YOLOE-R is an efficient single-stage Anchor-free rotated box detection model. Based on PP-YOLOE, PP-YOLOE-R introduces a series of useful designs to improve detection accuracy with minimal parameters and computational cost.</td>
+</tr>
+</table>
+<p><b>Note: The above accuracy metrics are on the <a href="https://captain-whu.github.io/DOTA/">DOTA</a> validation set mAP(0.5:0.95)。All model GPU inference times are based on an NVIDIA TRX2080 Ti machine, with precision type F16, and CPU inference speeds are based on an Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz, with 8 threads and precision type FP32.</b></p>
+> ❗ The above listed are the rotated object detection models currently supported by paddleX,actually PaddleDetection supports<b>10</b>rotated object detection models, For a detailed model list, please refer to <a href="https://github.com/PaddlePaddle/PaddleDetection/tree/release/2.8/configs/rotate">PaddleDetection</a>
+
+
+## III. Quick Integration
+> ❗ Before quick integration, please install the PaddleX wheel package. For details, please refer to [PaddleX Local Installation Tutorial](../../../installation/installation.en.md)
+
+After completing the installation of the wheel package, a few lines of code can complete the inference of the rotated object detection module. You can switch models under this module at will, and you can also integrate the model inference of the rotated object detection module into your project. Before running the following code, please download the [sample image](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/rotated_object_detection_001.png) to your local machine.
+
+```python
+from paddlex import create_model
+model = create_model("PP-YOLOE-R_L")
+output = model.predict("rotated_object_detection_001.png", batch_size=1)
+for res in output:
+    res.print(json_format=False)
+    res.save_to_img("./output/")
+    res.save_to_json("./output/res.json")
+```
+For more usage methods of the single model inference API in PaddleX, please refer to [PaddleX Single Model Python Script Usage Instructions](../../instructions/model_python_API.en.md).
+
+## IV. Secondary Development
+If you are pursuing higher accuracy with existing models, you can use PaddleX's secondary development capabilities to develop better rotated object detection models. Before using PaddleX to develop rotated object detection models, please ensure that you have installed the model training plugins related to rotated object detection in PaddleX. The installation process can be referred to [PaddleX Local Installation Tutorial](../../../installation/installation.en.md)
+
+### 4.1 Data Preparation
+Before model training, you need to prepare the dataset for the corresponding task module. PaddleX provides data verification functionality for each module, only data that passes the verification can be used for model training. Additionally, PaddleX provides a Demo dataset for each module, which you can use to complete subsequent development. If you wish to use a private dataset for subsequent model training, you can refer to [PaddleX Object Detection Task Module Data Annotation Tutorial](../../../data_annotations/cv_modules/object_detection.en.md).
+
+#### 4.1.1 Demo Data Download
+You can refer to the following command to download the Demo dataset to the specified folder:
+
+```bash
+wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/rdet_dota_examples.tar -P ./dataset
+tar -xf ./dataset/rdet_dota_examples.tar -C ./dataset/
+```
+After decompression, the dataset directory structure is as follows::
+```bash
+- dataset/DOTA-sampled200_crop1024_data
+  - annotations
+    - instance_train.json
+    - instance_val.json
+  - images
+    - img1.png
+    - img2.png
+    - img3.png
+    ...
+```
+#### 4.1.2 Data Verification
+A single command can complete data verification:
+
+```bash
+python main.py -c paddlex/configs/rotated_object_detection/PP-YOLOE-R_L.yaml \
+    -o Global.mode=check_dataset \
+    -o Global.dataset_dir=./dataset/DOTA-sampled200_crop1024_data
+```
+After executing the above command, PaddleX will verify the dataset and count the basic information of the dataset. After the command runs successfully, the log will print `Check dataset passed !`. The verification result file is saved in `./output/check_dataset_result.json`, and the related outputs are saved in the`./output/check_dataset`directory under the current directory, including visualized sample images and sample distribution histograms.
+
+<details><summary>👉 <b> Verification Result Details (Click to Expand)</b></summary>
+
+<p>The specific content of the verification result file is:</p>
+<pre><code class="language-bash">{
+  &quot;done_flag&quot;: true,
+  &quot;check_pass&quot;: true,
+  &quot;attributes&quot;: {
+    &quot;num_classes&quot;: 15,
+    &quot;train_samples&quot;: 1892,
+    &quot;train_sample_paths&quot;: [
+      &quot;check_dataset\/demo_img\/P2610__1.0__0___0.png&quot;,
+      &quot;check_dataset\/demo_img\/P1137__1.0__0___0.png&quot;,
+      &quot;check_dataset\/demo_img\/P1122__1.0__5888___1648.png&quot;,
+      &quot;check_dataset\/demo_img\/P0543__1.0__0___0.png&quot;,
+      &quot;check_dataset\/demo_img\/P0518__1.0__0___91.png&quot;,
+      &quot;check_dataset\/demo_img\/P0961__1.0__1648___87.png&quot;,
+      &quot;check_dataset\/demo_img\/P1732__1.0__0___824.png&quot;,
+      &quot;check_dataset\/demo_img\/P2766__1.0__4421___0.png&quot;,
+      &quot;check_dataset\/demo_img\/P2582__1.0__674___725.png&quot;,
+      &quot;check_dataset\/demo_img\/P1529__1.0__2976___1648.png&quot;
+    ],
+    &quot;val_samples&quot;: 473,
+    &quot;val_sample_paths&quot;: [
+      &quot;check_dataset\/demo_img\/P2342__1.0__890___0.png&quot;,
+      &quot;check_dataset\/demo_img\/P1386__1.0__2472___1648.png&quot;,
+      &quot;check_dataset\/demo_img\/P0961__1.0__824___87.png&quot;,
+      &quot;check_dataset\/demo_img\/P1651__1.0__824___824.png&quot;,
+      &quot;check_dataset\/demo_img\/P1529__1.0__824___2976.png&quot;,
+      &quot;check_dataset\/demo_img\/P0961__1.0__4944___87.png&quot;,
+      &quot;check_dataset\/demo_img\/P0725__1.0__634___0.png&quot;,
+      &quot;check_dataset\/demo_img\/P1679__1.0__1648___1648.png&quot;,
+      &quot;check_dataset\/demo_img\/P2726__1.0__824___1578.png&quot;,
+      &quot;check_dataset\/demo_img\/P0457__1.0__379___0.png&quot;,
+    ]
+  },
+  &quot;analysis&quot;: {
+    &quot;histogram&quot;: &quot;check_dataset/histogram.png&quot;
+  },
+  &quot;dataset_path&quot;: &quot;./dataset/DOTA-sampled200_crop1024_data&quot;,
+  &quot;show_type&quot;: &quot;image&quot;,
+  &quot;dataset_type&quot;: &quot;COCODetDataset&quot;
+}
+</code></pre>
+<p>In the above verification result, check_pass is true, indicating that the dataset format meets the requirements. The explanations for other indicators are as follows:</p>
+<ul>
+<li><code>attributes.num_classes</code>:The number of categories in this dataset is 15;</li>
+<li><code>attributes.train_samples</code>:The number of training set samples in this dataset is 1892;</li>
+<li><code>attributes.val_samples</code>:The number of validation set samples in this dataset is 473;</li>
+<li><code>attributes.train_sample_paths</code>:The relative path list of visualized training set sample images in this dataset;</li>
+<li><code>attributes.val_sample_paths</code>:The relative path list of visualized validation set sample images in this dataset;</li>
+</ul>
+<p>Additionally, the dataset verification also analyzes the distribution of sample quantities for all categories in the dataset and draws a distribution histogram (histogram.png):</p>
+<p><img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/robj_det/01.png"></p></details>
+
+#### 4.1.3 Dataset Format Conversion/Dataset Splitting (Optional)
+After completing the data verification, you can convert the dataset format or re-split the training/validation ratio of the dataset by modifying the configuration file or adding hyperparameters.
+
+<details><summary>👉 <b>Format Conversion/Dataset Splitting Details (Click to Expand))</b></summary>
+
+<p><b>(1)Dataset Format Conversion</b></p>
+
+Rotated object detection does not support dataset format conversion, only standard <b>DOTA COCO data format</b>
+<p><b>(2)Dataset Splitting</b></p>
+<p>The parameters for dataset splitting can be set by modifying the fields under <code>CheckDataset</code> in the configuration file. Some example explanations for the parameters in the configuration file are as follows:</p>
+<ul>
+<li><code>CheckDataset</code>:</li>
+<li><code>split</code>:</li>
+<li><code>enable</code>: Whether to re-split the dataset, set to <code>True</code> to convert the dataset format, default is <code>False</code>;</li>
+<li><code>train_percent</code>: If re-splitting the dataset, you need to set the percentage of the training set, which is any integer between 0-100, and needs to ensure that the sum with <code>val_percent</code> is 100;</li>
+<li><code>val_percent</code>: If re-splitting the dataset, you need to set the percentage of the validation set, which is any integer between 0-100, and needs to ensure that the sum with <code>train_percent</code> is 100;
+For example, if you want to re-split the dataset with 90% for the training set and 10% for the validation set, you need to modify the configuration file as follows:
+</li>
+</ul>
+<pre><code class="language-bash">......
+CheckDataset:
+  ......
+  split:
+    enable: True
+    train_percent: 90
+    val_percent: 10
+  ......
+</code></pre>
+<p>Then execute the command:</p>
+<pre><code class="language-bash">python main.py -c paddlex/configs/rotated_object_detection/PP-YOLOE-R_L.yaml \
+    -o Global.mode=check_dataset \
+    -o Global.dataset_dir=./dataset/DOTA-sampled200_crop1024_data
+</code></pre>
+<p>After the dataset splitting is executed, the original annotation files will be renamed to <code>xxx.bak</code>.</p>
+<p>The above parameters also support setting through adding command line parameters:</p>
+<pre><code class="language-bash">python main.py -c paddlex/configs/rotated_object_detection/PP-YOLOE-R_L.yaml \
+    -o Global.mode=check_dataset \
+    -o Global.dataset_dir=./dataset/DOTA-sampled200_crop1024_data \
+    -o CheckDataset.split.enable=True \
+    -o CheckDataset.split.train_percent=90 \
+    -o CheckDataset.split.val_percent=10
+</code></pre></details>
+
+### 4.2 Model Training
+A single command can complete model training, taking the training of the rotated object detection model `PP-YOLOE-R_L` as an example:
+
+```bash
+python main.py -c paddlex/configs/rotated_object_detection/PP-YOLOE-R_L.yaml \
+    -o Global.mode=train \
+    -o Global.dataset_dir=./dataset/DOTA-sampled200_crop1024_data
+```
+The following steps are required:
+
+* Specify the path of the model's `.yaml` configuration file (here it is `PP-YOLOE-R_L.yaml`. When training other models, you need to specify the corresponding configuration file. The correspondence between models and configuration files can be found in [PaddleX Model List (CPU/GPU))](../../../support_list/models_list.en.md))
+* Specify the mode as model training: `-o Global.mode=train`
+* Specify the training dataset path: `-o Global.dataset_dir`
+Other related parameters can be set by modifying the fields under Global and Train in the `.yaml` configuration file, or by adding parameters in the command line. For example, specify the first 2 GPU cards for training: `-o Global.device=gpu:0,1`; set the number of training epochs to 10: `-o Train.epochs_iters=10`. For more modifiable parameters and detailed explanations, please refer to the configuration file instructions for the corresponding task module [PaddleX Common Model Configuration File Parameter Instructions.](../../instructions/config_parameters_common.en.md).
+
+<details><summary>👉 <b>More Explanations (Click to Expand)</b></summary>
+
+<ul>
+<li>During model training, PaddleX automatically saves the model weight files, with the default being <code>output</code>. If you need to specify a save path, you can set it through the <code>-o Global.output</code> field in the configuration file.</li>
+<li>PaddleX shields you from the concepts of dynamic graph weights and static graph weights. During model training, both dynamic and static graph weights are produced, and static graph weights are selected by default for model inference.</li>
+<li>
+<p>After completing the model training, all outputs are saved in the specified output directory (default is <code>./output/</code>), typically including:</p>
+</li>
+<li>
+<p><code>train_result.json</code>: Training result record file, recording whether the training task was completed normally, as well as the output weight metrics, related file paths, etc.;</p>
+</li>
+<li><code>train.log</code>: Training log file, recording changes in model metrics and loss during training;</li>
+<li><code>config.yaml</code>: Training configuration file, recording the hyperparameter configuration for this training session;</li>
+<li><code>.pdparams</code>, <code>.pdema</code>, <code>.pdopt.pdstate</code>, <code>.pdiparams</code>, <code>.pdmodel</code>: Model weight-related files, including network parameters, optimizer, EMA, static graph network parameters, static graph network structure, etc.;</li>
+</ul></details>
+
+## <b>4.3 Model Evaluation</b>
+After completing model training, you can evaluate the specified model weights file on the validation set to verify the model's accuracy. Using PaddleX for model evaluation can be done with a single command:
+
+```bash
+python main.py -c paddlex/configs/rotated_object_detection/PP-YOLOE-R_L.yaml \
+    -o Global.mode=evaluate \
+    -o Global.dataset_dir=./dataset/DOTA-sampled200_crop1024_data
+```
+Similar to model training, the following steps are required:
+
+* Specify the `.yaml` configuration file path for the model (here it is `PP-YOLOE-R_L.yaml`)
+* Specify the mode as model evaluation: `-o Global.mode=evaluate`
+* Specify the path to the validation dataset: `-o Global.dataset_dir`. Other related parameters can be set by modifying the `Global` and `Evaluate` fields in the `.yaml` configuration file. For details, refer to [PaddleX Common Model Configuration File Parameter Description](../../instructions/config_parameters_common.en.md).
+
+<details><summary>👉 <b>More Details (Click to Expand)</b></summary>
+
+<p>When evaluating the model, you need to specify the model weights file path. Each configuration file has a default weight save path built-in. If you need to change it, simply set it by appending a command line parameter, such as <code>-o Evaluate.weight_path=./output/best_model/best_model.pdparams</code>.</p>
+<p>After completing the model evaluation, an <code>evaluate_result.json</code> file will be generated, which records the evaluation results, specifically whether the evaluation task was completed successfully and the model's evaluation metrics, including AP.</p></details>
+
+### <b>4.4 Model Inference and Integration</b>
+After completing model training and evaluation, you can use the trained model weights for inference predictions or Python integration.
+
+#### 4.4.1 Model Inference
+
+* To perform inference predictions through the command line, use the following command. Before running the following code, please download the [demo image](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/rotated_object_detection_001.png) to your local machine.
+```bash
+python main.py -c paddlex/configs/rotated_object_detection/PP-YOLOE-R_L.yaml  \
+    -o Global.mode=predict \
+    -o Predict.model_dir="./output/best_model/inference" \
+    -o Predict.input="rotated_object_detection_001.png"
+```
+Similar to model training and evaluation, the following steps are required:
+
+* Specify the `.yaml` configuration file path for the model (here it is `PP-YOLOE-R_L.yaml`)
+* Specify the mode as model inference prediction: `-o Global.mode=predict`
+* Specify the model weights path: `-o Predict.model_dir="./output/best_model/inference"`
+* Specify the input data path: `-o Predict.input="..."`
+Other related parameters can be set by modifying the `Global` and `Predict` fields in the `.yaml` configuration file. For details, refer to [PaddleX Common Model Configuration File Parameter Description](../../instructions/config_parameters_common.en.md).
+
+#### 4.4.2 Model Integration
+The model can be directly integrated into the PaddleX pipelines or directly into your own project.
+
+2.<b>Module Integration</b>
+
+The weights you produce can be directly integrated into the object detection module. Refer to the Python example code in [Quick Integration](#iii-quick-integration), and simply replace the model with the path to your trained model.
+

+ 258 - 0
docs/module_usage/tutorials/cv_modules/rotated_object_detection.md

@@ -0,0 +1,258 @@
+---
+comments: true
+---
+
+# 旋转目标检测模块使用教程
+
+## 一、概述
+旋转目标检测是目标检测模块中的一种衍生,它专门针对旋转目标进行检测。旋转框(Rotated Bounding Boxes)常用于检测带有角度信息的矩形框,即矩形框的宽和高不再与图像坐标轴平行。相较于水平矩形框,旋转矩形框一般包括更少的背景信息。旋转框检测常用于遥感等场景中。
+
+## 二、支持模型列表
+
+<table>
+<tr>
+<th>模型</th><th>模型下载链接</th>
+<th>mAP(%)</th>
+<th>GPU推理耗时 (ms)</th>
+<th>CPU推理耗时 (ms)</th>
+<th>模型存储大小 (M)</th>
+<th>介绍</th>
+</tr>
+<tr>
+<td>PP-YOLOE-R_L</td><td><a href="https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b1_v2/PP-YOLOE-R_L_infer.tar">推理模型</a>/<a href="https://paddledet.bj.bcebos.com/models/ppyoloe_r_crn_l_3x_dota.pdparams">训练模型</a></td>
+<td>78.14</td>
+<td>20.7039</td>
+<td>157.942</td>
+<td>211.0 M</td>
+<td rowspan="1">PP-YOLOE-R是一个高效的单阶段Anchor-free旋转框检测模型。基于PP-YOLOE, PP-YOLOE-R以极少的参数量和计算量为代价,引入了一系列有用的设计来提升检测精度。</td>
+</tr>
+</table>
+<p><b>注:以上精度指标为<a href="https://captain-whu.github.io/DOTA/">DOTA</a>验证集 mAP(0.5:0.95)。所有模型 GPU 推理耗时基于 NVIDIA TRX2080 Ti 机器,精度类型为 F16, CPU 推理速度基于 Intel(R) Xeon(R) Gold 5117 CPU @ 2.00GHz,线程数为8,精度类型为 FP32。</b></p>
+> ❗ 以上列出的是paddleX当前支持的旋转目标检测模型</b>,实际的PaddleDetection套件支持<b>10</b>个旋转目标检测模型,详细模型列表请参考<a href="https://github.com/PaddlePaddle/PaddleDetection/tree/release/2.8/configs/rotate">PaddleDetection</a>
+
+
+## 三、快速集成
+> ❗ 在快速集成前,请先安装 PaddleX 的 wheel 包,详细请参考 [PaddleX本地安装教程](../../../installation/installation.md)
+
+完成 wheel 包的安装后,几行代码即可完成旋转目标检测模块的推理,可以任意切换该模块下的模型,您也可以将旋转目标检测的模块中的模型推理集成到您的项目中。运行以下代码前,请您下载[示例图片](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/rotated_object_detection_001.png)到本地。
+
+```python
+from paddlex import create_model
+model = create_model("PP-YOLOE-R_L")
+output = model.predict("rotated_object_detection_001.png", batch_size=1)
+for res in output:
+    res.print(json_format=False)
+    res.save_to_img("./output/")
+    res.save_to_json("./output/res.json")
+```
+关于更多 PaddleX 的单模型推理的 API 的使用方法,可以参考[PaddleX单模型Python脚本使用说明](../../instructions/model_python_API.md)。
+
+## 四、二次开发
+如果你追求更高精度的现有模型,可以使用 PaddleX 的二次开发能力,开发更好的旋转目标检测模型。在使用 PaddleX 开发旋转目标检测模型之前,请务必安装 PaddleX的旋转目标检测相关模型训练插件,安装过程可以参考 [PaddleX本地安装教程](../../../installation/installation.md)
+
+### 4.1 数据准备
+在进行模型训练前,需要准备相应任务模块的数据集。PaddleX 针对每一个模块提供了数据校验功能,<b>只有通过数据校验的数据才可以进行模型训练</b>。此外,PaddleX 为每一个模块都提供了 Demo 数据集,您可以基于官方提供的 Demo 数据完成后续的开发。若您希望用私有数据集进行后续的模型训练,可以参考[PaddleX目标检测任务模块数据标注教程](../../../data_annotations/cv_modules/object_detection.md)。
+
+#### 4.1.1 Demo 数据下载
+您可以参考下面的命令将 Demo 数据集下载到指定文件夹:
+
+```bash
+wget https://paddle-model-ecology.bj.bcebos.com/paddlex/data/rdet_dota_examples.tar -P ./dataset
+tar -xf ./dataset/rdet_dota_examples.tar -C ./dataset/
+```
+解压后,数据集目录结构如下:
+```bash
+- dataset/DOTA-sampled200_crop1024_data
+  - annotations
+    - instance_train.json
+    - instance_val.json
+  - images
+    - img1.png
+    - img2.png
+    - img3.png
+    ...
+```
+#### 4.1.2 数据校验
+一行命令即可完成数据校验:
+
+```bash
+python main.py -c paddlex/configs/rotated_object_detection/PP-YOLOE-R_L.yaml \
+    -o Global.mode=check_dataset \
+    -o Global.dataset_dir=./dataset/DOTA-sampled200_crop1024_data
+```
+执行上述命令后,PaddleX 会对数据集进行校验,并统计数据集的基本信息,命令运行成功后会在log中打印出`Check dataset passed !`信息。校验结果文件保存在`./output/check_dataset_result.json`,同时相关产出会保存在当前目录的`./output/check_dataset`目录下,产出目录中包括可视化的示例样本图片和样本分布直方图。
+
+<details><summary>👉 <b>校验结果详情(点击展开)</b></summary>
+
+<p>校验结果文件具体内容为:</p>
+<pre><code class="language-bash">{
+  &quot;done_flag&quot;: true,
+  &quot;check_pass&quot;: true,
+  &quot;attributes&quot;: {
+    &quot;num_classes&quot;: 15,
+    &quot;train_samples&quot;: 1892,
+    &quot;train_sample_paths&quot;: [
+      &quot;check_dataset\/demo_img\/P2610__1.0__0___0.png&quot;,
+      &quot;check_dataset\/demo_img\/P1137__1.0__0___0.png&quot;,
+      &quot;check_dataset\/demo_img\/P1122__1.0__5888___1648.png&quot;,
+      &quot;check_dataset\/demo_img\/P0543__1.0__0___0.png&quot;,
+      &quot;check_dataset\/demo_img\/P0518__1.0__0___91.png&quot;,
+      &quot;check_dataset\/demo_img\/P0961__1.0__1648___87.png&quot;,
+      &quot;check_dataset\/demo_img\/P1732__1.0__0___824.png&quot;,
+      &quot;check_dataset\/demo_img\/P2766__1.0__4421___0.png&quot;,
+      &quot;check_dataset\/demo_img\/P2582__1.0__674___725.png&quot;,
+      &quot;check_dataset\/demo_img\/P1529__1.0__2976___1648.png&quot;
+    ],
+    &quot;val_samples&quot;: 473,
+    &quot;val_sample_paths&quot;: [
+      &quot;check_dataset\/demo_img\/P2342__1.0__890___0.png&quot;,
+      &quot;check_dataset\/demo_img\/P1386__1.0__2472___1648.png&quot;,
+      &quot;check_dataset\/demo_img\/P0961__1.0__824___87.png&quot;,
+      &quot;check_dataset\/demo_img\/P1651__1.0__824___824.png&quot;,
+      &quot;check_dataset\/demo_img\/P1529__1.0__824___2976.png&quot;,
+      &quot;check_dataset\/demo_img\/P0961__1.0__4944___87.png&quot;,
+      &quot;check_dataset\/demo_img\/P0725__1.0__634___0.png&quot;,
+      &quot;check_dataset\/demo_img\/P1679__1.0__1648___1648.png&quot;,
+      &quot;check_dataset\/demo_img\/P2726__1.0__824___1578.png&quot;,
+      &quot;check_dataset\/demo_img\/P0457__1.0__379___0.png&quot;,
+    ]
+  },
+  &quot;analysis&quot;: {
+    &quot;histogram&quot;: &quot;check_dataset/histogram.png&quot;
+  },
+  &quot;dataset_path&quot;: &quot;./dataset/DOTA-sampled200_crop1024_data&quot;,
+  &quot;show_type&quot;: &quot;image&quot;,
+  &quot;dataset_type&quot;: &quot;COCODetDataset&quot;
+}
+</code></pre>
+<p>上述校验结果中,check_pass 为 true 表示数据集格式符合要求,其他部分指标的说明如下:</p>
+<ul>
+<li><code>attributes.num_classes</code>:该数据集类别数为 15;</li>
+<li><code>attributes.train_samples</code>:该数据集训练集样本数量为 1892;</li>
+<li><code>attributes.val_samples</code>:该数据集验证集样本数量为 473;</li>
+<li><code>attributes.train_sample_paths</code>:该数据集训练集样本可视化图片相对路径列表;</li>
+<li><code>attributes.val_sample_paths</code>:该数据集验证集样本可视化图片相对路径列表;</li>
+</ul>
+<p>另外,数据集校验还对数据集中所有类别的样本数量分布情况进行了分析,并绘制了分布直方图(histogram.png):</p>
+<p><img src="https://raw.githubusercontent.com/BluebirdStory/PaddleX_doc_images/main/images/modules/robj_det/01.png"></p></details>
+
+#### 4.1.3 数据集格式转换/数据集划分(可选)
+在您完成数据校验之后,可以通过<b>修改配置文件</b>或是<b>追加超参数</b>的方式对数据集的格式进行转换,也可以对数据集的训练/验证比例进行重新划分。
+
+<details><summary>👉 <b>格式转换/数据集划分详情(点击展开)</b></summary>
+
+<p><b>(1)数据集格式转换</b></p>
+
+旋转目标检测赞不支持数据格式转换,只支持标准DOTA的COCO数据格式。
+
+<p><b>(2)数据集划分</b></p>
+<p>数据集划分的参数可以通过修改配置文件中 <code>CheckDataset</code> 下的字段进行设置,配置文件中部分参数的示例说明如下:</p>
+<ul>
+<li><code>CheckDataset</code>:</li>
+<li><code>split</code>:</li>
+<li><code>enable</code>: 是否进行重新划分数据集,为 <code>True</code> 时进行数据集格式转换,默认为 <code>False</code>;</li>
+<li><code>train_percent</code>: 如果重新划分数据集,则需要设置训练集的百分比,类型为0-100之间的任意整数,需要保证和 <code>val_percent</code> 值加和为100;</li>
+<li><code>val_percent</code>: 如果重新划分数据集,则需要设置验证集的百分比,类型为0-100之间的任意整数,需要保证和 <code>train_percent</code> 值加和为100;
+例如,您想重新划分数据集为 训练集占比90%、验证集占比10%,则需将配置文件修改为:</li>
+</ul>
+<pre><code class="language-bash">......
+CheckDataset:
+  ......
+  split:
+    enable: True
+    train_percent: 90
+    val_percent: 10
+  ......
+</code></pre>
+<p>随后执行命令:</p>
+<pre><code class="language-bash">python main.py -c paddlex/configs/rotated_object_detection/PP-YOLOE-R_L.yaml \
+    -o Global.mode=check_dataset \
+    -o Global.dataset_dir=./dataset/DOTA-sampled200_crop1024_data
+</code></pre>
+<p>数据划分执行之后,原有标注文件会被在原路径下重命名为 <code>xxx.bak</code>。</p>
+<p>以上参数同样支持通过追加命令行参数的方式进行设置:</p>
+<pre><code class="language-bash">python main.py -c paddlex/configs/rotated_object_detection/PP-YOLOE-R_L.yaml \
+    -o Global.mode=check_dataset \
+    -o Global.dataset_dir=./dataset/DOTA-sampled200_crop1024_data \
+    -o CheckDataset.split.enable=True \
+    -o CheckDataset.split.train_percent=90 \
+    -o CheckDataset.split.val_percent=10
+</code></pre></details>
+
+### 4.2 模型训练
+一条命令即可完成模型的训练,以此处旋转目标检测模型 `PP-YOLOE-R_L` 的训练为例:
+
+```bash
+python main.py -c paddlex/configs/rotated_object_detection/PP-YOLOE-R_L.yaml \
+    -o Global.mode=train \
+    -o Global.dataset_dir=./dataset/DOTA-sampled200_crop1024_data
+```
+需要如下几步:
+
+* 指定模型的`.yaml` 配置文件路径(此处为`PP-YOLOE-R_L.yaml`,训练其他模型时,需要的指定相应的配置文件,模型和配置的文件的对应关系,可以查阅[PaddleX模型列表(CPU/GPU)](../../../support_list/models_list.md))
+* 指定模式为模型训练:`-o Global.mode=train`
+* 指定训练数据集路径:`-o Global.dataset_dir`
+其他相关参数均可通过修改`.yaml`配置文件中的`Global`和`Train`下的字段来进行设置,也可以通过在命令行中追加参数来进行调整。如指定前 2 卡 gpu 训练:`-o Global.device=gpu:0,1`;设置训练轮次数为 10:`-o Train.epochs_iters=10`。更多可修改的参数及其详细解释,可以查阅模型对应任务模块的配置文件说明[PaddleX通用模型配置文件参数说明](../../instructions/config_parameters_common.md)。
+
+<details><summary>👉 <b>更多说明(点击展开)</b></summary>
+
+<ul>
+<li>模型训练过程中,PaddleX 会自动保存模型权重文件,默认为<code>output</code>,如需指定保存路径,可通过配置文件中 <code>-o Global.output</code> 字段进行设置。</li>
+<li>PaddleX 对您屏蔽了动态图权重和静态图权重的概念。在模型训练的过程中,会同时产出动态图和静态图的权重,在模型推理时,默认选择静态图权重推理。</li>
+<li>
+<p>在完成模型训练后,所有产出保存在指定的输出目录(默认为<code>./output/</code>)下,通常有以下产出:</p>
+</li>
+<li>
+<p><code>train_result.json</code>:训练结果记录文件,记录了训练任务是否正常完成,以及产出的权重指标、相关文件路径等;</p>
+</li>
+<li><code>train.log</code>:训练日志文件,记录了训练过程中的模型指标变化、loss 变化等;</li>
+<li><code>config.yaml</code>:训练配置文件,记录了本次训练的超参数的配置;</li>
+<li><code>.pdparams</code>、<code>.pdema</code>、<code>.pdopt.pdstate</code>、<code>.pdiparams</code>、<code>.pdmodel</code>:模型权重相关文件,包括网络参数、优化器、EMA、静态图网络参数、静态图网络结构等;</li>
+</ul></details>
+
+## <b>4.3 模型评估</b>
+在完成模型训练后,可以对指定的模型权重文件在验证集上进行评估,验证模型精度。使用 PaddleX 进行模型评估,一条命令即可完成模型的评估:
+
+```bash
+python main.py -c paddlex/configs/rotated_object_detection/PP-YOLOE-R_L.yaml \
+    -o Global.mode=evaluate \
+    -o Global.dataset_dir=./dataset/DOTA-sampled200_crop1024_data
+```
+与模型训练类似,需要如下几步:
+
+* 指定模型的`.yaml` 配置文件路径(此处为`PP-YOLOE-R_L.yaml`)
+* 指定模式为模型评估:`-o Global.mode=evaluate`
+* 指定验证数据集路径:`-o Global.dataset_dir`
+其他相关参数均可通过修改`.yaml`配置文件中的`Global`和`Evaluate`下的字段来进行设置,详细请参考[PaddleX通用模型配置文件参数说明](../../instructions/config_parameters_common.md)。
+
+<details><summary>👉 <b>更多说明(点击展开)</b></summary>
+
+<p>在模型评估时,需要指定模型权重文件路径,每个配置文件中都内置了默认的权重保存路径,如需要改变,只需要通过追加命令行参数的形式进行设置即可,如<code>-o Evaluate.weight_path=./output/best_model/best_model.pdparams</code>。</p>
+<p>在完成模型评估后,会产出<code>evaluate_result.json,其记录了</code>评估的结果,具体来说,记录了评估任务是否正常完成,以及模型的评估指标,包含 AP;</p></details>
+
+### <b>4.4 模型推理和模型集成</b>
+在完成模型的训练和评估后,即可使用训练好的模型权重进行推理预测或者进行Python集成。
+
+#### 4.4.1 模型推理
+
+* 通过命令行的方式进行推理预测,只需如下一条命令。运行以下代码前,请您下载[示例图片](https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/rotated_object_detection_001.png)到本地。
+```bash
+python main.py -c paddlex/configs/rotated_object_detection/PP-YOLOE-R_L.yaml  \
+    -o Global.mode=predict \
+    -o Predict.model_dir="./output/best_model/inference" \
+    -o Predict.input="rotated_object_detection_001.png"
+```
+与模型训练和评估类似,需要如下几步:
+
+* 指定模型的`.yaml` 配置文件路径(此处为`PP-YOLOE-R_L.yaml`)
+* 指定模式为模型推理预测:`-o Global.mode=predict`
+* 指定模型权重路径:`-o Predict.model_dir="./output/best_model/inference"`
+* 指定输入数据路径:`-o Predict.input="..."`
+其他相关参数均可通过修改`.yaml`配置文件中的`Global`和`Predict`下的字段来进行设置,详细请参考[PaddleX通用模型配置文件参数说明](../../instructions/config_parameters_common.md)。
+
+#### 4.4.2 模型集成
+模型可以直接集成到 PaddleX 产线中,也可以直接集成到您自己的项目中。
+
+1.<b>模块集成</b>
+
+您产出的权重可以直接集成到旋转目标检测模块中,可以参考[快速集成](#三快速集成)的 Python 示例代码,只需要将模型替换为你训练的到的模型路径即可。

+ 40 - 0
paddlex/configs/rotated_object_detection/PP-YOLOE-R_L.yaml

@@ -0,0 +1,40 @@
+Global:
+  model: PP-YOLOE-R_L
+  mode: check_dataset # check_dataset/train/evaluate/predict
+  dataset_dir: "dataset/rdet_dota_examples"
+  device: gpu:0,1,2,3
+  output: "output"
+
+CheckDataset:
+  convert:
+    enable: False
+    src_dataset_type: null
+  split:
+    enable: False
+    train_percent: null
+    val_percent: null
+
+Train:
+  num_classes: 15
+  epochs_iters: 10
+  batch_size: 1
+  learning_rate: 0.128
+  pretrain_weight_path: https://paddledet.bj.bcebos.com/models/pretrained/CSPResNetb_l_pretrained.pdparams
+  warmup_steps: 100
+  resume_path: null
+  log_interval: 10
+  eval_interval: 5
+
+Evaluate:
+  weight_path: "output/best_model/best_model.pdparams"
+  log_interval: 10
+
+Export:
+  weight_path: https://paddledet.bj.bcebos.com/models/ppyoloe_r_crn_l_3x_dota.pdparams
+
+Predict:
+  batch_size: 1
+  model_dir: "output/best_model/inference"
+  input: "https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/rotated_object_detection_001.png"
+  kernel_option:
+    run_mode: paddle

+ 39 - 1
paddlex/inference/components/task_related/det.py

@@ -43,6 +43,34 @@ def restructured_boxes(boxes, labels, img_size):
     return box_list
 
 
+def restructured_rotated_boxes(boxes, labels, img_size):
+
+    box_list = []
+    w, h = img_size
+
+    assert boxes.shape[1] == 10, 'The shape of rotated boxes should be [N, 10]'
+    for box in boxes:
+        x1, y1, x2, y2, x3, y3, x4, y4 = box[2:]
+        x1 = min(max(0, x1), w)
+        y1 = min(max(0, y1), h)
+        x2 = min(max(0, x2), w)
+        y2 = min(max(0, y2), h)
+        x3 = min(max(0, x3), w)
+        y3 = min(max(0, y3), h)
+        x4 = min(max(0, x4), w)
+        y4 = min(max(0, y4), h)
+        box_list.append(
+            {
+                "cls_id": int(box[0]),
+                "label": labels[int(box[0])],
+                "score": float(box[1]),
+                "coordinate": [x1, y1, x2, y2, x3, y3, x4, y4],
+            }
+        )
+
+    return box_list
+
+
 def rotate_point(pt, angle_rad):
     """Rotate a point by an angle.
     Args:
@@ -217,7 +245,17 @@ class DetPostProcess(BaseComponent):
         """apply"""
         expect_boxes = (boxes[:, 1] > self.threshold) & (boxes[:, 0] > -1)
         boxes = boxes[expect_boxes, :]
-        boxes = restructured_boxes(boxes, self.labels, img_size)
+        if boxes.shape[1] == 6:
+            """For Normal Object Detection"""
+            boxes = restructured_boxes(boxes, self.labels, img_size)
+        elif boxes.shape[1] == 10:
+            """Adapt For Rotated Object Detection"""
+            boxes = restructured_rotated_boxes(boxes, self.labels, img_size)
+        else:
+            """Unexpected Input Box Shape"""
+            raise ValueError(
+                f"The shape of boxes should be 6 or 10, instead of {boxes.shape[1]}"
+            )
         result = {"boxes": boxes}
 
         return result

+ 16 - 2
paddlex/inference/results/det.py

@@ -50,10 +50,24 @@ def draw_box(img, boxes):
         color = tuple(label2color[label])
         font_color = tuple(catid2fontcolor[label])
 
-        xmin, ymin, xmax, ymax = bbox
+        if len(bbox) == 4:
+            # draw bbox of normal object detection
+            xmin, ymin, xmax, ymax = bbox
+            rectangle = [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin), (xmin, ymin)]
+        elif len(bbox) == 8:
+            # draw bbox of rotated object detection
+            x1, y1, x2, y2, x3, y3, x4, y4 = bbox
+            rectangle = [(x1, y1), (x2, y2), (x3, y3), (x4, y4), (x1, y1)]
+            xmin = min(x1, x2, x3, x4)
+            ymin = min(y1, y2, y3, y4)
+        else:
+            raise ValueError(
+                f"Only support bbox format of [xmin,ymin,xmax,ymax] or [x1,y1,x2,y2,x3,y3,x4,y4], got bbox of shape {len(bbox)}."
+            )
+        
         # draw bbox
         draw.line(
-            [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin), (xmin, ymin)],
+            rectangle,
             width=draw_thickness,
             fill=color,
         )

+ 1 - 0
paddlex/inference/utils/official_models.py

@@ -268,6 +268,7 @@ PP-LCNet_x1_0_vehicle_attribute_infer.tar",
     "PP-YOLOE_plus-S_face": "https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/PP-YOLOE_plus-S_face_infer.tar",
     "MobileFaceNet": "https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/MobileFaceNet_infer.tar",
     "ResNet50_face": "https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/ResNet50_face_infer.tar",
+    "PP-YOLOE-R_L": "https://paddle-model-ecology.bj.bcebos.com/paddlex/official_inference_model/paddle3.0b2/PP-YOLOE-R_L_infer.tar",
 }
 
 

+ 12 - 1
paddlex/modules/object_detection/evaluator.py

@@ -22,11 +22,22 @@ class DetEvaluator(BaseEvaluator):
 
     entities = MODELS
 
+    def _update_dataset(self):
+        """update dataset settings"""
+        metric = self.pdx_config.metric if 'metric' in self.pdx_config else 'COCO'
+        data_fields = self.pdx_config.EvalDataset['data_fields'] if 'data_fields' in self.pdx_config.EvalDataset else None
+
+        self.pdx_config.update_dataset(
+            self.global_config.dataset_dir, "COCODetDataset",
+            data_fields=data_fields,
+            metric=metric,
+        )
+
     def update_config(self):
         """update evalution config"""
         if self.eval_config.log_interval:
             self.pdx_config.update_log_interval(self.eval_config.log_interval)
-        self.pdx_config.update_dataset(self.global_config.dataset_dir, "COCODetDataset")
+        self._update_dataset()
         self.pdx_config.update_weights(self.eval_config.weight_path)
 
     def get_eval_kwargs(self) -> dict:

+ 1 - 0
paddlex/modules/object_detection/model_list.py

@@ -71,4 +71,5 @@ MODELS = [
     "BlazeFace",
     "BlazeFace-FPN-SSH",
     "PP-YOLOE_plus-S_face",
+    "PP-YOLOE-R_L",
 ]

+ 8 - 1
paddlex/modules/object_detection/trainer.py

@@ -28,7 +28,14 @@ class DetTrainer(BaseTrainer):
 
     def _update_dataset(self):
         """update dataset settings"""
-        self.pdx_config.update_dataset(self.global_config.dataset_dir, "COCODetDataset")
+        metric = self.pdx_config.metric if 'metric' in self.pdx_config else 'COCO'
+        data_fields = self.pdx_config.TrainDataset['data_fields'] if 'data_fields' in self.pdx_config.TrainDataset else None
+
+        self.pdx_config.update_dataset(
+            self.global_config.dataset_dir, "COCODetDataset",
+            data_fields=data_fields,
+            metric=metric,
+        )
 
     def update_config(self):
         """update training config"""

+ 168 - 0
paddlex/repo_apis/PaddleDetection_api/configs/PP-YOLOE-R_L.yaml

@@ -0,0 +1,168 @@
+use_gpu: true
+use_xpu: false
+use_mlu: false
+use_npu: false
+log_iter: 20
+save_dir: output
+snapshot_epoch: 1
+print_flops: false
+print_params: false
+
+# Exporting the model
+export:
+  post_process: True  # Whether post-processing is included in the network when export model.
+  nms: True           # Whether NMS is included in the network when export model.
+  benchmark: False    # It is used to testing model performance, if set `True`, post-process and NMS will not be exported.
+  fuse_conv_bn: False
+
+log_iter: 10
+snapshot_epoch: 3
+weights: output/ppyoloe_r_crn_l_3x_dota/model_final
+
+pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/CSPResNetb_l_pretrained.pdparams
+depth_mult: 1.0
+width_mult: 1.0
+
+##### Data
+metric: RBOX
+num_classes: 15
+
+TrainDataset:
+    name: COCODataSet
+    image_dir: images
+    anno_path: annotations/instance_train.json
+    dataset_dir: /root/data/DOTA/DOTA-sampled200_crop1024_data
+    data_fields: ['image', 'gt_bbox', 'gt_class', 'is_crowd', 'gt_poly']
+
+EvalDataset:
+    name: COCODataSet
+    image_dir: images
+    anno_path: annotations/instance_val.json
+    dataset_dir: /root/data/DOTA/DOTA-sampled200_crop1024_data
+    data_fields: ['image', 'gt_bbox', 'gt_class', 'is_crowd', 'gt_poly']
+
+TestDataset:
+    name: ImageFolder
+    anno_path: annotations/instance_val.json
+    dataset_dir: /root/data/DOTA/DOTA-sampled200_crop1024_data
+
+worker_num: 4
+image_height: &image_height 1024
+image_width: &image_width 1024
+image_size: &image_size [*image_height, *image_width]
+
+TrainReader:
+  sample_transforms:
+    - Decode: {}
+    - Poly2Array: {}
+    - RandomRFlip: {}
+    - RandomRRotate: {angle_mode: 'value', angle: [0, 90, 180, -90]}
+    - RandomRRotate: {angle_mode: 'value', angle: [30, 60], rotate_prob: 0.5}
+    - RResize: {target_size: *image_size, keep_ratio: True, interp: 2}
+    - Poly2RBox: {filter_threshold: 2, filter_mode: 'edge', rbox_type: 'oc'}
+  batch_transforms:
+    - NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
+    - Permute: {}
+    - PadRGT: {}
+    - PadBatch: {pad_to_stride: 32}
+  batch_size: 4
+  shuffle: true
+  drop_last: true
+  use_shared_memory: true
+  collate_batch: true
+
+EvalReader:
+  sample_transforms:
+    - Decode: {}
+    - Poly2Array: {}
+    - RResize: {target_size: *image_size, keep_ratio: True, interp: 2}
+    - NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
+    - Permute: {}
+  batch_transforms:
+    - PadBatch: {pad_to_stride: 32}
+  batch_size: 6
+  collate_batch: false
+
+TestReader:
+  sample_transforms:
+    - Decode: {}
+    - Resize: {target_size: *image_size, keep_ratio: True, interp: 2}
+    - NormalizeImage: {mean: [0.485, 0.456, 0.406], std: [0.229, 0.224, 0.225], is_scale: True}
+    - Permute: {}
+  batch_transforms:
+    - PadBatch: {pad_to_stride: 32}
+  batch_size: 2
+
+##### Model
+
+architecture: YOLOv3
+norm_type: sync_bn
+use_ema: true
+ema_decay: 0.9998
+
+YOLOv3:
+  backbone: CSPResNet
+  neck: CustomCSPPAN
+  yolo_head: PPYOLOERHead
+  post_process: ~
+
+CSPResNet:
+  layers: [3, 6, 6, 3]
+  channels: [64, 128, 256, 512, 1024]
+  return_idx: [1, 2, 3]
+  use_large_stem: True
+  use_alpha: True
+
+CustomCSPPAN:
+  out_channels: [768, 384, 192]
+  stage_num: 1
+  block_num: 3
+  act: 'swish'
+  spp: true
+  use_alpha: True
+
+PPYOLOERHead:
+  fpn_strides: [32, 16, 8]
+  grid_cell_offset: 0.5
+  use_varifocal_loss: true
+  static_assigner_epoch: -1
+  loss_weight: {class: 1.0, iou: 2.5, dfl: 0.05}
+  static_assigner:
+    name: FCOSRAssigner
+    factor: 12
+    threshold: 0.23
+    boundary: [[512, 10000], [256, 512], [-1, 256]]
+  assigner:
+    name: RotatedTaskAlignedAssigner
+    topk: 13
+    alpha: 1.0
+    beta: 6.0
+  nms:
+    name: MultiClassNMS
+    nms_top_k: 2000
+    keep_top_k: -1
+    score_threshold: 0.1
+    nms_threshold: 0.1
+    normalized: False
+
+##### Optimizer
+
+epoch: 36
+
+LearningRate:
+  base_lr: 0.064
+  schedulers:
+    - !CosineDecay
+      max_epochs: 44
+    - !LinearWarmup
+      start_factor: 0.
+      steps: 1000
+
+OptimizerBuilder:
+  clip_grad_by_norm: 35.
+  optimizer:
+    momentum: 0.9
+    type: Momentum
+  regularizer:
+    factor: 0.0005
+    type: L2

+ 3 - 1
paddlex/repo_apis/PaddleDetection_api/object_det/config.py

@@ -56,6 +56,7 @@ class DetConfig(BaseConfig, PPDetConfigMixin):
         train_anno_path: str = "annotations/instance_train.json",
         val_anno_path: str = "annotations/instance_val.json",
         test_anno_path: str = "annotations/instance_val.json",
+        metric: str = "COCO",
     ):
         """update dataset settings
 
@@ -70,6 +71,7 @@ class DetConfig(BaseConfig, PPDetConfigMixin):
                 Defaults to "annotations/instance_val.json".
             test_anno_path (str, optional): the test annotations file that relative to `dataset_path`.
                 Defaults to "annotations/instance_val.json".
+            metric (str, optional): Evaluation metric. Defaults to "COCO".
 
         Raises:
             ValueError: the `dataset_type` error.
@@ -87,10 +89,10 @@ class DetConfig(BaseConfig, PPDetConfigMixin):
                 val_anno_path,
                 test_anno_path,
             )
-            self.set_val("metric", "COCO")
         else:
             raise ValueError(f"{repr(dataset_type)} is not supported.")
         self.update(ds_cfg)
+        self.set_val("metric", metric)
 
     def _make_dataset_config(
         self,

+ 15 - 0
paddlex/repo_apis/PaddleDetection_api/object_det/register.py

@@ -925,3 +925,18 @@ register_model_info(
         },
     }
 )
+
+register_model_info(
+    {
+        "model_name": "PP-YOLOE-R_L",
+        "suite": "Det",
+        "config_path": osp.join(PDX_CONFIG_DIR, "PP-YOLOE-R_L.yaml"),
+        "supported_apis": ["train", "evaluate", "predict", "export", "infer"],
+        "supported_dataset_types": ["COCODetDataset"],
+        "supported_train_opts": {
+            "device": ["cpu", "gpu_nxcx", "xpu", "npu", "mlu"],
+            "dy2st": False,
+            "amp": ["OFF"],
+        },
+    }
+)

+ 2 - 0
paddlex/repo_manager/repo.py

@@ -33,6 +33,7 @@ from .utils import (
     switch_working_dir,
     to_dep_spec_pep508,
     env_marker_ast2expr,
+    install_external_deps,
 )
 
 __all__ = ["build_repo_instance", "build_repo_group_installer"]
@@ -123,6 +124,7 @@ class PPRepository(object):
         with switch_working_dir(self.root_dir):
             try:
                 install_packages_using_pip(["."], editable=editable, no_deps=no_deps)
+                install_external_deps(self.name, self.root_dir)
             finally:
                 if clean:
                     # Clean build artifacts

+ 47 - 0
paddlex/repo_manager/utils.py

@@ -32,6 +32,31 @@ def _check_call(*args, **kwargs):
 def _check_output(*args, **kwargs):
     return subprocess.check_output(*args, **kwargs)
 
+def _compare_version(version1, version2):
+    import re
+    def parse_version(version_str):
+        version_pattern = re.compile(
+            r'^(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(?:-(?P<pre_release>.*))?(?:\+(?P<build_metadata>.+))?$'
+        )
+        match = version_pattern.match(version_str)
+        if not match:
+            raise ValueError(f"Unexpected version string: {version_str}")
+        return (
+            int(match.group('major')), int(match.group('minor')),
+            int(match.group('patch')), match.group('pre_release')
+        )
+
+    v1_infos = parse_version(version1)
+    v2_infos = parse_version(version2)
+    for v1_info, v2_info in zip(v1_infos, v2_infos):
+        if v1_info is None and v2_info is None: 
+            continue
+        if v1_info is None or (v2_info is not None and v1_info < v2_info): 
+            return -1
+        if v2_info is None or (v1_info is not None and v1_info > v2_info): 
+            return 1
+    return 0
+
 
 def check_installation_using_pip(pkg):
     """check_installation_using_pip"""
@@ -68,6 +93,28 @@ def install_packages_using_pip(
         args.extend(pip_flags)
     return _check_call(args)
 
+def install_external_deps(repo_name, repo_root):
+    """install paddle repository custom dependencies"""
+    import paddle
+    from ..utils import logging
+    paddle_version = paddle.__version__
+    paddle_w_cuda = paddle.is_compiled_with_cuda()
+    gcc_version = subprocess.check_output(["gcc", "--version"]).decode('utf-8').split()[2]
+
+    if repo_name == 'PaddleDetection':
+        if os.path.exists(os.path.join(repo_root, 'ppdet', 'ext_op')):
+            """Install custom op for rotated object detection"""
+            if _compare_version(paddle_version, '2.0.1') >= 0 and paddle_w_cuda and _compare_version(gcc_version, '8.2.0') >= 0:
+                with switch_working_dir(os.path.join(repo_root, 'ppdet', 'ext_op')):
+                    args = [sys.executable, 'setup.py', 'install']
+                    _check_call(args)
+            else:
+                logging.warning(
+                    "The custom operators in PaddleDetection for Rotated Object Detection is only supported when using CUDA, GCC>=8.2.0 and Paddle>=2.0.1, \
+                        your environment does not meet these requirements, so we will skip the installation of custom operators under PaddleDetection/ppdet/ext_ops, \
+                            which means you can not train the Rotated Object Detection models."
+                )
+
 
 def install_deps_using_pip():
     """install requirements"""