提交 54274731 编写于 作者: Y yezqNLP 提交者: Waleed

Update utils.py

上级 d56e13ce
......@@ -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)
......@@ -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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册