MCPcopy Create free account
hub / github.com/CompVis/diff2flow / ImageVisualizer

Class ImageVisualizer

diff2flow/visualizer.py:51–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49
50
51class ImageVisualizer:
52 def __call__(self, *images) -> Image:
53 # images: list of tensors that is not normalized in shape of [b c h w]
54 images = [i for i in images if i is not None] # hack to exclude None (e.g. x0 is noise)
55 images = torch.stack(images) # [n b c h w]
56 images = einops.rearrange(images, 'n b c h w -> (b h) (n w) c')
57 images = images / 2 + 0.5
58 images = images.cpu().numpy()
59 images = np.clip(images, 0, 1)
60 images = (images * 255).astype(np.uint8)
61 images = Image.fromarray(images)
62 return images
63
64
65class T2IVisualizer:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected