Skip to content

Prediction Outputs

Source

Module containing functions to convert prediction outputs to desired form.

combine_batches(predictions, tiled)

combine_batches(predictions: list[Any], tiled: Literal[True]) -> tuple[list[NDArray], list[TileInformation]]
combine_batches(predictions: list[Any], tiled: Literal[False]) -> list[NDArray]
combine_batches(predictions: list[Any], tiled: Union[bool, Literal[True], Literal[False]]) -> Union[list[NDArray], tuple[list[NDArray], list[TileInformation]]]

If predictions are in batches, they will be combined.

TODO improve description!

Parameters:

  • predictions (list) –

    Predictions that are output from Trainer.predict.

  • tiled (bool) –

    Whether the predictions are tiled.

Returns:

  • (list of numpy.ndarray) or tuple of (list of numpy.ndarray, list of TileInformation)

    Combined batches.

convert_outputs(predictions, tiled)

Convert the Lightning trainer outputs to the desired form.

This method allows stitching back together tiled predictions.

Parameters:

  • predictions (list) –

    Predictions that are output from Trainer.predict.

  • tiled (bool) –

    Whether the predictions are tiled.

Returns:

  • list of numpy.ndarray or numpy.ndarray

    list of arrays with the axes SC(Z)YX. If there is only 1 output it will not be in a list.

convert_outputs_pn2v(predictions, tiled)

Convert the Lightning trainer outputs to the desired form.

This method allows stitching back together tiled predictions.

Parameters:

  • predictions (list) –

    Predictions that are output from Trainer.predict. Length of list the total number of tiles divided by the batch size. Each element consists of a tuple of ((prediction, mse), tile_info_list). 1st dimension of each tensor is the bs. Length of tile info list is the batch size.

  • tiled (bool) –

    Whether the predictions are tiled.

Returns:

  • tuple[list[NDArray], list[NDArray]]

    Tuple of (predictions, mmse) where each is a list of arrays with axes SC(Z)YX.