输入图像以测试张量流模型的正确方法

时间:2016-07-20 17:11:33

标签: python image-processing tensorflow

我一直在尝试测试fcn实现posted here。我唯一改变的是设置输入图像以便对模型进行测试的方法。我的修改在下图中标有红色曲线。

enter image description here

但是,运行该程序会导致TypeError: The value of a feed cannot be a tf.Tensor object. Acceptable feed values include Python scalars, strings, lists, or numpy ndarrays. 发生以下错误消息down, up = sess.run(tensors, feed_dict=feed_dict)。我很想知道我的实现中有什么问题,以及如何修改它。在原始帖子中,作者使用img1 = skimage.io.imread("./test_data/tabby_cat.png") 输入图像。

如果我将batch_images=tf.expand_dims(images,0)更改为batch_images=tf.expand_dims(img1,0),程序将输出以下错误消息。

enter image description here

1 个答案:

答案 0 :(得分:0)

如错误所示,可用作提要的值类型是Python标量,字符串,列表或numpy数组。您尝试将其用作Feed的是img1,即tf.image.decode_png的输出,其类型为tf.Tensor。因此错误。您有两种选择:

1)在喂食之前将img1转换为numpy数组。您可以通过评估 img1完成此操作,如下所示:

feed_dict = {images:img1.eval()}

2)使用img1本身作为模型其余部分的输入。你可以这样做:

batch_images = tf.expand_dims(img1, 0)