这篇分类总结比较完整
数据处理是模型训练之前的必备的一步,在Pytorch的TORCHVISION.TRANSFORMS.TRANSFORMS包含下面一下图像处理的函数(transform中的函数主要是处理PIL格式图像):

  1. Compose
Args:transforms (list of ``Transform`` objects): list of transforms to compose.

"Composes several transforms together” 组合几种不同的变形方法

  1. ToTensor

Convert a PIL Image or numpy.ndarray to tensor. Converts a PIL Image or numpy.ndarray (H x W x C) in the range
[0, 255] to a torch.FloatTensor of shape (C x H x W) in the range [0.0, 1.0]。将PIL图像或者numpy.ndarry类型数据转成tensor.

  1. ToPILImage

Convert a tensor or an ndarray to PIL Image.
Converts a torch.*Tensor of shape C x H x W or a numpy ndarray of shape H x W x C to a PIL Image while preserving the value range.

  1. Normalize 有参数(mean,std)
    处理的数据类型是tensor类型

Normalize a tensor image with mean and standard deviation.

Args:mean (sequence): Sequence of means for each channel.std (sequence): Sequence of standard deviations for each channel.

Given mean: (M1,...,Mn) and std: (S1,..,Sn) for n channels, this transform will normalize each channel of the input torch.*Tensor i.e. input[channel] = (input[channel] - mean[channel]) / std[channel]

  1. Resize

Resize the input PIL Image to the given size,默认采用PIL.Image.BILINEAR插值法。

Args:size (sequence or int): Desired output size. If size is a sequence like(h, w), output size will be matched to this. If size is an int,smaller edge of the image will be matched to this number.i.e, if height > width, then image will be rescaled to(size * height / width, size)interpolation (int, optional): Desired interpolation. Default is``PIL.Image.BILINEAR``
  1. Scale

推荐换成Resize

  1. CenterCrop 参数(目标尺寸)

Crops the given PIL Image at the center
Args:
size (sequence or int): Desired output size of the crop. If size is an
int instead of sequence like (h, w), a square crop (size, size) is
made

  1. Pad

Pad the given PIL Image on all sides with the given “pad” value
Args:
padding (int or tuple):
fill (int or tuple):
padding_mode (str):

  1. Lambda

Apply a user-defined lambda as a transform
Args:
lambd (function): Lambda/function to be used for transform.

  1. RandomTransforms

Base class for a list of transformations with randomness
Args:
transforms (list or tuple): list of transformations

  1. RandomApply

Apply randomly a list of transformations with a given probability
Args:
transforms (list or tuple): list of transformations
p (float): probability

  1. RandomOrder

Apply a list of transformations in a random order

  1. RandomChoice

Apply single transformation randomly picked from a list

  1. RandomCrop

Crop the given PIL Image at a random location.

Args:size (sequence or int)padding (int or sequence, optional):pad_if_needed (boolean)fillpadding_mode
  1. RandomHorizontalFlip

Horizontally flip the given PIL Image randomly with a given probability.

 Args:p (float): probability of the image being flipped. Default value is 0.5
  1. RandomVerticalFlip

Verticallly flip the given PIL Image randomly with a given probability.

 Args:p (float): probability of the image being flipped. Default value is 0.5
  1. RandomPerspective

Performs Perspective transformation of the given PIL Image randomly with a given probability.

  1. RandomResizedCrop

Crop the given PIL Image to random size and aspect ratio

  1. RandomSizedCrop

废弃

  1. FiveCrop

Crop the given PIL Image into four corners and the central crop

  1. TenCrop

Five Crop后翻转(默认是水平翻转)

  1. LinearTransformation

Transform a tensor image with a square transformation matrix and a mean_vector computed
offline

  1. ColorJitter

Randomly change the brightness, contrast and saturation of an image.
args:brightness=0, contrast=0, saturation=0, hue=0

  1. RandomRotation

Rotate the image by angle
args:degrees, resample=False, expand=False, center=None

  1. RandomAffine

Random affine transformation of the image keeping center invariant
degrees, translate=None, scale=None, shear=None, resample=False, fillcolor=0

  1. Grayscale

Convert image to grayscale.
args:num_output_channels=1

  1. RandomGrayscale

Randomly convert image to grayscale with a probability of p (default 0.1)

