Resize函数用于对PIL图像的预处理,它的包在:
from torchvision.transforms import Compose, CenterCrop, ToTensor, Resize
使用如:
def input_transform(crop_size, upscale_factor): return Compose([ CenterCrop(crop_size), Resize(crop_size // upscale_factor), ToTensor(), ])
而Resize函数有两个参数,
CLASS torchvision.transforms.Resize(size, interpolation=2)
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
size : 获取输出图像的大小
interpolation : 插值,默认的 PIL.Image.BILINEAR, 一共有4中的插值方法
Image.BICUBIC,PIL.Image.LANCZOS,PIL.Image.BILINEAR,PIL.Image.NEAREST
本文介绍了PyTorch中的Resize函数,该函数用于PIL图像预处理,用于调整图像大小。Resize函数接受两个参数:输出图像的尺寸size和插值方法interpolation,默认采用PIL.Image.BILINEAR。文章探讨了四种不同的插值方法。
1872

被折叠的 条评论
为什么被折叠?



