当前位置:   article > 正文

pointpillar openpcd框架下实现_openpcd pointpillars 推理

openpcd pointpillars 推理

一、PointPillars网络结构和数据预处理

  网络结构已经在之前训练的结构中进行了详细的介绍。这里将跳过这部分内容直接续接到之前的检测头实现代码中解析推理实现。

        在推理之前,需要对原始的点云数据进行预处理操作;需要把在指定范围之外的点云移除,同时还需要使用VoxelGeneratorWrapper将点云生成一个一个pillar。详情可以看训练博客介绍。

二、网络推理结果


        在PointPillars的最终结果中,我们得到了特征图上的每个anchor和每个anchor预测7个回归参数、1一个类别、一个方向分类这三个结果。其中7回归参数 (x, y, z, w, l, h, θ);x, y,  z预测了目标中心点到该anchor左上顶点的偏移数值, w,l,h预测了基于该anchor长宽高的调整系数,θ预测了box的旋转角度、方向类别预测了box的朝向,两个方向关系如下:

代码:

  1. import numpy as np
  2. import torch.nn as nn
  3. from .anchor_head_template import AnchorHeadTemplate
  4. class AnchorHeadSingle(AnchorHeadTemplate):
  5. """
  6. Args:
  7. model_cfg: AnchorHeadSingle的配置
  8. input_channels: 384 输入通道数
  9. num_class: 3
  10. class_names: ['Car','Pedestrian','Cyclist']
  11. grid_size: (432, 496, 1)
  12. point_cloud_range: (0, -39.68, -3, 69.12, 39.68, 1)
  13. predict_boxes_when_training: False
  14. """
  15. def __init__(self, model_cfg, input_channels, num_class, class_names, grid_size, point_cloud_range,
  16. predict_boxes_when_training=True, **kwargs):
  17. super().__init__(
  18. model_cfg=model_cfg, num_class=num_class, class_names=class_names, grid_size=grid_size,
  19. point_cloud_range=point_cloud_range,
  20. predict_boxes_when_training=predict_boxes_when_training
  21. )
  22. # 每个点有3个尺度的个先验框 每个先验框都有两个方向(0度,90度) num_anchors_per_location:[2, 2, 2]
  23. self.num_anchors_per_location = sum(self.num_anchors_per_location) # sum([2, 2, 2])
  24. # Conv2d(512,18,kernel_size=(1,1),stride=(1,1))
  25. self.conv_cls = nn.Conv2d(
  26. input_channels, self.num_anchors_per_location * self.num_class,
  27. kernel_size=1
  28. )
  29. # Conv2d(512,42,kernel_size=(1,1),stride=(1,1))
  30. self.conv_box = nn.Conv2d(
  31. input_channels, self.num_anchors_per_location * self.box_coder.code_size,
  32. kernel_size=1
  33. )
  34. # 如果存在方向损失,则添加方向卷积层Conv2d(512,12,kernel_size=(1,1),stride=(1,1))
  35. if self.model_cfg.get('USE_DIRECTION_CLASSIFIER', None) is not None:
  36. self.conv_dir_cls = nn.Conv2d(
  37. input_channels,
  38. self.num_anchors_per_location * self.model_cfg.NUM_DIR_BINS,
  39. kernel_size=1
  40. )
  41. else:
  42. self.conv_dir_cls = None
  43. self.init_weights()
  44. # 初始化参数
  45. def init_weights(self):
  46. pi = 0.01
  47. # 初始化分类卷积偏置
  48. nn.init.constant_(self.conv_cls.bias, -np.log((1 - pi) / pi))
  49. # 初始化分类卷积权重
  50. nn.init.normal_(self.conv_box.weight, mean=0, std=0.001)
  51. def forward(self, data_dict):
  52. # 从字典中取出经过backbone处理过的信息
  53. # spatial_features_2d 维度 (batch_size, 384, 248, 216
  54. spatial_features_2d = data_dict['spatial_features_2d']
  55. # 每个坐标点上面6个先验框的类别预测 --> (batch_size, 18, 200, 176)
  56. cls_preds = self.conv_cls(spatial_features_2d)
  57. # 每个坐标点上面6个先验框的参数预测 --> (batch_size, 42, 200, 176) 其中每个先验框需要预测7个参数,分别是(x, y, z, w, l, h, θ)
  58. box_preds = self.conv_box(spatial_features_2d)
  59. # 维度调整,将类别放置在最后一维度 [N, H, W, C] --> (batch_size, 200, 176, 18)
  60. cls_preds = cls_preds.permute(0, 2, 3, 1).contiguous()
  61. # 维度调整,将先验框调整参数放置在最后一维度 [N, H, W, C] --> (batch_size ,200, 176, 42)
  62. box_preds = box_preds.permute(0, 2, 3, 1).contiguous()
  63. # 将类别和先验框调整预测结果放入前向传播字典中
  64. self.forward_ret_dict['cls_preds'] = cls_preds
  65. self.forward_ret_dict['box_preds'] = box_preds
  66. # 进行方向分类预测
  67. if self.conv_dir_cls is not None:
  68. # # 每个先验框都要预测为两个方向中的其中一个方向 --> (batch_size, 12, 200, 176)
  69. dir_cls_preds = self.conv_dir_cls(spatial_features_2d)
  70. # 将类别和先验框方向预测结果放到最后一个维度中 [N, H, W, C] --> (batch_size, 248, 216, 12)
  71. dir_cls_preds = dir_cls_preds.permute(0, 2, 3, 1).contiguous()
  72. # 将方向预测结果放入前向传播字典中
  73. self.forward_ret_dict['dir_cls_preds'] = dir_cls_preds
  74. else:
  75. dir_cls_preds = None
  76. """
  77. 如果是在训练模式的时候,需要对每个先验框分配GT来计算loss
  78. """
  79. if self.training:
  80. # targets_dict = {
  81. # 'box_cls_labels': cls_labels, # (4211200
  82. # 'box_reg_targets': bbox_targets, # (4211200, 7
  83. # 'reg_weights': reg_weights # (4211200
  84. # }
  85. targets_dict = self.assign_targets(
  86. gt_boxes=data_dict['gt_boxes'] # (4398
  87. )
  88. # 将GT分配结果放入前向传播字典中
  89. self.forward_ret_dict.update(targets_dict)
  90. # 如果不是训练模式,则直接生成进行box的预测
  91. if not self.training or self.predict_boxes_when_training:
  92. # 根据预测结果解码生成最终结果
  93. batch_cls_preds, batch_box_preds = self.generate_predicted_boxes(
  94. batch_size=data_dict['batch_size'],
  95. cls_preds=cls_preds, box_preds=box_preds, dir_cls_preds=dir_cls_preds
  96. )
  97. data_dict['batch_cls_preds'] = batch_cls_preds # (1, 211200, 3) 70400*3=211200
  98. data_dict['batch_box_preds'] = batch_box_preds # (1, 211200, 7)
  99. data_dict['cls_preds_normalized'] = False
  100. return data_dict

 

 经过头预测后,可以得到三个张量,分别是:

