i am trying to read 30 images and create a large numpy array from it by appending the numpy array for each image to that one single array so that i can use it later in a flow function for keras.
I have an empty list to which I am appending numpy arrays after doing face detection in a loop, after which I am creating a large numpy array from this list. The problem is that when,I create a numpy array from this list, it changes the shape of my array, which was originally (1,139,139,3), to (30,1,139,139,3). It basically adds the total number of images at the start as I am appending, and I want to get back to original shape. I do not want to use reshape as that might affect the data.
Here is the code:
img_width, img_height = 139, 139
confidence = 0.8
#graph = K.get_session().graph
data1 = []
def get_face(path):
with graph.as_default():
img = io.imread(path)
dets = detector(img, 1)
output = None
for i, d in enumerate(dets):
img = img[d.top():d.bottom(), d.left():d.right()]
img = resize(img, (img_width, img_height))
output = np.expand_dims(img, axis=0)
break
return output
for row in df.itertuples():
data1.append(get_face(row[1]))
data1 = np.array(data1)
print(data1)
expand_dimscall?