Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add equalScore param #47

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions csrc/faster_eval_api/coco_eval/cocoeval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ namespace coco_eval
std::vector<double> *recalls,
std::vector<double> *precisions_out,
std::vector<double> *scores_out,
std::vector<double> *recalls_out)
std::vector<double> *recalls_out,
bool equal_score)
{
assert(recalls_out->size() > recalls_out_index);

Expand Down Expand Up @@ -391,9 +392,15 @@ namespace coco_eval
recalls->emplace_back(recall);
const int64_t num_valid_detections =
true_positives_sum + false_positives_sum;
const double precision = num_valid_detections > 0
? static_cast<double>(true_positives_sum) / num_valid_detections
: 0.0;

double precision = 0;
if(equal_score){
precision = num_valid_detections > 0 ? 1 : 0.0;
}else{
precision = num_valid_detections > 0
? static_cast<double>(true_positives_sum) / num_valid_detections
: 0.0;
}
precisions->emplace_back(precision);
}

Expand Down Expand Up @@ -445,6 +452,7 @@ namespace coco_eval
const int num_area_ranges = (const int) py::len(params.attr("areaRng"));
const int num_max_detections = (const int) py::len(params.attr("maxDets"));
const int num_images = (const int) py::len(params.attr("imgIds"));
bool equal_score = params.attr("equalScore").cast<bool>();

std::vector<double> precisions_out(
num_iou_thresholds * num_recall_thresholds * num_categories *
Expand Down Expand Up @@ -537,7 +545,8 @@ namespace coco_eval
&recalls,
&precisions_out,
&scores_out,
&recalls_out);
&recalls_out,
equal_score);
}
}
}
Expand Down Expand Up @@ -864,4 +873,4 @@ namespace coco_eval

} // namespace COCOeval

} // namespace coco_eval
} // namespace coco_eval
5 changes: 5 additions & 0 deletions faster_coco_eval/core/cocoeval.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,11 @@ def __init__(
# f: Frequent: >= 100
self.imgCountLbl = ["r", "c", "f"]

# https://github.com/MiXaiLL76/faster_coco_eval/issues/46
# mAP is wrong if all scores are equal (=not providing a score)
# set equalScore = True
self.equalScore = False

@property
def useSegm(self):
return int(self.iouType == "segm")
Expand Down
Loading