in gt_converter/convert_coco.py [0:0]
def _create_submasks(annotated_image, category_ids):
"""
Create masks for each labels annotation label
:param annotated_image: Numpy array of annotated image
:param category_ids: Dictionary of label ids mapped to RGB values
:return: Dictionary of numpy arrays for each labels annotations
"""
sub_masks = {}
for color in category_ids.keys():
color = ast.literal_eval(color)
sub_mask = np.pad(
np.alltrue(annotated_image == list(color), axis=2),
pad_width=1,
mode="constant",
constant_values=False,
)
if np.sum(sub_mask) > 0:
sub_masks[str(color)] = sub_mask
return sub_masks