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

Python bindings for Facemark Training Code #2197

Open
wants to merge 2 commits into
base: 4.x
Choose a base branch
from

Conversation

saiteja-talluri
Copy link

@saiteja-talluri saiteja-talluri commented Jul 22, 2019

This pull request contains my progress in the GSoC project on facial landmark detection.

This pull request does the following updates to the facemark api.

  1. FacemarkKazemi now inherits from FacemarkTrain and is in same level as FacemarkAAM and FacemarkLBF
  2. Python bindings have been added to most of the functions so that the training can be done now in python as well.

Examples for the python code for training and fitting can be found here - https://github.com/saiteja-talluri/GSoC-OpenCV

More detailed report of the project can be found here - https://gist.github.com/saiteja-talluri/1d0e4fc4c75774b936b99c7c52b65fe6/

Relevant tests have been updated post the modifications.

@mshabunin mshabunin added the GSoC label Jul 26, 2019
@StevenPuttemans
Copy link

hi @saiteja-talluri just out of curiosity (was mentor of a similar GSoC project in 2017) how does this training code differ from the facemark Kazemi training example (and backend functionality to apply the training) we did back then? You can see it at: https://github.com/sukhad-app/opencv_contrib/blob/face_alignment/modules/face/samples/sample_train_landmark_detector.cpp

Or did you basically expand it for the other 2 models?

@saiteja-talluri
Copy link
Author

hello @StevenPuttemans . There is no change in the training code as such, but the inheritance structure for the AAM, LBF and Kazemi are different, so creating python bindings became very difficult. So I basically changed the structure keeping the training logic same and added suitable functions so that the python users have same power as the C++ users.

@StevenPuttemans
Copy link

@saiteja-talluri thank you for the elaboration! Thumbs up for the nice work done.

@utkarshparasarampuria
Copy link

utkarshparasarampuria commented Feb 5, 2020

Any particular reason why this is not merged yet? It would be great to have this feature in the Python library.

@@ -38,10 +38,15 @@ TEST(CV_Face_FacemarkKazemi, can_create_default) {
TEST(CV_Face_FacemarkKazemi, can_loadTrainingData) {
string filename = cvtest::findDataFile("face/lbpcascade_frontalface_improved.xml", true);
string configfile_name = cvtest::findDataFile("face/config.xml", true);
string modelfilename = "face_landmark_model.dat";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where the file is located?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saiteja-talluri can you share the file so that it can be merged?

Copy link

@vikasgupta-github vikasgupta-github Apr 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asmorkalov Is there any other way we can merge this. The python bindings are pretty important. If the rest of the code is fine, can we skip the test_face_align.cpp code and merge the rest of it?

Copy link
Contributor

@berak berak Apr 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asmorkalov ,@vikasgupta-github

Where the file is located?

"face_landmark_model.dat" is the name of the output file, the trained kazemi model.
it will get created, where the script runs
(there is nothing to share or redistribute here)

(btw, when building opencv libs, cmake will also download a pretrained version into .cache)

can we merge it now, and add the missing input validation later ? (i'd even volunteer to do so :])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not 100% sure, but it looks like an example face_landmark_model.dat file is here

CV_UNUSED(items);
return false;
}
bool FacemarkKazemiImpl::addTrainingSample(InputArray image, std::vector<Point2f> & landmarks){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some asserts for input values can be useful here.

return faceDetector(image, faces, faceDetectorData);
}
bool FacemarkKazemiImpl::defaultFaceDetector(const Mat& image, std::vector<Rect>& faces){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some asserts for input values can be useful here.

@vikasgupta-github
Copy link

vikasgupta-github commented Sep 2, 2020

Hi @saiteja-talluri. Can you provide further info so that it can be merged? This would be really useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants