目录
torchvision.transforms是包含一系列常用图像变换方法的包,可用于图像预处理、数据增强等工作,但是注意它更适合于classification等对数据增强后无需改变图像的label的情况,对于Segmentation等对图像增强时需要同步改变label的情况可能不太实用,需要自己重新封装一下。
官方文档:https://pytorch.org/docs/stable/torchvision/transforms.html
1 torchvision.transforms下的具体操作
先来了解一下几个东西
1.1 ToTensor()
torchvision.transforms.ToTensor()
Convert a PIL Image or numpy.ndarray to tensor.
Converts a PIL Image or numpy.ndarray (H x W x C)(注意C(channel)的位置) in the range [0, 255] to a torch.FloatTenso