diff --git a/dlib/dnn/loss.h b/dlib/dnn/loss.h index 7d4365ad6..ab2807b19 100644 --- a/dlib/dnn/loss.h +++ b/dlib/dnn/loss.h @@ -993,6 +993,36 @@ namespace dlib } } + std::ostream& operator<<(std::ostream& out, const std::vector& detector_windows) + { + // write detector windows grouped by label + // example output: aeroplane:74x30,131x30,70x45,54x70,198x30;bicycle:70x57,32x70,70x32,51x70,128x30,30x121;car:70x36,70x60,99x30,52x70,30x83,30x114,30x200 + + std::map> detector_windows_by_label; + for (const auto& detector_window : detector_windows) + detector_windows_by_label[detector_window.label].push_back(detector_window); + + size_t label_count = 0; + for (const auto& i : detector_windows_by_label) + { + const auto& label = i.first; + const auto& detector_windows = i.second; + + if (label_count++ > 0) + out << ";"; + out << label << ":"; + + for (size_t j = 0; j < detector_windows.size(); ++j) + { + out << detector_windows[j].width << "x" << detector_windows[j].height; + if (j + 1 < detector_windows.size()) + out << ","; + } + } + + return out; + } + // ---------------------------------------------------------------------------------------- class loss_mmod_ @@ -1395,37 +1425,10 @@ namespace dlib { out << "loss_mmod\t ("; - out << "detector_windows:("; auto& opts = item.options; - { - // write detector windows grouped by label - // example output: detector_windows:(aeroplane:74x30,131x30,70x45,54x70,198x30;bicycle:70x57,32x70,70x32,51x70,128x30,30x121;car:70x36,70x60,99x30,52x70,30x83,30x114,30x200) - typedef std::deque detector_windows; - std::map detector_windows_by_label; - for (const auto& detector_window : opts.detector_windows) - detector_windows_by_label[detector_window.label].push_back(&detector_window); + out << "detector_windows:(" << opts.detector_windows << ")"; - size_t label_count = 0; - for (const auto& i : detector_windows_by_label) - { - const auto& label = i.first; - const auto& detector_windows = i.second; - - if (label_count++ > 0) - out << ";"; - out << label << ":"; - - for (size_t i = 0; i < detector_windows.size(); ++i) - { - out << detector_windows[i]->width << "x" << detector_windows[i]->height; - if (i+1 < detector_windows.size()) - out << ","; - } - } - } - - out << ")"; out << ", loss per FA:" << opts.loss_per_false_alarm; out << ", loss per miss:" << opts.loss_per_missed_target; out << ", truth match IOU thresh:" << opts.truth_match_iou_threshold;