INNER CODE UNIT · Python
LazyInstanceSegmentationMasks
allenai/ai2thor · ai2thor/server.py:59
class LazyInstanceSegmentationMasks(LazyMask):
def __init__(self, image_ids_data: bytes, metadata: dict):
self._masks: Dict[str, np.ndarray] = {}
self._loaded = False
screen_width = metadata["screenWidth"]
screen_height = metadata["screenHeight"]
item_size = int(len(image_ids_data) / (screen_width * screen_height))
self._unique_integer_keys: Optional[Set[np.uint32]] = None
self._empty_mask: Optional[np.ndarray] = None
if item_size == 4:
self.instance_segmentation_frame_uint32 = read_buffer_image(
image_ids_data, screen_width, screen_height, dtype=np.uint32
).squeeze()
# within ImageSynthesis.cs a RGBA32 frame is read, the alpha channel
# is always equal to 255
self._alpha_channel_value = 255