-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
第七章图片预处理关于完整样例中读取文件报错 #60
Comments
@saselovejulie # coding=utf-8 |
@ScorpioCPH |
试一下下面这个代码,测试过可以正常工作: # 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 |
@ScorpioCPH |
@ScorpioCPH |
我用的 python 2.7,那可能是版本的问题 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
谢谢
The text was updated successfully, but these errors were encountered: