PyTorch: how to use torchvision.transforms.AugMIx with torch.float32?

Hello!

I am trying to apply data augmentation in image dataset by using torchvision.transforms.AugMIx, but I have the following error:

  File "/vol/ideadata/oc69ubiw/conda/env/lib/python3.10/site-packages/torchvision/transforms/functional_tensor.py", line 813, in posterize
raise TypeError(f"Only torch.uint8 image tensors are supported, but found {img.dtype}")

TypeError: Only torch.uint8 image tensors are supported, but found torch.float32

I tried to convert it to int, but I have another error:

  File "/vol/ideadata/oc69ubiw/conda/env/lib/python3.10/site-packages/torchvision/transforms/functional_tensor.py", line 83, in convert_image_dtype
raise RuntimeError(msg)

RuntimeError: The cast from torch.float32 to torch.int32 cannot be performed safely.

Any help is appreciated!

This might help you: PyTorch: how to use torchvision.transforms.AugMIx with torch.float32?