每个anchor的类别预测: (batch_size, 248, 216, 18)

每个anchor的7个回归参数预测: (batch_size ,248, 216, 42)

每个anchor的方向分类: (batch_size ,248, 216, 12)

其中18可以看成是6个anchor,每个anchor预测3个类别;

其中42可以看成是6个anchor,每个anchor预测7个回归参数;

其中12可以看成是6个anchor,每个anchor预测2个方向;

代码:

  1. def generate_predicted_boxes(self, batch_size, cls_preds, box_preds, dir_cls_preds=None):
  2. """
  3. Args:
  4. batch_size:
  5. cls_preds: (N, H, W, C1)
  6. box_preds: (N, H, W, C2)
  7. dir_cls_preds: (N, H, W, C3)
  8. Returns:
  9. batch_cls_preds: (B, num_boxes, num_classes)
  10. batch_box_preds: (B, num_boxes, 7+C)
  11. """
  12. if isinstance(self.anchors, list):
  13. # 是否使用多头预测,默认否
  14. if self.use_multihead:
  15. anchors = torch.cat([anchor.permute(3, 4, 0, 1, 2, 5).contiguous().view(-1, anchor.shape[-1])
  16. for anchor in self.anchors], dim=0)
  17. else:
  18. """
  19. 每个类别anchor的生成情况:
  20. [(Z, Y, X, anchor尺度, 该尺度anchor方向, 7个回归参数)
  21. (Z, Y, X, anchor尺度, 该尺度anchor方向, 7个回归参数)
  22. (Z, Y, X, anchor尺度, 该尺度anchor方向, 7个回归参数)]
  23. 在倒数第三个维度拼接
  24. anchors 维度 (Z, Y, X, 3个anchor尺度, 每个尺度两个方向, 7)
  25. (1, 248, 216, 3, 2, 7)
  26. """
  27. anchors = torch.cat(self.anchors, dim=-3)
  28. else:
  29. anchors = self.anchors
  30. # 计算一共有多少个anchor Z*Y*X*num_of_anchor_scale*anchor_rot
  31. num_anchors = anchors.view(-1, anchors.shape[-1]).shape[0]
  32. # (batch_size, Z*Y*X*num_of_anchor_scale*anchor_rot, 7)
  33. batch_anchors = anchors.view(1, -1, anchors.shape[-1]).repeat(batch_size, 1, 1)
  34. # 将预测结果都flatten为一维的
  35. # (batch_size, Z*Y*X*num_of_anchor_scale*anchor_rot, 3)
  36. batch_cls_preds = cls_preds.view(batch_size, num_anchors, -1).float() \
  37. if not isinstance(cls_preds,
  38. list) else cls_preds
  39. # (batch_size, Z*Y*X*num_of_anchor_scale*anchor_rot, 7)
  40. batch_box_preds = box_preds.view(batch_size, num_anchors, -1) if not isinstance(box_preds, list) \
  41. else torch.cat(box_preds, dim=1).view(batch_size, num_anchors, -1)
  42. # 对7个预测的box参数进行解码操作
  43. batch_box_preds = self.box_coder.decode_torch(batch_box_preds, batch_anchors)
  44. # 每个anchor的方向预测
  45. if dir_cls_preds is not None:
  46. # 0.78539 方向偏移
  47. dir_offset = self.model_cfg.DIR_OFFSET
  48. # 0
  49. dir_limit_offset = self.model_cfg.DIR_LIMIT_OFFSET # 0
  50. # 将方向预测结果flatten为一维的 (batch_size, Z*Y*X*num_of_anchor_scale*anchor_rot, 2)
  51. dir_cls_preds = dir_cls_preds.view(batch_size, num_anchors, -1) if not isinstance(dir_cls_preds, list) \
  52. else torch.cat(dir_cls_preds, dim=1).view(batch_size, num_anchors, -1) # (1, 321408, 2)
  53. # (batch_size, Z*Y*X*num_of_anchor_scale*anchor_rot)
  54. # 取出所有anchor的方向分类 : 正向和反向
  55. dir_labels = torch.max(dir_cls_preds, dim=-1)[1]
  56. # pi
  57. period = (2 * np.pi / self.model_cfg.NUM_DIR_BINS)
  58. # 将角度在0到pi之间 在OpenPCDet中,坐标使用的是统一规范坐标,x向前,y向左,z向上
  59. # 这里参考训练时候的原因,现将角度角度沿着x轴的逆时针旋转了45度得到dir_rot
  60. dir_rot = common_utils.limit_period(
  61. batch_box_preds[..., 6] - dir_offset, dir_limit_offset, period
  62. )
  63. """
  64. 从新将角度旋转回到激光雷达坐标系中,所以需要加回来之前减去的45度,
  65. 如果dir_labels是1的话,说明方向在是180度的,因此需要将预测的角度信息加上180度,
  66. 否则预测角度即是所得角度
  67. """
  68. batch_box_preds[..., 6] = dir_rot + dir_offset + period * dir_labels.to(batch_box_preds.dtype)
  69. # PointPillars中无此项
  70. if isinstance(self.box_coder, box_coder_utils.PreviousResidualDecoder):
  71. batch_box_preds[..., 6] = common_utils.limit_period(
  72. -(batch_box_preds[..., 6] + np.pi / 2), offset=0.5, period=np.pi * 2
  73. )
  74. return batch_cls_preds, batch_box_preds

 上述代码中的box解码操作,也就是编码的逆操作:

