您的位置:首页 > 其它

error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

2017-10-19 10:24 901 查看
最近在研究tensorflow的工程,遇到一些小白鼠错误,记录一下。

问题:error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

解决:

def _process_image(filename, coder):
with tf.gfile.FastGFile(filename, 'r') as f:
image_data = f.read()

# image_data = image_data.rstrip("\n").decode("utf-16")
# image_data = image_data.split("\r\n")
image = coder.decode_png(image_data)

修改为:
def _process_image(filename, coder):
with tf.gfile.FastGFile(filename, 'rb') as f:
image_data = f.read()

# image_data = image_data.rstrip("\n").decode("utf-16")
# image_data = image_data.split("\r\n")
image = coder.decode_png(image_data)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