Skip to content

Commit 6495d65

Browse files
committed
update segmentation image, indoor example minor update
1 parent aafbb67 commit 6495d65

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

MinkowskiEngine/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# Please cite "4D Spatio-Temporal ConvNets: Minkowski Convolutional Neural
2323
# Networks", CVPR'19 (https://arxiv.org/abs/1904.08755) if you use any part
2424
# of the code.
25-
__version__ = "0.5.1"
25+
__version__ = "0.5.2"
2626

2727
import os
2828
import sys

docs/images/segmentation.png

23.3 KB
Loading

examples/indoor.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ def load_file(file_name):
107107
return coords, colors, pcd
108108

109109

110+
def normalize_color(color: torch.Tensor, is_color_in_range_0_255: bool = False) -> torch.Tensor:
111+
r"""
112+
Convert color in range [0, 1] to [-0.5, 0.5]. If the color is in range [0,
113+
255], use the argument `is_color_in_range_0_255=True`.
114+
115+
`color` (torch.Tensor): Nx3 color feature matrix
116+
`is_color_in_range_0_255` (bool): If the color is in range [0, 255] not [0, 1], normalize the color to [0, 1].
117+
"""
118+
if is_color_in_range_0_255:
119+
color /= 255
120+
color -= 0.5
121+
return color.float()
122+
123+
110124
if __name__ == '__main__':
111125
config = parser.parse_args()
112126
device = torch.device('cuda' if (
@@ -124,7 +138,7 @@ def load_file(file_name):
124138
voxel_size = 0.02
125139
# Feed-forward pass and get the prediction
126140
in_field = ME.TensorField(
127-
features=torch.from_numpy(colors).float(),
141+
features=normalize_color(torch.from_numpy(colors)),
128142
coordinates=ME.utils.batched_coordinates([coords / voxel_size], dtype=torch.float32),
129143
quantization_mode=ME.SparseTensorQuantizationMode.UNWEIGHTED_AVERAGE,
130144
minkowski_algorithm=ME.MinkowskiAlgorithm.SPEED_OPTIMIZED,

0 commit comments

Comments
 (0)