代码:

  1. def decode_torch(self, box_encodings, anchors):
  2. """
  3. Args:
  4. box_encodings: (B, N, 7 + C) or (N, 7 + C) [x, y, z, dx, dy, dz, heading or *[cos, sin], ...]
  5. anchors: (B, N, 7 + C) or (N, 7 + C) [x, y, z, dx, dy, dz, heading, ...]
  6. Returns:
  7. """
  8. # 这里指torch.split的第二个参数 torch.split(tensor, split_size, dim=) split_size是切分后每块的大小,不是切分为多少块!,多余的参数使用*cags接收
  9. xa, ya, za, dxa, dya, dza, ra, *cas = torch.split(anchors, 1, dim=-1)
  10. # 分割编码后的box PointPillar为False
  11. if not self.encode_angle_by_sincos:
  12. xt, yt, zt, dxt, dyt, dzt, rt, *cts = torch.split(box_encodings, 1, dim=-1)
  13. else:
  14. xt, yt, zt, dxt, dyt, dzt, cost, sint, *cts = torch.split(box_encodings, 1, dim=-1)
  15. # 计算anchor对角线长度
  16. diagonal = torch.sqrt(dxa ** 2 + dya ** 2) # (B, N, 1)-->(1, 321408, 1)
  17. # loss计算中anchor与GT编码的运算:g表示gt,a表示anchor
  18. # ∆x = (x^gt − xa^da)/diagonal --> x^gt = ∆x * diagonal + x^da
  19. # 下同
  20. xg = xt * diagonal + xa
  21. yg = yt * diagonal + ya
  22. zg = zt * dza + za
  23. # ∆l = log(l^gt / l^a)的逆运算 --> l^gt = exp(∆l) * l^a
  24. # 下同
  25. dxg = torch.exp(dxt) * dxa
  26. dyg = torch.exp(dyt) * dya
  27. dzg = torch.exp(dzt) * dza
  28. # 如果角度是cos和sin编码,采用新的解码方式 PointPillar为False
  29. if self.encode_angle_by_sincos:
  30. rg_cos = cost + torch.cos(ra)
  31. rg_sin = sint + torch.sin(ra)
  32. rg = torch.atan2(rg_sin, rg_cos)
  33. else:
  34. # rts = [rg - ra] 角度的逆运算
  35. rg = rt + ra
  36. # PointPillar无此项
  37. cgs = [t + a for t, a in zip(cts, cas)]
  38. return torch.cat([xg, yg, zg, dxg, dyg, dzg, rg, *cgs], dim=-1)

