face recognition program use transfer learning first we have to install some library (tensorflow,keras,numpy,glob,matplotlib,opencv,pillow)
i use vgg16 for pretrained weights and keras has vgg16 model as object
VGG16 is a convolutional neural network model proposed by K. Simonyan and A. Zisserman from the University of Oxford in the paper “Very Deep Convolutional Networks for Large-Scale Image Recognition”. The model achieves 92.7% top-5 test accuracy in ImageNet, which is a dataset of over 14 million images belonging to 1000 classes. It was one of the famous model submitted to ILSVRC-2014. It makes the improvement over AlexNet by replacing large kernel-sized filters (11 and 5 in the first and second convolutional layer, respectively) with multiple 3×3 kernel-sized filters one after another. VGG16 was trained for weeks and was using NVIDIA Titan Black GPU’s.
===========================================================================================================================================after loading the image in Dataset/Train just give the path in program
it will find face and crop it than save it in same file
It do the same with whole data set
this type of image will use in dataset
In this i add preprocessing layer to the front of VGG and than i cut the last layer vgg and add my softmax layer
vgg = VGG16(input_shape=IMAGE_SIZE + [3], weights='imagenet', include_top=False)
To don't train existing weights i put false in vgg which creat up
layer.trainable = False
by this i add the sotfmax layer in my model
prediction = Dense(len(folders), activation='softmax')(x)
model = Model(inputs=vgg.input, outputs=prediction)e
and by this i save the model in file
model.save('facefeatures_new_model.h5')
Basically it's used the model and give prediction to us by just passing image
In this i fisrt check the face in image by haarcascade_frontalface_default.xml
and than by just passing the image array in model it give the prediction of each class
In prediction it give list of every class how much similer are in ther
and in return it make a result.jpg file with prediction
it do same process as face_detect_img.py it but it get image form you defult laptop camera or any other camera by just passing the image
and i get this much accuracy and loss for 5 class
'val_loss': [0.31096458435058594, 0.5319749712944031, 0.17712721228599548, 0.20998987555503845, 0.16552892327308655],
'val_accuracy': [0.9615384340286255, 0.807692289352417, 0.9615384340286255, 0.9615384340286255, 0.9615384340286255],
'loss': [1.2948014206356473, 0.4617767201529609, 0.24304395113830213, 0.11090589121535972, 0.08772868594085728],
'accuracy': [0.6111111, 0.8240741, 0.8981481, 0.9583333, 0.9768519]