首页 > 解决方案 > 枕头没有从本地系统加载图像 - 没有这样的文件或目录:'home/hp/DeepLearning/images/picasso.jpg'

问题描述

imsize = 512 if torch.cuda.is_available() else 128 

loader = transforms.Compose([transforms.Resize(imsize),transforms.ToTensor()])

def image_loader(image_name):
    image = Image.open(image_name)
    image = loader(image).unsqueeze(0)
    return image.to(device, torch.float)
style_img = image_loader("home/hp/DeepLearning/images/picasso.jpg")
content_img = image_loader("home/hp/DeepLearning/images/picasso.jpg")
assert style_img.size() == content_img.size(),\"we need to import style and content images of the same size"

当我尝试从本地系统加载图像时,它显示错误。我努力了os.path.abspath()

标签: python-3.xpytorchpython-imaging-libraryubuntu-18.04

解决方案


推荐阅读