Commit e89e28b9 authored by Juha Reunanen's avatar Juha Reunanen Committed by Davis E. King
Browse files

Clear truth_idxs between samples (#1870)

* Clear truth_idxs between samples

* Move truth_idxs inside loop body after all

* Push to truth_idxs even when the box can't be detected; improve formatting
parent 170877da
...@@ -1125,7 +1125,6 @@ namespace dlib ...@@ -1125,7 +1125,6 @@ namespace dlib
const float* out_data = output_tensor.host(); const float* out_data = output_tensor.host();
std::vector<size_t> truth_idxs; truth_idxs.reserve(truth->size());
std::vector<intermediate_detection> dets; std::vector<intermediate_detection> dets;
for (long i = 0; i < output_tensor.num_samples(); ++i) for (long i = 0; i < output_tensor.num_samples(); ++i)
{ {
...@@ -1140,6 +1139,8 @@ namespace dlib ...@@ -1140,6 +1139,8 @@ namespace dlib
det_thresh_speed_adjust = std::max(det_thresh_speed_adjust,dets[max_num_initial_dets].detection_confidence + options.loss_per_false_alarm); det_thresh_speed_adjust = std::max(det_thresh_speed_adjust,dets[max_num_initial_dets].detection_confidence + options.loss_per_false_alarm);
} }
std::vector<size_t> truth_idxs;
truth_idxs.reserve(truth->size());
// The loss will measure the number of incorrect detections. A detection is // The loss will measure the number of incorrect detections. A detection is
// incorrect if it doesn't hit a truth rectangle or if it is a duplicate detection // incorrect if it doesn't hit a truth rectangle or if it is a duplicate detection
...@@ -1155,6 +1156,7 @@ namespace dlib ...@@ -1155,6 +1156,7 @@ namespace dlib
{ {
// Ignore boxes that can't be detected by the CNN. // Ignore boxes that can't be detected by the CNN.
loss -= options.loss_per_missed_target; loss -= options.loss_per_missed_target;
truth_idxs.push_back(0);
continue; continue;
} }
const size_t idx = (k*output_tensor.nr() + p.y())*output_tensor.nc() + p.x(); const size_t idx = (k*output_tensor.nr() + p.y())*output_tensor.nc() + p.x();
...@@ -1241,7 +1243,6 @@ namespace dlib ...@@ -1241,7 +1243,6 @@ namespace dlib
hit_truth_table.assign(hit_truth_table.size(), false); hit_truth_table.assign(hit_truth_table.size(), false);
final_dets.clear(); final_dets.clear();
// Now figure out which detections jointly maximize the loss and detection score sum. We // Now figure out which detections jointly maximize the loss and detection score sum. We
// need to take into account the fact that allowing a true detection in the output, while // need to take into account the fact that allowing a true detection in the output, while
// initially reducing the loss, may allow us to increase the loss later with many duplicate // initially reducing the loss, may allow us to increase the loss later with many duplicate
......
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