Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Add RLE support (#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
botcs authored and fmassa committed Apr 13, 2019
1 parent 42fa3a1 commit c5c4d52
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions maskrcnn_benchmark/structures/segmentation_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ def __init__(self, masks, size):
elif isinstance(masks, (list, tuple)):
if isinstance(masks[0], torch.Tensor):
masks = torch.stack(masks, dim=2).clone()
elif isinstance(masks[0], dict) and "count" in masks[0]:
elif isinstance(masks[0], dict) and "counts" in masks[0]:
# RLE interpretation

masks = mask_utils
assert all(
[(size[0], size[1]) == tuple(inst["size"]) for inst in masks]
)
masks = mask_utils.decode(masks)
masks = torch.tensor(masks).permute(2, 0, 1)
else:
RuntimeError(
"Type of `masks[0]` could not be interpreted: %s" % type(masks)
Expand Down

0 comments on commit c5c4d52

Please sign in to comment.