in mapillary_vistas/evaluation/instance_specific_instance_level.py [0:0]
def calculate_iou_for_indices(ground_truth_indices, prediction_indices, ground_truth_size, prediction_size):
"""
Helper function to calculate the overlap of a match.
"""
# optimised version of
# np.count_nonzero(np.logical_and(ground_truth_indices, prediction_indices))
intersection = np.count_nonzero(prediction_indices[ground_truth_indices])
union = prediction_size + ground_truth_size - intersection
if union == 0:
iou = float('nan')
else:
iou = intersection / float(union)
return {
'intersection': intersection,
'iou': iou,
'false_positives': prediction_size - intersection,
'false_negatives': ground_truth_size - intersection,
'prediction_size': prediction_size,
'ground_truth_size': ground_truth_size,
}