Fix keras model loading issue with loading model with KerasH5
Created by: calad0i
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.
-
Bug fix (non-breaking change that fixes an issue) -
Documentation update -
New feature (non-breaking change which adds functionality) -
Breaking change (fix or feature that would cause existing functionality to not work as expected) -
A new research paper code implementation -
Other (Specify)
Tests
📝 Please describe the tests that you ran to verify your changes.
- Provide instructions so we can reproduce.
- Please also list any relevant details for your test configuration.
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 -> crash
Checklist
-
I have read the guidelines for contributing. -
I have commented my code, particularly in hard-to-understand areas. -
I have made corresponding changes to the documentation. -
My changes generate no new warnings. -
I have added tests that prove my fix is effective or that my feature works.B