前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >pytorch之Resize()函数具体使用详解

pytorch之Resize()函数具体使用详解

作者头像
砸漏
发布2020-11-05 11:12:58
2.8K0
发布2020-11-05 11:12:58
举报
文章被收录于专栏:恩蓝脚本

Resize函数用于对PIL图像的预处理,它的包在:

代码语言:javascript
复制
from torchvision.transforms import Compose, CenterCrop, ToTensor, Resize

使用如:

代码语言:javascript
复制
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中的插值方法

代码语言:javascript
复制
Image.BICUBIC,PIL.Image.LANCZOS,PIL.Image.BILINEAR,PIL.Image.NEAREST

到此这篇关于pytorch之Resize()函数具体使用详解的文章就介绍到这了,更多相关pytorch Resize() 内容请搜索ZaLou.Cn以前的文章或继续浏览下面的相关文章希望大家以后多多支持ZaLou.Cn!

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020-09-11 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档