简体   繁体   English

PyTorch 相当于 tfa.image.transform 的 function

[英]PyTorch equivalent function for tfa.image.transform

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 ?我想在 PyTorch 中使用变换矩阵执行图像变换。我之前的代码是在 TensorFlow 中实现的,所以我想知道是否有任何 PyTorch 等效于 tfa.image.transform 的function

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.我认为您正在寻找torch.nn.functional.grid_sample以根据新的空间坐标对图像(或 2D 特征图)进行采样。 When used in conjunction with torch.nn.functional.affine_grid performs an affine spatial transformation of the input image / feature map.当与 torch.nn.functional.affine_grid 结合使用时,对输入图像/特征torch.nn.functional.affine_grid执行仿射空间变换。

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.投影图像变换可以使用 kornia 库的kornia.geometry.transform.warp_affine function 完成。API 可能不是 tfa.image.transform 的替代品。 For details refer https://kornia.readthedocs.io/en/latest/geometry.transform.html#kornia-geometry-transform有关详细信息,请参阅https://kornia.readthedocs.io/en/latest/geometry.transform.html#kornia-geometry-transform

Below is the image from kornia transformation.下面是来自 kornia 变换的图像。

来自 kornia 的仿射变换

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM