Skip to content

Commit

Permalink
update segmentation image, indoor example minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischoy committed Mar 5, 2021
1 parent aafbb67 commit 6495d65
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion MinkowskiEngine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# Please cite "4D Spatio-Temporal ConvNets: Minkowski Convolutional Neural
# Networks", CVPR'19 (https://arxiv.org/abs/1904.08755) if you use any part
# of the code.
__version__ = "0.5.1"
__version__ = "0.5.2"

import os
import sys
Expand Down
Binary file modified docs/images/segmentation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion examples/indoor.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ def load_file(file_name):
return coords, colors, pcd


def normalize_color(color: torch.Tensor, is_color_in_range_0_255: bool = False) -> torch.Tensor:
r"""
Convert color in range [0, 1] to [-0.5, 0.5]. If the color is in range [0,
255], use the argument `is_color_in_range_0_255=True`.
`color` (torch.Tensor): Nx3 color feature matrix
`is_color_in_range_0_255` (bool): If the color is in range [0, 255] not [0, 1], normalize the color to [0, 1].
"""
if is_color_in_range_0_255:
color /= 255
color -= 0.5
return color.float()


if __name__ == '__main__':
config = parser.parse_args()
device = torch.device('cuda' if (
Expand All @@ -124,7 +138,7 @@ def load_file(file_name):
voxel_size = 0.02
# Feed-forward pass and get the prediction
in_field = ME.TensorField(
features=torch.from_numpy(colors).float(),
features=normalize_color(torch.from_numpy(colors)),
coordinates=ME.utils.batched_coordinates([coords / voxel_size], dtype=torch.float32),
quantization_mode=ME.SparseTensorQuantizationMode.UNWEIGHTED_AVERAGE,
minkowski_algorithm=ME.MinkowskiAlgorithm.SPEED_OPTIMIZED,
Expand Down

0 comments on commit 6495d65

Please sign in to comment.