I want to perform an image transformation using a transformation matrix in PyTorch. My previous code was implemented in TensorFlow, so I wonder if there is any PyTorch equivalent function for tfa.image.transform ?
Thank you.
I want to perform an image transformation using a transformation matrix in PyTorch. My previous code was implemented in TensorFlow, so I wonder if there is any PyTorch equivalent function for tfa.image.transform ?
Thank you.
I think you are looking for torch.nn.functional.grid_sample
to sample an image (or a 2D feature map) according to new spatial coordinates. When used in conjunction with torch.nn.functional.affine_grid
performs an affine spatial transformation of the input image / feature map.
Projective image transformations can be done using kornia library's
kornia.geometry.transform.warp_affine
function. The API maynot be a drop in replacement of tfa.image.transform. For details refer https://kornia.readthedocs.io/en/latest/geometry.transform.html#kornia-geometry-transformBelow is the image from kornia transformation.