Fix issues #609, #649 and correct RandLA-Net preprocessing#680
Fix issues #609, #649 and correct RandLA-Net preprocessing#680lkpopo wants to merge 1 commit intoisl-org:mainfrom
Conversation
…org#649) - Correct RandLA-Net preprocessing: apply augmentation and convert large coordinates safely
There was a problem hiding this comment.
Pull request overview
This PR addresses issues #609 and #649 while fixing critical bugs in RandLA-Net preprocessing. The changes focus on fixing log statement placement, correcting data type handling, and ensuring augmentation results are properly captured.
Changes:
- Moved test accuracy logging inside the batch loop for proper metrics display
- Fixed RandLA-Net to capture augmentation return values that were previously ignored
- Improved data type handling in prediction label conversion with proper vectorization
- Added float64 precision handling in data recentering to prevent numerical errors with large coordinates
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ml3d/torch/pipelines/semantic_segmentation.py | Relocated logging statement inside batch loop to display metrics during testing |
| ml3d/torch/models/randlanet.py | Fixed augmentation call to capture returned transformed data |
| ml3d/datasets/customdataset.py | Improved label-to-name conversion with type checking and vectorization |
| ml3d/datasets/augment/augmentation.py | Enhanced numerical precision by using float64 during recentering operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| data_float64 = data.astype(np.float64) | ||
| mean_vals = data_float64[:, dim].mean(0) | ||
| data_float64[:, dim] -= mean_vals | ||
|
|
There was a problem hiding this comment.
Remove trailing whitespace on this empty line to maintain consistent code formatting.
| 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) |
There was a problem hiding this comment.
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)].
| 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) |
Summary
This PR fixes the following issues and improves data preprocessing:
Issues TypeError: unhashable type: 'numpy.ndarray' when saving test results with Custom3D dataset #609, Summarize the question. (e.g., "How to do inference on custom dataset ? ") #649:
RandLA-Net preprocessing:
Notes