【发布时间】:2018-06-22 08:28:55
【问题描述】:
我创建了一个函数,可以将我的所有图像添加到列表中。 函数如下:
def load_data(train_path,test_path):
X_train=[]
X_test=[]
for i in os.listdir(train_path):
X_train.append(i)
for j in os.listdir(test_path):
X_test.append(j)
return X_train,X_test
当我尝试使用索引 X_train[10] 显示图像时,我得到一个文件未找到错误。
img=mpimg.imread(X_train[10])
imgplot = plt.imshow(img)
plt.show()
错误如下:
FileNotFoundError Traceback (most recent call last)
<ipython-input-7-869e21232029> in <module>()
----> 1 img=mpimg.imread(X_train[10])
2 imgplot = plt.imshow(img)
3 plt.show()
/Users/ViditShah/anaconda/envs/dl/lib/python3.6/site-packages/matplotlib/image.py in imread(fname, format)
1295 return handler(fd)
1296 else:
-> 1297 with open(fname, 'rb') as fd:
1298 return handler(fd)
1299 else:
FileNotFoundError: [Errno 2] No such file or directory: 'scan_0001001.png'
【问题讨论】:
标签: matplotlib python-3.5