Compute IoU for each class in Mask R-cnn

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'])
        APs.append(AP)
    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?

Topic faster-rcnn object-detection computer-vision python

Category Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.