Pytorch中图像预处理相关函数相关推荐

  1. 关于MNN中图像预处理

    MNN工程化中,首先遇到图像预处理,其中要做的是对图像归一化,这里不需要我们自己用代码实现,MNN自动帮我们处理,代码如下,根据MNN回复,处理公式是 dst = (img - mean) * nor ...

  2. 深度学习中图像预处理均值

    图像中的均值,均方差等名字解释 均值 表示信号中直流分量的大小,一般用E(x)表示,其公式为: 对于高斯白噪声而言,其均值为0. 均方值 表示信号平方后的均值,一般用E(x^2)表示,一般是用来表示信 ...

  3. PyTorch框架学习六——图像预处理transforms(二)

    PyTorch框架学习六--图像预处理transforms(二) (续)二.transforms的具体方法 4.图像变换 (1)尺寸变换:transforms.Resize() (2)标准化:tran ...

  4. PyTorch框架学习五——图像预处理transforms(一)

    PyTorch框架学习五--图像预处理transforms(一) 一.transforms运行机制 二.transforms的具体方法 1.裁剪 (1)随机裁剪:transforms.RandomCr ...

  5. pytorch —— 图像预处理模块(Transforms)

    transforms运行机制 torchvision是pytorch的计算机视觉工具包,在torchvision中有三个主要的模块: torchvision.transforms,常用的图像预处理方法 ...

  6. PyTorch中的数据输入和预处理

    文章目录 PyTorch中的数据输入和预处理 数据载入类 映射类型的数据集 torchvision工具包的使用 可迭代类型的数据集 总结 PyTorch中的数据输入和预处理 数据载入类 在使用PyTo ...

  7. PyTorch系列入门到精通——图像预处理transforms

    PyTorch系列入门到精通--图像预处理transforms

  8. pytorch 图像预处理之减去均值,除以方差

    在使用 torchvision.transforms进行数据处理时我们经常进行的操作是: transforms.Normalize((0.485,0.456,0.406), (0.229,0.224, ...

  9. Pytorch中CNN图像回归问题预测值都一样

    ** Pytorch中CNN图像回归问题预测值都一样 ** 上网也查阅了许多资料,然后对比各种方法都试了一遍,归结为以下几点: 1.出现预测值都一样的情况,一般都是在某一层梯度消失了,然后导致输入到下 ...

最新文章

  1. 【Qt】调用Python函数:无参数、单个参数、多个参数、数组参数
  2. 作用c语言算圆的周长,C语言入门级代码 输入圆的半径求出圆的周长及面积
  3. IntelliJ IDEA 2019.3发布,饱受性能诟病的2019.2版本终于成为过去式
  4. 4.1 - 并发编程 - 进程练习题
  5. 统计学习/机器学习常用小知识
  6. vue --- 使用vue-router获取带参数的路由
  7. Keras-3 Keras With Otto Group
  8. csv文件怎么转成excel_Python操作Excel文件(1):花式大师pyexcel
  9. CentOS 7部署 Ceph分布式存储架构
  10. zabbix4.0 mysql本地数据库迁移到腾讯云数据库
  11. Python库安装注意事项
  12. 迭代器:斐波那契数列
  13. windows安装talib
  14. linux系统超好用的QQ
  15. bootice.exe linux 启动盘,BOOTICE(无损)制作启动盘-适用于移动硬盘与U盘(支持BIOS及EFI启动)...
  16. Java —— EJB 到底是什么
  17. Docker的深入浅出(入门新手篇)
  18. 网页制作之JavaScript篇
  19. 虚拟人实时互动之基于Android驱动表情随动
  20. PHP中的opcode

热门文章

  1. php string to array,php string转数组的方法
  2. mac鼠标和触控板滚动方向_Apple 无线鼠标、键盘或触控板各型号的Mac系统要求和区别...
  3. access开发精要(3)-子数据表
  4. C指针原理(39)-GLIB
  5. 新书首发 | 《机器学习 公式推导与代码实现》正式出版!(文末送书)
  6. 【NLP】面向对话的机器阅读理解任务(Dialogue MRC)相关论文整理
  7. 推荐特征筛选偷懒神器-M3USelector
  8. 真相了!算法工程师的一天
  9. 人脸口罩检测现开源PyTorch、TensorFlow、MXNet等全部五大主流深度学习框架模型和代码...
  10. REALM后续:最近邻搜索,MIPS,LSH和ALSH