Predictions

Main module for predictions.

This module contains generic predictions functions:

  • pred_single

  • pred

  • pred multiple

And interface predictions functions made for CLI:

  • pred_seg

  • pred_seg_eval

  • pred_seg_eval_single

biom3d.pred.pred(log: str | list[str], path_in: str, path_out: str, skip_preprocessing: bool = False) str[source]

Predict on all images in a collecion.

Parameters:

logstr or list of string

Path to the model/log directory or configuration.

path_instr

Path to collection containing input images.

path_outstr

Path to collection to save prediction outputs.

skip_preprocessingbool, default=False

If True, skips preprocessing step.

Returns:

str

Path to the output directory containing predictions.

biom3d.pred.pred_multiple(log: str | list[str], path_in: str, path_out: str, skip_preprocessing: bool = False) str[source]

Predict on multiple folders of images. DEPRECATED.

This method is deprecated because the default behavior of DataHandlers now supports multiple folder prediction.

Parameters:

Same as pred()

Returns:

Same as pred()

biom3d.pred.pred_seg(log: Path | str | list[str] = PosixPath('/home/docs'), path_in: Path | str = PosixPath('/home/docs'), path_out: Path | str = PosixPath('/home/docs'), skip_preprocessing: bool = False) None[source]

Run prediction on a folder of images using default paths.

Parameters:

logpathlib.Path, str or list of str, default=home directory

Path to the model or log directory.

path_inpathlib.Path or str, default=home directory

Path to collection containing images.

path_outpathlib.Path or str, default=home directory

Path to collection where predictions will be saved.

skip_preprocessingbool, default=False

If True, skips preprocessing step.

rtype:

None

biom3d.pred.pred_seg_eval(log: Path | str | list[str] = PosixPath('/home/docs'), path_in: Path | str = PosixPath('/home/docs'), path_out: Path | str = PosixPath('/home/docs'), path_lab: Path | str | None = None, eval_only: bool = False, skip_preprocessing: bool = False) None[source]

Run prediction on a folder of images and optionally evaluate segmentation (with dice).

Parameters:

logpathlib.Path, str or list of str, default=home directory

Path to the model or log directory.

path_inpathlib.Path or str, default=home directory

Path to collection containing images.

path_outpathlib.Path or str, default=home directory

Path to collection where predictions will be saved.

path_labpathlib.Path or str, optional

Path to collection containing ground-truth label masks for evaluation.

eval_onlybool, default=False

If True, skips prediction and runs evaluation only.

skip_preprocessingbool, default=False

If True, skips preprocessing step.

rtype:

None

biom3d.pred.pred_seg_eval_single(log: str | list[str], img_path: str, out_path: str, msk_path: str, skip_preprocessing: bool = False) None[source]

Run prediction on a single image and compute evaluation metric (dice) against mask.

Parameters:

logstr or list of str

Path to the model or log directory.

img_pathstr

Path to the input image file.

out_pathstr

Directory where prediction output will be saved.

msk_pathstr

Path to the ground-truth mask for evaluation.

skip_preprocessingbool, default=False

If True, skips preprocessing step.

Returns:

None

biom3d.pred.pred_single(log: str | list[str], img_path: str, out_path: str, skip_preprocessing: bool = False) tuple[int, str][source]

Predict segmentation or classification on a single image.

Parameters:

logstr or list of str

Path to the model/log directory or configuration.

img_pathstr

Path to the input image file.

out_pathstr

Directory where the prediction output will be saved.

skip_preprocessingbool, default=False

If True, skips preprocessing step.

Returns:

num_classes: int

Number of classes + 1 (the background)

path_out: str

Path to the saved mask output.