怎么在pytorch中使用Resize()函数

发布时间:2021-03-20 16:35:57 作者:Leah
来源:亿速云 阅读:1019

这篇文章将为大家详细讲解有关怎么在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()函数就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

推荐阅读:
  1. Windows下PyTorch开发环境安装教程
  2. index_select()函数怎么在pytorch中使用

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

pytorch resize

上一篇:怎么在php中使用fputcsv导出大数据

下一篇:php中与html标签相关的函数有哪些

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》