From 4c08252cc343027880a4c321213088260e732d47 Mon Sep 17 00:00:00 2001 From: keineahnung2345 Date: Tue, 23 Oct 2018 15:51:05 +0800 Subject: [PATCH] [Bug fix]compute_overlaps_masks In compute_overlaps_masks(), the code checking the shape of masks1 and masks2 is not correct. 1. It should check masks' last dimension instead of first dimension to determine whether it's empty or not 2. When masks1 or masks2 is empty, it should return a zero array of shape (masks1.shape[-1], masks2.shape[-1]) --- mrcnn/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mrcnn/utils.py b/mrcnn/utils.py index 7e1c9d2..f65a56d 100644 --- a/mrcnn/utils.py +++ b/mrcnn/utils.py @@ -102,8 +102,8 @@ def compute_overlaps_masks(masks1, masks2): """ # If either set of masks is empty return empty result - if masks1.shape[0] == 0 or masks2.shape[0] == 0: - return np.zeros((masks1.shape[0], masks2.shape[-1])) + if masks1.shape[-1] == 0 or masks2.shape[-1] == 0: + return np.zeros((masks1.shape[-1], masks2.shape[-1])) # flatten masks and compute their areas masks1 = np.reshape(masks1 > .5, (-1, masks1.shape[-1])).astype(np.float32) masks2 = np.reshape(masks2 > .5, (-1, masks2.shape[-1])).astype(np.float32) -- GitLab