【问题标题】:i have been trying to print a images ,where images is in another folder and the id of image is in another csv folder我一直在尝试打印图像,其中图像在另一个文件夹中,图像的 ID 在另一个 csv 文件夹中
【发布时间】:2021-06-02 05:46:55
【问题描述】:
train_image = []
for i in tqdm(range(a.shape[0])):
    img = image.load_img('C:\Users\Acer\Pictures\archive(1)\vinbigdata

\train'+a['image_id'][i]+'.png',target_size=(400,400,3))
    img = image.img_to_array(img)
    img = img/255
    train_image.append(img)
X = np.array(train_image)
#this the code.  a is the csv file containing ids of image
and the error that i am getting is
 File "<ipython-input-37-556a7dc6abfa>", line 3
    img = image.load_img('C:\Users\Acer\Pictures\archive(1)\vinbigdata\train'+a['image_id'][i]+'.png',target_size=(400,400,3))
                        ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

【问题讨论】:

    标签: python image visualization detection


    【解决方案1】:
    'C:\\Users\\Acer\\Pictures\\archive(1)\\vinbigdata
    
    \\train'+a['image_id'][i]+'.png',target_size=(400,400,3))
    

    在你的路径中再添加一个\

    或 添加r 以制作原始字符串

    r'C:\Users\Acer\Pictures\archive(1)\vinbigdata
    
    \train'+a['image_id'][i]+'.png'
    

    \Uxxxxxxxx 具有 32 位十六进制值 xxxxxxxx 的字符 您已经 'C:\Users .Python 将其视为转义字符

    【讨论】:

      猜你喜欢
      • 2021-03-14
      • 1970-01-01
      • 1970-01-01
      • 2022-10-07
      • 2013-03-25
      • 1970-01-01
      • 2015-04-21
      • 2018-03-18
      • 1970-01-01
      相关资源
      最近更新 更多