pytorch之Resize()函数

Posted zgqcn

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pytorch之Resize()函数相关的知识,希望对你有一定的参考价值。

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()函数的主要内容,如果未能解决你的问题,请参考以下文章

cv2.resize中的None是什么意思?

pytorch的Tensor的操作

Python图像resize前后颜色不一致问题

我的Android进阶之旅NDK开发之在C++代码中使用Android Log打印日志,打印出C++的函数耗时以及代码片段耗时详情

pytorch深度学习实践_p9_多分类问题_pytorch手写实现数字辨识

pytorch之transforms.Compose()函数理解