用os的join遍历图片文件时出错了
import os
import tensorflow as tf
with tf.Session() as sess:
softmax_tensor = sess.graph.get_tensor_by_name('final_result:0')
#遍历目录
for root,dirs,file in os.walk('data/train/'):
#载入图片
image_data = tf.gfile.FastGFile(os.path.join(root,file), 'rb').read()
predictions = sess.run(softmax_tensor,{'DecodeJpeg/contents:0': image_data})#图片格式是jpg格式
predictions = np.squeeze(predictions)#把结果转为1维数据
#打印图片路径及名称
image_path = os.path.join(root,file)
print(image_path)
报错信息:
File "D:\Anaconda3\envs\tensorflow-gpu\lib\genericpath.py", line 149, in _check_arg_types
(funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'list'
求大神帮帮忙吧 !
TypeError: join() argument must be str or bytes, not 'list',这个错误不是提示了吗,os.walk('data/train/'),你这个输出的file是list类型,os.path.join参数不能是list类型
菜鸟教程os.walk用法:http://www.runoob.com/python/...