Skip to content

Commit

Permalink
Fix: color_splash when no masks are detected
Browse files Browse the repository at this point in the history
Reported here: #500
  • Loading branch information
waleedka committed Jun 5, 2018
1 parent ed72103 commit a593c30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mrcnn/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2429,7 +2429,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(masks.shape[1:3] + (0,))
if full_masks else np.empty(original_image_shape[:2] + (0,))

return boxes, class_ids, scores, full_masks

Expand Down
8 changes: 4 additions & 4 deletions samples/balloon/balloon.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ def color_splash(image, mask):
# Make a grayscale copy of the image. The grayscale copy still
# has 3 RGB channels, though.
gray = skimage.color.gray2rgb(skimage.color.rgb2gray(image)) * 255
# We're treating all instances as one, so collapse the mask into one layer
mask = (np.sum(mask, -1, keepdims=True) >= 1)
# Copy color pixels from the original color image where mask is set
if mask.shape[0] > 0:
if mask.shape[-1] > 0:
# We're treating all instances as one, so collapse the mask into one layer
mask = (np.sum(mask, -1, keepdims=True) >= 1)
splash = np.where(mask, image, gray).astype(np.uint8)
else:
splash = gray
splash = gray.astype(np.uint8)
return splash


Expand Down

0 comments on commit a593c30

Please sign in to comment.