【发布时间】:2018-11-29 03:32:05
【问题描述】:
代码如下:
filename = tf.placeholder(tf.string)
image_raw_data = tf.gfile.FastGFile(filename, "rb").read()
image = tf.image.decode_jpeg(image_raw_data)
with tf.Session() as sess:
sess.run(image, feed_dict={filename: "4.jpg"})
这是错误:
Traceback (most recent call last):
File "C:/Users/fanpw.fnst/Desktop/ip8/test.py", line 26, in <module>
image_raw_data = tf.gfile.FastGFile(filename, "rb").read()
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 120, in read
self._preread_check()
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 80, in _preread_check
compat.as_bytes(self.__name), 1024 * 512, status)
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\util\compat.py", line 67, in as_bytes
(bytes_or_text,))
TypeError: Expected binary or unicode string, got <tf.Tensor 'Placeholder:0' shape=<unknown> dtype=string>
我想知道如何将变量 filename 从类型 tf.string 转换为 unicode string。或者有其他方法可以解决这个问题。
任何建议将不胜感激。
【问题讨论】:
-
你有没有发现这个问题?我也有类似的情况。见stackoverflow.com/questions/51297195/…
标签: python tensorflow