我试图使用kornia.geometry.transform.rotate函数,在Python中,以任意角度旋转一个PyTorch张量。然而,如果我做一个简单的90度旋转,得到的张量看起来并不是完全旋转的。
下面是一些示例代码:
import torch
from kornia.geometry.transform import rotate
import matplotlib.pyplot as plt
a = torch.ones((1,64,64))
a[0,:,2] += 1
angle = torch.tensor([90])
c = rotate(a,angle)
plt.figure()
plt.subplot(121)
plt.imshow(a[0].detach().numpy())
plt.subplot(122)
plt.imshow(c[0].detach().numpy())以及轮调前后的结果:

我是不是因为张量太粗而忽略了一个微妙之处,这会引起插值问题,或者用一个细粒度的张量来缓解一些问题?
事先非常感谢!
我正在使用的Note:
发布于 2020-07-06 15:07:42
要使用科尼亚,可以使用班级。
下面是将所有张量在一个小批量中旋转45度的例子:
import kornia as tgm
# set the rotation angles - assume batch size is N;
angle = torch.tensor([45]*N).cuda()
# do the rotation:
tensor_rotated = tgm.Rotate(angle)(tensor_input)现在唯一要提醒的是,它看起来超慢..。
希望这能有所帮助!
https://stackoverflow.com/questions/61076613
复制相似问题