I'm trying to compute the IoU, with the matterport Mask R-cnn implementation, for each class (13 in total) that i have in my dataset. For now i managed to compute the average IoU for all the classes with this code:

def compute_batch_ap(image_ids):
    APs = []
    for image_id in image_ids:
        # Load image
        image, image_meta, gt_class_id, gt_bbox, gt_mask =\
            modellib.load_image_gt(dataset, config,
                                   image_id, use_mini_mask= False)
        # Run object detection
        results = model.detect([image], verbose=0)
        # Compute AP
        r = results[0]
        AP, precisions, recalls, overlaps =\
            utils.compute_ap(gt_bbox, gt_class_id, gt_mask,
                              r['rois'], r['class_ids'], r['scores'], r['masks'])
    return APs
image_ids = dataset.image_ids
APs = compute_batch_ap(image_ids)
print("mAP @ IoU=50: ", np.mean(APs))

I've tried to search everywhere for a solution but i didn't find anything. How could i resolve this problem?

  • $\begingroup$ hello, welcome to Artificial Intelligence Stack Exchange. If your question is about programming, then it is considered as an off-topic. Read here for more details regarding this. $\endgroup$
    – hanugm
    Jul 29, 2021 at 7:38


You must log in to answer this question.

Browse other questions tagged .