I am having trouble generating preprocessed images. This is what I have
datagen = ImageDataGenerator(
rotation_range=20,
width_shift_range=0.2,
height_shift_range=0.2,
horizontal_flip=True)
I get the following error when I run this:
for i in datagen.flow(train_images,train_images,32):
print i
File ".../keras/preprocessing/image.py", line 302, in next
x = self.random_transform(x.astype('float32'))File ".../keras/preprocessing/image.py", line 359, in random_transform
ty = np.random.uniform(-self.width_shift_range, self.width_shift_range) * x.shape[img_col_index]IndexError: tuple index out of range
numpy.shape(train_images)
is (100,256,256). It has 100 grayscale images each of which is 256x256 in size. The generator however works with the cifar10 dataset in the sample code.
I think I see it. ImageDataGenerator thinks that there are 3 channels. Is there a way I can use it for grayscale images?
Edit: Had a look at the code and figured that reshaping it to (100,1,256,256) would work (and it does).
numpy.shape(train_images)
is (100,256,256). It has 100 grayscale images each of which is 256x256 in size.
Reshape train_images
to (100,1,256,256).
can you help me i convert imgs to 3 channels and still get the same error
File "/home/wafaaismail/Desktop/gp/c/Cerebro/model/model.py", line 64, in fit
history = self.model.fit_generator((data_gen.flow(ret,np.array(ys), batch_size=self.batch_size)),
File "/home/wafaaismail/.local/lib/python3.6/site-packages/keras_preprocessing/image.py", line 916, in flow
subset=subset)
File "/home/wafaaismail/.local/lib/python3.6/site-packages/keras_preprocessing/image.py", line 1577, in __init__
if type(x[1]) is not list:
IndexError: list index out of range
Most helpful comment
I think I see it. ImageDataGenerator thinks that there are 3 channels. Is there a way I can use it for grayscale images?
Edit: Had a look at the code and figured that reshaping it to (100,1,256,256) would work (and it does).