ToDtype

class torchaug.transforms.ToDtype(dtype, scale=False)[source]

Converts the input to a specific dtype, optionally scaling the values for images or videos.

Note

ToDtype(dtype, scale=True) is the recommended replacement for ConvertImageDtype(dtype).

Parameters:
  • dtype (Union[dtype, Dict[Union[Type, str], Optional[dtype]]]) – The dtype to convert to. If a torch.dtype is passed, e.g. torch.float32, only images and videos will be converted to that dtype: this is for compatibility with torchvision.transforms.v2.ConvertImageDtype. A dict can be passed to specify per-ta_tensor conversions, e.g. dtype={ta_tensors.Image: torch.float32, ta_tensors.Mask: torch.int64, "others":None}. The “others” key can be used as a catch-all for any other ta_tensor type, and None means no conversion.

  • scale (bool, optional) – Whether to scale the values for images or videos. Default: False