image-super-resolution
image-super-resolution copied to clipboard
AttributeError: 'str' object has no attribute 'decode'
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
I had the same problem, try this: pip install 'h5py==2.10.0' --force-reinstall
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.
I had the same problem, try this: pip install 'h5py==2.10.0' --force-reinstall
Thanks so much! This worked for me.
Thank for
I had the same problem, try this: pip install 'h5py==2.10.0' --force-reinstall
Thanks, its work for me