How can I rotate random degree in 4D tensor (B,C,H,W)? Thanks
1 Like
4D tensor, not PIL.Image.
I typically use scipy’s rotate function:
https://docs.scipy.org/doc/scipy-0.16.1/reference/generated/scipy.ndimage.interpolation.rotate.html
Unfortunately it’s not very fast and you have to apply it on a numpy tensor, i.e. before you convert it to a pytorch tensor.
What about this:
The function torch.rot90(tensor, number_of_times_of_rotation:int, rotate_axis:list) is available