三、推理结果后处理

此处对所有的预测结果进行了无类别的nms操作,得到了最终的预测结果。

代码:

  1. def post_processing(self, batch_dict):
  2. """
  3. Args:
  4. batch_dict:
  5. batch_size:
  6. batch_cls_preds: (B, num_boxes, num_classes | 1) or (N1+N2+..., num_classes | 1)
  7. or [(B, num_boxes, num_class1), (B, num_boxes, num_class2) ...]
  8. multihead_label_mapping: [(num_class1), (num_class2), ...]
  9. batch_box_preds: (B, num_boxes, 7+C) or (N1+N2+..., 7+C)
  10. cls_preds_normalized: indicate whether batch_cls_preds is normalized
  11. batch_index: optional (N1+N2+...)
  12. has_class_labels: True/False
  13. roi_labels: (B, num_rois) 1 .. num_classes
  14. batch_pred_labels: (B, num_boxes, 1)
  15. Returns:
  16. """
  17. # post_process_cfg后处理参数,包含了nms类型、阈值、使用的设备、nms后最多保留的结果和输出的置信度等设置
  18. post_process_cfg = self.model_cfg.POST_PROCESSING
  19. # 推理默认为1
  20. batch_size = batch_dict['batch_size']
  21. # 保留计算recall的字典
  22. recall_dict = {}
  23. # 预测结果存放在此
  24. pred_dicts = []
  25. # 逐帧进行处理
  26. for index in range(batch_size):
  27. if batch_dict.get('batch_index', None) is not None:
  28. assert batch_dict['batch_box_preds'].shape.__len__() == 2
  29. batch_mask = (batch_dict['batch_index'] == index)
  30. else:
  31. assert batch_dict['batch_box_preds'].shape.__len__() == 3
  32. # 得到当前处理的是第几帧
  33. batch_mask = index
  34. # box_preds shape (所有anchor的数量, 7)
  35. box_preds = batch_dict['batch_box_preds'][batch_mask]
  36. # 复制后,用于recall计算
  37. src_box_preds = box_preds
  38. if not isinstance(batch_dict['batch_cls_preds'], list):
  39. # (所有anchor的数量, 3)
  40. cls_preds = batch_dict['batch_cls_preds'][batch_mask]
  41. # 同上
  42. src_cls_preds = cls_preds
  43. assert cls_preds.shape[1] in [1, self.num_class]
  44. if not batch_dict['cls_preds_normalized']:
  45. # 损失函数计算使用的BCE,所以这里使用sigmoid激活函数得到类别概率
  46. cls_preds = torch.sigmoid(cls_preds)
  47. else:
  48. cls_preds = [x[batch_mask] for x in batch_dict['batch_cls_preds']]
  49. src_cls_preds = cls_preds
  50. if not batch_dict['cls_preds_normalized']:
  51. cls_preds = [torch.sigmoid(x) for x in cls_preds]
  52. # 是否使用多类别的NMS计算,否。
  53. if post_process_cfg.NMS_CONFIG.MULTI_CLASSES_NMS:
  54. if not isinstance(cls_preds, list):
  55. cls_preds = [cls_preds]
  56. multihead_label_mapping = [torch.arange(1, self.num_class, device=cls_preds[0].device)]
  57. else:
  58. multihead_label_mapping = batch_dict['multihead_label_mapping']
  59. cur_start_idx = 0
  60. pred_scores, pred_labels, pred_boxes = [], [], []
  61. for cur_cls_preds, cur_label_mapping in zip(cls_preds, multihead_label_mapping):
  62. assert cur_cls_preds.shape[1] == len(cur_label_mapping)
  63. cur_box_preds = box_preds[cur_start_idx: cur_start_idx + cur_cls_preds.shape[0]]
  64. cur_pred_scores, cur_pred_labels, cur_pred_boxes = model_nms_utils.multi_classes_nms(
  65. cls_scores=cur_cls_preds, box_preds=cur_box_preds,
  66. nms_config=post_process_cfg.NMS_CONFIG,
  67. score_thresh=post_process_cfg.SCORE_THRESH
  68. )
  69. cur_pred_labels = cur_label_mapping[cur_pred_labels]
  70. pred_scores.append(cur_pred_scores)
  71. pred_labels.append(cur_pred_labels)
  72. pred_boxes.append(cur_pred_boxes)
  73. cur_start_idx += cur_cls_preds.shape[0]
  74. final_scores = torch.cat(pred_scores, dim=0)
  75. final_labels = torch.cat(pred_labels, dim=0)
  76. final_boxes = torch.cat(pred_boxes, dim=0)
  77. else:
  78. # 得到类别预测的最大概率,和对应的索引值
  79. cls_preds, label_preds = torch.max(cls_preds, dim=-1)
  80. if batch_dict.get('has_class_labels', False):
  81. label_key = 'roi_labels' if 'roi_labels' in batch_dict else 'batch_pred_labels'
  82. label_preds = batch_dict[label_key][index]
  83. else:
  84. # 类别预测值加1
  85. label_preds = label_preds + 1
  86. # 无类别NMS操作
  87. # selected : 返回了被留下来的anchor索引
  88. # selected_scores : 返回了被留下来的anchor的置信度分数
  89. selected, selected_scores = model_nms_utils.class_agnostic_nms(
  90. # 每个anchor的类别预测概率和anchor回归参数
  91. box_scores=cls_preds, box_preds=box_preds,
  92. nms_config=post_process_cfg.NMS_CONFIG,
  93. score_thresh=post_process_cfg.SCORE_THRESH
  94. )
  95. # 无此项
  96. if post_process_cfg.OUTPUT_RAW_SCORE:
  97. max_cls_preds, _ = torch.max(src_cls_preds, dim=-1)
  98. selected_scores = max_cls_preds[selected]
  99. # 得到最终类别预测的分数
  100. final_scores = selected_scores
  101. # 根据selected得到最终类别预测的结果
  102. final_labels = label_preds[selected]
  103. # 根据selected得到最终box回归的结果
  104. final_boxes = box_preds[selected]
  105. # 如果没有GT的标签在batch_dict中,就不会计算recall值
  106. recall_dict = self.generate_recall_record(
  107. box_preds=final_boxes if 'rois' not in batch_dict else src_box_preds,
  108. recall_dict=recall_dict, batch_index=index, data_dict=batch_dict,
  109. thresh_list=post_process_cfg.RECALL_THRESH_LIST
  110. )
  111. # 生成最终预测的结果字典
  112. record_dict = {
  113. 'pred_boxes': final_boxes,
  114. 'pred_scores': final_scores,
  115. 'pred_labels': final_labels
  116. }
  117. pred_dicts.append(record_dict)
  118. return pred_dicts, recall_dict

