我有一个数据帧,它由尺寸为137*236
的greascale(c=1)图像组成,总共有32332
个像素。我想使用ImageDataGenerator()
来扩充每个图像,但是当我使用下面的代码时,会出现一个错误Invalid dimensions for image data
samples = np.expand_dims(df.iloc[[65],1:].values.reshape(137,236,1), 0)
# create image data augmentation generator
datagen = ImageDataGenerator(width_shift_range=[-200,200])
# prepare iterator
it = datagen.flow(samples, batch_size=1)
# generate samples and plot
for i in range(9):
# define subplot
pyplot.subplot(330 + 1 + i)
# generate batch of images
batch = it.next()
# convert to unsigned integers for viewing
image = batch[0].astype('uint8')
print(image.shape)
pyplot.imshow(image)
# show the figure
pyplot.show()
当我使用samples = np.expand_dims(df.iloc[[65],1:].values.reshape(137,236), 0)
时,将错误显示为'Input data in `NumpyArrayIterator` should have rank 4. You passed an array with shape', (1, 137, 236)
这里出了什么问题
目前没有回答
相关问题 更多 >
编程相关推荐