Skip to content

Commit

Permalink
fix gt bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sunjiahao1999 committed Apr 25, 2023
1 parent 2cdc91a commit b900f2d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mmdet3d/models/data_preprocessors/data_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def __init__(self,
voxel: bool = False,
voxel_type: str = 'hard',
voxel_layer: OptConfigType = None,
max_voxels: int = 80000,
mean: Sequence[Number] = None,
std: Sequence[Number] = None,
pad_size_divisor: int = 1,
Expand All @@ -103,6 +104,7 @@ def __init__(self,
batch_augments=batch_augments)
self.voxel = voxel
self.voxel_type = voxel_type
self.max_voxels = max_voxels
if voxel:
self.voxel_layer = VoxelizationByGridShape(**voxel_layer)

Expand Down Expand Up @@ -427,11 +429,13 @@ def voxelize(self, points: List[torch.Tensor],
res_coors_numpy, return_index=True, return_inverse=True)
point2voxel_map = torch.from_numpy(point2voxel_map).cuda()
if self.training:
if len(inds) > 80000:
inds = np.random.choice(inds, 80000, replace=False)
if len(inds) > self.max_voxels:
inds = np.random.choice(
inds, self.max_voxels, replace=False)
inds = torch.from_numpy(inds).cuda()
data_sample.gt_pts_seg.voxel_semantic_mask \
= data_sample.gt_pts_seg.pts_semantic_mask[inds]
if hasattr(data_sample.gt_pts_seg, 'pts_semantic_mask'):
data_sample.gt_pts_seg.voxel_semantic_mask \
= data_sample.gt_pts_seg.pts_semantic_mask[inds]
res_voxel_coors = res_coors[inds]
res_voxels = res[inds]
res_voxel_coors = F.pad(
Expand Down

0 comments on commit b900f2d

Please sign in to comment.