patrikhuber / superviseddescent

C++11 implementation of the supervised descent optimisation method
http://patrikhuber.github.io/superviseddescent/
Apache License 2.0
402 stars 188 forks source link

Questions: how to optimize the speed of landmark detection code #46

Closed ardeal closed 7 years ago

ardeal commented 7 years ago

Hi Patrikhuber,

I would like to run only landmark detection on your SDM code, and I would like to make the prediction code run faster as long as the landmark accuracy is good for me.

as you might know that, the most time needed for SDM landmark is for HOG calculation, and the time is mostly related with the size of ROI image calculated in adaptive_vlhog.hpp file.

my questions are: 1) in your rcr-train.cpp file, you set hog_params as follows: std::vector hog_params{ { VlHogVariant::VlHogVariantUoctti, 5, 11, 4, 1.0f }, { VlHogVariant::VlHogVariantUoctti, 5, 10, 4, 0.7f }, { VlHogVariant::VlHogVariantUoctti, 5, 8, 4, 0.4f }, { VlHogVariant::VlHogVariantUoctti, 5, 6, 4, 0.25f } }; why is num_cells 5? shouldn't it be an even number?

2) in order to keep the accuracy and promote the speed, what are the best hog_params according to your experience?

3) in rcr-train.cpp file, the regressor level is 4. should it be smaller? what is the best regressor level according to your experience?

patrikhuber commented 7 years ago

Hi,

1: I think an odd number is fine ;-) But for this one you should really look at the VlHog documentation, it will have all the details!

2: The ones that are set are pretty good and also a good trade-off. You can search through the issue list here, I think in one of the issues I posted a table or XLS with some parameter values and results. As for the speed, I'm not sure which parameters have main influence on speed, you'll have to test that.

3: 4 is the best trade-off imho, 3 is too little, 5 gives slightly better result but is slower/bigger.

ardeal commented 7 years ago

Thanks Patrikhuber for your answer!

I tested some parameters and would like to share my test result with you and all developers: I tried to reduce the cell size from big to small, and I found out that the following HOG parameters gave the best trade-off between and performance and speed: rcr::HoGParam hogptemp1 = { VlHogVariant::VlHogVariantUoctti, 4, 6, 4, 0.6f }; rcr::HoGParam hogptemp2 = { VlHogVariant::VlHogVariantUoctti, 4, 4, 4, 0.4f }; rcr::HoGParam hogptemp3 = { VlHogVariant::VlHogVariantUoctti, 4, 3, 4, 0.3f }; rcr::HoGParam hogptemp4 = { VlHogVariant::VlHogVariantUoctti, 4, 2, 4, 0.2f };

I set the landmarks number to 21 and the time needed is 6.6ms on I5 3.2G CPU, 7 landmarks and the time is 2.6ms.

ardeal commented 7 years ago

the major time needed for SDM prediction is to calculate HOG for each regressor and each landmark. if we reduce the number of landmarks, the time needed will be greatly reduced. Furthermore, HOG parameters will also greatly affect the time needed, especially cell size of HOG.

patrikhuber commented 7 years ago

Yep that makes total sense! Thanks for posting back for anyone that may find it useful.