davisking / dlib-models

Trained model files for dlib example programs.
Creative Commons Zero v1.0 Universal
1.46k stars 377 forks source link

How to train my own dlib_face_recognition_resnet_model_v1.dat #11

Open 74981 opened 5 years ago

74981 commented 5 years ago

How to train my own dlib_face_recognition_resnet_model_v1.dat. Please help and if possible share the python api for the same.

nicolaerosia commented 5 years ago

@davisking I'm also interested if you're willing to release the dataset. In any case, I understand that it involved a lot of work.

davisking commented 5 years ago

You can use the trillion faces or ms celeb datasets. They are already available and very large.

pdstanley commented 5 years ago

Davis, is there a python API for training your own model? Thank you, sir! Dlib is amazing.

davisking commented 5 years ago

No

shenjackson commented 5 years ago

@davisking , I don't know how to train my dlib_face_recognition_resnet_model_v1 model, can you give me some methods!

davisking commented 5 years ago

This example program goes into the details: http://dlib.net/dnn_metric_learning_on_images_ex.cpp.html

csaftoiu commented 4 years ago

@davisking Just to be sure, is that C++ code the one used to train this model? I'd like to transfer learn on my own dataset and want to be sure I'm starting from the right place

csaftoiu commented 4 years ago

Also we’re rhe input images aligned centered cropped etc or just resized to 150x150 with a crop from a face finding model? Also be helpful to know this just in terms of using the base model - I see the sample code that uses it does this so I presume it was trained that way As well

davisking commented 4 years ago

The notes on how this model was trained are in the example program that shows how to use it: http://dlib.net/dnn_face_recognition_ex.cpp.html

csaftoiu commented 4 years ago

Ah thanks for that! Very helpful.

I managed to get it to train a few steps on some images of my own. However I couldn’t load it into a net_type because the saved weights have the affine layers while the net_type has batchnorm layers. Though I see it auto converts from batchnorm to affine when saving, I wasn’t able to get it to auto convert from affine to batchnorm to keep training. So I have been training the anet_type directly.

Is there a way to retrieve the net_type from the saved weights on the repo? Or are part of the batchnorm parameters lost when saving the model meaning I can’t transfer learn it?

On Thu, Oct 31, 2019 at 12:02 AM Davis E. King notifications@github.com wrote:

The notes on how this model was trained are in the example program that shows how to use it: http://dlib.net/dnn_face_recognition_ex.cpp.html

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/davisking/dlib-models/issues/11?email_source=notifications&email_token=AAAKQ2OQY3ISUSKPO7BLFTDQRIOC5A5CNFSM4GMJTZUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECWEUAY#issuecomment-548162051, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAKQ2IQAVDMXCVBUR3ZWQLQRIOC5ANCNFSM4GMJTZUA .

davisking commented 4 years ago

Some things are lost when converting from batch norm to affine. Save in batch norm form when doing training.

On Thu, Oct 31, 2019 at 9:17 AM Claudiu notifications@github.com wrote:

Ah thanks for that! Very helpful.

I managed to get it to train a few steps on some images of my own. However I couldn’t load it into a net_type because the saved weights have the affine layers while the net_type has batchnorm layers. Though I see it auto converts from batchnorm to affine when saving, I wasn’t able to get it to auto convert from affine to batchnorm to keep training. So I have been training the anet_type directly.

Is there a way to retrieve the net_type from the saved weights on the repo? Or are part of the batchnorm parameters lost when saving the model meaning I can’t transfer learn it?

On Thu, Oct 31, 2019 at 12:02 AM Davis E. King notifications@github.com wrote:

The notes on how this model was trained are in the example program that shows how to use it: http://dlib.net/dnn_face_recognition_ex.cpp.html

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/davisking/dlib-models/issues/11?email_source=notifications&email_token=AAAKQ2OQY3ISUSKPO7BLFTDQRIOC5A5CNFSM4GMJTZUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECWEUAY#issuecomment-548162051 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AAAKQ2IQAVDMXCVBUR3ZWQLQRIOC5ANCNFSM4GMJTZUA

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/davisking/dlib-models/issues/11?email_source=notifications&email_token=ABPYFR6IRGWI4PNRKTODKX3QRLLFRA5CNFSM4GMJTZUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECXXJLI#issuecomment-548369581, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPYFR3L2HVRKDUDMGM23LLQRLLFRANCNFSM4GMJTZUA .

