如何检查string_input_producer读取的文件名数量?根据输入数据的大小,将执行不同的操作,所以我需要知道将读取或读取多少图像。tensorflow获取string_input_producer的大小
下面的代码不告诉我有多少图片我已阅读或即将阅读。
import tensorflow as tf
import matplotlib.pyplot as plt
# Make a queue of file names including all the JPEG images files in the relative image directory.
filename_queue = tf.train.string_input_producer(tf.train.match_filenames_once("./MNIST_data/*.png"))
reader = tf.WholeFileReader()
key, value = reader.read(filename_queue)
image = tf.image.decode_png(value) # use png or jpg decoder based on your files.
num_preprocess_threads = 1
min_queue_examples = 256
batch_size=2;
images = tf.train.shuffle_batch([image], batch_size, min_queue_examples + 3 * batch_size, num_threads=num_preprocess_threads, min_after_dequeue=min_queue_examples)
with tf.Session() as sess:
sess.run(tf.initialize_all_variables())
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
t_image = image.eval() #here is your image Tensor :)
fig = plt.figure()
plt.imshow(t_image)
plt.show()
coord.request_stop()
coord.join(threads)
你有你的答案算法?我编辑我的代码包括shuffle_batch但即时通讯错误。你能显示完整的代码来阅读图像然后绘图吗?请fensortlow硬是 – kong
你得到哪种错误?我看了你的代码,我认为没关系 –
它说所有的形状都必须完全定义。错误指向tf.train.shuffle_batch – kong