Python 使用tensorflow验证tfrecord文件中的图像数据

Python 使用tensorflow验证tfrecord文件中的图像数据,python,numpy,tensorflow,computer-vision,Python,Numpy,Tensorflow,Computer Vision,我是tensorflow的新手,我试图通过将图像提取为tensor并转换为np数组并将其显示为JPEG来验证我的自定义数据集tfrecord数据 但它似乎永远挂在这一步>>>sess.run(图\u tensor) 我的代码如下所示:- dataset = Dataset.Dataset("Imagenet","train") print('starting data_files scan....') assert dataset.data_files() print('done data_fi

我是tensorflow的新手,我试图通过将图像提取为tensor并转换为np数组并将其显示为JPEG来验证我的自定义数据集tfrecord数据

但它似乎永远挂在这一步>>>sess.run(图\u tensor)

我的代码如下所示:-

dataset = Dataset.Dataset("Imagenet","train")
print('starting data_files scan....')
assert dataset.data_files()
print('done data_files scan....')
print('FLAGS.num_preprocess_threads >> ',FLAGS.num_preprocess_threads)

images, labels = distorted_inputs(dataset,num_preprocess_threads=FLAGS.num_preprocess_threads)
print('labels >>>',labels) # Tensor("batch_processing/Reshape_1:0", shape=(1,), dtype=int32, device=/device:CPU:0)
print('images >> ', images) # Tensor("batch_processing/Reshape:0", shape=(1, 199, 199, 3), dtype=float32, device=/device:CPU:0)
reshaped_img = tf.reshape(images,[199,199,3])
#tmp_var = tf.Variable(reshaped_img)
print('new >>> ',reshaped_img.shape)#199,199,3 
with tf.Session() as sess:
    init_op = tf.global_variables_initializer()
    sess.run(init_op)
    example, l = sess.run([reshaped_img, label])# its hung at this step forever no error
    img = PIL.Image.fromarray(example, 'RGB')
    img.save( "output/" + str(i) + '-train.png')
    # OR >>> PIL.Image.fromarray(np.asarray(x)).show()
这一步永远挂起没有错误:--


您能告诉我我做错了什么吗?

队列可能是在某个地方启动的,如果没有QueueRunner图形,执行将无限期地阻塞,等待有东西进入队列。您可以选择,也可以切换到使用
tf.contrib.learn.Estimator
,它可以为您处理此初始化和其他初始化。@AllenLavoie感谢您指出正确的方向,这对您有所帮助。现在我可以绘制一个图像,但下一个问题是图像只是一个随机的颜色模式,而不是我在tfrecord文件中捆绑的颜色模式。关于出列,你有什么基本概念可以告诉我吗?基本上,我想以批/流的形式将数据输入我的自定义convNet,这样我就可以在验证+测试运行中收取更多的费用。要从队列中读取一批数据,您可以
dequeue\u many
。通常在单个图像上并行地调整大小,并将这些结果添加到队列中,成批读取以供培训。不知道为什么图像没有出来;如果你能想出一个最简单的例子,那么把它放在一个新问题中可能是有意义的。
example, l = sess.run([reshaped_img, label])