当前位置:网站首页>图像变换 torchvision.transforms 笔记

图像变换 torchvision.transforms 笔记

2022-06-11 19:21:00 秋山丶雪绪

1. Transforms on PIL Image

CenterCrop 中心裁剪

torchvision.transforms.CenterCrop(size)
参数:
size: (h,w) or int

ColorJitter 随机改变亮度、对比度、饱和度

torchvision.transforms.ColorJitter(brightness=0, contrast=0, saturation=0, hue=0)
参数:
brightness: float or (min,max), 亮度, [max(0, 1 - brightness), 1 + brightness] or [min, max], 非负数
contrast: float or (min,max), 对比度, [max(0, 1 - contrast), 1 + contrast] or [min, max], 非负数
saturation: float or (min,max), 饱和度, [max(0, 1 - saturation), 1 + saturation] or [min, max], 非负数
hue: float or (min,max), 色相, [-hue, hue] or [min, max], 0 <= hue <= 0.5 or -0.5 <= min <= max <= 0.5

RandomResizedCrop 随机大小和长宽比裁剪并resize

torchvision.transforms.RandomResizedCrop(size, scale=(0.08, 1.0), ratio=(0.75, 1.33), interpolation=2)
参数:
size: 最终大小
scale: 裁剪原始图像尺寸
ratio: 长宽比
interpolation: 插值方法,默认 PIL.Image.BILINEAR

RandomHorizontalFlip 随机水平翻转

torchvision.transforms.RandomHorizontalFlip(p=0.5)
参数:
p: float

RandomApply 随机应用一系列变换

torchvision.transforms.RandomApply(transforms, p=0.5)
参数:
transforms: list or tuple
p: float

RandomGrayscale 随机灰度化

torchvision.transforms.RandomGrayscale(p=0.1)
参数:
p: float
注:
p 概率变为灰度图,1-p 概率不变;
输入图为1通道,灰度图为1通道;输入图为3通道,灰度图为3通道,r == g == b。

原网站

版权声明
本文为[秋山丶雪绪]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_43605641/article/details/108943487