1. 一般代码:
from torchvision import transforms
transforms.Compose([transforms.Resize((300,300)),
transforms.CenterCrop(size=(224,224)),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
transforms.Normalize([0.485,0.456,0.406],[0.229,0.224,0.225])])
2. 推荐几个写的全的博客及官网文档
(1) https://www.cnblogs.com/ghgxj/p/14219097.html 张量化(ToTensor) 灰度化(Grayscale) 标准化(Normalize) 组合转换(Compose) 中心裁剪(CenterCrop) 边缘拓展(Pad) 随机裁剪(RandomCrop) 尺寸缩放(Resize) 随机旋转(RandomRotation) 水平翻转(RandomHorizontalFlip) 垂直翻转(RandomVerticalFlip) 色彩抖动(ColorJitter) 高斯模糊(GaussianBlur) 仿射变换(RandomAffine)(包含平移) (2) https://www.jianshu.com/p/3b67b31de8b3 (3) https://zhuanlan.zhihu.com/p/54527197 (4) https://pytorch.org/docs/stable/torchvision/transforms.html
|