使用此功能
def imRead (fold, file):
image = Image.open(os.path.join(fold, file)).convert('L')
image = image.resize((int(image.size[0]/100), int(image.size[1]/100)), Image.ANTIALIAS)
imData = np.asanyarray(image.getdata()).reshape(image.size)
return imData/255
我正在将灰度图像读取到数据框的列中
data02 = data02.values
for j in range(0, len(data02)):
data02[j][2] = imRead(train_image_path, data02[j][0])
然后分割图像数据和标签
X = data02[:,2]
Y = data02[:,1]
最后,我的 X是一个数组数组,其长度为图像数量(测试为20),每个元素-数组210 * 140(图像大小) 我该如何重塑X以将其输入到Conv NN层中?
model = Sequential()
model.add(Conv2D(filters = 32, kernel_size = (5,5),padding = 'Same',
activation ='relu', input_shape = (210,140,1)))
X.reshape(20, 210,140,1)
给出错误'cannot reshape array of size 20 into shape (20,210,140,1)'
我尝试应用许多其他形状,但没有成功,因为主数组只是(20,)数组。
如何重塑数组数组?