PyTorch equivalent function for tfa.image.transform

300 views Asked by At

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.

2

There are 2 answers

0
MSS On BEST ANSWER

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-transform

Below is the image from kornia transformation.

Affine transformation from kornia

0
Shai On

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.