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
test vgg-face with 4096 dimensional outputs on LFW dataset #944
Comments
If we change, VGGFace.py as # from
# vgg_face_descriptor = Model(inputs=model.layers[0].input, outputs=model.layers[-2].output)
# to
base_model_output = Sequential()
base_model_output = Convolution2D(4096, (1, 1), name="predictions")(model.layers[-4].output)
base_model_output = Flatten()(base_model_output)
vgg_face_descriptor = Model(inputs=model.input, outputs=base_model_output) and update distance.py as "VGG-Face": {"cosine": 0.66, "euclidean": 0.61, "euclidean_l2": 1.12} thresholds are found from this tutorial. cosine and euclidean_l2 metrics are giving good results but euclidean is giving bad result as shown in attachment. |
|
When I do perform a test for VGG-Face and mtcnn detector
So, using its early layer obviously contributed the score btw, the best thresholds are 0.6975578183956332 for cosine and 1.186702879413616 for euclidean_l2. |
To avoid the failure in euclidean distance metric, what if we add normalization layer to the descriptor? I do not want to overwrite euclidean to euclidean_l2 when model is set to VGG. base_model_output = Sequential()
base_model_output = Convolution2D(4096, (1, 1), name="predictions")(model.layers[-4].output)
base_model_output = Flatten()(base_model_output)
base_model_output = Lambda(lambda x: K.l2_normalize(x, axis=1), name="norm_layer")(
base_model_output
)
vgg_face_descriptor = Model(inputs=model.input, outputs=base_model_output) distribution graph on deepface unit test items according to this tutorial becomes stable for euclidean (because it would be equivalent to euclidean_l2), and negative impact on cosine and euclidean_l2. now, testing all metrics on LFW. |
To sum up, (model_name ="VGG-Face", detector_backend = "mtcnn", align = True, enforce_detection = False) configuration is tested on LFW dataset's test samples (1000 instances distributed 50% 50% for same person and different persons);
and these are the thresholds: cosine 0.7077406336745886 So, doing this action increases the model performance 6% o 14%! |
now, it is creating different embeddings in every run. we should get rid of the Convolution2D in the descriptor because it generates random weights for that layer! base_model_output = Sequential()
base_model_output = Flatten()(model.layers[-5].output)
base_model_output = Lambda(lambda x: K.l2_normalize(x, axis=1), name="norm_layer")(
base_model_output
)
vgg_face_descriptor = Model(inputs=model.input, outputs=base_model_output) |
With the new structure, same accuracy values gotten
for these thresholds
|
Closed with PR - #948 |
vgg-face is the default facial recognition model. so, this improvement will affect every user of deepface. |
Currently, our vgg-face model has 2622 outputs. But this is the output for classification model of vgg-face model. In original paper, they are using its early layer with 4096 dimensions for descriptor. Test this and compare with exisiting model.
The text was updated successfully, but these errors were encountered: