mirror of https://github.com/davisking/dlib.git
Made this trainer automatically determine decent parameters
for the test_box_overlap object when it is used and the user hasn't specifically assigned an overlap tester.
This commit is contained in:
parent
9027f84ceb
commit
806c637259
|
@ -50,6 +50,14 @@ namespace dlib
|
|||
loss_per_false_alarm = 1;
|
||||
|
||||
scanner.copy_configuration(scanner_);
|
||||
|
||||
auto_overlap_tester = is_same_type<overlap_tester_type,test_box_overlap>::value;
|
||||
}
|
||||
|
||||
bool auto_set_overlap_tester (
|
||||
) const
|
||||
{
|
||||
return auto_overlap_tester;
|
||||
}
|
||||
|
||||
void set_overlap_tester (
|
||||
|
@ -57,11 +65,19 @@ namespace dlib
|
|||
)
|
||||
{
|
||||
overlap_tester = tester;
|
||||
auto_overlap_tester = false;
|
||||
}
|
||||
|
||||
overlap_tester_type get_overlap_tester (
|
||||
) const
|
||||
{
|
||||
// make sure requires clause is not broken
|
||||
DLIB_ASSERT(auto_set_overlap_tester() == false,
|
||||
"\t overlap_tester_type structural_object_detection_trainer::get_overlap_tester()"
|
||||
<< "\n\t You can't call this function if the overlap tester is generated dynamically."
|
||||
<< "\n\t this: " << this
|
||||
);
|
||||
|
||||
return overlap_tester;
|
||||
}
|
||||
|
||||
|
@ -235,8 +251,32 @@ namespace dlib
|
|||
<< "\n\t is_learning_problem(images,truth_rects): " << is_learning_problem(images,truth_rects)
|
||||
);
|
||||
|
||||
overlap_tester_type local_overlap_tester;
|
||||
|
||||
if (auto_overlap_tester)
|
||||
{
|
||||
image_scanner_type local_scanner;
|
||||
local_scanner.copy_configuration(scanner);
|
||||
std::vector<std::vector<rectangle> > mapped_rects(truth_rects.size());
|
||||
for (unsigned long i = 0; i < truth_rects.size(); ++i)
|
||||
{
|
||||
local_scanner.load(images[i]);
|
||||
mapped_rects[i].resize(truth_rects[i].size());
|
||||
for (unsigned long j = 0; j < truth_rects[i].size(); ++j)
|
||||
{
|
||||
mapped_rects[i][j] = local_scanner.get_best_matching_rect(truth_rects[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
local_overlap_tester = find_tight_overlap_tester(mapped_rects);
|
||||
}
|
||||
else
|
||||
{
|
||||
local_overlap_tester = overlap_tester;
|
||||
}
|
||||
|
||||
structural_svm_object_detection_problem<image_scanner_type,overlap_tester_type,image_array_type >
|
||||
svm_prob(scanner, overlap_tester, images, truth_rects, num_threads);
|
||||
svm_prob(scanner, local_overlap_tester, images, truth_rects, num_threads);
|
||||
|
||||
if (verbose)
|
||||
svm_prob.be_verbose();
|
||||
|
@ -253,7 +293,7 @@ namespace dlib
|
|||
solver(svm_prob,w);
|
||||
|
||||
// report the results of the training.
|
||||
return object_detector<image_scanner_type,overlap_tester_type>(scanner, overlap_tester, w);
|
||||
return object_detector<image_scanner_type,overlap_tester_type>(scanner, local_overlap_tester, w);
|
||||
}
|
||||
|
||||
|
||||
|
@ -271,6 +311,7 @@ namespace dlib
|
|||
unsigned long max_cache_size;
|
||||
double loss_per_missed_target;
|
||||
double loss_per_false_alarm;
|
||||
bool auto_overlap_tester;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -60,6 +60,24 @@ namespace dlib
|
|||
- #get_loss_per_false_alarm() == 1
|
||||
- This object will attempt to learn a model for the given
|
||||
scanner object when train() is called.
|
||||
- if (overlap_tester_type == test_box_overlap) then
|
||||
- #auto_set_overlap_tester() == true
|
||||
- else
|
||||
- #auto_set_overlap_tester() == false
|
||||
!*/
|
||||
|
||||
bool auto_set_overlap_tester (
|
||||
) const;
|
||||
/*!
|
||||
ensures
|
||||
- if (this object will automatically determine an appropriate
|
||||
state for the overlap tester used for non-max suppression.) then
|
||||
- returns true
|
||||
- In this case, it is determined using the find_tight_overlap_tester()
|
||||
routine based on the truth_rects given to the
|
||||
structural_object_detection_trainer::train() method.
|
||||
- else
|
||||
- returns false
|
||||
!*/
|
||||
|
||||
void set_overlap_tester (
|
||||
|
@ -68,11 +86,14 @@ namespace dlib
|
|||
/*!
|
||||
ensures
|
||||
- #get_overlap_tester() == tester
|
||||
- #auto_set_overlap_tester() == false
|
||||
!*/
|
||||
|
||||
overlap_tester_type get_overlap_tester (
|
||||
) const;
|
||||
/*!
|
||||
requires
|
||||
- auto_set_overlap_tester() == false
|
||||
ensures
|
||||
- returns the overlap tester object which will be used to perform non-max suppression.
|
||||
In particular, this function returns the overlap tester which will populate the
|
||||
|
|
Loading…
Reference in New Issue