仅作为记录,大佬请跳过。
import torchvision.transforms as transformsunloader = transforms.ToPILImage()
def tensor_to_PIL(tensor):image = tensor.cpu().clone()image = image.squeeze(0)image = unloader(image)return imageimg_t_i=tensor_to_PIL(img_t)
感谢大佬博主文章:传送门