I get this error for when I try to load a
.h5 file into a variable:
File "C:\Users\user\Desktop\Diplomski\faceVerify1.py", line 72, in <module> model = load_model('facenet_keras.h5') File "C:\Users\user\anaconda3\envs\tf\lib\site-packages\keras\engine\saving.py", line 492, in load_wrapper include_optimizer: If True, save optimizer's state together. File "C:\Users\user\anaconda3\envs\tf\lib\site-packages\keras\engine\saving.py", line 584, in load_model File "C:\Users\user\anaconda3\envs\tf\lib\site-packages\keras\engine\saving.py", line 273, in _deserialize_model if len(layer_names) != len(filtered_layers): AttributeError: 'str' object has no attribute 'decode'
After doing some reasearch I found out that the most likely reaosn for this is the mismatch or tensorflow, keras and h5py packages.
h5py as to be below 3.0.0 which I downgraded
And for tensorflow and keras versions I used this website that was shared in many other posts where people had this issue.
I check in anaconda what my versions are and they are good:
tensorflow 1.14.0 h1f41ff6_0 conda-forge tensorflow-base 1.14.0 py37hc8dfbb8_0 conda-forge tensorflow-estimator 1.14.0 py37h5ca1d4c_0 conda-forge keras 2.2.5 py37_1 conda-forge h5py 2.10.0 nompi_py37he280515_106 conda-forge
SO I am kind of out of ideas. I check a lot of questions on stackoverflow and on the github forums, and matching the versions doesn’t seem to work. The model
.h5 file I use is the standard face recog file I got from here :
Fixed it by manually removing ever instance of "decode( " From the keras functions used to load the model.
Answered By – Josip Juros