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

Class T2IVisualizer

diff2flow/visualizer.py:65–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63
64
65class T2IVisualizer:
66 def __init__(self, show_x1=False):
67 self.show_x1 = show_x1
68
69 def __call__(self, x0=None, x1=None, x1_pred=None):
70 if self.show_x1:
71 images = torch.cat([x1, x1_pred], dim=-1) # [b c h (2w)]
72 images = tensor2im(images) # (b h w c) in [0, 255]
73 images = einops.rearrange(images, 'b h w c -> (b h) w c')
74 images = Image.fromarray(images)
75 else:
76 # ignore x0 and x1, only visualize x1_pred
77 images = tensor2im(x1_pred) # (b h w c) in [0, 255]
78 images = ims_to_grid(images, stack="row", split=2, channel_last=True) # (h w c)
79 images = Image.fromarray(images)
80 return images
81
82
83def per_sample_min_max_normalization(x):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected