oarriaga / face_classification

Real-time face detection and emotion/gender classification using fer2013/imdb datasets with a keras CNN model and openCV.
MIT License
5.61k stars 1.59k forks source link

can't change trained models... #47

Closed alighofrani95 closed 6 years ago

alighofrani95 commented 6 years ago

hi dear friends, if i run the gender recognition by default train model "simple_CNN.81-0.96.hdf5" it recognizes all the person as man after i myself train the imdb dataset 5 times and create new hdf5 files and change the model with "gender_mini_XCEPTION.01-0.95.hdf5"

i got this problem: ValueError: Error when checking : expected input_1 to have shape (None, 64, 64, 1) but got array with shape (1, 64, 64, 3)

please help me i absolutely mix up

oarriaga commented 6 years ago

the error mistake is probably due to the mismatch of the network that expects (64,64,1) (the last 1 corresponds to a grayscale image) while the array that you are giving the network is (64, 64, 3) which is a RGB image. Either transform your images to grayscale or just change the input size to the network.

alighofrani95 commented 6 years ago

Thanks i change input to gray image and works but problem still don't solve because no woman detect and accuracy is 96 precent.

mirceaciu commented 6 years ago

in gender detection offsets play a big role. After a face is detected the offsets are used to crop the face from the frame, and then this cropped region is sent to the predictor. If the offset are to small the face is not cropped entirely, if the offsets are to big then to much space around the face is included. Both cases affect the prediction.

try using cv2.imshow to visualize the cropped face, see if it's correct. Then adjust the offsets