Skip to content

Commit 6294dd6

Browse files
committed
Spconv 2 & fix
1 parent 629973d commit 6294dd6

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

model/spconv_backbone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from functools import partial
22
import numpy as np
33

4-
import spconv
4+
import spconv.pytorch as spconv
55
import torch.nn as nn
66

77

pretrain/dataloader_nuscenes_spconv.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
from pyquaternion import Quaternion
77
from torch.utils.data import Dataset
88
from nuscenes.nuscenes import NuScenes
9+
from spconv.pytorch.utils import PointToVoxel
910
from nuscenes.utils.geometry_utils import view_points
1011
from nuscenes.utils.splits import create_splits_scenes
1112
from nuscenes.utils.data_classes import LidarPointCloud
12-
from spconv.utils import VoxelGeneratorV2 as VoxelGenerator
1313

1414

1515
CUSTOM_SPLIT = [
@@ -123,11 +123,12 @@ def __init__(
123123
self.point_cloud_range = np.array([-51.2, -51.2, -5.0, 51.2, 51.2, 3.0], dtype=np.float32) # nuScenes
124124
MAX_POINTS_PER_VOXEL = 10 # nuScenes
125125
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
131132
)
132133
else:
133134
raise Exception("Dataset unknown")
@@ -297,9 +298,8 @@ def __len__(self):
297298
return len(self.list_keyframes)
298299

299300
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
303303
return voxels, coordinates, num_points
304304

305305
def __getitem__(self, idx):
@@ -318,7 +318,6 @@ def __getitem__(self, idx):
318318

319319
if self.cloud_transforms:
320320
pc = self.cloud_transforms(pc)
321-
# pc = torch.cat((pc, intensity), 1)
322321
if self.mixed_transforms:
323322
(
324323
pc,
@@ -331,17 +330,19 @@ def __getitem__(self, idx):
331330
pc, intensity, images, pairing_points, pairing_images, superpixels
332331
)
333332

333+
pc = torch.cat((pc, intensity), 1)
334+
334335
voxels, coordinates, num_points = self._voxelize(pc)
335336

336337
discrete_coords = torch.cat(
337338
(
338339
torch.zeros(coordinates.shape[0], 1, dtype=torch.int32),
339-
torch.tensor(coordinates),
340+
coordinates,
340341
),
341342
1,
342343
)
343-
voxels = torch.tensor(voxels)
344-
num_points = torch.tensor(num_points)
344+
voxels = voxels
345+
num_points = num_points
345346

346347
return (
347348
pc,

0 commit comments

Comments
 (0)