Arsey/keras-transfer-learning-for-oxford102

Exception: Error when checking : data should be a Numpy array, or list/dict of Numpy arrays. Found: None...

debarko opened this issue · 6 comments

Exception: Error when checking : data should be a Numpy array, or list/dict of Numpy arrays. Found: None...
Arsey commented

@debarko please post here the whole error stack

Using TensorFlow backend.
Found 6149 images belonging to 102 classes.
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 404, in data_generator_task
generator_output = next(generator)
File "/home/ubuntu/cnn/2/learn/util.py", line 160, in custom_next
batch_x, batch_y = original_next(self)
File "/usr/local/lib/python2.7/dist-packages/keras/preprocessing/image.py", line 603, in next
img = load_img(os.path.join(self.directory, fname), grayscale=grayscale, target_size=self.target_size)
File "/usr/local/lib/python2.7/dist-packages/keras/preprocessing/image.py", line 172, in load_img
from PIL import Image
ImportError: No module named PIL

Traceback (most recent call last):
File "train.py", line 37, in
bottlenecks.save_bottleneck_features()
File "/home/ubuntu/cnn/2/learn/bottlenecks.py", line 23, in save_bottleneck_features
bottleneck_features_train = model.predict_generator(generator, config.nb_train_samples)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1652, in predict_generator
outs = self.predict_on_batch(x)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1273, in predict_on_batch
self.internal_input_shapes)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 73, 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...

For the import error "ImportError: No module named PIL"
Ideally no need to import PIL. You can just do import Image. It will still work.

Arsey commented

@debarko PIL is required by Keras, not by my code. Please install PIL (pip install Pillow) and try to run train.py again

sorted.