2

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 Answers2

1

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.

Shai
  • 111,146
  • 38
  • 238
  • 371
1

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

MSS
  • 3,306
  • 1
  • 19
  • 50