Tensorflow模型im2txt问题

时间:2016-12-01 09:44:36

标签: tensorflow deep-learning

当我使用im2txt测试时,我的plantform是MAC OS 10.12

with tf.gfile.FastGFile(captions_file, "r") as f:
caption_data = json.load(f)

出现错误

TypeError: the JSON object must be str, not 'bytes'

然后我尝试将类型更改为字符串,编码为'utf-8'并对象为字符串......但是没有效果

2 个答案:

答案 0 :(得分:2)

这对我有用

 with tf.gfile.FastGFile(captions_file, "r") as f:
        caption_data = json.loads(str(f.read(), encoding = "utf-8"))

答案 1 :(得分:1)

尝试修改这样的代码:

with open(captions_file, "r") as f:
    caption_data = json.load(f)