INNER CODE UNIT · Python

unique_integer_keys

allenai/ai2thor · ai2thor/server.py:119

    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
        return a[0]

    def _load_all(self):
        if not self._loaded:
            all_integer_keys = self.unique_integer_keys
            for color_name, color in self.instance_colors.items():
                if self._integer_color_key(color) in all_integer_keys:
                    self.__getitem__(color_name)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…