Open Zumbalamambo opened 7 years ago
What do you mean by model files?
I mean the pretrained model to recognize gender and age
Here there are the 2 models I used for the Webcam app
https://www.dropbox.com/sh/zavlrdh5k4y0b6t/AACDiu6mVTsIGalgBLilxDCta?dl=0
The results are not really good because we were limited by the GPU memory (only 2go) for the training . So our CNN is really basic with few layers and we used small images (128x128).
Is there by any means that I can retrain the model?
Yes, the images are available here wiki-crop. It contains images and their labels.
The script faces.py pre-process the images and the labels and create numpy arrays. (It requires OpenCV to detect faces with haarcascade, because the original images in the database are not really centered on the face) This script generates several files X... (for the images) and Y... (for the labels). They are just numpy arrays saved into files, so that they can be easily loaded later in the CNN. You will probably need to do some changes for the paths in the script, the size of the images you want and for the label (if you want age, gender of both in the array)
After you can use CNNxxx.py scripts depending on what you want (gender classification, age classification, age regression) Again, you will probably have to do some changes in the script to load the files generated X... and Y... (paths, dimensions of the tensors, ...)
okay thank you. let me try that
ValueError: Error when checking : expected conv2d_1_input to have shape (None, 128, 128, 3) but got array with shape (1, 500, 750, 3)
Exception ignored in: <bound method BaseSession.__del__ of <tensorflow.python.client.session.Session object at 0x12a784898>>
Traceback (most recent call last):
Im getting the above error while running CNNAge_reg_pred.py
and if I run CNNAge_reg.py
, Im getting the following error
FileNotFoundError: [Errno 2] No such file or directory: '128_age_gender/xtrain_128_0.dat'
It's normal, you have to adapt the paths used in the scripts.
Have you manage to run faces.py ?
I think if you want to use the scripts in "age_prediction_app", you should run the script face.py with these changes :
taille_img_out = 32
change to 128
x_train = np.array([np.array(cv2.imread("/home/pierre/Downloads/wiki_crop/"+fname[0], 1)) for fname in a[it*batchSize:(it+1)*batchSize]])
change to your path to wiki_crop (not /home/pierre/Downloads/wiki_crop/
)
the script will generates files data\x...
and data\y...
in CNNAge_reg.py you should change the path to the data, to point the files generated before with faces.py (you should probably use absolute paths)
x_tmp = np.load("128_age_gender/xtrain_128_" + str(it) + ".dat")
y_tmp = np.load("128_age_gender/ytrain_128_" + str(it) + ".dat")
The script CNNAge_reg_pred.py was used to test predictions with a face image (128x128) as input. Your image is apparently (500, 750) which is not possible.
Thank you so much. gonna use the pretrained model better instead of retraining it. CNNAge_reg_pred.py
fires the following error,
ValueError: Error when checking : expected conv2d_1_input to have shape (None, 128, 128, 3) but got array with shape (1, 500, 750, 3) Exception ignored in: <bound method BaseSession.del of <tensorflow.python.client.session.Session object at 0x12a784898>> Traceback (most recent call last):
the model was trained with 128x128 pixel images, so when you make a prediction for a new image you need a 128x128 pixels image.
files = ["pp.jpg"]
Here pp.jpg have to be 128x128 pixels
Can you please share the model files too?