参考网站:https://www.cnblogs.com/lantingg/p/9259840.html
import tensorflow as tf
from PIL import Image
if __name__ == '__main__':
train_name = 'D:\\python_work\\model_project\\dataset\\test\\sxs'
# # imagelist = os.listdir(train_name) # 读取images文件夹下所有文件的名字
# 显示图片
for filename in os.listdir(train_name):
# im为彩色图片,生成的numpy数组为三通道数组
print('filename:',filename)
im = Image.open(train_name + '\\' +filename)
# im.show() #生成图片
# im_array = np.array(im) #图片转换为 numpy 数组