tensorflow错误: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte的解决办法

在执行下面语句时:

image_raw_data = tf.gfile.FastGFile('00000.jpg', 'r').read()

报了以下错误:

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

可能是因为文件不是utf-8编码格式造成的,解决办法是:

image_raw_data = tf.gfile.FastGFile('00000.jpg', 'rb').read()

猜你喜欢

转载自blog.csdn.net/heiheiya/article/details/81288271