Skip to content

Commit 2e97753

Browse files
committed
voxel rcnn release
1 parent c956d3a commit 2e97753

10 files changed

+75
-264
lines changed

LICENSE

-201
This file was deleted.

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,15 @@ This is the official implementation of [**Voxel R-CNN: Towards High Performance
3636
├── pcdet
3737
├── tools
3838
```
39+
Generate the data infos by running the following command:
40+
```
41+
python -m pcdet.datasets.kitti.kitti_dataset create_kitti_infos tools/cfgs/dataset_configs/kitti_dataset.yaml
42+
```
3943
4044
3. Setup.
4145
4246
```
43-
python setup.py build develop
47+
python setup.py develop
4448
```
4549
4650
### Getting Started

pcdet/models/model_utils/model_nms_utils.py

+25
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,28 @@ def multi_classes_nms(cls_scores, box_preds, nms_config, score_thresh=None):
6363
pred_boxes = torch.cat(pred_boxes, dim=0)
6464

6565
return pred_scores, pred_labels, pred_boxes
66+
67+
68+
def fast_bev_nms(box_scores, box_preds, nms_config, score_thresh=None):
69+
src_box_scores = box_scores
70+
if score_thresh is not None:
71+
scores_mask = (box_scores >= score_thresh)
72+
box_scores = box_scores[scores_mask]
73+
box_preds = box_preds[scores_mask]
74+
75+
selected = []
76+
if box_scores.shape[0] > 0:
77+
box_scores_nms, indices = torch.topk(box_scores, k=min(nms_config.NMS_PRE_MAXSIZE, box_scores.shape[0]))
78+
boxes_for_nms = box_preds[indices]
79+
bev_iou = iou3d_nms_utils.boxes_iou_bev(boxes_for_nms, boxes_for_nms)
80+
bev_iou.triu_(diagonal=1)
81+
iou_max, _ = torch.max(bev_iou, dim=0)
82+
selected = indices[iou_max <= nms_config.NMS_THRESH]
83+
selected = selected[:nms_config.NMS_POST_MAXSIZE]
84+
# import pdb
85+
# pdb.set_trace()
86+
87+
if score_thresh is not None:
88+
original_idxs = scores_mask.nonzero(as_tuple=False)[:, 0].view(-1)
89+
selected = original_idxs[selected]
90+
return selected, src_box_scores[selected]

pcdet/models/roi_heads/roi_head_template.py

+18-35
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import torch.nn.functional as F
55

66
from ...utils import box_coder_utils, common_utils, loss_utils
7-
from ..model_utils.model_nms_utils import class_agnostic_nms
7+
from ..model_utils.model_nms_utils import class_agnostic_nms, fast_bev_nms
88
from .target_assigner.proposal_target_layer import ProposalTargetLayer
99

1010

@@ -63,7 +63,7 @@ def proposal_layer(self, batch_dict, nms_config):
6363
"""
6464
batch_size = batch_dict['batch_size']
6565
batch_box_preds = batch_dict['batch_box_preds']
66-
batch_cls_preds = batch_dict['batch_cls_preds']
66+
batch_cls_preds = torch.sigmoid(batch_dict['batch_cls_preds'])
6767
rois = batch_box_preds.new_zeros((batch_size, nms_config.NMS_POST_MAXSIZE, batch_box_preds.shape[-1]))
6868
roi_scores = batch_box_preds.new_zeros((batch_size, nms_config.NMS_POST_MAXSIZE))
6969
roi_labels = batch_box_preds.new_zeros((batch_size, nms_config.NMS_POST_MAXSIZE), dtype=torch.long)
@@ -83,9 +83,22 @@ def proposal_layer(self, batch_dict, nms_config):
8383
if nms_config.MULTI_CLASSES_NMS:
8484
raise NotImplementedError
8585
else:
86-
selected, selected_scores = class_agnostic_nms(
87-
box_scores=cur_roi_scores, box_preds=box_preds, nms_config=nms_config
88-
)
86+
if self.training:
87+
selected, selected_scores = class_agnostic_nms(
88+
box_scores=cur_roi_scores, box_preds=box_preds, nms_config=nms_config
89+
)
90+
else:
91+
if nms_config.get("USE_FAST_NMS", False):
92+
selected, selected_scores = fast_bev_nms(
93+
box_scores=cur_roi_scores, box_preds=box_preds, nms_config=nms_config, score_thresh=nms_config.SCORE_THRESH
94+
)
95+
else:
96+
selected, selected_scores = class_agnostic_nms(
97+
box_scores=cur_roi_scores, box_preds=box_preds, nms_config=nms_config
98+
)
99+
# selected, selected_scores = class_agnostic_nms(
100+
# box_scores=cur_roi_scores, box_preds=box_preds, nms_config=nms_config
101+
# )
89102

90103
rois[index, :len(selected), :] = box_preds[selected]
91104
roi_scores[index, :len(selected)] = cur_roi_scores[selected]
@@ -189,36 +202,6 @@ def get_box_reg_layer_loss(self, forward_ret_dict):
189202

190203
rcnn_loss_reg += loss_corner
191204
tb_dict['rcnn_loss_corner'] = loss_corner.item()
192-
193-
if loss_cfgs.GRID_3D_IOU_LOSS and fg_sum > 0:
194-
fg_rcnn_reg = rcnn_reg.view(rcnn_batch_size, -1)[fg_mask]
195-
fg_roi_boxes3d = roi_boxes3d.view(-1, code_size)[fg_mask]
196-
197-
fg_roi_boxes3d = fg_roi_boxes3d.view(1, -1, code_size)
198-
batch_anchors = fg_roi_boxes3d.clone().detach()
199-
roi_ry = fg_roi_boxes3d[:, :, 6].view(-1)
200-
roi_xyz = fg_roi_boxes3d[:, :, 0:3].view(-1, 3)
201-
batch_anchors[:, :, 0:3] = 0
202-
rcnn_boxes3d = self.box_coder.decode_torch(
203-
fg_rcnn_reg.view(batch_anchors.shape[0], -1, code_size), batch_anchors
204-
).view(-1, code_size)
205-
206-
rcnn_boxes3d = common_utils.rotate_points_along_z(
207-
rcnn_boxes3d.unsqueeze(dim=1), roi_ry
208-
).squeeze(dim=1)
209-
rcnn_boxes3d[:, 0:3] += roi_xyz
210-
211-
loss_iou3d = loss_utils.get_gridify_iou3d_loss(
212-
gt_of_rois_src[fg_mask][:, :7],
213-
rcnn_boxes3d[:, :7]
214-
215-
)
216-
217-
loss_iou3d = loss_iou3d.mean()
218-
loss_iou3d = loss_iou3d * loss_cfgs.LOSS_WEIGHTS['rcnn_iou3d_weight']
219-
220-
rcnn_loss_reg += loss_iou3d
221-
tb_dict['rcnn_loss_iou3d'] = loss_iou3d.item()
222205
else:
223206
raise NotImplementedError
224207

pcdet/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1.0+c41ee6c"
1+
__version__ = "0.1.0+19ea2bd"

requirements.txt

-8
This file was deleted.

tools/cfgs/voxel_rcnn/voxel_rcnn_3classes.yaml

+6-4
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ MODEL:
128128
TEST:
129129
NMS_TYPE: nms_gpu
130130
MULTI_CLASSES_NMS: False
131-
NMS_PRE_MAXSIZE: 4096
131+
USE_FAST_NMS: True
132+
SCORE_THRESH: 0.0
133+
NMS_PRE_MAXSIZE: 2048
132134
NMS_POST_MAXSIZE: 100
133135
NMS_THRESH: 0.7
134136

@@ -139,8 +141,8 @@ MODEL:
139141
POOL_LAYERS:
140142
x_conv3:
141143
MLPS: [[32, 32], [32, 32]]
142-
QUERY_RANGES: [[3, 3, 3], [6, 6, 6]]
143-
POOL_RADIUS: [0.6, 1.2]
144+
QUERY_RANGES: [[2, 2, 2], [4, 4, 4]]
145+
POOL_RADIUS: [0.4, 0.8]
144146
NSAMPLE: [16, 16]
145147
POOL_METHOD: max_pool
146148
x_conv4:
@@ -212,4 +214,4 @@ OPTIMIZATION:
212214
LR_WARMUP: False
213215
WARMUP_EPOCH: 1
214216

215-
GRAD_NORM_CLIP: 10
217+
GRAD_NORM_CLIP: 10

tools/cfgs/voxel_rcnn/voxel_rcnn_car.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ MODEL:
108108
TEST:
109109
NMS_TYPE: nms_gpu
110110
MULTI_CLASSES_NMS: False
111-
NMS_PRE_MAXSIZE: 4096
111+
USE_FAST_NMS: True
112+
SCORE_THRESH: 0.0
113+
NMS_PRE_MAXSIZE: 2048
112114
NMS_POST_MAXSIZE: 100
113115
NMS_THRESH: 0.7
114116

@@ -119,8 +121,8 @@ MODEL:
119121
POOL_LAYERS:
120122
x_conv3:
121123
MLPS: [[32, 32], [32, 32]]
122-
QUERY_RANGES: [[3, 3, 3], [6, 6, 6]]
123-
POOL_RADIUS: [0.6, 1.2]
124+
QUERY_RANGES: [[2, 2, 2], [4, 4, 4]]
125+
POOL_RADIUS: [0.4, 0.8]
124126
NSAMPLE: [16, 16]
125127
POOL_METHOD: max_pool
126128
x_conv4:

0 commit comments

Comments
 (0)