| 63 | |
| 64 | |
| 65 | class 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 | |
| 83 | def per_sample_min_max_normalization(x): |
nothing calls this directly
no outgoing calls
no test coverage detected