我正在做一个图像处理任务,我想连接两个网站的图片。为了连接,我先将图像转换为张量,然后将张量转换为PIL图像来显示它,但报错了。有人可以帮助我吗?这是我的代码:
import skimage.io as io
import torch
from torchvision import models, transforms
from PIL import Image
import matplotlib.pyplot as plt
from torchvision.transforms import ToPILImage
import numpy as np
from skimage import data_dir,io,color
coll1 = io.ImageCollection('F:\\code1/*.jpg')
coll2 = io.ImageCollection('F:\\code2/*.jpg')
a = torch.tensor(coll1)
print(a)
print(a.shape)
b = torch.tensor(coll2)
print(b)
print(b.shape)
c=torch.cat((a,b),1)
print(c.shape)
print(c)
img= transforms.ToPILImage()
img.show()
Run Code Online (Sandbox Code Playgroud)
这是错误代码:
回溯(最近一次调用最后一次):文件“F:/filelist.py”,第 39 行,在 img.show() AttributeError: 'ToPILImage' 对象没有属性 'show'