码迷,mamicode.com
首页 > 其他好文 > 详细

pytorch之Resize()函数

时间:2019-05-26 16:09:34      阅读:2657      评论:0      收藏:0      [点我收藏+]

标签:ike   imp   inpu   line   tensor   res   出图   pos   sequence   

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()函数

标签:ike   imp   inpu   line   tensor   res   出图   pos   sequence   

原文地址:https://www.cnblogs.com/zgqcn/p/10926192.html

(2)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!