Added num_threads to shape_predictor_training_options.

This commit is contained in:
Davis King 2018-02-11 18:15:40 -05:00
parent 2a26521b0b
commit aca8087371
2 changed files with 9 additions and 0 deletions

View File

@ -208,6 +208,8 @@ void bind_shape_predictors(py::module &m)
e.g a padding of 0.5 would cause the algorithm to sample pixels from a box that was 2x2 pixels") e.g a padding of 0.5 would cause the algorithm to sample pixels from a box that was 2x2 pixels")
.def_readwrite("random_seed", &type::random_seed, .def_readwrite("random_seed", &type::random_seed,
"The random seed used by the internal random number generator") "The random seed used by the internal random number generator")
.def_readwrite("num_threads", &type::num_threads,
"Use this many threads/CPU cores for training.")
.def("__str__", &::print_shape_predictor_training_options) .def("__str__", &::print_shape_predictor_training_options)
.def(py::pickle(&getstate<type>, &setstate<type>)); .def(py::pickle(&getstate<type>, &setstate<type>));
} }

View File

@ -30,6 +30,7 @@ namespace dlib
num_test_splits = 20; num_test_splits = 20;
feature_pool_region_padding = 0; feature_pool_region_padding = 0;
random_seed = ""; random_seed = "";
num_threads = 0;
} }
bool be_verbose; bool be_verbose;
@ -43,6 +44,9 @@ namespace dlib
unsigned long num_test_splits; unsigned long num_test_splits;
double feature_pool_region_padding; double feature_pool_region_padding;
std::string random_seed; std::string random_seed;
// not serialized
unsigned long num_threads;
}; };
inline void serialize ( inline void serialize (
@ -110,6 +114,7 @@ namespace dlib
<< "num_test_splits=" << o.num_test_splits << "," << "num_test_splits=" << o.num_test_splits << ","
<< "feature_pool_region_padding=" << o.feature_pool_region_padding << "," << "feature_pool_region_padding=" << o.feature_pool_region_padding << ","
<< "random_seed=" << o.random_seed << "random_seed=" << o.random_seed
<< "num_threads=" << o.num_threads
<< ")"; << ")";
return sout.str(); return sout.str();
} }
@ -165,6 +170,7 @@ namespace dlib
trainer.set_feature_pool_region_padding(options.feature_pool_region_padding); trainer.set_feature_pool_region_padding(options.feature_pool_region_padding);
trainer.set_lambda(options.lambda_param); trainer.set_lambda(options.lambda_param);
trainer.set_num_test_splits(options.num_test_splits); trainer.set_num_test_splits(options.num_test_splits);
trainer.set_num_threads(options.num_threads);
if (options.be_verbose) if (options.be_verbose)
{ {
@ -176,6 +182,7 @@ namespace dlib
std::cout << "Training with oversampling amount: " << options.oversampling_amount << std::endl; std::cout << "Training with oversampling amount: " << options.oversampling_amount << std::endl;
std::cout << "Training with feature pool size: " << options.feature_pool_size << std::endl; std::cout << "Training with feature pool size: " << options.feature_pool_size << std::endl;
std::cout << "Training with feature pool region padding: " << options.feature_pool_region_padding << std::endl; std::cout << "Training with feature pool region padding: " << options.feature_pool_region_padding << std::endl;
std::cout << "Training with " << options.num_threads << " threads." << std::endl;
std::cout << "Training with lambda_param: " << options.lambda_param << std::endl; std::cout << "Training with lambda_param: " << options.lambda_param << std::endl;
std::cout << "Training with " << options.num_test_splits << " split tests."<< std::endl; std::cout << "Training with " << options.num_test_splits << " split tests."<< std::endl;
trainer.be_verbose(); trainer.be_verbose();