csaftoiu commented 4 years ago

Is there any way to get the batch norm form of the model on the repo? Or is this reserved for secret sauce not for public consumption? :). I understand if it’s the latter.

If it’s not available I suppose we can’t transfer learn it as-is. If we load weights and swap out the affine for a random batch norm it seems that’d lose all the learning in first few steps. Best option seems to be to keep the affine as-is. Let me know what you think.

On Thu, Oct 31, 2019 at 11:52 PM Davis E. King notifications@github.com wrote:

Some things are lost when converting from batch norm to affine. Save in batch norm form when doing training.

On Thu, Oct 31, 2019 at 9:17 AM Claudiu notifications@github.com wrote:

Ah thanks for that! Very helpful.

I managed to get it to train a few steps on some images of my own. However I couldn’t load it into a net_type because the saved weights have the affine layers while the net_type has batchnorm layers. Though I see it auto converts from batchnorm to affine when saving, I wasn’t able to get it to auto convert from affine to batchnorm to keep training. So I have been training the anet_type directly.

Is there a way to retrieve the net_type from the saved weights on the repo? Or are part of the batchnorm parameters lost when saving the model meaning I can’t transfer learn it?

On Thu, Oct 31, 2019 at 12:02 AM Davis E. King <notifications@github.com

wrote:

The notes on how this model was trained are in the example program that shows how to use it: http://dlib.net/dnn_face_recognition_ex.cpp.html

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <

https://github.com/davisking/dlib-models/issues/11?email_source=notifications&email_token=AAAKQ2OQY3ISUSKPO7BLFTDQRIOC5A5CNFSM4GMJTZUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECWEUAY#issuecomment-548162051

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AAAKQ2IQAVDMXCVBUR3ZWQLQRIOC5ANCNFSM4GMJTZUA

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/davisking/dlib-models/issues/11?email_source=notifications&email_token=ABPYFR6IRGWI4PNRKTODKX3QRLLFRA5CNFSM4GMJTZUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECXXJLI#issuecomment-548369581 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ABPYFR3L2HVRKDUDMGM23LLQRLLFRANCNFSM4GMJTZUA

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/davisking/dlib-models/issues/11?email_source=notifications&email_token=AAAKQ2OIPL4XCVLKHUDYJTLQRNVVVA5CNFSM4GMJTZUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECZS6HQ#issuecomment-548613918, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAKQ2OEDSXHAB65ZNDRVT3QRNVVVANCNFSM4GMJTZUA .

davisking commented 4 years ago

You could copy the layer parameters into a network with batch norm layers and go in and manually fill in the missing batch norm parameters with something reasonable.

ismailpolas commented 4 years ago

Does anyone build the dlib_face_recognition_resnet_model_v1.dat with custom dataset? If Yes, Please share the method. Thanks in Advance.

davisking commented 4 years ago

http://dlib.net/dnn_face_recognition_ex.cpp.html and http://dlib.net/dnn_metric_learning_on_images_ex.cpp.html explain all that.

On Wed, Sep 9, 2020 at 6:06 AM ismailpolas notifications@github.com wrote:

Does anyone build the dlib_face_recognition_resnet_model_v1.dat with custom dataset? If Yes, Please share the method. Thanks in Advance.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/davisking/dlib-models/issues/11#issuecomment-689463468, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPYFRZ4RB3SAR3D2ZM6KPDSE5HRNANCNFSM4GMJTZUA .

aishaandatt commented 2 years ago

I tried Loading a custom dataset and successfully made the resnet .dat file but I'm getting this error. ERROR: Unexpected version found while deserializing dlib::input_rgb_image_sized. Please refer to the issue link given below for more detials on this error. https://github.com/davisking/dlib/issues/2598