PlantSeg CNN Predictions
plantseg.predictions.functional.predictions.unet_predictions(raw: np.ndarray, model_name: Optional[str], model_id: Optional[str], patch: Tuple[int, int, int] = (80, 160, 160), single_batch_mode: bool = True, device: str = 'cuda', model_update: bool = False, disable_tqdm: bool = False, handle_multichannel: bool = False, config_path: Optional[Path] = None, model_weights_path: Optional[Path] = None, **kwargs) -> np.ndarray
Generate predictions from raw data using a specified 3D U-Net model.
This function handles both single and multi-channel outputs from the model, returning appropriately shaped arrays based on the output channel configuration.
Parameters:
-
raw
(ndarray
) –Raw input data as a 3D array of shape (Z, Y, X).
-
model_name
(str
) –The name of the model to use.
-
patch
(Tuple[int, int, int]
, default:(80, 160, 160)
) –Patch size for prediction. Defaults to (80, 160, 160).
-
single_batch_mode
(bool
, default:True
) –Whether to use a single batch for prediction. Defaults to True.
-
device
(str
, default:'cuda'
) –The computation device ('cpu', 'cuda', etc.). Defaults to 'cuda'.
-
model_update
(bool
, default:False
) –Whether to update the model to the latest version. Defaults to False.
-
disable_tqdm
(bool
, default:False
) –If True, disables the tqdm progress bar. Defaults to False.
-
handle_multichannel
(bool
, default:False
) –If True, handles multi-channel output properly. Defaults to False.
Returns:
-
pmap
(ndarray
) –The predicted boundaries as a 3D (Z, Y, X) or 4D (C, Z, Y, X) array, normalized between 0 and 1.
Source code in plantseg/predictions/functional/predictions.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|