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

Add RLE support #657

Merged
merged 1 commit into from
Apr 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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