Commit 0fede57e authored by Davis King's avatar Davis King
Browse files

Make the mmod loss not spam messages in the unit tests

parent c5c761b5
...@@ -941,6 +941,9 @@ namespace dlib ...@@ -941,6 +941,9 @@ namespace dlib
test_box_overlap overlaps_ignore; test_box_overlap overlaps_ignore;
bool use_bounding_box_regression = false; bool use_bounding_box_regression = false;
double bbr_lambda = 100; double bbr_lambda = 100;
// This field is intentionally not serialized because I want people to really think hard
// about ignoring the warnings that this suppresses.
bool be_quiet = false;
use_image_pyramid assume_image_pyramid = use_image_pyramid::yes; use_image_pyramid assume_image_pyramid = use_image_pyramid::yes;
...@@ -1432,10 +1435,13 @@ namespace dlib ...@@ -1432,10 +1435,13 @@ namespace dlib
const auto i = idx_to_truth_rect.find(idx); const auto i = idx_to_truth_rect.find(idx);
if (i != idx_to_truth_rect.end()) if (i != idx_to_truth_rect.end())
{ {
// Ignore duplicate truth box in feature coordinates. if (!options.be_quiet)
std::cout << "Warning, ignoring object. We encountered a truth rectangle located at " << x.rect; {
std::cout << ", and we are ignoring it because it maps to the exact same feature coordinates "; // Ignore duplicate truth box in feature coordinates.
std::cout << "as another truth rectangle located at " << i->second << "." << std::endl; std::cout << "Warning, ignoring object. We encountered a truth rectangle located at " << x.rect;
std::cout << ", and we are ignoring it because it maps to the exact same feature coordinates ";
std::cout << "as another truth rectangle located at " << i->second << "." << std::endl;
}
loss -= options.loss_per_missed_target; loss -= options.loss_per_missed_target;
truth_idxs.push_back(-1); truth_idxs.push_back(-1);
...@@ -1515,11 +1521,14 @@ namespace dlib ...@@ -1515,11 +1521,14 @@ namespace dlib
// added for it in the code above. // added for it in the code above.
loss -= options.loss_per_missed_target-out_data[idx]; loss -= options.loss_per_missed_target-out_data[idx];
g[idx] = 0; g[idx] = 0;
std::cout << "Warning, ignoring object. We encountered a truth rectangle located at " << (*truth)[i].rect; if (!options.be_quiet)
std::cout << " that is suppressed by non-max-suppression "; {
std::cout << "because it is overlapped by another truth rectangle located at " << best_matching_truth_box std::cout << "Warning, ignoring object. We encountered a truth rectangle located at " << (*truth)[i].rect;
<< " (IoU:"<< box_intersection_over_union(best_matching_truth_box,(*truth)[i]) <<", Percent covered:" std::cout << " that is suppressed by non-max-suppression ";
<< box_percent_covered(best_matching_truth_box,(*truth)[i]) << ")." << std::endl; std::cout << "because it is overlapped by another truth rectangle located at " << best_matching_truth_box
<< " (IoU:"<< box_intersection_over_union(best_matching_truth_box,(*truth)[i]) <<", Percent covered:"
<< box_percent_covered(best_matching_truth_box,(*truth)[i]) << ")." << std::endl;
}
} }
} }
} }
......
...@@ -861,6 +861,11 @@ namespace dlib ...@@ -861,6 +861,11 @@ namespace dlib
// getting the bounding box shape correct. // getting the bounding box shape correct.
double bbr_lambda = 100; double bbr_lambda = 100;
// Tell the loss not to print warnings about impossible labels. You should think very hard
// before turning this off as it's very often telling you something is really wrong with
// your training data.
bool be_quiet = false;
mmod_options ( mmod_options (
const std::vector<std::vector<mmod_rect>>& boxes, const std::vector<std::vector<mmod_rect>>& boxes,
const unsigned long target_size, const unsigned long target_size,
......
...@@ -4006,6 +4006,7 @@ namespace ...@@ -4006,6 +4006,7 @@ namespace
const std::vector<mmod_rect> labels = generate_labels(); const std::vector<mmod_rect> labels = generate_labels();
mmod_options options(use_image_pyramid::no, { labels }); mmod_options options(use_image_pyramid::no, { labels });
options.be_quiet = true;
// Define a simple network. // Define a simple network.
using net_type = loss_mmod<con<1,5,5,1,1,con<1,5,5,2,2,input<input_image_type>>>>; using net_type = loss_mmod<con<1,5,5,1,1,con<1,5,5,2,2,input<input_image_type>>>>;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment