Skip to content
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: 'NoneType' object has no attribute 'shape' #10

Closed
FelixIsCoding opened this issue Dec 25, 2017 · 2 comments
Closed

AttributeError: 'NoneType' object has no attribute 'shape' #10

FelixIsCoding opened this issue Dec 25, 2017 · 2 comments

Comments

@FelixIsCoding
Copy link

Hello, I've meet some errors when trying to use this code.
I have the same version as mentioned and I didn't change any code. But it gives me these two errors.
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 425, in data_generator_task
generator_output = next(generator)
File "main.py", line 48, in generator_test
yield [preprocess_images(images[counter:counter + b_s], shape_r, shape_c), gaussian]
File "/home/huying/workspace_linux/Saliency/sam-master/utilities.py", line 79, in preprocess_images
padded_image = padding(original_image, shape_r, shape_c, 3)
File "/home/huying/workspace_linux/Saliency/sam-master/utilities.py", line 13, in padding
original_shape = img.shape
AttributeError: 'NoneType' object has no attribute 'shape'

Traceback (most recent call last):
File "main.py", line 112, in
predictions = m.predict_generator(generator_test(b_s=b_s, imgs_test_path=imgs_test_path), nb_imgs_test)[0]
File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1634, in predict_generator
outs = self.predict_on_batch(x)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1268, in predict_on_batch
self.internal_input_shapes)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 70, in standardize_input_data
'Found: ' + str(data)[:200] + '...')
Exception: Error when checking : data should be a Numpy array, or list/dict of Numpy arrays. Found: None...

Can you help with that?

@FelixIsCoding
Copy link
Author

FelixIsCoding commented Dec 25, 2017

I'm using the sample images in your code, and I put a print in main.py
images = [imgs_test_path + f for f in os.listdir(imgs_test_path) if f.endswith(('.jpg', '.jpeg', '.png'))]
images.sort()
print len(images)
So I'm sure the images have been read.

@FelixIsCoding
Copy link
Author

OMG, such a silly bug! I lost a '/' when giving the image path....
/home/usr/workspace_linux/Saliency/Image
to
/home/usr/workspace_linux/Saliency/Image/
problem solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant