【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 数据集的均值和标准差)
])
相关推荐
凉、介1 小时前
深入 QEMU Guest Agent:虚拟机内外通信的隐形纽带
c语言·笔记·学习·嵌入式·虚拟化
njsgcs2 小时前
SIMA2 论文阅读 Google 任务设定器、智能体、奖励模型
人工智能·笔记
云半S一3 小时前
pytest的学习过程
经验分享·笔记·学习·pytest
AI视觉网奇3 小时前
ue5.7 配置 audio2face
笔记·ue5
All The Way North-4 小时前
PyTorch从零实现CIFAR-10图像分类:保姆级教程,涵盖数据加载、模型搭建、训练与预测全流程
pytorch·深度学习·cnn·图像分类·实战项目·cifar-10·gpu加速
崎岖Qiu5 小时前
【OS笔记35】:文件系统的使用、实现与管理
笔记·操作系统·存储管理·文件系统·os
曦月逸霜6 小时前
离散数学-学习笔记(持续更新中~)
笔记·学习·离散数学
hunter14506 小时前
windows server AD域与CA部署证书
笔记
im_AMBER6 小时前
Leetcode 101 对链表进行插入排序
数据结构·笔记·学习·算法·leetcode·排序算法
laplace01236 小时前
# 第四章|智能体经典范式构建 —— 学习笔记(详细版)
笔记·学习