src.model.model_op

Classes

ModelOp(model, op)

Exceptions

ModelOpException([message])

exception src.model.model_op.ModelOpException(message='')
Author:

Alberto M. Esmoris Pena

Class for exceptions related to model operations. See VL3DException.

class src.model.model_op.ModelOp(model, op)
Author:

Alberto M. Esmoris Pena

Class wrapping a model associated to an operation (useful to handle different model operations like train and predict during pipelines).

Variables:
  • model (Model) – The model.

  • op (enum) – The operation.

class OP(*values)
TRAIN = 1
PREDICT = 2
__init__(model, op)

Root initialization for any instance of type ModelOp.

Parameters:
  • model – The model associated to the operation.

  • op – The operation associated to the model.

__call__(pcloud=None, out_prefix=None)

Make the model do the operation.

Parameters:
  • pcloud (PointCloud or None) – Input point cloud. Train and predict operations require it is not None.

  • out_prefix – Optional argument to specify the output prefix for any path in the model that starts with ‘*’.

Returns:

Whatever the operation returns.

update_model_paths(out_prefix)

Update the output paths in the model object.

For each path that starts with “*” it will be updated to replace the “*” by the prefix.

Parameters:

out_prefix (str) – The prefix for the output paths. It is expected to end with “*”.

Returns:

A dictionary with the paths before the update. Note the model is updated in place.

Return type:

dict

update_dl_model_paths(out_prefix, old_paths)

Update the model assuming it is a deep learning model. This method will not check that self.model is a deep learning model. Instead, it assumes it is because otherwise the method MUST NOT be called.

See model_op.ModelOp.update_model_paths().

Parameters:

old_paths (dict) – The output parameter. It must be a dictionary where any modified path (value) will be stored before it is updated, associated to its variable (key).

Returns:

Nothing at all, the old_paths list argument is updated if necessary.

restore_model_paths(old_paths)

Restore previously updated model paths to their original values.

Parameters:

old_paths – The dictionary with the paths before the update.

Returns:

Nothing, the model is restored in place.

restore_dl_model_paths(old_paths)

Restore the model assuming it is a deep learning model. This method will not check that self.model is a deep learning model. Instead, it assumes it is because otherwise the method MUST NOT be called.

See model_op.ModelOp.restore_model_paths().

Parameters:

old_paths (dict) – The output parameter. It must be a dictionary where any variable (key) that needs to restore its old path (value) is represented.

Returns:

Nothing at all, the old_paths dictionary is used to restore the variables of the model to its previous value.

static path_needs_update(path: str) bool

Check whether a model path needs to be updated or not.

A model path needs to be updated if it starts by “*”.

Parameters:

path – The model path to be checked.

Returns:

True if the model path needs to be updated, False otherwise.

Return type:

bool

static merge_path(out_prefix: str, path: str) str

Merge the output prefix to the model path assuming the output prefix ends by “*” and the model path starts with “*”.

Parameters:
  • out_prefix – The output prefix for the merge.

  • path – The model path for the merge.

Returns:

The merged path.

Return type:

str