Skip to content

Uninitialized precision variable in cocoeval.cpp #188

Description

@HaaniaSiddiqui

Hi, I noticed a possible uninitialized variable issue in evaluation/fastevaluate/fastevaluate/cocoeval.cpp.

precision_value_tmp is declared but not initialized:

precision_value = 0;
recall_value = 0;
double precision_value_tmp, recall_value_tmp;
for (int t = 0; t < T; t++) {
    for (int r = R-1; r >= 0; r--) {
        offset = t*R*K*A*M + r*K*A*M + k*A*M + aind*M + mind;
        if (precision[offset] > 0) {
            precision_value_tmp = precision[offset];
            break;
        }
    }
    precision_value += precision_value_tmp;
    offset = t*K*A*M + k*A*M + aind*M + mind;
    recall_value_tmp = recall[offset];
    recall_value += recall_value_tmp; 
}
precision_value /= T;
recall_value /= T;

If all precision[offset] values for a given IoU threshold are 0 or -1, then precision_value_tmp may never be assigned before it is added to precision_value. This can overestimate averaged precision, and therefore F1, by reusing a previous positive precision value where the current threshold/category should contribute 0.

A possible fix would be to initialize it per threshold:

for (int t = 0; t < T; t++) {
    double precision_value_tmp = 0.0;
    ...
}

Could you confirm whether this is intentional, or whether initializing the temporary value to 0.0 would be the expected behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions