Skip to content

Commit

Permalink
Clipping bbox in the mAP evaluator calculation. (#8872)
Browse files Browse the repository at this point in the history
  • Loading branch information
qingqing01 authored Mar 8, 2018
1 parent fecc9a3 commit ffda2c4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion paddle/fluid/operators/detection_map_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ class DetectionMAPOpKernel : public framework::OpKernel<T> {
}
}

inline void ClipBBox(const Box& bbox, Box* clipped_bbox) const {
T one = static_cast<T>(1.0);
T zero = static_cast<T>(0.0);
clipped_bbox->xmin = std::max(std::min(bbox.xmin, one), zero);
clipped_bbox->ymin = std::max(std::min(bbox.ymin, one), zero);
clipped_bbox->xmax = std::max(std::min(bbox.xmax, one), zero);
clipped_bbox->ymax = std::max(std::min(bbox.ymax, one), zero);
}

void GetBoxes(const framework::LoDTensor& input_label,
const framework::LoDTensor& input_detect,
std::vector<std::map<int, std::vector<Box>>>& gt_boxes,
Expand Down Expand Up @@ -360,7 +369,9 @@ class DetectionMAPOpKernel : public framework::OpKernel<T> {
size_t max_idx = 0;
auto score = pred_boxes[i].first;
for (size_t j = 0; j < matched_bboxes.size(); ++j) {
T overlap = JaccardOverlap(pred_boxes[i].second, matched_bboxes[j]);
Box& pred_box = pred_boxes[i].second;
ClipBBox(pred_box, &pred_box);
T overlap = JaccardOverlap(pred_box, matched_bboxes[j]);
if (overlap > max_overlap) {
max_overlap = overlap;
max_idx = j;
Expand Down

0 comments on commit ffda2c4

Please sign in to comment.