deep learning - Create readable image dataset for training in Keras -


i trying create own image recognition program of keras, have encounter problem. trying take folder(s) pictures , create dataset model.fit() use. aware of fit_generator() trying know generator images. thats why manuely trying create array/dataset of numbers images.

the model using vgg16, end , beginning of model:

model = sequential() model.add(zeropadding2d((1, 1), input_shape=(256, 256, 3))) model.add(convolution2d(64, 3, 3, activation='relu')) model.add(zeropadding2d((1, 1))) ... model.add(dense(4096, activation='relu')) model.add(dropout(0.5)) model.add(dense(3, activation='softmax')) 

compiler:

sgd = sgd(lr=0.1, decay=1e-6, momentum=0.9, nesterov=true) model.compile(optimizer=sgd, loss='categorical_crossentropy') 

fit:

model.fit(test_x, 1, batch_size=32, nb_epoch=10, verbose=1, callbacks=none, validation_split=0.1) 

array generator:

path_temp = %path%  list = os.listdir(path_temp) array_list = []  file in list:      img = imread(path_temp + '\\' + file, flatten=true)     img = np.arange(1 * 3 * 256 * 256).reshape((-1, 256, 256, 3))      img = img.astype('float32')     array_list.append(img)  test_x = np.stack(array_list) test_x /= 255.0 

error:

valueerror: error when checking model input: expected zeropadding2d_input_1 have 4 dimensions, got array shape (990, 1, 256, 256, 3) 

this have, there way here create readable dataset/array fit()?

i change code provided in for loop:

for file in list:      img = imread(path_temp + '\\' + file, flatten=true)     img = np.arange(1 * 3 * 256 * 256).reshape((256, 256, 3))     # img = np.array(img).reshape((256, 256, 3)) <- consider      img = img.astype('float32')     array_list.append(img) 

first problem came fact stacking images - there no need add sample dimension in reshape. second thing - reading img file , erasing creating new np.array using np.arange function. intended or not? if not - check code snippet provided.


Comments