I am trying to process a bunch of images for face recognition.
I have several sets of images which I am trying to process, some of them processed fine but in a particular set there are some images which are not able to process and gives this particular error: could not broadcast input array from shape
I am using MTCNN which is implemented using mxnet and python here is the link to the original repo.
This error comes in the second stage of the mtcnn detector, here is the code:
#############################################
# second stage
#############################################
num_box = total_boxes.shape[0]
# pad the bbox
[dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph] = self.pad(total_boxes, width, height)
# (3, 24, 24) is the input shape for RNet
input_buf = np.zeros((num_box, 3, 24, 24), dtype=np.float32)
for i in range(num_box):
tmp = np.zeros((tmph[i], tmpw[i], 3), dtype=np.uint8)
tmp[dy[i]:edy[i]+1, dx[i]:edx[i]+1, :] = img[y[i]:ey[i]+1, x[i]:ex[i]+1, :]
input_buf[i, :, :, :] = adjust_input(cv2.resize(tmp, (24, 24)))
output = self.RNet.predict(input_buf)
# filter the total_boxes with threshold
passed = np.where(output[1][:, 1] > self.threshold[1])
total_boxes = total_boxes[passed]
if total_boxes.size == 0:
return None
In the for loop when it tries to change the shape it throws an error.
If anyone needs to view more code or want the exact pic do let me know.