Paterson_Wang
Paterson_Wang

Reputation: 1

Tensorflow models im2txt issue

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

Answers (2)

Suraksha Ajith
Suraksha Ajith

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

user7299826
user7299826

Reputation: 11

try modify code like this:

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

Upvotes: 1

Related Questions