Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions ml3d/datasets/augment/augmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copilot AI Feb 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove trailing whitespace on this empty line to maintain consistent code formatting.

Suggested change

Copilot uses AI. Check for mistakes.
return data_float64.astype(np.float32)

def normalize(self, pc, feat, cfg):
"""Normalize pointcloud and/or features.
Expand Down
7 changes: 5 additions & 2 deletions ml3d/datasets/customdataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Copilot AI Feb 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using np.vectorize with a lambda function is inefficient for large arrays as it's essentially a Python loop. Consider using array indexing directly with pred_names = np.array([self.label_to_names[int(x)] for x in pred]) or converting label_to_names to a numpy array and using advanced indexing like np.array(self.label_to_names)[pred.astype(int)].

Suggested change
pred_names = np.vectorize(lambda x: self.label_to_names[int(x)])(pred)
flat_pred = pred.ravel()
pred_names = np.array(
[self.label_to_names[int(x)] for x in flat_pred]
).reshape(pred.shape)

Copilot uses AI. Check for mistakes.
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)
2 changes: 1 addition & 1 deletion ml3d/torch/models/randlanet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions ml3d/torch/pipelines/semantic_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down