devanshkv / fetch

A set of deep learning models for FRB/RFI binary classification.
GNU General Public License v3.0
42 stars 32 forks source link

Cannot load model #16

Closed caseyjlaw closed 3 years ago

caseyjlaw commented 3 years ago

Describe the bug Reading a model (using keras) produces an error. It looks like some attribute is a string, but a byte was expected. Some of the dependencies did get upgraded, so there may be some backwards-incompatible change introduced.

> fetch.utils.get_model('a')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-32e1218fd4f0> in <module>
----> 1 fetch.utils.get_model('a')

~/anaconda/envs/deployment/lib/python3.6/site-packages/fetch-0.1.8-py3.6.egg/fetch/utils.py in get_model(model_idx)
     96 
     97     # dump weights
---> 98     model.load_weights(weights)
     99 
    100     return model

~/anaconda/envs/deployment/lib/python3.6/site-packages/keras/engine/saving.py in load_wrapper(*args, **kwargs)
    490                 os.remove(tmp_filepath)
    491             return res
--> 492         return load_function(*args, **kwargs)
    493 
    494     return load_wrapper

~/anaconda/envs/deployment/lib/python3.6/site-packages/keras/engine/network.py in load_weights(self, filepath, by_name, skip_mismatch, reshape)
   1228             else:
   1229                 saving.load_weights_from_hdf5_group(
-> 1230                     f, self.layers, reshape=reshape)
   1231             if hasattr(f, 'close'):
   1232                 f.close()

~/anaconda/envs/deployment/lib/python3.6/site-packages/keras/engine/saving.py in load_weights_from_hdf5_group(f, layers, reshape)
   1181     """
   1182     if 'keras_version' in f.attrs:
-> 1183         original_keras_version = f.attrs['keras_version'].decode('utf8')
   1184     else:
   1185         original_keras_version = '1'

AttributeError: 'str' object has no attribute 'decode'

To Reproduce Running fetch 0.1.8 with CUDA 9.2 and the following:

> conda list | egrep 'tensor|keras'
keras                     2.3.1                    py36_0    conda-forge
keras-applications        1.0.8                      py_1    conda-forge
keras-preprocessing       1.1.2              pyhd8ed1ab_0    conda-forge
tensorboard               1.14.0                   py36_0    conda-forge
tensorflow                1.14.0               hc3e5e64_0    conda-forge
tensorflow-base           1.14.0           py36hc3e5e64_0    conda-forge
tensorflow-estimator      1.14.0           py36h5ca1d4c_0    conda-forge

Then:

> import fetch.utils
> fetch.utils.get_model('a')
devanshkv commented 3 years ago

According to https://github.com/keras-team/keras/issues/14265, this is caused by h5py>3.0.0. Would you please tell us which h5py version you are using?

caseyjlaw commented 3 years ago

I am using h5py=3.1.0. Rolling back and testing again, it works with 3.0.0. Thanks!