将tensor转换为numpy
import tensor
import numpy as np
def tensor2img(tensor, out_type=np.uint8, min_max=...(0, 1)):
''' Converts a torch Tensor into an image Numpy array Input: 4D(B,(3/1),H,W), 3D(C,H,W), or...img_np = np.transpose(img_np[[2, 1, 0], :, :], (1, 2, 0)) # HWC, BGR
elif n_dim == 3:
img_np = tensor.numpy...Unlike matlab, numpy.unit8() WILL NOT round by default.
return img_np.astype(out_type)
版权声明:本文内容由互联网用户自发贡献...如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。