Vision data
Prediction to mask
pred_to_multiclass_mask
def pred_to_multiclass_mask(
pred:Tensor
)->Tensor:
Apply Softmax on the predicted tensor to rescale the values in the range [0, 1] and sum to 1. Then apply argmax to get the indices of the maximum value of all elements in the predicted Tensor.
Args: pred: [C,W,H,D] activation tensor.
Returns: Predicted mask.
batch_pred_to_multiclass_mask
def batch_pred_to_multiclass_mask(
pred:Tensor
)->(<class 'torch.Tensor'>, <class 'int'>):
Convert a batch of predicted activation tensors to masks.
Args: pred: [B, C, W, H, D] batch of activations.
Returns: Tuple of batch of predicted masks and number of classes.
pred_to_binary_mask
def pred_to_binary_mask(
pred:Tensor
)->Tensor:
Apply Sigmoid function that squishes activations into a range between 0 and 1. Then we classify all values greater than or equal to 0.5 to 1, and the values below 0.5 to 0.
Args: pred: [B, C, W, H, D] or [C, W, H, D] activation tensor
Returns: Predicted binary mask(s).
MedDataBlock
def MedDataBlock(
blocks:list=None, dl_type:TfmdDL=None, getters:list=None, n_inp:int | None=None, item_tfms:list=None,
batch_tfms:list=None, apply_reorder:bool=False, target_spacing:(<class 'int'>, <class 'list'>)=None,
kwargs:VAR_KEYWORD
):
Container to quickly build dataloaders.
TransformBlock for segmentation
MedMaskBlock
def MedMaskBlock(
):
Create a TransformBlock for medical masks.
MedImageDataLoaders
def MedImageDataLoaders(
loaders:VAR_POSITIONAL, # `DataLoader` objects to wrap
path:str | Path='.', # Path to store export objects
device:NoneType=None, # Device to put `DataLoaders`
):
Higher-level MedDataBlock API.