15、调整尺寸 transforms.Resize()
transforms.Resize(size, interpolation=<InterpolationMode.BILINEAR: 'bilinear'>, max_size=None, antialias=None) antialias :如果img是PIL图像,则忽略该标志,并始终为True。如果img是张量,则默认情况下该标志为Falseimport torchvision.t
·
transforms.Resize(size, interpolation=<InterpolationMode.BILINEAR: 'bilinear'>, max_size=None, antialias=None) antialias :如果img是PIL图像,则忽略该标志,并始终为True。如果img是张量,则默认情况下该标志为False
import torchvision.transforms as transform
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
import torch
img0=Image.open('lin-xiao-xun-000003.jpg')
img1=transform.Resize((128,128))(img0)
img2=transform.Resize((256,256))(img0)
axs = plt.figure().subplots(1, 3)
axs[0].imshow(img0);axs[0].set_title('src');axs[0].axis('off')
axs[1].imshow(img1);axs[1].set_title('128x128');axs[1].axis('off')
axs[2].imshow(img2);axs[2].set_title('256x256');axs[2].axis('off')
plt.show()
实图演示:
更多推荐
已为社区贡献4条内容
所有评论(0)