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

file_io.FileIO throws UnicodeDecodeError when reading .h5 model file #2

Open
jaungiers opened this issue Jan 17, 2018 · 4 comments
Open

Comments

@jaungiers
Copy link

with file_io.FileIO('model.h5', mode='r') as input_f:
        with file_io.FileIO(job_dir + '/model.h5', mode='w+') as output_f:

The above throws a UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte as the .h5 model file is a bytes file. To correct this issue use bytes mode for reading/writing using FileIO:

with file_io.FileIO('model.h5', mode='rb') as input_f:
        with file_io.FileIO(job_dir + '/model.h5', mode='wb+') as output_f:
@LouisArcane
Copy link

Hi I have the exact same issue, did you find a solution ?

@LouisArcane
Copy link

A workaround is to use the os library : os.system("gsutil cp your_model gs://your_bucket/your_model")

@clintonreece
Copy link
Owner

@LouisArcane Did you try to use bytes mode as mentioned?

@LouisArcane
Copy link

Hi, right after I wrote my comment I realized that I was trying
with file_io.FileIO('model.h5', mode='b') as input_f: ( 'b' instead of 'rb')
so you can probably delete my comments to clean, sorry :)

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

3 participants