Skip to content

Transforms (pytorch.transforms)

class albumentations.pytorch.transforms.ToTensorV2 (transpose_mask=False, always_apply=True, p=1.0) [view source on GitHub]

Converts images/masks to PyTorch Tensors, inheriting from BasicTransform. Supports images in numpy HWC format and converts them to PyTorch CHW format. If the image is in HW format, it will be converted to PyTorch HW.


transpose_mask (bool): If True, transposes 3D input mask dimensions from `[height, width, num_channels]` to
    `[num_channels, height, width]`.
always_apply (bool): Indicates if this transformation should be always applied. Default: True.
p (float): Probability of applying the transform. Default: 1.0.