def print_all(self): if plt is None: logger.log(('matplotlib', logger.Text.highlight), ' not found. So cannot display images') images = [to_numpy(v) for v in self._values.values()] images = np.concatenate(images) n_images = len(images) cols = max(1, int(math.sqrt(n_images))) fig: plt.Figure fig, axs = plt.subplots((n_images + cols - 1) // cols, cols, sharex='all', sharey='all', figsize=(8, 10)) fig.suptitle(self.name) for i, img in enumerate(images): if len(images) > 1: ax: plt.Axes = axs[i // cols, i % cols] else: ax = axs if img.shape[0] == 1: img = img[0, :, :] else: img = img.transpose(1, 2, 0) if img.dtype.type in (np.float32, np.float64): img = np.clip(img, 0., 1.) else: img = np.clip(img, 0, 255) ax.imshow(img) plt.show()
def print_all(self): if plt is None: logger.log(('matplotlib', logger.Text.highlight), ' not found. So cannot display images') images = [to_numpy(v) for v in self._values.values()] cols = 3 fig: plt.Figure fig, axs = plt.subplots((len(images) + cols - 1) // cols, cols, sharex='all', sharey='all', figsize=(8, 10)) fig.suptitle(self.name) for i, img in enumerate(images): ax: plt.Axes = axs[i // cols, i % cols] ax.imshow(img) plt.show()
def _collect_value(self, key: str, value): self._values[key] = to_numpy(value)
def collect_value(self, value): value = to_numpy(value).ravel() if len(value) > 0: self._values.append(to_numpy(value).ravel())
def collect_value(self, value): self._is_empty = False self._values.append(to_numpy(value).ravel())
def collect_value(self, value): self._values.append(to_numpy(value).ravel())