opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.43k stars 5.76k forks source link

Expose training code of the Facemark API for python #2071

Open shardulparab97 opened 5 years ago

shardulparab97 commented 5 years ago

I believe that exposing the Facemark APIs training section for python would be helpful for python users. However, I think that some sections of the code will require refactoring before exposing.

Would like to hear ideas from the community regarding the same. Would put in a PR regarding this issue in the next couple of days. :smiley:

shardulparab97 commented 5 years ago

@berak @spmallick need your thoughts about the same.

shardulparab97 commented 5 years ago

I feel the main thing to disucss is the best way to set our own detector - which is required by the calcMeanShape() function called by the training() function - (say for Kazemi)

shardulparab97 commented 5 years ago

This is a basic attempt made a few weeks ago - to expose Kazemi training via python

[]()https://github.com/opencv/opencv_contrib/compare/master...shardulparab97:sparab_face_opencv

It creates the function trainKazemi - which can be called via python to train using Kazemi.

However, herein I had to set in my own default detector - in calcMeanShape - because otherwise we need to set the detector using setFaceDetector - we need to do major refactoring to bring in this function out to python/ search for some other way out.

This code is very preliminary, simple giving a start to solve the given issue.

@spmallick @berak would like to hear your thoughts on the same.

shardulparab97 commented 5 years ago

Also added a sample file to show the functionality of trainKazemi ( currently only using the fit function of LBF to get landmarks).

[]()https://github.com/opencv/opencv_contrib/blob/e6a50d366a5eacbc53bbdb200bb807fd4bdd5d8b/modules/face/samples/facemarkKazemi_train.py

alalek commented 5 years ago

@shardulparab97 Could you please create PR with your patch? (for easy review of patch)

shardulparab97 commented 5 years ago

@alalek Sure will do. However, this is not the ideal solution, because have used shortwiring in places. Getting a review will be great so that can receive ideas especially for cases of refactoring the code! :smiley: