0
我是tensorflow的新手,我有张量(字符串类型),其中存储了我想用于训练模型的所有必需图像的图像路径。如何从tensorflow中的字符串张量读取数据集名称
问题:如何读取张量进行排队然后进行批处理。
我的做法是:是给我的错误
img_names = dataset['f0']
file_length = len(img_names)
type(img_names)
tf_img_names = tf.stack(img_names)
filename_queue = tf.train.string_input_producer(tf_img_names, num_epochs=num_epochs, shuffle=False)
wd=getcwd()
print('In input pipeline')
tf_img_queue = tf.FIFOQueue(file_length,dtypes=[tf.string])
col_Image = tf_img_queue.dequeue(filename_queue)
### Read Image
img_file = tf.read_file(wd+'/'+col_Image)
image = tf.image.decode_png(img_file, channels=num_channels)
image = tf.cast(image, tf.float32)/255.
image = tf.image.resize_images(image,[image_width, image_height])
min_after_dequeue = 100
capacity = min_after_dequeue + 3 * batch_size
image_batch, label_batch = tf.train.batch([image, onehot], batch_size=batch_size, capacity=capacity, allow_smaller_final_batch = True, min_after_dequeue=min_after_dequeue)
错误:类型错误:预期的字符串或缓冲区”
我不知道如果我的做法是正确与否
如果我已阅读使用numpy的'genfromtxt' csv文件就像 'csv_file = np.genfromtxt(args.dataset,分隔符= '',skip_header = 1,usecols =(0,1,2,3 ,4,5),dtype = None) 如何使用string_input_producer排队和批处理文件.... –
您不必使用numpy阅读。使用tf.TextLineReader()并将每行解析为所需内容并加载图像。看看这个:https://stackoverflow.com/questions/37091899/how-to-actually-read-csv-data-in-tensorflow – hars