其他分享
首页 > 其他分享> > Transforms

Transforms

作者:互联网

一、

from PIL import Image
from torch.utils.tensorboard import SummaryWriter
from torchvision import transforms

# python的用法-》tensor数据类型
# 通过transforms.ToTensor去解决两个问题

# 2、为什么我们需要Tensor数据类型

img_path = "C:\\Users\\admin\Pictures\Camera Roll\jiaxiao.webp"
img = Image.open(img_path)
# writer用于tensorboard显示图片
writer = SummaryWriter('logs')

# 1、transsforms该如何使用
tensor_trans = transforms.ToTensor()
tensor_img = tensor_trans(img)

writer.add_image("Tensor_img", tensor_img)
writer.close()
View Code

二、在Terminal界面输入  tensorboard --logdir=logs

三、点击界面出现的地址

标签:tensor,img,writer,transforms,tensorboard,import,Transforms
来源: https://www.cnblogs.com/wangzhaojun1670/p/16157130.html