Skip to content

Commit

Permalink
Fix handling detections that return no masks.
Browse files Browse the repository at this point in the history
  • Loading branch information
waleedka committed Apr 13, 2018
1 parent 9ea12cd commit e67a6c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mrcnn/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2418,7 +2418,7 @@ def unmold_detections(self, detections, mrcnn_mask, original_image_shape,
full_mask = utils.unmold_mask(masks[i], boxes[i], original_image_shape)
full_masks.append(full_mask)
full_masks = np.stack(full_masks, axis=-1)\
if full_masks else np.empty((0,) + masks.shape[1:3])
if full_masks else np.empty(masks.shape[1:3] + (0,))

return boxes, class_ids, scores, full_masks

Expand Down
3 changes: 3 additions & 0 deletions samples/nucleus/nucleus.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ def rle_decode(rle, shape):
def mask_to_rle(image_id, mask, scores):
"Encodes instance masks to submission format."
assert mask.ndim == 3, "Mask must be [H, W, count]"
# If mask is empty, return line with image ID only
if mask.shape[-1] == 0:
return "{},".format(image_id)
# Remove mask overlaps
# Multiply each instance mask by its score order
# then take the maximum across the last dimension
Expand Down

0 comments on commit e67a6c8

Please sign in to comment.