无类别nms操作

代码:

  1. def class_agnostic_nms(box_scores, box_preds, nms_config, score_thresh=None):
  2. # 1.首先根据置信度阈值过滤掉部过滤掉大部分置信度低的box,加速后面的nms操作
  3. src_box_scores = box_scores
  4. if score_thresh is not None:
  5. # 得到类别预测概率大于score_thresh的mask
  6. scores_mask = (box_scores >= score_thresh)
  7. # 根据mask得到哪些anchor的类别预测大于score_thresh-->anchor类别
  8. box_scores = box_scores[scores_mask]
  9. # 根据mask得到哪些anchor的类别预测大于score_thresh-->anchor回归的7个参数
  10. box_preds = box_preds[scores_mask]
  11. # 初始化空列表,用来存放经过nms后保留下来的anchor
  12. selected = []
  13. # 如果有anchor的类别预测大于score_thresh的话才进行nms,否则返回空
  14. if box_scores.shape[0] > 0:
  15. # 这里只保留最大的K个anchor置信度来进行nms操作,
  16. # k取min(nms_config.NMS_PRE_MAXSIZE, box_scores.shape[0])的最小值
  17. box_scores_nms, indices = torch.topk(box_scores, k=min(nms_config.NMS_PRE_MAXSIZE, box_scores.shape[0]))
  18. # box_scores_nms只是得到了类别的更新结果;
  19. # 此处更新box的预测结果 根据tokK重新选取并从大到小排序的结果 更新boxes的预测
  20. boxes_for_nms = box_preds[indices]
  21. # 调用iou3d_nms_utils的nms_gpu函数进行nms,
  22. # 返回的是被保留下的box的索引,selected_scores = None
  23. # 根据返回索引找出box索引值
  24. keep_idx, selected_scores = getattr(iou3d_nms_utils, nms_config.NMS_TYPE)(
  25. boxes_for_nms[:, 0:7], box_scores_nms, nms_config.NMS_THRESH, **nms_config
  26. )
  27. selected = indices[keep_idx[:nms_config.NMS_POST_MAXSIZE]]
  28. if score_thresh is not None:
  29. # 如果存在置信度阈值,scores_mask是box_scores在src_box_scores中的索引,即原始索引
  30. original_idxs = scores_mask.nonzero().view(-1)
  31. # selected表示的box_scores的选择索引,经过这次索引,
  32. # selected表示的是src_box_scores被选择的box索引
  33. selected = original_idxs[selected]
  34. return selected, src_box_scores[selected]

