gingerbread.user_package_files package#
Subpackages#
Submodules#
gingerbread.user_package_files.central_processing module#
- class gingerbread.user_package_files.central_processing.CentralProcessing#
Bases:
CPNeoTemplate
Central processing unit for preprocessing, postprocessing, predicting and training.
- Parameters:
args (argparse.Namespace) – The arguments for the central processing unit.
Warning
Remember to include methods for preprocessing, postprocessing, predict_step or you will get an error.
- postprocess(data: ndarray, extras: dict[str, Any] | None = {}) ndarray #
Postprocess the data after training/val/test/predict
- Parameters:
data (np.ndarray) – the data to be postprocessed (e.g image, Size [C, D, H, W]). We remove batch in the backend from predict.
extras (dict) –
additional arguments for preprocessing such as resolution information etc. If provided, explain in depth in the docstring of the input and the input type. Example of extras:
resolution [list]: resolution of the image, e.g. {“resolution”: [1.0, 1.0, 1.0]}
Important
Extras dictionary is something the researchers need to define. There has to be a proper explanation of what the extras dictionary is and what it contains, as shown in the example above.
- Returns:
the postprocessed data
- Return type:
np.ndarray
- predict_step(data: ndarray, model: ModelInput) ndarray #
Predict step function.
- Parameters:
data (np.ndarray) – data input (e.g image, Size [C, D, H, W]) ( Hence, you need to unsqueeze the data to make it [1, C, D, H, W])
- Returns:
Predictions, Must be of size [1, C, D, H, W]) the reason for this is that we might use monte carlo prediction.
- Return type:
np.ndarray
- preprocess(data: ndarray, extras: dict[str, Any] | None = {}) ndarray #
Preprocess the data before training/val/test/predict.
- Parameters:
data (np.ndarray) – the data to be preprocessed (e.g image, Size [C, D, H, W])
extras (dict) –
additional arguments for preprocessing such as resolution information etc. If provided, explain in depth in the docstring of the input and the input type. Example of extras:
resolution [list]: resolution of the image, e.g. {“resolution”: [1.0, 1.0, 1.0]}
Important
Extras dictionary is something the researchers need to define. There has to be a proper explanation of what the extras dictionary is and what it contains, as shown in the example above.
- Returns:
the preprocessed data
- Return type:
np.ndarray