Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Face Verification using Pre-Trained Model #4

Closed
ajinkya933 opened this issue Dec 31, 2019 · 4 comments
Closed

Face Verification using Pre-Trained Model #4

ajinkya933 opened this issue Dec 31, 2019 · 4 comments

Comments

@ajinkya933
Copy link
Contributor

ajinkya933 commented Dec 31, 2019

My question is concerned about face verification testing after I have a model file.

I have downloaded VGGFace2 data set, and have manually added more images to its training set. The orignal dataset is of around 9,000 people. I have added more people and now I have 11,000 people.

I want to train this model of 11,000 people and use it for face verification .
I am referring to issue #1 and took this code

# required imports
from tensorflow.keras.preprocessing.image import load_img, img_to_array
from deepface import create_deepface
from deepface import Dataset

model = create_deepface()
model.load_weights('VGGFace2_DeepFace_weights_val-0.9034.h5')

# fine tune the deepface model for your dataset
# for fine tuning, remove last dense layer only; (as per paper)
# set all pretrained parameters to non trainable
# add a dense layer with dim = num_classes (your dataset)
# set dense layer to trainable and train the model

img = load_img(path)
img = img.resize((152,152))
img_array = img_to_array(img)
img_array = img_array.reshape((-1, 152, 152, 3))
res = model.predict(img_array)

Can this code be used for face verification in my case as I am adding more dataset to the training data itself? Also, how do I tell that 2 faces match, should I look for both of their res values?

@ajinkya933 ajinkya933 changed the title Question Question regarding face verification after training Dec 31, 2019
@ajinkya933
Copy link
Contributor Author

ajinkya933 commented Dec 31, 2019

I observed the output of res. and found out res is a list of lists :[[0.0, 0.0, ...... 0.0]]
so I printed each item inside this list using:

l1=[]
for term in res:
    for item in term:
        l1.append(item)
print(l1)

output:

[0.0, 0.0, ... 1.0, 0.0, 0.0, ..., 2.244257e-26, 0.0, ..., 0.0, 0.0, 0.0]

These are the non zero terms appearing in later stages of this list :

1.0
2.244257e-26

How do I interpreat these terms? is there a way to find similarity between two images using these values.

@swghosh swghosh changed the title Question regarding face verification after training Face Verification using Pre-Trained Model Jan 2, 2020
@swghosh
Copy link
Owner

swghosh commented Jan 2, 2020

This issue is possibly a duplicate of Issue #1.
Please give the following a read and let me know if there are further queries.

#1 (comment)

I'll share the code for finetuning the pre-trained network based on the needs that you have specified. As per the paper, the network is designed to carry out face recognition task specifically.

A face verification task can be carried using DeepFace feature vector extracted from particular images. Such a feature vector can be obtained from the second last dense layer of the model. The paper also discusses a face verification technique based on use of Chi² similarity distance based SVMs. (either can be used: fine-tuning the network for new classes / chi² kernel SVM for verification)

@swghosh
Copy link
Owner

swghosh commented Feb 7, 2020

Hi @ajinkya933,
Any updates?

@ajinkya933
Copy link
Contributor Author

@swghosh I switched to facenet, as I needed face comparision and facenet was good at doing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants