Skip to content

Fix bug in detection_map_op. #8777

Closed
Closed
@qingqing01

Description

@qingqing01

The Output(AccumPosCount) is a LoDTensor with a shape [class_number, 1], but following code will get the shape: [max_class_id + 1, 1], the max_class_id + 1 is not alwasy equal to class_number.

https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/fluid/operators/detection_map_op.h#L186

    int max_class_id = 0;
    int true_pos_count = 0;
    int false_pos_count = 0;
    for (auto it = label_pos_count.begin(); it != label_pos_count.end(); ++it) {
      int label = it->first;
      if (label > max_class_id) max_class_id = label;
      int label_num_pos = it->second;
      if (label_num_pos == 0 || true_pos.find(label) == true_pos.end())
        continue;
      auto label_true_pos = true_pos.find(label)->second;
      auto label_false_pos = false_pos.find(label)->second;
      true_pos_count += label_true_pos.size();
      false_pos_count += label_false_pos.size();
    }

    int* pos_count_data = output_pos_count.mutable_data<int>(
        framework::make_ddim({max_class_id + 1, 1}), ctx.GetPlace());

The Output(AccumTruePos) and Output(AccumFalsePos) also have problem.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions