Skip to content

Commit

Permalink
fix max_voxels
Browse files Browse the repository at this point in the history
  • Loading branch information
sunjiahao1999 committed Apr 26, 2023
1 parent b900f2d commit 8e6c33e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 3 additions & 4 deletions configs/_base_/models/minkunet.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
point_cloud_range=[-100, -100, -20, 100, 100, 20],
voxel_size=[0.05, 0.05, 0.05],
max_voxels=(-1, -1)),
),
max_voxels=80000),
backbone=dict(
type='MinkUNetBackbone',
in_channels=4,
base_channels=32,
encoder_channels=[32, 64, 128, 256],
decoder_channels=[256, 128, 96, 96],
num_stages=4,
init_cfg=None),
encoder_channels=[32, 64, 128, 256],
decoder_channels=[256, 128, 96, 96]),
decode_head=dict(
type='MinkUNetHead',
channels=96,
Expand Down
4 changes: 2 additions & 2 deletions configs/_base_/models/spvcnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
point_cloud_range=[-100, -100, -20, 100, 100, 20],
voxel_size=[0.05, 0.05, 0.05],
max_voxels=(-1, -1)),
),
max_voxels=80000),
backbone=dict(
type='SPVCNNBackbone',
in_channels=4,
base_channels=32,
num_stages=4,
encoder_channels=[32, 64, 128, 256],
decoder_channels=[256, 128, 96, 96],
num_stages=4,
drop_ratio=0.3),
decode_head=dict(
type='MinkUNetHead',
Expand Down
6 changes: 4 additions & 2 deletions mmdet3d/models/data_preprocessors/data_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class Det3DDataPreprocessor(DetDataPreprocessor):
voxelization and dynamic voxelization. Defaults to 'hard'.
voxel_layer (dict or :obj:`ConfigDict`, optional): Voxelization layer
config. Defaults to None.
max_voxels (int): Maximum number of voxels in each voxel grid. Defaults
to None.
mean (Sequence[Number], optional): The pixel mean of R, G, B channels.
Defaults to None.
std (Sequence[Number], optional): The pixel standard deviation of
Expand Down Expand Up @@ -77,7 +79,7 @@ def __init__(self,
voxel: bool = False,
voxel_type: str = 'hard',
voxel_layer: OptConfigType = None,
max_voxels: int = 80000,
max_voxels: Optional[int] = None,
mean: Sequence[Number] = None,
std: Sequence[Number] = None,
pad_size_divisor: int = 1,
Expand Down Expand Up @@ -428,7 +430,7 @@ def voxelize(self, points: List[torch.Tensor],
inds, point2voxel_map = self.sparse_quantize(
res_coors_numpy, return_index=True, return_inverse=True)
point2voxel_map = torch.from_numpy(point2voxel_map).cuda()
if self.training:
if self.training and self.max_voxels is not None:
if len(inds) > self.max_voxels:
inds = np.random.choice(
inds, self.max_voxels, replace=False)
Expand Down

0 comments on commit 8e6c33e

Please sign in to comment.