nms_gpu

代码:

  1. def nms_gpu(boxes, scores, thresh, pre_maxsize=None, **kwargs):
  2. """
  3. :param boxes: 经过筛选的anchor的7个回归预测结果(N, 7) [x, y, z, dx, dy, dz, heading]
  4. :param scores: 经过筛选的anchor的类别,与boxes一一对应(N)
  5. :param thresh:
  6. :return:
  7. """
  8. assert boxes.shape[1] == 7
  9. # 对分数按列降序排序(从大到小),并取出对应索引
  10. # dim=0 按列排序,dim=1 按行排序,默认 dim=1
  11. # 因为传入的scores已经在之前进行过排序,所以order就是[0 ,1, 2, 3, ...]
  12. order = scores.sort(0, descending=True)[1]
  13. # 如果存在NMS前的最大box数量(4096),则取出前4096个box索引
  14. if pre_maxsize is not None:
  15. order = order[:pre_maxsize]
  16. # 取出NMS前的box, 之前已经有序,此处无变化
  17. boxes = boxes[order].contiguous()
  18. # 构造一个boxes.size维度的向量 PPP
  19. keep = torch.LongTensor(boxes.size(0))
  20. # 调用cuda函数进行加速
  21. # keep:记录保留目标框的下标
  22. # num_out:返回保留下来的个数
  23. num_out = iou3d_nms_cuda.nms_gpu(boxes, keep, thresh)
  24. # 经过iou3d_nms_cuda之后,之所以要取前num_out个数的原因是keep初始化的最大长度是4096
  25. return order[keep[:num_out].cuda()].contiguous(), None

四、可视化
可视化代码运行:

1、权重文件:
https://drive.google.com/file/d/1wMxWTpU1qUoY3DsCH31WJmvJxcjFXKlm/view
https://drive.google.com/file/d/1wMxWTpU1qUoY3DsCH31WJmvJxcjFXKlm/view

2、kitti数据集:
The KITTI Vision Benchmark Suite
http://www.cvlibs.net/datasets/kitti/eval_object.php?obj_benchmark=3d
 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/795094
推荐阅读
相关标签
  

闽ICP备14008679号