PointPillars
PointPillars 是一个用于点云数据中 3D 对象检测的模型。与图像不同,点云数据本质上是 3D 空间中稀疏点的集合。每个点云样本(示例)被称为一个场景(在此处存储为扩展名为 .bin
的文件)。对于每个场景,它通常包含 3D 欧几里得空间中可变数量的点。因此,单个场景中数据的形状为 (N, K)
,其中 N
表示此场景中点的数量,通常是一个可变的整数;K
是每个点的特征数量,应为 4。因此,每个点的特征可以表示为:(x, y, z, r)
,其中 x, y, z, r
分别表示 X 坐标、Y 坐标、Z 坐标和反射率(强度)。这些数字都是浮点数,反射率 (r
) 是 [0.0, 1.0]
区间内的实数,表示激光雷达感知到的在 3D 空间中某点反射回来的激光束的强度(比例)。
3D 欧几里得空间中的对象可以描述为 3D 边界框。形式上,3D 边界框可以用 (x, y, z, dx, dy, dz, yaw)
表示。元组中的 7 个数字分别表示对象中心的 X 坐标、对象中心的 Y 坐标、对象中心的 Z 坐标、长度(X 方向)、宽度(Y 方向)、高度(Z 方向)和 3D 欧几里得空间中的方向角。
为了处理点和对象的坐标,需要一个坐标系。在 TAO PointPillars 中,坐标系定义如下
坐标系的原点是激光雷达的中心
X 轴指向前方
Y 轴指向左侧
Z 轴指向上方
yaw 是水平面(X-Y 平面)内的旋转,方向为逆时针。因此,X 轴对应于
yaw = 0
,Y 轴对应于yaw = pi / 2
,依此类推。
坐标系的图示如下所示。
up z x front (yaw=0)
^ ^
| /
| /
(yaw=0.5*pi) left y <------ 0
PointPillars 的数据集包含点云数据和相应的 3D 对象注释。点云数据是一个点云文件目录(扩展名为 .bin),注释是一个 KITTI 格式的文本文件目录。
目录结构应组织如下,其中点云文件的目录名称必须为 lidar
,注释的目录名称必须为 label
。2 个目录中的文件名可以是任意的,只要每个 .bin
文件都有其唯一的对应 .txt
文件,反之亦然。
/lidar
0.bin
1.bin
...
/label
0.txt
1.txt
...
最后,必须像往常一样为 PointPillars 维护 train/val 拆分。因此,对于训练数据集和验证集,我们都必须确保它们遵循上述相同的结构。因此,整体结构应如下所示。不需要完全相同的名称 train
和 val
,但按惯例是首选。
/train
/lidar
0.bin
1.bin
...
/label
0.txt
1.txt
...
/val
/lidar
0.bin
1.bin
...
/label
0.txt
1.txt
...
每个 .bin
文件都应符合上述格式。每个 .txt
标签文件都应符合 KITTI 格式。与标准 KITTI 格式相比,PointPillars 标签格式有一个例外。虽然结构与 KITTI 相同,但每个对象的最后一个字段的解释不同。在 KITTI 中,最后一个字段是 Rotation_y(相机坐标系中绕 Y 轴的旋转),而在 PointPillars 中,它们是 Rotation_z(激光雷达坐标系中绕 Z 轴的旋转)。
下面是一个示例,我们应该以不同于标准 KITTI 的方式解释 -1.59, -2.35, -0.03
。
car 0.00 0 -1.58 587.01 173.33 614.12 200.12 1.65 1.67 3.64 -0.65 1.71 46.70 -1.59
cyclist 0.00 0 -2.46 665.45 160.00 717.93 217.99 1.72 0.47 1.65 2.45 1.35 22.10 -2.35
pedestrian 0.00 2 0.21 423.17 173.67 433.17 224.03 1.60 0.38 0.30 -5.87 1.63 23.11 -0.03
PointPillars 标签的解释与标准 KITTI 格式略有不同。在 PointPillars 中,yaw 是激光雷达坐标系中绕 Z 轴的旋转,如上所述,而在标准 KITTI 解释中,yaw 是相机坐标系中绕 Y 轴的旋转。通过这种方式,PointPillars 数据集不依赖于相机信息和相机校准。
一旦上述数据集目录结构准备就绪,将基本名称复制并粘贴到 spec 文件的 dataset.data_split
字典中。例如,
{
'train': train,
'test': val
}
此外,在 dataset.info_path
参数中设置 pickle 信息文件的名称。例如,
{
'train': ['infos_train.pkl'],
'test': ['infos_val.pkl'],
}
完成这些操作后,应通过 dataset_convert
命令生成数据集的统计信息,以生成上述 pickle 文件。pickle 文件将在训练过程中的数据增强中使用。
转换数据集
pickle 信息文件需要基于原始点云文件和 KITTI 文本标签文件生成。这通过命令行完成。
tao model pointpillars dataset_convert -e $SPECS_DIR/pointpillars.yaml
-e
提供训练的 spec 文件,请参见下文。
PointPillars 的 spec 文件包括 dataset
、model
、train
、evaluate
、inference
、export
和 prune
参数。下面是一个在 KITTI 数据集上进行训练的 spec 文件示例。
dataset:
class_names: ['Car', 'Pedestrian', 'Cyclist']
type: 'GeneralPCDataset'
data_path: '/path/to/tao-experiments/data/pointpillars'
data_split: {
'train': train,
'test': val
}
info_path: {
'train': [infos_train.pkl],
'test': [infos_val.pkl],
}
balanced_resampling: False
point_feature_encoding: {
encoding_type: absolute_coordinates_encoding,
used_feature_list: ['x', 'y', 'z', 'intensity'],
src_feature_list: ['x', 'y', 'z', 'intensity'],
}
point_cloud_range: [0, -39.68, -3, 69.12, 39.68, 1]
data_augmentor:
disable_aug_list: ['placeholder']
aug_config_list:
- name: gt_sampling
db_info_path:
- dbinfos_train.pkl
preface: {
filter_by_min_points: ['Car:5', 'Pedestrian:5', 'Cyclist:5'],
}
sample_groups: ['Car:15','Pedestrian:15', 'Cyclist:15']
num_point_features: 4
disable_with_fake_lidar: False
remove_extra_width: [0.0, 0.0, 0.0]
limit_whole_scene: False
- name: random_world_flip
along_axis_list: ['x']
- name: random_world_rotation
world_rot_angle: [-0.78539816, 0.78539816]
- name: random_world_scaling
world_scale_range: [0.95, 1.05]
data_processor:
- name: mask_points_and_boxes_outside_range
remove_outside_boxes: True
- name: shuffle_points
shuffle: {
'train': True,
'test': False
}
- name: transform_points_to_voxels
voxel_size: [0.16, 0.16, 4]
max_points_per_voxel: 32
max_number_of_voxels: {
'train': 16000,
'test': 10000
}
num_workers: 4
model:
name: PointPillar
pretrained_model_path: null
vfe:
name: PillarVFE
with_distance: False
use_absolue_xyz: True
use_norm: True
num_filters: [64]
map_to_bev:
name: PointPillarScatter
num_bev_features: 64
backbone_2d:
name: BaseBEVBackbone
layer_nums: [3, 5, 5]
layer_strides: [2, 2, 2]
num_filters: [64, 128, 256]
upsample_strides: [1, 2, 4]
num_upsample_filters: [128, 128, 128]
dense_head:
name: AnchorHeadSingle
class_agnostic: False
use_direction_classifier: True
dir_offset: 0.78539
dir_limit_offset: 0.0
num_dir_bins: 2
anchor_generator_config: [
{
'class_name': 'Car',
'anchor_sizes': [[3.9, 1.6, 1.56]],
'anchor_rotations': [0, 1.57],
'anchor_bottom_heights': [-1.78],
'align_center': False,
'feature_map_stride': 2,
'matched_threshold': 0.6,
'unmatched_threshold': 0.45
},
{
'class_name': 'Pedestrian',
'anchor_sizes': [[0.8, 0.6, 1.73]],
'anchor_rotations': [0, 1.57],
'anchor_bottom_heights': [-0.6],
'align_center': False,
'feature_map_stride': 2,
'matched_threshold': 0.5,
'unmatched_threshold': 0.35
},
{
'class_name': 'Cyclist',
'anchor_sizes': [[1.76, 0.6, 1.73]],
'anchor_rotations': [0, 1.57],
'anchor_bottom_heights': [-0.6],
'align_center': False,
'feature_map_stride': 2,
'matched_threshold': 0.5,
'unmatched_threshold': 0.35
}
]
target_assigner_config:
name: AxisAlignedTargetAssigner
pos_fraction: -1.0
sample_size: 512
norm_by_num_examples: False
match_height: False
box_coder: ResidualCoder
loss_config:
loss_weights: {
'cls_weight': 1.0,
'loc_weight': 2.0,
'dir_weight': 0.2,
'code_weights': [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
}
post_processing:
recall_thresh_list: [0.3, 0.5, 0.7]
score_thresh: 0.1
output_raw_score: False
eval_metric: kitti
nms_config:
multi_classes_nms: False
nms_type: nms_gpu
nms_thresh: 0.01
nms_pre_max_size: 4096
nms_post_max_size: 500
sync_bn: False
train:
batch_size: 4
num_epochs: 80
optimizer: adam_onecycle
lr: 0.003
weight_decay: 0.01
momentum: 0.9
moms: [0.95, 0.85]
pct_start: 0.4
div_factor: 10
decay_step_list: [35, 45]
lr_decay: 0.1
lr_clip: 0.0000001
lr_warmup: False
warmup_epoch: 1
grad_norm_clip: 10
resume_training_checkpoint_path: null
pruned_model_path: "/path/to/pointpillar_workspace/33/pruned_0.5.tlt"
tcp_port: 18888
random_seed: null
checkpoint_interval: 1
max_checkpoint_save_num: 30
merge_all_iters_to_one_epoch: False
evaluate:
batch_size: 1
checkpoint: "/path/to/pointpillar_workspace/33/ckpt/checkpoint_epoch_80.tlt"
inference:
max_points_num: 25000
batch_size: 1
checkpoint: "/path/to/pointpillar_workspace/33/ckpt/checkpoint_epoch_80.tlt"
viz_conf_thresh: 0.1
export:
gpu_id: 0
checkpoint: "/path/to/tao-experiments/ckpt/checkpoint_epoch_80.tlt"
onnx_file: "/path/to/tao-experiments/ckpt/checkpoint_epoch_80.tlt.onnx"
prune:
model: "/path/to/tlt-experiments/ckpt/checkpoint_epoch_80.tlt"
下表提供了 spec 文件的顶层描述。
参数 | 数据类型 | 默认值 | 描述 |
class_names |
字符串列表 | – | 数据集中类名称的列表 |
data_path |
字符串 | – | 数据集的路径 |
data_split |
字典 | – | 将 train 和 test 拆分映射到实际目录名称的字典 |
info_path |
字典 | – | 将 train 和 test 拆分映射到实际 pickle 信息名称的字典 |
balanced_resampling |
布尔值 | False | 是否在数据加载器中启用平衡重采样 |
point_feature_encoding |
集合 | – | 点特征编码的配置 |
point_feature_encoding |
集合 | – | 点特征编码的配置 |
point_cloud_range |
浮点数列表 | – | 点云坐标范围,格式为 [xmin, ymin, zmin, xmax, ymax, zmax] |
data_augmentor |
集合 | – | 数据增强的配置 |
data_processor |
集合 | – | 数据处理的配置 |
num_workers |
整数 | 1 | 用于数据加载器的工作线程数 |
类名称
class_names
参数提供数据集中对象类名称的列表。它只是一个字符串列表。
数据集
dataset
参数定义了 PointPillars 模型的训练和验证/评估数据集,如下所述。
参数 | 数据类型 | 默认值 | 描述 |
dataset |
集合 | – | 数据集的配置 |
model |
集合 | – | PointPillars 模型的配置 |
train |
集合 | – | 训练过程的配置 |
inference |
集合 | – | 推理过程的配置 |
evaluate |
集合 | – | 评估过程的配置 |
export |
集合 | – | 导出模型的配置 |
prune |
集合 | – | 剪枝模型的配置 |
点特征编码
点特征编码定义了每个点的特征如何表示。此参数在此版本中是固定的,必须为
{
encoding_type: absolute_coordinates_encoding,
used_feature_list: ['x', 'y', 'z', 'intensity'],
src_feature_list: ['x', 'y', 'z', 'intensity'],
}
数据增强
数据增强管道由参数 data_augmentor
定义。请参见下表。
参数 | 数据类型 | 默认值 | 描述 |
disable_aug_list |
字符串列表 | ["placeholder"] |
要禁用的增强列表 |
aug_config_list |
集合列表 | – | 增强列表,其名称应按顺序为 gt_sampling, random_world_flip, random_world_rotation, random_world_scaling |
下面提供了 gt_sampling
的参数。
参数 | 数据类型 | 默认值 | 描述 |
name |
字符串 | gt_sampling |
名称,必须为 gt_sampling |
db_info_path |
字符串列表 | dbinfos_train.pkl |
用于采样的 db 信息列表 |
preface |
字典 | – | gt 采样的前言 |
sample_groups |
字符串列表 | – | 字符串列表,用于提供每个类的样本组 |
num_point_features |
整数 | 4 | 每个点的特征数 |
disable_with_fake_lidar |
布尔值 | False | 是否启用伪激光雷达 |
remove_extra_width |
浮点数列表 | – | 每个类要删除的额外宽度 |
limit_whole_scene |
布尔值 | False | 是否限制整个场景 |
下面描述了 random_world_flip
的参数。
参数 | 数据类型 | 默认值 | 描述 |
along_axis_list |
字符串列表 | – | 沿其翻转坐标的轴列表 |
下面描述了 random_world_rotation
的参数。
参数 | 数据类型 | 默认值 | 描述 |
world_rot_angle |
浮点数列表 | – | 要旋转的最大角度 |
下面描述了 random_world_scaling
的参数。
参数 | 数据类型 | 默认值 | 描述 |
world_scale_range |
浮点数列表 | – | 最小和最大缩放因子 |
数据处理
数据集处理由 DATA_PROCESSOR
参数定义。
参数 | 数据类型 | 默认值 | 描述 |
data_processor |
集合列表 | – | 数据处理列表,应按顺序包括 mask_points_and_boxes_outside_range, shuffle_points, transform_points_to_voxels |
下面描述了 mask_points_and_boxes_outside_range
的参数。
参数 | 数据类型 | 默认值 | 描述 |
name |
字符串 | mask_points_and_boxes_outside_range |
名称,必须为 mask_points_and_boxes_outside_range |
remove_outside_boxes |
布尔值 | True | 是否删除外部框 |
下面描述了 shuffle_points
的参数。
参数 | 数据类型 | 默认值 | 描述 |
name |
字符串 | shuffle_points |
名称,必须为 shuffle_points |
shuffle_enabled |
字典 | {'train': True, 'test': False} |
用于启用/禁用 train/val 数据集洗牌的字典 |
下面描述了 transform_points_to_voxels
的参数。
参数 | 数据类型 | 默认值 | 描述 |
name |
字符串 | transform_points_to_voxels |
名称,必须为 transform_points_to_voxels |
voxel_size |
浮点数列表 | – | 体素大小,格式为 [dx, dy, dz] |
max_points_per_voxel |
整数 | 32 | 每个体素的最大点数 |
max_number_of_voxels |
字典 | – | 提供训练和测试/验证模式下最大体素数的字典 |
模型架构
PointPillars 模型架构在参数 model
中定义,下表详细介绍。
参数 | 数据类型 | 默认值 | 描述 |
name |
字符串 | PointPillar |
名称,必须为 PointPillar |
vfe |
集合 | – | 体素特征提取器的定义 |
map_to_bev |
集合 | – | 散布模块的定义 |
backbone_2d |
集合 | – | 2D 主干网络的定义 |
dense_head |
集合 | – | 密集头的定义 |
post_processing |
集合 | – | 后处理 |
sync_bn |
布尔值 | False | 是否启用同步 BN |
体素特征提取器
体素特征提取器由参数 vfe
配置,如下所述。
参数 | 数据类型 | 默认值 | 描述 |
name |
字符串 | PillarVFE |
名称,必须为 PillarVFE |
with_distance |
布尔值 | False | 是否包含距离信息 |
use_absolue_xyz |
布尔值 | True | 是否使用绝对 XYZ 坐标 |
use_norm |
布尔值 | True | 是否使用归一化 |
num_filters |
整数列表 | 64 | 滤波器数量 |
散布
散布过程由参数 map_to_bev
配置,如下所述。
参数 | 数据类型 | 默认值 | 描述 |
name |
字符串 | PointPillarScatter |
名称,必须为 PointPillarScatter |
num_bev_features |
整数 | 64 | 鸟瞰图的特征数 |
2D 主干网络
2D 主干网络由参数 backbone_2d
配置,如下所述。
参数 | 数据类型 | 默认值 | 描述 |
name |
字符串 | BaseBEVBackbone |
名称,必须为 BaseBEVBackbone |
layer_nums |
整数列表 | [3, 5, 5] | 层数 |
layer_strides |
整数列表 | [2, 2, 2] | 步幅数 |
num_filters |
整数列表 | [64, 128, 256] | 滤波器数量 |
upsample_strides |
整数列表 | [1, 2, 4] | 上采样步幅 |
num_upsample_filters |
整数列表 | [128, 128, 128] | 上采样滤波器数量 |
密集头
密集头由参数 dense_head
配置,如下所述。
参数 | 数据类型 | 默认值 | 描述 |
name |
字符串 | AnchorHeadSingle |
名称,必须为 AnchorHeadSingle |
class_agnostic |
布尔值 | False | 是否与类别无关 |
use_direction_classifier |
布尔值 | True | 是否使用方向分类器 |
dir_offset |
浮点数 | 0.78539 | 方向偏移量 |
dir_limit_offset |
浮点数 | 0.0 | 方向限制偏移量 |
num_dir_bins |
整数 | 2 | 方向 bin 的数量 |
anchor_generator_config |
字典列表 | – | 每个类别的锚点生成器配置 |
target_assigner_config |
集合 | – | 目标分配器配置 |
loss_config |
集合 | – | 损失函数配置 |
anchor_generator_config
的参数是字典列表。每个字典都遵循相同的格式,如下所述。
{
'class_name': 'Car',
'anchor_sizes': [[3.9, 1.6, 1.56]],
'anchor_rotations': [0, 1.57],
'anchor_bottom_heights': [-1.78],
'align_center': False,
'feature_map_stride': 2,
'matched_threshold': 0.6,
'unmatched_threshold': 0.45
}
下面描述了 target_assigner_config
的参数。
参数 | 数据类型 | 默认值 | 描述 |
name |
字符串 | AxisAlignedTargetAssigner |
名称,必须为 AxisAlignedTargetAssigner |
pos_fraction |
浮点数 | -1.0 | 正例比例 |
sample_size |
整数 | 512 | 样本大小 |
norm_by_num_examples |
布尔值 | False | 是否按示例数进行归一化 |
match_height |
布尔值 | False | 是否匹配高度 |
box_coder |
字符串 | ResidualCoder | 框编码器的名称 |
下面描述了 loss_config
的参数。
参数 | 数据类型 | 默认值 | 描述 |
loss_weights |
字典 | – | 提供损失权重因子的字典 |
loss_weights
字典应采用以下格式。
{
'cls_weight': 1.0,
'loc_weight': 2.0,
'dir_weight': 0.2,
'code_weights': [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
}
后处理
后处理在参数 post_processing
中定义,如下所述。
参数 | 数据类型 | 默认值 | 描述 |
recall_thresh_list |
浮点数列表 | – | 提供损失权重因子的字典 |
score_thresh |
浮点数 | 0.1 | 分数阈值 |
output_raw_score |
布尔值 | False | 是否输出原始分数 |
eval_metric |
字符串 | kitti |
评估指标,仅支持 kitti |
nms_config |
集合 | – | NMS 配置 |
非极大值抑制 (NMS) 由 nms_config
参数配置,如下所述。
参数 | 数据类型 | 默认值 | 描述 |
multi_classes_nms |
布尔值 | False | 是否进行多类别 NMS |
nms_type |
字符串 | nms_gpu |
NMS 类型 |
nms_thresh |
浮点数 | 0.01 | NMS IoU 阈值 |
nms_pre_maxsize |
整数 | – | NMS 前的最大框数 |
nms_post_maxsize |
整数 | – | NMS 后的最大框数 |
训练过程
train
参数定义了训练过程的超参数。
参数 | 数据类型 | 默认值 | 描述 | 支持的值 |
batch_size_per_gpu |
整数 | 4 | 每个 GPU 的批大小 | >=1 |
num_epochs |
整数 | 80 | 训练模型的 epoch 数 | >=1 |
optimizer |
字符串 | adam_onecycle |
优化器名称(类型) | adam_onecycle |
lr |
浮点数 | 0.003 | 初始学习率 | >0.0 |
weight_decay |
浮点数 | 0.01 | 权重衰减 | >0.0 |
momentum |
浮点数 | 0.9 | SGD 优化器的动量 | >0, <1 |
moms |
浮点数列表 | [0.95, 0.85] | One Cycle 学习率调度器的动量 | [0.95, 0.85] |
pct_start |
浮点数 | 0.4 | 周期中用于增加学习率的百分比 | 0.4 |
div_factor |
浮点数 | 10.0 | 除法因子 | 10.0 |
decay_step_list |
整数列表 | [35, 45] | 在其上衰减学习率的 epoch 数列表 | 元素 < NUM_EPOCHS 的列表 |
lr_decay |
浮点数 | 0.1 | 学习率的衰减 | >0, <1 |
lr_clip |
浮点数 | 0.0000001 | 学习率的最小值 | >0, <1 |
lr_warmup |
布尔值 | False | 是否启用学习率预热 | True/False |
warmup_epoch |
整数 | 1 | 预热学习率的 epoch 数 | >=1 |
grad_norm_clip |
浮点数 | 10.0 | 应用于梯度范数裁剪的限制 | >0 |
resume_model_path |
字符串 | – | 要恢复训练的模型的路径 | Unix 路径 |
pretrained_model_path |
字符串 | – | 预训练模型的路径 | Unix 路径 |
pruned_model_path |
字符串 | – | 要重新训练的剪枝模型的路径 | Unix 路径 |
tcp_port |
整数 | 18888 | 多 GPU 训练的 TCP 端口 | 18888 |
random_seed |
整数 | – | 随机种子 | 整数 |
checkpoint_interval |
整数 | 1 | 保存检查点的时间间隔(epoch) | >=1 |
max_checkpoint_save_num |
整数 | 1 | 要保存的最大检查点数 | >=1 |
merge_all_iters_to_one_epoch |
布尔值 | False | 是否将一个 epoch 中的所有训练步骤合并 | False |
评估
evaluation
参数定义了评估过程的超参数。评估指标为 mAP(3D 和 BEV)。
参数 | 数据类型 | 默认值/建议值 | 描述 | 支持的值 |
batch_size |
整数 | 1 | 评估的批大小 | >=1 |
checkpoint |
字符串 | – | 要运行评估的模型的路径 | Unix 路径 |
推理
inference
参数定义了推理过程的超参数。推理将在图像上绘制边界框并将其可视化。
参数 | 数据类型 | 默认值/建议值 | 描述 | 支持的值 |
batch_size |
整数 | 1 | 推理的批大小 | >=1 |
checkpoint |
字符串 | – | 要运行推理的模型的路径 | Unix 路径 |
max_points_num |
整数 | – | 点云文件中点的最大数量 | >=1 |
vis_conf_thresh |
浮点数 | 0.1 | 可视化置信度阈值 | >0, <1 |
导出
export
参数定义了导出过程的超参数。
参数 | 数据类型 | 默认值/建议值 | 描述 | 支持的值 |
gpu_id |
整数 | 0 | 要使用的 GPU 的索引 | >=0 |
checkpoint |
字符串 | – | 要运行导出的模型的路径 | Unix 路径 |
onnx_file |
字符串 | – | 导出模型的输出路径 | Unix 路径 |
data_type |
字符串 | ‘fp32’ | TensorRT 引擎的数据类型 | ‘fp32’, ‘fp16’ |
batch_size |
整数 | 1 | 要导出的批大小 | >=1 |
workspace_size |
整数 | 1024 | 构建 TensorRT 引擎的工作区大小(MB) | >=1 |
save_engine |
字符串 | – | 要保存到的 TensorRT 引擎的路径 | Unix 路径 |
剪枝
prune
参数定义了剪枝过程的超参数。
参数 | 数据类型 | 默认值/建议值 | 描述 | 支持的值 |
model |
字符串 | – | 要剪枝的模型的路径 | Unix 路径 |
使用以下命令运行 PointPillars 训练
tao model pointpillars train -e <experiment_spec_file>
[-h, --help]
[results_dir=<global_results_dir>]
[model.<model_option>=<model_option_value>]
[dataset.<dataset_option>=<dataset_option_value>]
[train.<train_option>=<train_option_value>]
[train.gpu_ids=<gpu indices>]
[train.num_gpus=<number of gpus>]
必需参数
-e, --experiment_spec_file
: 实验 spec 文件的路径
可选参数
-h, --help
: 显示此帮助消息并退出。model.<model_option>
: 模型选项。dataset.<dataset_option>
: 数据集选项。train.<train_option>
: 训练选项。
对于训练、评估和推理,我们为每个相应的任务公开 2 个变量:num_gpus
和 gpu_ids
,默认值分别为 1
和 [0]
。如果两者都已传递,但前后不一致,例如 num_gpus = 1
,gpu_ids = [0, 1]
,则会修改它们以遵循具有更多 GPU 的设置,例如 num_gpus = 1 -> num_gpus = 2
。
PointPillars 的评估指标是 mAP(BEV 和 3D)。
使用以下命令运行 PointPillars 评估
tao model pointpillars evaluate -e <experiment_spec_file>
evaluate.checkpoint=<model to be evaluated>
results_dir=<results_dir>
[-h, --help]
必需参数
-e, --experiment_spec_file
: 用于设置评估实验的实验 spec 文件。这应与训练 spec 文件相同。results_dir
: 实验输出应写入的文件夹的路径。evaluate.checkpoint
: 要评估的.pth
模型。
可选参数
-h, --help
: 显示此帮助消息并退出。evaluate.<evaluate_option>
: 评估选项。
TAO PointPillars 中的评估指标与 KITTI 点云检测的官方指标不同。虽然 KITTI 指标考虑了对象的 easy/moderate/hard 类别,并过滤掉了尺寸小于阈值的小对象,但这仅对 KITTI 数据集有意义。相反,TAO PointPillars 指标是一个通用指标,它不将对象分类为 easy/moderate/hard 类别,也不排除对象来计算指标。这使得 TAO PointPillars 指标成为适用于通用数据集的通用指标。最终结果是平均精度 (AP) 和平均平均精度 (mAP),而与其计算细节无关。因此,尽管 TAO PointPillars 指标与 KITTI 数据集上的 KITTI 官方指标大致相同,但它们不具有可比性。
使用以下命令在 PointPillars 上运行推理,使用 .tlt
模型或 TensorRT 引擎
tao model pointpillars inference -e <experiment_spec_file>
results_dir=<results_dir>
inference.checkpoint=<inference model>
[-h, --help]
必需参数
-e, --experiment_spec_file
: 用于设置推理实验的实验 spec 文件。这应与训练 spec 文件相同。results_dir
: 实验输出应写入的文件夹的路径。inference.checkpoint
: 要在其上运行推理的.pth
模型。
可选参数
-h, --help
: 显示此帮助消息并退出。inference.<inference_option>
: 推理选项。
TAO PointPillars 模型支持模型剪枝。模型剪枝减少了模型参数,因此可以在 NVIDIA GPU 上提高推理帧率 (FPS),同时保持(几乎)相同的精度 (mAP)。
剪枝应用于已训练的 PointPillars 模型。剪枝将输出一个参数数量较少的新模型。一旦我们有了剪枝模型,就有必要在同一数据集上进行微调,以恢复精度 (mAP)。微调只是再次运行训练,但使用剪枝模型作为其预训练模型。
使用以下命令在 PointPillars .tlt
模型上运行剪枝。
tao model pointpillars prune -e <experiment_spec_file>
results_dir=<results_dir>
prune.model=<path_to_tlt_model_to_prune>
[prune.pruning_thresh=<pruning_threshold>]
必需参数
-e, --experiment_spec_file
: 用于设置推理实验的实验 spec 文件。这应与训练 spec 文件相同。results_dir
: 实验输出应写入的文件夹的路径。prune.model
: 要剪枝的模型的路径。
可选参数
prune.pruning_thresh
: 剪枝阈值,应为 0-1 之间的浮点数。默认为 0.1。
剪枝后,剪枝模型可用于重新训练(微调)。要开始重新训练,我们只需在配置文件中提供剪枝模型的路径作为参数 OPTIMIZATION.PRUNED_MODEL_PATH
,然后启动上述训练命令即可。
使用以下命令将 PointPillars 导出为 .onnx
格式以进行部署
tao model pointpillars export -m <model>
-e <experiment_spec>
export.checkpoint=<model to export>
export.onnx_file=<output_file>
[export.<export_option>=<export_option_value>]
[-h, --help]
必需参数
-e, --experiment_spec
: 实验 spec 文件的路径export.checkpoint
: 要导出的.pth
模型。export.onnx_file
: 保存.etlt
或.onnx
模型的路径。
可选参数
-h, --help
: 显示此帮助消息并退出。export.<export_option>
: 导出选项。
您可以使用以下可选参数来保存生成的 TRT 引擎,以验证导出
export.save_engine
: 序列化的 TensorRT 引擎文件的路径。请注意,此文件是硬件特定的,不能在 GPU 之间通用。可用于在主机上使用 TensorRT 快速测试模型精度。由于 TensorRT 引擎文件是硬件特定的,因此除非部署 GPU 与训练 GPU 相同,否则您不能将此引擎文件用于部署。
您训练的 PointPillars 模型可以部署在边缘设备上,例如 Jetson Xavier、Jetson Nano 或 Tesla,或在云端使用 NVIDIA GPU。
DeepStream SDK 当前不支持 PointPillars 模型的部署。相反,PointPillars 模型只能通过独立的 TensorRT 应用程序部署。TensorRT 示例被开发为一个演示,展示如何在 TAO 中部署训练的 PointPillars 模型。
使用 trtexec
有关使用 trtexec
命令生成 TensorRT 引擎的说明,请参阅 ReIdentificationNet 的 trtexec 指南。