davidsandberg / facenet

Face recognition using Tensorflow
MIT License
13.82k stars 4.81k forks source link

Poor results in verification #785

Open modanesh opened 6 years ago

modanesh commented 6 years ago

I'm trying to verify faces using compare.py.

I've trained a model on a custom dataset that is consisting of frames from selfie videos. Here is its training loss:

screen shot 2018-06-10 at 4 07 50 pm

However, when I use the trained model in compare.py and get a new image(with the different situation from the dataset images) the distance between the training images and the given image seems weird. Images from the same person have L2 distance more that 1.1 and images from different persons have the distance less than 1.1.

Is it because of the overfitting in training? Or what is happening?

Thanks.

heiwushi commented 6 years ago

Did you train the model using softmax loss ? I got a poor result too. Now I wonder if the softmax loss can't give a same performance as triplet loss on verification by L2 distance.

modanesh commented 6 years ago

@heiwushi Yes, I trained the softmax loss. Have you tried the triplet loss on verification? Any improvements on results?

heiwushi commented 6 years ago

@modanesh No, I haven't. I just tried the pretrained model provided by the author.

whSwitching commented 6 years ago

@heiwushi the pretrained model requires permission, how did you get that 20180402-114759

modanesh commented 6 years ago

@whSwitching give some information regarding "20180402-114759". What is the "20180402-114759" model? What it's been trained on?

whSwitching commented 6 years ago

@modanesh home page pre-trained-models https://github.com/davidsandberg/facenet#pre-trained-models

rain2008204 commented 6 years ago

@modanesh How did you train the network by using you custom datasets? did you have use finetuing?

modanesh commented 6 years ago

@rain2008204 Yes I finetuned a model which was trained on MS-Celeb.

Victoria2333 commented 6 years ago

@modanesh,@rain2008204 , how did you finetune on your dataset?? I have been recently using this pretrained model to train my few-shot dataset of 43 persons, but i always got the error of classes not matching. maybe because my dataset size is 43 while MS-Celeb size is 10575. I'm not familiar with the saving and restoring models in TF, I want to restore part of the parameters and to finetune on my small dataset. So would you please give me some instructions about your finetune step?? Thank you~~~

modanesh commented 6 years ago

@Victoria2333 Look it up here #139

Victoria2333 commented 6 years ago

@modanesh,@rain2008204 But the accuracy finetuning on my own dataset is very low, i don't know why. I run: python src/train_softmax.py --data_dir /home/han/facenet/train_face_160 --image_size 160 __embedding_size 512 /home/han/facenet/src/pretrained_models/20180408-102900/model-2018408-102900.ckpt-90 Here is my code: all_vars = tf.trainable_variables() var_to_restore = [v for v in all_vars if not v.name.startswith('Mixed_8b')] in inception-renet-v1 saver = tf.train.Saver(var_to_restore) And I freeze the created ckpt file to pb file which is loaded in my_classifier.py to train and test but the training accuracy is 1 while test accuracy is about 0.4... I tried to finetune my dataset on david's pretrained model to get higher accuracy, but the resut turns out to be bad. I want to, for exmaple, freeze the old weights of L-2 layer and restore the weights of remaining 2 layer and finetune the last 2 layers. I don't mean to drop some variables which could lower the accuracy, so how can i finetune?? Could you please help me with this?Thanks

modanesh commented 6 years ago

@Victoria2333 I guess your model is overfitted.

Victoria2333 commented 6 years ago

@modanesh, I think it too, but i also doubt the finetune method, cause the variables shouldn't be dropped ,instead just the weights need to be finetuned rather than initialized??

batjandra commented 5 years ago

Did you try it with a new identity that's different from LFW? Since it's trained in softmax, it can only recognise the identities found in its training set (LFW).

tangchen2 commented 5 years ago

Did you try it with a new identity that's different from LFW? Since it's trained in softmax, it can only recognise the identities found in its training set (LFW).

i think the softmax loss helps network learn how to extract features of different people, so if the model is pre-trained well , it can also extract new identity's feature instead of recognising identities in dataSet

batjandra commented 5 years ago

Did you try it with a new identity that's different from LFW? Since it's trained in softmax, it can only recognise the identities found in its training set (LFW).

i think the softmax loss helps network learn how to extract features of different people, so if the model is pre-trained well , it can also extract new identity's feature instead of recognising identities in dataSet

Hi tangchen, can you elaborate on this? Because if you train it on softmax, the embeddings of different features won't have any guarantees on how they are different. For example, imagine training a dog-cat classifier with softmax with a 128D embedding before the final layer.

Giving it an image of a hyena or a penguin will probably give it a different embedding than a dog say, but comparing the two embeddings by L1 or L2 probably will not give any meaningful interpretation.