From 2e002ac2da700ac87fda47de5fcad8026affc50e Mon Sep 17 00:00:00 2001 From: Evgeniy Fominov Date: Wed, 30 Mar 2016 10:37:03 +0300 Subject: [PATCH] Python/Simple object detector trainer. Added upsample_limit option --- tools/python/src/object_detection.cpp | 10 +++++++++- tools/python/src/simple_object_detector.h | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/python/src/object_detection.cpp b/tools/python/src/object_detection.cpp index 1d77e30b9..58a7ab297 100644 --- a/tools/python/src/object_detection.cpp +++ b/tools/python/src/object_detection.cpp @@ -159,7 +159,15 @@ solver more accurate but might take longer to train.") &type::num_threads, "train_simple_object_detector() will use this many threads of \n\ execution. Set this to the number of CPU cores on your machine to \n\ -obtain the fastest training speed."); +obtain the fastest training speed.") + .add_property("upsample_limit", &type::upsample_limit, + &type::upsample_limit, +"train_simple_object_detector() will upsample images if needed \n\ +no more than upsample_limit times. Value 0 will forbid trainer to \n\ +upsample any images. If trainer is unable to fit all boxes with \n\ +required upsample_limit, exception will be thrown. Higher values \n\ +of upsample_limit exponentially increases memory requiremens. \n\ +Values higher than 2 (default) are not recommended."); } { typedef simple_test_results type; diff --git a/tools/python/src/simple_object_detector.h b/tools/python/src/simple_object_detector.h index b1cfcdfdf..4fceab429 100644 --- a/tools/python/src/simple_object_detector.h +++ b/tools/python/src/simple_object_detector.h @@ -33,6 +33,7 @@ namespace dlib detection_window_size = 80*80; C = 1; epsilon = 0.01; + upsample_limit = 2; } bool be_verbose; @@ -41,6 +42,7 @@ namespace dlib unsigned long detection_window_size; double C; double epsilon; + unsigned long upsample_limit; }; // ---------------------------------------------------------------------------------------- @@ -175,7 +177,7 @@ namespace dlib // upsample the images at most two times to help make the boxes obtainable. std::vector > temp(boxes), removed; removed = remove_unobtainable_rectangles(trainer, images, temp); - while (impl::contains_any_boxes(removed) && upsampling_amount < 2) + while (impl::contains_any_boxes(removed) && upsampling_amount < options.upsample_limit) { ++upsampling_amount; if (options.be_verbose)