Inference and evaluation of a trained Superpoint Transformer model.
See script documentation for more details
clfSPTInfer is the inference step of the SPT workflow (clfSPTPreprocess -> clfSPTInfer). It loads a trained model bundle, classifies one or more point cloud tiles, and writes the predicted class labels back into the input file(s). If the input carries ground-truth labels, the module additionally reports evaluation metrics (OA, mIoU, mAcc) and a confusion matrix.
A training run directory (Runs/Train/<timestamp>), or a standalone model bundle provides everything the module needs: the frozen config.yaml, the transforms, a checkpoint, and dataset_config.py. Its components can also be pointed to individually, for example to test a specific checkpoint other than the automatically selected best one from the same run, or when the run bundle's files have been relocated and no longer share a common -runDir. Combining a checkpoint with a config.yaml from a different run, or a manually edited one is not recommended. Unlike clfSPTTrain, the inference step requires a preprocessed tile. For each input tile, it checks for a cache in this order:
config.yaml as the currently loaded run. This is the case for tiles smaller than the subtiling grid size used during preprocessing.config.yaml.Predictions are computed on the superpoint hierarchy and distributed back onto the original, full-resolution points using the full-resolution indices stored in the NAG. For sub-tiled inputs, every sub-tile is classified over its full footprint (core plus a surrounding buffer of context), but only the predictions for its own core zone are kept in the final result. Points in the buffer zone of one tile are points of the core zone in the neighboring tile, so each point gets classified.
For .odm, .las, and .laz inputs, predictions are written in-place, .copc.laz is a special case: the COPC spatial-indexing structure is not preserved when writing, so the result is a plain .laz. The point data itself is unaffected, only the query optimization is lost. For any other input format, a new file is written into the desired point format (.odm / .las) instead, carrying all original attributes plus the prediction. As a safety net, predictions are first backed up to a local file before being written to the target, if writing fails, the compute is not lost. The backup is removed again once the module completes successfully.
By default, two additional point attributes are written into the classified tile:
Since the model predicts per superoint, all points with the same SuperopointID share the same class and confidence. Points that could not be classified have confidence = 0.0 and SuperpointID = -1.
Within Opals an already trained model is available. It performs a binary classification into ground and non-ground points. Water is treated as ground. The foundation for the training were selected tiles from three cities, taken from three different datasets:
The individual tiles include scenes from urban, suburban and rural areas. The aim was to provide a classifier that generalizes across different areas, hence data from three cities was used. For more information about the individual datasets see: Walicka and Pfeifer (2025)
| possible input | evaluates to |
|---|---|
| 1, true, yes, Boolean(True), True | Boolean(True) |
| 0, false, no, Boolean(False), False | Boolean(False) |
| possible input | evaluates to |
|---|---|
| 1, true, yes, Boolean(True), True | Boolean(True) |
| 0, false, no, Boolean(False), False | Boolean(False) |
| odm |
| las |
Before using any SPT scripts, the SPT package and all its dependencies are required to be installed as described Example section of clfSPTWorkflows.
The first example uses the provided pretrained model for ground point classification. The data used in this example can be found in the $OPALS_ROOT/demo/ directory. The point cloud of fullwave2.fwf is imported into an OPALS data manager using the following command:
The model directory already includes the matching config files which are necessary for preprocessing and inference. Please do not modify the config files as they have to match the configuration used for training.
With -mapBack True, the predicted classes are written as original class codes instead of the internal train IDs.
Before running inference with a user-trained SPT model (see clfSPTWorkflows for a complete SPT workflow), the input data tiles must be preprocessed, assuming project_name as intial SPT project directory
The -tileSize 0 flag disables sub-tiling. For large tiles (>1 million points), omit this option or specify an appropriate tile size to reduce memory consumption and avoid out-of-memory errors.
Both single files and directories are accepted. Relative paths are resolved against the current working directory.