-
Notifications
You must be signed in to change notification settings - Fork 409
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
Fix keras model loading issue with loading model with KerasH5 #664
Conversation
This is probably due to changes in the h5py. What version are you using? |
Currently 3.7.0. |
hls4ml/converters/keras_to_hls.py
Outdated
@@ -232,7 +232,10 @@ def keras_to_hls(config): | |||
if model_arch is None: | |||
raise ValueError('No model found in config file.') | |||
else: | |||
model_arch = json.loads(model_arch.decode('utf-8')) | |||
# model_arch should be a string by default. Keeping this if just for compatibility. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this, and it seems to be an issue dating back to h5py version 3.0.0. Can you update this comment to include that? It will be easier in the future when we decide to clean up the codebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tasting this out. I have updated the comment here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
…chinelearning#664) * Fix keras model loading issue with loading model with KerasH5 * Add unit test for KerasH5 loader * comment on h5py version causing KerasH5 loading issue
A# Description
In the current version of hls4ml, if one use the key "KerasH5" and not supplying the json model file to load the Keras model, the framework will try to decode the string in h5.attrs[ ] in utf-8 and fails. This PR patchs this issue by doing a type check first.
Type of change
For a new feature or function, please create an issue first to discuss it
with us before submitting a pull request.
Note: Please delete options that are not relevant.
Tests
Test Configuration:
Unit test added for KerasH5 loader at
test/pytest/test_keras_h5_loader.py
Create any keras model, save it to .h5 and use only the
KerasH5
without providing the in the config dictionary (or command line interface) to load it model json -> crashChecklist