2016-12-01 66 views
0

我plantform是MAC OS 10.12,在使用im2txt測試Tensorflow車型im2txt問題

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'和反對字符串......但沒有效果

+0

'json.load(f.read())'? – sygi

回答

1

請嘗試修改代碼,例如:

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

這爲我工作

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