Review fixes

This commit is contained in:
Juha Reunanen 2019-11-11 16:05:42 +02:00
parent a8eef91ac7
commit 0b4a0bc2ad
1 changed files with 31 additions and 28 deletions

View File

@ -993,6 +993,36 @@ namespace dlib
}
}
std::ostream& operator<<(std::ostream& out, const std::vector<mmod_options::detector_window_details>& 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<std::string, std::deque<mmod_options::detector_window_details>> 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<const dlib::mmod_options::detector_window_details*> detector_windows;
std::map<std::string, detector_windows> 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;