Skip to content

Commit

Permalink
Update utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
yqNLP authored and waleedka committed Jun 5, 2018
1 parent d56e13c commit 5427473
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mrcnn/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,14 @@ def compute_overlaps_masks(masks1, masks2):
'''Computes IoU overlaps between two sets of masks.
masks1, masks2: [Height, Width, instances]
'''

#if the model detect nothing,the return r['mask'].shape=[0,28,28],and the following np.reshape() would report an error.
if masks1.shape[0]==0:
return np.zeros((masks1.shape[0],masks2.shape[-1]))
# flatten masks
masks1 = np.reshape(masks1 > .5, (-1, masks1.shape[-1])).astype(np.float32)
masks2 = np.reshape(masks2 > .5, (-1, masks2.shape[-1])).astype(np.float32)

area1 = np.sum(masks1, axis=0)
area2 = np.sum(masks2, axis=0)

Expand All @@ -113,6 +118,7 @@ def compute_overlaps_masks(masks1, masks2):
return overlaps



def non_max_suppression(boxes, scores, threshold):
"""Performs non-maximum supression and returns indicies of kept boxes.
boxes: [N, (y1, x1, y2, x2)]. Notice that (y2, x2) lays outside the box.
Expand Down

0 comments on commit 5427473

Please sign in to comment.