Skip to content

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

@debanjangg

Description

@debanjangg

Followed the steps, and while executing train.py, this is the error I came across:

Traceback (most recent call last):
File "train.py", line 64, in
visual_model = model_factory.get_model(FLAGS)
File "F:\Github\Chest-X-Ray-Tags-Classification\visual_model_selector.py", line 232, in get_model
pooling=FLAGS.final_layer_pooling)
File "F:\Github\Chest-X-Ray-Tags-Classification\projenv\lib\site-packages\tensorflow_core\python\keras\applications_init_.py", line 46, in wrapper
return base_fun(*args, **kwargs)
File "F:\Github\Chest-X-Ray-Tags-Classification\projenv\lib\site-packages\tensorflow_core\python\keras\applications\densenet.py", line 32, in DenseNet121
return densenet.DenseNet121(*args, **kwargs)
File "F:\Github\Chest-X-Ray-Tags-Classification\projenv\lib\site-packages\keras_applications\densenet.py", line 311, in DenseNet121
**kwargs)
File "F:\Github\Chest-X-Ray-Tags-Classification\projenv\lib\site-packages\keras_applications\densenet.py", line 293, in DenseNet
model.load_weights(weights_path)
File "F:\Github\Chest-X-Ray-Tags-Classification\projenv\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 234, in load_weights
return super(Model, self).load_weights(filepath, by_name, skip_mismatch)
File "F:\Github\Chest-X-Ray-Tags-Classification\projenv\lib\site-packages\tensorflow_core\python\keras\engine\network.py", line 1222, in load_weights
hdf5_format.load_weights_from_hdf5_group(f, self.layers)
File "F:\Github\Chest-X-Ray-Tags-Classification\projenv\lib\site-packages\tensorflow_core\python\keras\saving\hdf5_format.py", line 651, in load_weights_from_hdf5_group
original_keras_version = f.attrs['keras_version'].decode('utf8')
AttributeError: 'str' object has no attribute 'decode'

The only way I got to fix it was change 2/3 lines in the Chest-X-Ray-Tags-Classification\projenv\lib\site-packages\tensorflow_core\python\keras\saving\hdf5_format.py file where the decode() method is used, but I'm hoping there's some other fix?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions