pytorch之Resize()函数
生活随笔
收集整理的這篇文章主要介紹了
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()函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: BZOJ1834 [ZJOI2010]n
- 下一篇: iOS网络编程开发-数据加密