av-savchenko / face-emotion-recognition

Efficient face emotion recognition in photos and videos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A error when runing codes.

kiva12138 opened this issue · comments

commented

When runing AFEW_train.ipynb,
an error occured:

could not broadcast input array from shape (0,112,3) into shape (60,112,3)
at facial_anylysis.py line 274 :
tmp[dy[k]-1:edy[k],dx[k]-1:edx[k],:] = img[y[k]-1:ey[k],x[k]-1:ex[k],:]

why dose this occured? could you please fixed it?

Thanks for this comment! This part is a code borrowed by me from some early implementation of MTCNN. It should work in most cases, so that it seems there is an error for some specific image. Could you provide additional details, what is the file you try to process in AFEW_train.ipynb. Please log filename, shape of frame, etc. If the image is opened correctly, please provide the link to this file so that I can test the issue of MTCNN face detector with this particular picture.

commented

Thanks for the reply.
I just followed the AFEW_train.ipynb step by step, by at Feature extraction>Detect faces in frames>MTCNN the error occured.

bounding_boxes, _ = imgProcessing.detect_faces(frame)

I just print the shape before the bug:
tmp = np.zeros((int(tmph[k]),int(tmpw[k]),3)) print(tmp.shape, img.shape, tmp[dy[k]-1:edy[k],dx[k]-1:edx[k],:].shape, img[y[k]-1:ey[k],x[k]-1:ex[k],:]) tmp[dy[k]-1:edy[k],dx[k]-1:edx[k],:] = img[y[k]-1:ey[k],x[k]-1:ex[k],:] if tmp.shape[0]>0 and tmp.shape[1]>0 or tmp.shape[0]==0 and tmp.shape[1]==0: tempimg[:,:,:,k] = cv2.resize(tmp, (24,24), interpolation=cv2.INTER_AREA) else: return np.empty()
The result shows:
(229,251,3) (229,251,3) (0,251,3) (229,251,3)

All the images are extracted by the former operation from AFEW dataset in the same ipynb and I can open them normally, so I dont think it's the images problem.

So, any clues about this bug?

As I said, this is an external code of one of implementations of MTCNN. It seems that for some reason dy[k]-1:edy[k] is incorrect, but I do not know the reason... This code definitely works for arbitrary input image. You could share your video frame, for which you observe this issue. There are several versions of AFEW dataset, so that I am not sure what is exactly your version and do we have the same versions. Moreover, there are several OS-specific procedures for frame extraction, so that I am not sure that ffmpeg in your environment works similarly to my environment.