脚本专栏 
首页 > 脚本专栏 > 浏览文章

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

(编辑:jimmy 日期: 2024/5/9 浏览:3 次 )

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
上一篇:浅谈python输出列表元素的所有排列形式
下一篇:python GUI库图形界面开发之PyQt5 UI主线程与耗时线程分离详细方法实例
一句话新闻
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网