ml¶
occulus.ml
¶
Deep learning semantic segmentation for point clouds.
Provides inference wrappers for pre-trained models (ONNX Runtime or PyTorch backends) to classify points into semantic categories such as ground, vegetation, building, water, and powerline.
This module does not train models — it loads pre-trained weights and runs inference only.
SegmentationPrediction
dataclass
¶
Result of semantic segmentation inference.
Attributes:
| Name | Type | Description |
|---|---|---|
labels |
NDArray[int32]
|
Per-point predicted class label. |
probabilities |
NDArray[float32]
|
Per-point class probabilities, shape (N, num_classes). |
class_names |
dict[int, str]
|
Mapping from class ID to human-readable name. |
Source code in src/occulus/ml/__init__.py
predict_semantic(cloud, model_path, *, backend='onnx', batch_size=4096, device='cpu', num_classes=9, class_names=None)
¶
Run semantic segmentation inference on a point cloud.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cloud
|
PointCloud
|
Input point cloud. |
required |
model_path
|
str or Path
|
Path to a pre-trained model file (.onnx or .pt/.pth). |
required |
backend
|
str
|
Inference backend: 'onnx' (ONNX Runtime) or 'torch' (PyTorch). |
'onnx'
|
batch_size
|
int
|
Number of points per inference batch. |
4096
|
device
|
str
|
Device for inference ('cpu' or 'cuda'). |
'cpu'
|
num_classes
|
int
|
Number of output classes. |
9
|
class_names
|
dict[int, str]
|
Custom class name mapping. Defaults to ASPRS-like names. |
None
|
Returns:
| Type | Description |
|---|---|
SegmentationPrediction
|
Per-point labels and class probabilities. |
Raises:
| Type | Description |
|---|---|
OcculusMLError
|
If the model cannot be loaded or inference fails. |
Source code in src/occulus/ml/__init__.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
prepare_features(cloud, *, use_rgb=True, use_intensity=True, use_normals=False, normalize=True)
¶
Prepare input features for ML inference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cloud
|
PointCloud
|
Input point cloud. |
required |
use_rgb
|
bool
|
Include RGB channels if available. |
True
|
use_intensity
|
bool
|
Include intensity channel if available. |
True
|
use_normals
|
bool
|
Include surface normals if available. |
False
|
normalize
|
bool
|
Center and scale XYZ to unit sphere. |
True
|
Returns:
| Type | Description |
|---|---|
NDArray[float32]
|
Feature matrix of shape (N, D) where D depends on available attributes. |