【pytorch函数笔记】transforms的使用

接上篇:ToTensor()将图像转为tensor格式

用的不是很多,了解基础的就行了。

python 复制代码
transforms_train = torchvision.transforms.Compose([
    torchvision.transforms.ToPILImage(),
    # imagenet mean and std
    torchvision.transforms.RandomHorizontalFlip(p=0.5),  # 翻转概率的p=0.5
    torchvision.transforms.RandomAffine(degrees=10, shear=16),  # 对图像进行随机仿射变换,包括旋转、平移、缩放和剪切等。
    torchvision.transforms.ColorJitter(brightness=0.1, contrast=0.1, saturation=0.1, hue=0.1),
    # 对图像进行颜色抖动,包括亮度、对比度、饱和度和色调等方面的随机变化。
    # torchvision.transforms.RandomGrayscale(p=0.1),
    # not in the original paper
    torchvision.transforms.Resize((256, 256)),
    torchvision.transforms.RandomCrop((227, 227)),  # VGG16
    torchvision.transforms.ToTensor(),
    # torchvision.transforms.Normalize([0.4816, 0.4199, 0.3884], [0.2568, 0.2408, 0.2323]),
    torchvision.transforms.Normalize([0.485, 0.456, 0.406],
                                     [0.229, 0.224, 0.225])
    # :对张量进行标准化处理,其中 mean 和 std 是预先计算好的均值和标准差(此处使用的是 ImageNet 数据集的均值和标准差)
])
相关推荐
西岸行者4 天前
学习笔记:SKILLS 能帮助更好的vibe coding
笔记·学习
starlaky4 天前
Django入门笔记
笔记·django
勇气要爆发4 天前
吴恩达《LangChain LLM 应用开发精读笔记》1-Introduction_介绍
笔记·langchain·吴恩达
悠哉悠哉愿意4 天前
【单片机学习笔记】串口、超声波、NE555的同时使用
笔记·单片机·学习
勇气要爆发4 天前
吴恩达《LangChain LLM 应用开发精读笔记》2-Models, Prompts and Parsers 模型、提示和解析器
android·笔记·langchain
qianshanxue114 天前
计算机操作的一些笔记标题
笔记
土拨鼠烧电路4 天前
笔记11:数据中台:不是数据仓库,是业务能力复用的引擎
数据仓库·笔记
土拨鼠烧电路4 天前
笔记14:集成与架构:连接孤岛,构建敏捷响应能力
笔记·架构
烟花落o4 天前
栈和队列的知识点及代码
开发语言·数据结构·笔记·栈和队列·编程学习