Pytorch
Transforms
- class ToPytorch(transpose_mask: bool = True, always_apply: bool = True, normalize: None | Sequence[float] = None, p=1.0)[source]
Bases:
BasicTransformConvert image and mask to torch.Tensor. The numpy HWDC image is converted to pytorch CDHW tensor. If the image is in HWD format (grayscale image), it will be converted to pytorch DHW tensor.
- Parameters:
transpose_mask (bool) – If True and an input mask has three spatial dimensions, this transform will transpose dimensions so the shape [height, width, depth, channel] becomes [channel, depth, height, width]. The latter format is a standard format for PyTorch Tensors. Default: True.
always_apply (bool) – Indicates whether this transformation should be always applied. Default: True.
p (float) – Probability of applying the transform. Default: 1.0.
- property targets: Dict[str, Callable]