INNER CODE UNIT · Python
empty_mask
allenai/ai2thor · ai2thor/server.py:111
def empty_mask(self) -> np.ndarray:
if self._empty_mask is None:
self._empty_mask = np.zeros(self.instance_segmentation_frame_uint32.shape, dtype=bool)
self._empty_mask.flags["WRITEABLE"] = False
return self._empty_mask
@property
def unique_integer_keys(self) -> Set[np.uint32]:
if self._unique_integer_keys is None:
self._unique_integer_keys = set(np.unique(self.instance_segmentation_frame_uint32))
return self._unique_integer_keys
def _integer_color_key(self, color: List[int]) -> np.uint32:
a = np.array(color + [self._alpha_channel_value], dtype=np.uint8)
# mypy complains, but it is safe to modify the dtype on an ndarray
a.dtype = np.uint32 # type: ignore