我尝试使用os.listdir(directory)
和Keras读取图像:
import os
from PIL import Image
from keras.preprocessing import image
img_path = 'D:\folder\train'
images = [(img, label) for (img, label) in zip(label_train.Image[:5], label_train.Id[:5])]
fig, m_axs = plt.subplots(1, len(images), figsize = (20, 10))
#show the images and label them
for ii, c_ax in enumerate(m_axs):
c_ax.imshow(imread(os.path.join(img_path,images[ii][0])))
c_ax.set_title(images[ii][1])
我在此行收到错误:c_ax.imshow(imread(os.path.join(img_path,images[ii][0])))
错误消息Invalid argument: 'D:\\folder\train\\00001.jpg
。
我正在使用Python3。应该如何编辑代码?