Commit 390b87ae authored by charlie's avatar charlie
Browse files

Formatting

parent 2c1cdd15
......@@ -160,8 +160,8 @@ struct nonmaxsuppression
// filter boxes below score_threshold
template <class T>
std::priority_queue<std::pair<double, int64_t>> filter_boxes_by_score(
T scores_start, std::size_t num_boxes, double score_threshold) const
std::priority_queue<std::pair<double, int64_t>>
filter_boxes_by_score(T scores_start, std::size_t num_boxes, double score_threshold) const
{
std::priority_queue<std::pair<double, int64_t>> boxes_heap;
auto insert_to_boxes_heap =
......@@ -180,16 +180,14 @@ struct nonmaxsuppression
}
template <class H, class S>
void select_boxes(
H& boxes_heap,
void select_boxes(H& boxes_heap,
std::vector<std::pair<double, int64_t>>& selected_boxes_inside_class,
std::vector<int64_t>& selected_indices,
S batch_boxes_start,
std::size_t max_output_boxes_per_class,
double iou_threshold,
std::size_t batch_idx,
std::size_t class_idx
) const
std::size_t class_idx) const
{
selected_boxes_inside_class.clear();
// Get the next box with top score, filter by iou_threshold
......@@ -199,8 +197,8 @@ struct nonmaxsuppression
// Check with existing selected boxes for this class, remove box if it
// exceeds the IOU (Intersection Over Union) threshold
const auto next_top_score = boxes_heap.top();
bool not_selected = std::any_of(
selected_boxes_inside_class.begin(),
bool not_selected =
std::any_of(selected_boxes_inside_class.begin(),
selected_boxes_inside_class.end(),
[&](auto selected_index) {
return this->suppress_by_iou(
......@@ -250,12 +248,20 @@ struct nonmaxsuppression
auto batch_idx = idx[0];
auto class_idx = idx[1];
// index offset for this class
auto scores_start = scores.begin() + (batch_idx * num_classes + class_idx) * num_boxes;
auto scores_start =
scores.begin() + (batch_idx * num_classes + class_idx) * num_boxes;
// iterator to first value of this batch
auto batch_boxes_start = boxes.begin() + batch_idx * num_boxes * 4;
auto boxes_heap =
filter_boxes_by_score(scores_start, num_boxes, score_threshold);
select_boxes(boxes_heap, selected_boxes_inside_class, selected_indices, batch_boxes_start, max_output_boxes_per_class, iou_threshold, batch_idx, class_idx);
select_boxes(boxes_heap,
selected_boxes_inside_class,
selected_indices,
batch_boxes_start,
max_output_boxes_per_class,
iou_threshold,
batch_idx,
class_idx);
});
std::copy(selected_indices.begin(), selected_indices.end(), output.begin());
});
......
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