apollo_logo
2
0

本地训练centerpoint+ApolloScape

本教程介绍用户在本地使用apolloscape数据集训练centerpoint模型。

环境配置和安装

详见文档:https://github.com/ApolloAuto/apollo-model-centerpoint/blob/master/docs/installation.md

将ApolloScape转化为KITTI标准格式

ApolloScape数据集的下载和处理参考文档 ApolloScape数据集的下载和处理。

用户需要自己生成train.txt和val.txt,分别保存着训练数据和评测数据的索引,下面是train.txt的内容示例:

000000
000001
000003
000004
000006
000008
000010
000011
000014
....

处理完成后数据组织形式如下所示:

|-- ImageSets
|-- train.txt
|-- val.txt
|-- training
|-- label_2
|-- 000000.txt
|-- 000001.txt
|-- ....
|-- velodyne
|-- 000000.bin
|-- 000001.bin
|-- ....

velodyne文件夹中存放着每一帧的点云数据,以.bin形式存储。
label_2文件夹中存放着每一帧的标签信息,下面是标签文件示例:

pedestrian 0 0 0 0 0 0 0 1.018863 0.648392 0.348114 -32.12419891357422 40.14154434204102 -0.9670228362083435 -1.637705
pedestrian 0 0 0 0 0 0 0 0.661574 0.297775 0.735925 -18.38454437255859 -4.152974128723145 -1.521841764450073 1.564056
pedestrian 0 0 0 0 0 0 0 0.772804 0.287372 0.35712 -12.922926902771 25.13016510009766 -0.3287706673145294 0.02878607
pedestrian 0 0 0 0 0 0 0 0.620953 0.373367 0.447131 -12.88798904418945 25.85581016540527 -0.4463132917881012 0.07662772
cyclist 0 0 0 0 0 0 0 1.716547 0.619485 1.912308 7.602930545806885 -3.483364820480347 -0.9519524574279785 -0.03732504

上述标签文件仿照KITTI格式,但稍有不同,按顺序15个元素的含义如下所示:

KITTI数据集

类别

被截断程度

被遮挡程度

观测角

2d box 左、上、右、下边界坐标

3d box 高度、宽度、长度

3d box在相机坐标系下的中心坐标

3d box在相机坐标系下的旋转角

用户自主数据集(例如apolloscape数据集)

类别

0

0

0

0

3d box 高度、宽度、长度

3d box在雷达坐标系下的中心坐标

3d box在雷达坐标系下的旋转角


类别映射

当前centerpoint模型输出5种类别,如下所示

类别

包括类别

smallMot

小型车

bigMot

大型车

nonMot

三轮车

二轮车

骑摩托车的人

骑三轮车的人

骑自行车的人

pedestrian

行人

TrafficCone

交通锥筒

水马

施工牌

防撞筒



修改paddle3d/datasets/apollo/apollo_utils.py中的class_information,将apolloscape数据集的类别映射为上述5种类别:

  • apolloscape中小型车的类别为smallvehicle,需要映射为smallMot,也即'map_class': 'smallMot'
  • difficulty_threshold表示根据点云数量定义目标困难程度,[20, 40]表示小于20个点时为hard,大于20小于40个点时为moderate,大于40个点为easy。用户可自定义设置
class_information = {
# smallMot
'smallmot': {'map_class': 'smallMot', 'difficulty_threshold': [20, 40]},
'midmot': {'map_class': 'smallMot', 'difficulty_threshold': [20, 40]},
'smallcar': {'map_class': 'smallMot', 'difficulty_threshold': [20, 40]},
'smallvehicle': {'map_class': 'smallMot', 'difficulty_threshold': [20, 40]},
.....

在Paddle3D的目录下创建软链接 datasets/apolloscape,指向到上面的数据集目录:

mkdir datasets
ln -s /path/to/apolloscape ./datasets/apolloscape

生成gt base

使用object sample数据增强方法可以显著增强检测效果,需要使用下面的脚本生成gt base

python tools/create_det_gt_database.py --config configs/centerpoint/centerpoint_pillars_02voxel_apolloscape.yml --dataset_name apollo

训练&评测&导出

训练apolloscape数据集

python -m paddle.distributed.launch --gpus 0,1,2,3,4,5,6,7 tools/train.py --config configs/centerpoint/centerpoint_pillars_02voxel_apolloscape.yml --save_dir ./output_apolloscape --num_workers 4 --save_interval 5

用户可使用Apollo官方提供的预训练模型进行训练,以获得更好的检测效果,预训练模型的模型配置可参考centerpoint_pillars_02voxel_apolloscape.yml,训练方式如下:

python -m paddle.distributed.launch --gpus 0,1,2,3,4,5,6,7 tools/train.py --config configs/centerpoint/centerpoint_pillars_02voxel_apolloscape.yml --model ./centerpoint_core_pretrained_model/model.pdparams --save_dir ./output_apolloscape --num_workers 4 --save_interval 5

评测apolloscape数据集

python tools/evaluate.py --config configs/centerpoint/centerpoint_pillars_02voxel_apolloscape.yml --model ./output_apolloscape/epoch_160/model.pdparams --batch_size 1 --num_workers 4

导出模型。建议导出时将配置文件中的score_threshold设置为较小数值(例如0.1),保证Apllo的配置center_point_param.pb.txt中的score_threshold参数生效

python tools/export.py --config configs/centerpoint/centerpoint_pillars_02voxel_apolloscape.yml --model /path/to/model.pdparams --save_dir /path/to/output --export_for_apollo

原创声明,本文由作者授权发布于Apollo开发者社区,未经许可,不得转载。
发表评论已发表 0 条评论
登录后可评论,请前往 登录
暂无评论~快去发表自己的独特见解吧!
目录
环境配置和安装
将ApolloScape转化为KITTI标准格式
类别映射
生成gt base
训练&评测&导出