我想使用 Pytorch 数据加载器显示一些图像及其各自的标签。
然而显示的图像是非常小的网格。
如何增加每个图像的宽度,使其更大。
这是我使用的代码:
mean_nums = [0.485, 0.456, 0.406]
std_nums = [0.229, 0.224, 0.225]
def imshow(inp, title=None):
"""Imshow for Tensor."""
inp = inp.numpy().transpose((1, 2, 0))
mean = np.array(mean_nums)
std = np.array(std_nums)
inp = std * inp + mean
inp = np.clip(inp, 0, 1)
plt.imshow(inp)
if title is not None:
plt.title(title)
plt.pause(0.001) # pause a bit so that plots are updated
# Get a batch of training data
inputs, classes = next(iter(dataloaders['trainLoader']))
# Make a grid from batch
out = torchvision.utils.make_grid(inputs,nrow=2)
imshow(out, title=[image_datasets['train'].classes[x] for x in classes])
狐的传说
千万里不及你
相关分类