Closed saselovejulie closed 7 years ago
@saselovejulie 脚本里面,最前面加上下面这句试下:
# coding=utf-8
@ScorpioCPH 加上了还是有这个issue, 麻烦有时间看看.谢谢 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
试一下下面这个代码,测试过可以正常工作:
# coding=utf-8
import tensorflow as tf
# cat.jpg 放到相同目录
image_raw_data = tf.gfile.FastGFile("./cat.jpg",'r').read()
with tf.Session() as sess:
img_data = tf.image.decode_jpeg(image_raw_data)
# 输出解码之后的三维矩阵
print 'img_data: ', img_data.eval()
img_data.set_shape([1797, 2673, 3])
print 'img_shape: ', img_data.get_shape()
PS,你用的 python 2 还是 3
@saselovejulie
@ScorpioCPH 谢谢, 我试试. 我是Python3.5
@ScorpioCPH 你给我的代码还是改成rb, 看来是python版本问题... thanks
我用的 python 2.7,那可能是版本的问题
image_raw_data = tf.gfile.FastGFile("../../datasets/cat.jpg", "r").read() 代码中读取图片的代码. 在我本地报错.UnicodeDecodeError: 'utf-8' codec can't decode byte error
将 image_raw_data = tf.gfile.FastGFile("../../datasets/cat.jpg", "r").read() 改为 image_raw_data = tf.gfile.FastGFile("../../datasets/cat.jpg", "rb").read() 错误消失, 我初学python,查了一下rb是读取二进制文件. 请问老师是否要改成rb? 谢谢