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

couldn't get the same embeddings from .pb and .dat #1

Open
arunxz98 opened this issue Apr 30, 2019 · 3 comments
Open

couldn't get the same embeddings from .pb and .dat #1

arunxz98 opened this issue Apr 30, 2019 · 3 comments

Comments

@arunxz98
Copy link

First of all, thank you @ksachdeva for providing an excellent source for converting dlib_face_recognition_resnet_model_v1.dat to dlib_face_recognition_resnet_model_v1.pb.
i converted the model to .pb just like you mentioned. but when i tested both .dat and .pb by giving same image as input to both models, the embeddings i get from both the models are different. the preprocessing of the image for both model inputs are the same.
it would be very helpful if you could help me understand why it happens, and how to get same embeddings from both .dat and .pb.
thank you.

@ksachdeva
Copy link
Owner

Hi @arunxz98

I am glad you find it useful.

There are 3 main reasons for the differences in the embeddings generated using .dat and .pb

  1. The conversion process first requires to convert from .dat to .xml. This is provided by dlib library itself. However, when I do this conversion there is a change in the floating point precision. This is hardcoded in the dlib i.e. I do not have a way to control the precision from my converter. Locally I hacked it inside dlib and change it to a bigger value.

  2. The linear algebra libraries used by dlib and tensorflow are different and they contribute to the differences

  3. The target CPU/GPU contributes to the difference.

In order to see this yourself, you can create a small example for face recognition using dlib c++ toolkit. Run this example on windows and linux or osx or two different CPU architectures and you will see that the embeddings generated are different.

Hope this helps.

@arunxz98
Copy link
Author

arunxz98 commented May 9, 2019

thankyou @ksachdeva
but does dlib_face_recognition_resnet_model_v1.dat and dlib_face_recognition_resnet_model_v1.pb perform with same accuracy?

@RishengZhou
Copy link

RishengZhou commented Jul 25, 2019

thankyou @ksachdeva
but does dlib_face_recognition_resnet_model_v1.dat and dlib_face_recognition_resnet_model_v1.pb perform with same accuracy?

Yes! I got the same output when I used the 'h5' model and 'pb' model to extract the features of a grope of pictures. It's quite useful.

Thanks for @ksachdeva and Davis King !

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

3 participants