Reputation: 1
My plantform is MAC OS 10.12, when I using im2txt to test
with tf.gfile.FastGFile(captions_file, "r") as f:
caption_data = json.load(f)
there has an error
TypeError: the JSON object must be str, not 'bytes'
then I have try to change type to string , encode to 'utf-8' and object to string…… but there is no effect
Upvotes: 0
Views: 168
Reputation: 892
This worked for me
with tf.gfile.FastGFile(captions_file, "r") as f:
caption_data = json.loads(str(f.read(), encoding = "utf-8"))
Upvotes: 2
Reputation: 11
try modify code like this:
with open(captions_file, "r") as f:
caption_data = json.load(f)
Upvotes: 1