如何在张量板中查看多个图像?

How to see several images in tensorboard?

我想重写我的代码以可视化数据集中的所有标签,并查看比较结果。

你可以看到左边的标签图像和右边的 hand-side 学习输出:

我所有的图像都有不同的形状,我用

阅读它们
for i in range(len(files_mask)):
    t_image_left = tf.read_file(files_left[i], name='read_fileimage_left')
    t_image_right = tf.read_file(files_right[i], name='read_fileimage_right')
    t_image_mask = tf.read_file(files_mask[i], name='read_fileimage_mask')

并将它们重塑为

    t_left = tf.reshape(t_left, [1, sh[0] / scaling, sh[1] / scaling, 3], name='reshape_t_left')
    t_right = tf.reshape(t_right, [1, sh[0] / scaling, sh[1] / scaling, 3], name='reshape_t_right')
    t_mask = tf.reshape(t_mask, [1, sh[0] / scaling, sh[1] / scaling, 1], name='reshape_t_mask')

然后,我定义了一些占位符,然后....

t_im0 = tf.placeholder(tf.float32, [None, None, None, 3], name='left_img')
t_im1 = tf.placeholder(tf.float32, [None, None, None, 3], name='right_img')
t_label = tf.placeholder(tf.float32, [None, None, None, 1], name='label')

...将它们放入我的神经元网络:

tn_prediction0, tn_prediction1 = cnn.construct_stereo_img(t_im0, t_im1)
t_img = tf.subtract(tn_prediction0, tn_prediction1)
tn_logits = cnn.construct_nn2(t_img)

在火车范围内我打印它们:

with tf.name_scope("Train"):
    optimizer = tf.train.AdamOptimizer(FLAGS.learning_rate).minimize(cost_function)
    tf.summary.image('logits', tn_logits, max_outputs=4)
    tf.summary.image('label', t_label, max_outputs=4)

让他们 运行 在 session:

with tf.Session(config=tf.ConfigProto(gpu_options=tf.GPUOptions(per_process_gpu_memory_fraction=0.333))) as sess:

    coord = tf.train.Coordinator()
    threads = tf.train.start_queue_runners(sess=sess, coord=coord)
    sess.run(init)

    for epoch in range(FLAGS.training_epochs):
        for img in images:
            _, summary_str, costs = sess.run([optimizer, merged_summary_op, cost_function],
                                             feed_dict={t_im0: img.l_img.eval(), t_im1: img.r_img.eval(),
                                                        t_label: img.mask.eval()})

现在,我的问题来了:我想用 sess.run( ) 替换循环以不遍历所有图像。

它目前正在一个接一个地输入三张图片。如何同时显示多个图像,例如 [4, ?, ?, 3]。我尝试使用 tf.concat(),但是如果我执行 img.l_img.eval() 就会出错,因为图像具有不同的高度和宽度。

我也完全愿意重组整个项目。

无法增加图像 [1, h, w, rgb] 的第一维,除非 images/batches 具有相同的大小。

Resizing/cropping 会导致不好的结果。

短是不可能的。