MCPcopy Create free account
hub / github.com/CompVis/zigma / array2grid

Function array2grid

wandb_utils.py:91–105  ·  view source on GitHub ↗
(x, to255=False)

Source from the content-addressed store, hash-verified

89
90
91def array2grid(x, to255=False):
92 nrow = round(math.sqrt(x.size(0)))
93 x = make_grid(x, nrow=nrow, normalize=True, value_range=(-1, 1))
94 if to255:
95 x = (
96 x.mul(255)
97 .add_(0.5)
98 .clamp_(0, 255)
99 .permute(1, 2, 0)
100 .to("cpu", torch.uint8)
101 .numpy()
102 )
103 else:
104 x = x.permute(1, 2, 0).to("cpu", torch.uint8).numpy()
105 return x
106
107
108def array2grid_pixel(x):

Callers 1

log_imageFunction · 0.85

Calls 1

toMethod · 0.80

Tested by

no test coverage detected