6
6
from pyquaternion import Quaternion
7
7
from torch .utils .data import Dataset
8
8
from nuscenes .nuscenes import NuScenes
9
+ from spconv .pytorch .utils import PointToVoxel
9
10
from nuscenes .utils .geometry_utils import view_points
10
11
from nuscenes .utils .splits import create_splits_scenes
11
12
from nuscenes .utils .data_classes import LidarPointCloud
12
- from spconv .utils import VoxelGeneratorV2 as VoxelGenerator
13
13
14
14
15
15
CUSTOM_SPLIT = [
@@ -123,11 +123,12 @@ def __init__(
123
123
self .point_cloud_range = np .array ([- 51.2 , - 51.2 , - 5.0 , 51.2 , 51.2 , 3.0 ], dtype = np .float32 ) # nuScenes
124
124
MAX_POINTS_PER_VOXEL = 10 # nuScenes
125
125
MAX_NUMBER_OF_VOXELS = 60000 # nuScenes
126
- self ._voxel_generator = VoxelGenerator (
127
- voxel_size = self .voxel_size ,
128
- point_cloud_range = self .point_cloud_range ,
129
- max_num_points = MAX_POINTS_PER_VOXEL ,
130
- max_voxels = MAX_NUMBER_OF_VOXELS
126
+ self ._voxel_generator = PointToVoxel (
127
+ vsize_xyz = self .voxel_size ,
128
+ coors_range_xyz = self .point_cloud_range ,
129
+ num_point_features = 4 ,
130
+ max_num_points_per_voxel = MAX_POINTS_PER_VOXEL ,
131
+ max_num_voxels = MAX_NUMBER_OF_VOXELS
131
132
)
132
133
else :
133
134
raise Exception ("Dataset unknown" )
@@ -297,9 +298,8 @@ def __len__(self):
297
298
return len (self .list_keyframes )
298
299
299
300
def _voxelize (self , points ):
300
- voxel_output = self ._voxel_generator .generate (points .numpy ())
301
- voxels , coordinates , num_points = \
302
- voxel_output ['voxels' ], voxel_output ['coordinates' ], voxel_output ['num_points_per_voxel' ]
301
+ voxel_output = self ._voxel_generator .generate_voxel_with_id (points )
302
+ voxels , coordinates , num_points , indexes = voxel_output
303
303
return voxels , coordinates , num_points
304
304
305
305
def __getitem__ (self , idx ):
@@ -318,7 +318,6 @@ def __getitem__(self, idx):
318
318
319
319
if self .cloud_transforms :
320
320
pc = self .cloud_transforms (pc )
321
- # pc = torch.cat((pc, intensity), 1)
322
321
if self .mixed_transforms :
323
322
(
324
323
pc ,
@@ -331,17 +330,19 @@ def __getitem__(self, idx):
331
330
pc , intensity , images , pairing_points , pairing_images , superpixels
332
331
)
333
332
333
+ pc = torch .cat ((pc , intensity ), 1 )
334
+
334
335
voxels , coordinates , num_points = self ._voxelize (pc )
335
336
336
337
discrete_coords = torch .cat (
337
338
(
338
339
torch .zeros (coordinates .shape [0 ], 1 , dtype = torch .int32 ),
339
- torch . tensor ( coordinates ) ,
340
+ coordinates ,
340
341
),
341
342
1 ,
342
343
)
343
- voxels = torch . tensor ( voxels )
344
- num_points = torch . tensor ( num_points )
344
+ voxels = voxels
345
+ num_points = num_points
345
346
346
347
return (
347
348
pc ,
0 commit comments