Skip to content

Commit 74ed361

Browse files
authored
Merge branch 'dev' into dev
2 parents 783a3bb + fb87da2 commit 74ed361

File tree

10 files changed

+32
-35
lines changed

10 files changed

+32
-35
lines changed

ml3d/datasets/kitti.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,11 @@ def __len__(self):
266266

267267
def get_data(self, idx):
268268
pc_path = self.path_list[idx]
269-
label_path = pc_path.replace('velodyne',
270-
'label_2').replace('.bin', '.txt')
271-
calib_path = label_path.replace('label_2', 'calib')
269+
270+
# Replace the last instance of "velodyne" in the path by label_2, and the '.bin' by '.txt'
271+
label_path = ("label_2".join(pc_path.rsplit("velodyne", 1))).replace(
272+
'.bin', '.txt')
273+
calib_path = "calib".join(label_path.rsplit("label_2", 1))
272274

273275
pc = self.dataset.read_lidar(pc_path)
274276
calib = self.dataset.read_calib(calib_path)

ml3d/datasets/matterport_objects.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ def __len__(self):
262262

263263
def get_data(self, idx):
264264
pc_path = self.path_list[idx]
265-
label_path = pc_path.replace('pc', 'boxes').replace('.bin', '.txt')
265+
label_path = ("boxes".join(pc_path.rsplit("pc",
266+
1))).replace('.bin', '.txt')
266267

267268
pc = self.dataset.read_lidar(pc_path)
268269
label = self.dataset.read_label(label_path)

ml3d/datasets/waymo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ def __len__(self):
250250

251251
def get_data(self, idx):
252252
pc_path = self.path_list[idx]
253-
label_path = pc_path.replace('velodyne',
254-
'label_all').replace('.bin', '.txt')
255-
calib_path = label_path.replace('label_all', 'calib')
253+
label_path = ("label_all".join(pc_path.rsplit("velodyne", 1))).replace(
254+
'.bin', '.txt')
255+
calib_path = "calib".join(label_path.rsplit("label_all", 1))
256256

257257
pc = self.dataset.read_lidar(pc_path)
258258
calib = self.dataset.read_calib(calib_path)

ml3d/torch/models/kpconv.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ def inference_preprocess(self):
557557

558558
return inputs
559559

560-
def update_probs(self, inputs, results, test_probs, test_labels):
560+
def update_probs(self, inputs, results, test_probs):
561561
self.test_smooth = 0.95
562562
stk_probs = torch.nn.functional.softmax(results, dim=-1)
563563
stk_probs = stk_probs.cpu().data.numpy()
@@ -577,16 +577,14 @@ def update_probs(self, inputs, results, test_probs, test_labels):
577577
for b_i, length in enumerate(lengths):
578578
# Get prediction
579579
probs = stk_probs[i0:i0 + length]
580-
labels = np.argmax(probs, 1)
581580

582581
proj_inds = r_inds_list[b_i]
583582
proj_mask = r_mask_list[b_i]
584583
test_probs[proj_mask] = self.test_smooth * test_probs[proj_mask] + (
585584
1 - self.test_smooth) * probs
586-
test_labels[proj_mask] = labels
587585
i0 += length
588586

589-
return test_probs, test_labels
587+
return test_probs
590588

591589
def inference_end(self, inputs, results):
592590
m_softmax = torch.nn.Softmax(dim=-1)

ml3d/torch/models/point_pillars.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ def flatten_idx(idx, j):
907907
# for each anchor the gt with max IoU
908908
max_overlaps, argmax_overlaps = overlaps.max(dim=0)
909909
# for each gt the anchor with max IoU
910-
gt_max_overlaps, _ = overlaps.max(dim=1)
910+
gt_max_overlaps, gt_argmax_overlaps = overlaps.max(dim=1)
911911

912912
pos_idx = max_overlaps >= pos_th
913913
neg_idx = (max_overlaps >= 0) & (max_overlaps < neg_th)
@@ -916,6 +916,7 @@ def flatten_idx(idx, j):
916916
for k in range(len(target_bboxes[i])):
917917
if gt_max_overlaps[k] >= neg_th:
918918
pos_idx[overlaps[k, :] == gt_max_overlaps[k]] = True
919+
argmax_overlaps[gt_argmax_overlaps[k]] = k
919920

920921
# encode bbox for positive matches
921922
assigned_bboxes.append(

ml3d/torch/models/point_transformer.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,13 @@ def transform(self, data, attr):
304304

305305
return data
306306

307-
def update_probs(self, inputs, results, test_probs, test_labels):
307+
def update_probs(self, inputs, results, test_probs):
308308
result = results.reshape(-1, self.cfg.num_classes)
309309
probs = torch.nn.functional.softmax(result, dim=-1).cpu().data.numpy()
310-
labels = np.argmax(probs, 1)
311310

312311
self.trans_point_sampler(patchwise=False)
313312

314-
return probs, labels
313+
return probs
315314

316315
def inference_begin(self):
317316
data = self.preprocess(data, {'split': 'test'})

ml3d/torch/models/pvcnn.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,13 @@ def transform(self, data, attr):
250250

251251
return data
252252

253-
def update_probs(self, inputs, results, test_probs, test_labels):
253+
def update_probs(self, inputs, results, test_probs):
254254
result = results.reshape(-1, self.cfg.num_classes)
255255
probs = torch.nn.functional.softmax(result, dim=-1).cpu().data.numpy()
256-
labels = np.argmax(probs, 1)
257256

258257
self.trans_point_sampler(patchwise=False)
259258

260-
return probs, labels
259+
return probs
261260

262261
def inference_begin(self, data):
263262
data = self.preprocess(data, {'split': 'test'})

ml3d/torch/models/randlanet.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -438,17 +438,16 @@ def inference_end(self, inputs, results):
438438
else:
439439
return False
440440

441-
def update_probs(self, inputs, results, test_probs, test_labels):
441+
def update_probs(self, inputs, results, test_probs):
442442
"""Update test probabilities with probs from current tested patch.
443443
444444
Args:
445445
inputs: input to the model.
446446
results: output of the model.
447447
test_probs: probabilities for whole pointcloud
448-
test_labels: ground truth for whole pointcloud.
449448
450449
Returns:
451-
updated probabilities and labels
450+
updated probabilities
452451
453452
"""
454453
self.test_smooth = 0.95
@@ -458,14 +457,12 @@ def update_probs(self, inputs, results, test_probs, test_labels):
458457
result = torch.reshape(results[b], (-1, self.cfg.num_classes))
459458
probs = torch.nn.functional.softmax(result, dim=-1)
460459
probs = probs.cpu().data.numpy()
461-
labels = np.argmax(probs, 1)
462460
inds = inputs['data']['point_inds'][b]
463461

464462
test_probs[inds] = self.test_smooth * test_probs[inds] + (
465463
1 - self.test_smooth) * probs
466-
test_labels[inds] = labels
467464

468-
return test_probs, test_labels
465+
return test_probs
469466

470467

471468
MODEL._register_module(RandLANet, 'torch')

ml3d/torch/pipelines/semantic_segmentation.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ def run_inference(self, data):
153153
model.trans_point_sampler = infer_sampler.get_point_sampler()
154154
self.curr_cloud_id = -1
155155
self.test_probs = []
156-
self.test_labels = []
157156
self.ori_test_probs = []
158157
self.ori_test_labels = []
159158

@@ -219,7 +218,6 @@ def run_test(self):
219218
model.trans_point_sampler = test_sampler.get_point_sampler()
220219
self.curr_cloud_id = -1
221220
self.test_probs = []
222-
self.test_labels = []
223221
self.ori_test_probs = []
224222
self.ori_test_labels = []
225223

@@ -277,8 +275,6 @@ def update_tests(self, sampler, inputs, results):
277275
self.test_probs.append(
278276
np.zeros(shape=[num_points, self.model.cfg.num_classes],
279277
dtype=np.float16))
280-
self.test_labels.append(np.zeros(shape=[num_points],
281-
dtype=np.int16))
282278
self.complete_infer = False
283279

284280
this_possiblility = sampler.possibilities[sampler.cloud_id]
@@ -287,10 +283,11 @@ def update_tests(self, sampler, inputs, results):
287283
self.pbar_update)
288284
self.pbar_update = this_possiblility[
289285
this_possiblility > end_threshold].shape[0]
290-
self.test_probs[self.curr_cloud_id], self.test_labels[
291-
self.curr_cloud_id] = self.model.update_probs(
292-
inputs, results, self.test_probs[self.curr_cloud_id],
293-
self.test_labels[self.curr_cloud_id])
286+
self.test_probs[self.curr_cloud_id] = self.model.update_probs(
287+
inputs,
288+
results,
289+
self.test_probs[self.curr_cloud_id],
290+
)
294291

295292
if (split in ['test'] and
296293
this_possiblility[this_possiblility > end_threshold].shape[0]
@@ -303,10 +300,12 @@ def update_tests(self, sampler, inputs, results):
303300
if proj_inds is None:
304301
proj_inds = np.arange(
305302
self.test_probs[self.curr_cloud_id].shape[0])
303+
test_labels = np.argmax(
304+
self.test_probs[self.curr_cloud_id][proj_inds], 1)
305+
306306
self.ori_test_probs.append(
307307
self.test_probs[self.curr_cloud_id][proj_inds])
308-
self.ori_test_labels.append(
309-
self.test_labels[self.curr_cloud_id][proj_inds])
308+
self.ori_test_labels.append(test_labels)
310309
self.complete_infer = True
311310

312311
def run_train(self):

requirements-tensorflow.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
tensorflow~=2.8.4
1+
tensorflow~=2.8.4 ; sys_platform != 'darwin' or platform_machine != 'arm64'
2+
tensorflow-macos==2.8.0 ; sys_platform == 'darwin' and platform_machine == 'arm64'

0 commit comments

Comments
 (0)