myria3d.models

Model

class myria3d.models.model.Model(**kwargs)[source]

Model training, validation, test and prediction of point cloud semantic segmentation.

During training and validation, metrics are calculed based on sumbsampled points only. At test time, metrics are calculated considering all the points.

To keep this module light, a callback takes care of metric computations.

Read the Pytorch Lightning docs:

https://pytorch-lightning.readthedocs.io/en/latest/common/lightning_module.html

configure_optimizers()[source]

Choose what optimizers and learning-rate schedulers to use in your optimization.

Returns

An optimizer, or a config of a scheduler and an optimizer.

forward(batch: torch_geometric.data.batch.Batch) torch.Tensor[source]

Forward pass of neural network.

Parameters
  • batch (Batch) – Batch of data including x (features), pos (xyz positions),

  • y (and) –

Returns

targets torch.Tensor (B*N,C): logits

Return type

torch.Tensor (B*N,1)

predict_step(batch: torch_geometric.data.batch.Batch) dict[source]

Prediction step.

Move to CPU to avoid acucmulation of predictions into gpu memory.

Parameters
  • batch (torch_geometric.data.Batch) – Batch of data including x (features), pos (xyz positions),

  • y (and) –

Returns

Dictionnary with predicted logits as well as input batch.

Return type

dict

test_step(batch: torch_geometric.data.batch.Batch, batch_idx: int)[source]

Test step.

Parameters
  • batch (torch_geometric.data.Batch) – Batch of data including x (features), pos (xyz positions),

  • y (and) –

Returns

Dictionnary with full-cloud predicted logits as well as the full-cloud (transformed) targets.

Return type

dict

training_step(batch: torch_geometric.data.batch.Batch, batch_idx: int) dict[source]

Training step.

Parameters
  • batch (torch_geometric.data.Batch) – Batch of data including x (features), pos (xyz positions),

  • y (and) –

  • batch_idx (int) – batch identified (unused)

Returns

a dict containing the loss, logits, and targets.

Return type

dict

validation_step(batch: torch_geometric.data.batch.Batch, batch_idx: int) dict[source]

Validation step.

Parameters
  • batch (torch_geometric.data.Batch) – Batch of data including x (features), pos (xyz positions),

  • y (and) –

  • batch_idx (int) – batch identified (unused)

Returns

a dict containing the loss, logits, and targets.

Return type

dict

myria3d.models.model.get_neural_net_class(class_name: str) torch.nn.modules.module.Module[source]

A Class Factory to class of neural net based on class name.

Parameters

class_name (str) – the name of the class to get.

Returns

CLass of requested neural network.

Return type

nn.Module

Interpolation

class myria3d.models.interpolation.Interpolator(interpolation_k: int = 10, classification_dict: Dict[int, str] = {}, probas_to_save: Union[List[str], Literal['all']] = 'all', predicted_classification_channel: Optional[str] = 'PredictedClassification', entropy_channel: Optional[str] = 'entropy')[source]

A class to load, update with classification, update with probas (optionnal), and save a LAS.

load_full_las_for_update(src_las: str, epsg: str) Tuple[numpy.ndarray, Dict][source]

Loads a LAS and adds necessary extradim.

Parameters
  • filepath (str) – Path to LAS for which predictions are made.

  • epsg (str) – epsg to force the reading with

reduce_predicted_logits(nb_points) Tuple[torch.Tensor, numpy.ndarray][source]

Interpolate logits to points without predictions using an inverse-distance weightning scheme.

Returns

interpolated logits classification

Return type

torch.Tensor, torch.Tensor

reduce_predictions_and_save(raw_path: str, output_dir: str, epsg: str) str[source]

Interpolate all predicted probabilites to their original points in LAS file, and save.

Parameters
  • interpolation (torch.Tensor, torch.Tensor) – output of _interpolate, of which we need the logits.

  • basename – str: file basename to save it with the same one

  • output_dir (Optional[str], optional) – Directory to save output LAS with new predicted classification, entropy,

  • None. (and _sphinx_paramlinks_myria3d.models.interpolation.Interpolator.reduce_predictions_and_save.probabilities. Defaults to) –

  • epsg (str) – epsg to force the reading with

Returns

path of the updated, saved LAS file.

Return type

str

store_predictions(logits, idx_in_original_cloud) None[source]

Keep a list of predictions made so far.