-
Notifications
You must be signed in to change notification settings - Fork 768
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
AttributeError: 'str' object has no attribute 'decode' #197
Comments
I had the same problem, try this: |
If the above does not work, try changing: original_keras_version = f.attrs['keras_version'].decode('utf8') to: original_keras_version = f.attrs['keras_version'] and: original_backend = f.attrs['backend'].decode('utf8') to: original_backend = f.attrs['backend'] in the load_weights_from_hdf5_group [1] function in hdf5_format.py from TensorFlow/Keras. For the creator of this issue, this file would, e.g., be located here: "/home/agam/.local/lib/python3.6/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py" May not be ideal, but depending on your setup and goals, this may work just fine. Personally, I run a few image processing steps including super resolution upsampling using this package in an isolated environment and just need to process a certain number of images once and then be done with it. In a similar case, simply adapting the above two lines may be a similarly quick and effective solution as it was for me. [1] Depending on what exactly you are trying to do, you may need to adapt additional lines in a similar fashion. |
Thanks so much! This worked for me. |
Thank for
Thanks, its work for me |
Hi,
I installed using pip and used python3 enhace.py to run the piece of code below :
`
import numpy as np
from PIL import Image
img = Image.open('/home/agam/flash_images/lib/uncompressed/upload_1.jpg')
lr_img = np.array(img)
from ISR.models import RDN
rdn = RDN(weights='psnr-small')
sr_img = rdn.predict(lr_img)
Image.fromarray(sr_img)
`
However it gives me the following error :
Traceback (most recent call last): File "enhance.py", line 9, in <module> rdn = RDN(weights='psnr-small') File "/home/agam/.local/lib/python3.6/site-packages/ISR/models/rdn.py", line 109, in __init__ self.model.load_weights(weights_path) File "/home/agam/.local/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training.py", line 181, in load_weights return super(Model, self).load_weights(filepath, by_name) File "/home/agam/.local/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/network.py", line 1177, in load_weights saving.load_weights_from_hdf5_group(f, self.layers) File "/home/agam/.local/lib/python3.6/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'
Sorry im new to this. Please let me know if any additional details are required.
Agam
The text was updated successfully, but these errors were encountered: