From 09840f435532061ca5e6b15ad70bf6b7bf154d5d Mon Sep 17 00:00:00 2001 From: "pengfei.deng" Date: Thu, 28 Aug 2025 13:55:44 +0800 Subject: [PATCH] - Adjust log positions and type conversions (issues #609, #649) - Correct RandLA-Net preprocessing: apply augmentation and convert large coordinates safely --- ml3d/datasets/augment/augmentation.py | 7 +++++-- ml3d/datasets/customdataset.py | 7 +++++-- ml3d/torch/models/randlanet.py | 2 +- ml3d/torch/pipelines/semantic_segmentation.py | 6 +++--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ml3d/datasets/augment/augmentation.py b/ml3d/datasets/augment/augmentation.py index a7673c47b..c92648be5 100644 --- a/ml3d/datasets/augment/augmentation.py +++ b/ml3d/datasets/augment/augmentation.py @@ -27,8 +27,11 @@ def recenter(self, data, cfg): if not cfg: return data dim = cfg.get('dim', [0, 1, 2]) - data[:, dim] = data[:, dim] - data.mean(0)[dim] - return data + data_float64 = data.astype(np.float64) + mean_vals = data_float64[:, dim].mean(0) + data_float64[:, dim] -= mean_vals + + return data_float64.astype(np.float32) def normalize(self, pc, feat, cfg): """Normalize pointcloud and/or features. diff --git a/ml3d/datasets/customdataset.py b/ml3d/datasets/customdataset.py index 2817f733a..c184f9b9e 100644 --- a/ml3d/datasets/customdataset.py +++ b/ml3d/datasets/customdataset.py @@ -220,10 +220,13 @@ def save_test_result(self, results, attr): make_dir(path) pred = results['predict_labels'] - pred = np.array(self.label_to_names[pred]) + if isinstance(pred, np.ndarray): + pred_names = np.vectorize(lambda x: self.label_to_names[int(x)])(pred) + else: + pred_names = self.label_to_names[int(pred)] store_path = join(path, name + '.npy') - np.save(store_path, pred) + np.save(store_path, pred_names) DATASET._register_module(Custom3D) diff --git a/ml3d/torch/models/randlanet.py b/ml3d/torch/models/randlanet.py index 390c53cbe..e88ea7cd7 100644 --- a/ml3d/torch/models/randlanet.py +++ b/ml3d/torch/models/randlanet.py @@ -191,7 +191,7 @@ def transform(self, data, attr, min_possibility_idx=None): if 'normalize' in augment_cfg: val_augment_cfg['normalize'] = augment_cfg.pop('normalize') - self.augmenter.augment(pc, feat, label, val_augment_cfg, seed=rng) + pc, feat, label = self.augmenter.augment(pc, feat, label, val_augment_cfg, seed=rng) if attr['split'] in ['training', 'train']: pc, feat, label = self.augmenter.augment(pc, diff --git a/ml3d/torch/pipelines/semantic_segmentation.py b/ml3d/torch/pipelines/semantic_segmentation.py index bed7205b7..c18575b27 100644 --- a/ml3d/torch/pipelines/semantic_segmentation.py +++ b/ml3d/torch/pipelines/semantic_segmentation.py @@ -257,14 +257,14 @@ def run_test(self): self.metric_test.update(valid_scores, valid_labels) log.info(f"Accuracy : {self.metric_test.acc()}") log.info(f"IoU : {self.metric_test.iou()}") + log.info( + f"Overall Testing Accuracy : {self.metric_test.acc()[-1]}, mIoU : {self.metric_test.iou()[-1]}" + ) dataset.save_test_result(inference_result, attr) # Save only for the first batch if 'test' in record_summary and 'test' not in self.summary: self.summary['test'] = self.get_3d_summary( results, inputs['data'], 0, save_gt=False) - log.info( - f"Overall Testing Accuracy : {self.metric_test.acc()[-1]}, mIoU : {self.metric_test.iou()[-1]}" - ) log.info("Finished testing")