from PIL import Image from torch.utils.tensorboard import SummaryWriter from torchvision import transforms writer = SummaryWriter("logs") img = Image.open("images/outside.jpg") trans_totensor = transforms.ToTensor() img_tensor = trans_totensor(img) writer.add_image("ToTensor", img_tensor) # normalize trans_norm = transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5]) img_norm = trans_norm(img_tensor) writer.add_image("Normalize", img_norm, 2) #resize print(img.size) trans_resize = transforms.Resize((512, 512)) img_resize = trans_resize(img_tensor) writer.add_image("resize", img_resize, 2) writer.close()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)