Skip to content

Commit e67a6c8

Browse files
committed
Fix handling detections that return no masks.
1 parent 9ea12cd commit e67a6c8

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

mrcnn/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2418,7 +2418,7 @@ def unmold_detections(self, detections, mrcnn_mask, original_image_shape,
24182418
full_mask = utils.unmold_mask(masks[i], boxes[i], original_image_shape)
24192419
full_masks.append(full_mask)
24202420
full_masks = np.stack(full_masks, axis=-1)\
2421-
if full_masks else np.empty((0,) + masks.shape[1:3])
2421+
if full_masks else np.empty(masks.shape[1:3] + (0,))
24222422

24232423
return boxes, class_ids, scores, full_masks
24242424

samples/nucleus/nucleus.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ def rle_decode(rle, shape):
335335
def mask_to_rle(image_id, mask, scores):
336336
"Encodes instance masks to submission format."
337337
assert mask.ndim == 3, "Mask must be [H, W, count]"
338+
# If mask is empty, return line with image ID only
339+
if mask.shape[-1] == 0:
340+
return "{},".format(image_id)
338341
# Remove mask overlaps
339342
# Multiply each instance mask by its score order
340343
# then take the maximum across the last dimension

0 commit comments

Comments
 (0)