Skip to content
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

Problem with model2json #16

Open
mishra-avinash opened this issue Sep 14, 2017 · 1 comment
Open

Problem with model2json #16

mishra-avinash opened this issue Sep 14, 2017 · 1 comment

Comments

@mishra-avinash
Copy link

mishra-avinash commented Sep 14, 2017

As you provided a python script. ./tool/model2json, to convert model to json file. When i am running this script with my model i am getting error:

TypeError: write() argument must be str, not bytes

Getting this error make sense because, how can you write bytes to a file that is opened in string mode. At line
model = base64.b64encode(bytes(open(sys.argv[3], 'rb').read()))

You are reading it in bytes but in line

with open(sys.argv1, 'w') as fo:

you are opening file in string mode and in line

fo.write(model)

You are writing bytes to string.
May be i am missing something, help me out with this.

@hackerman04
Copy link

This is probably because you are using python 3 which is more restrictive on byte/string conversions.

Add .decode() to the end of
model = base64.b64encode(bytes(open(sys.argv[3], 'rb').read()))

This fixed it for me as it explicitly converts it into a string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants