(x)
| 25 | |
| 26 | |
| 27 | def custom_to_np(x): |
| 28 | # saves the batch in adm style as in https://github.com/openai/guided-diffusion/blob/main/scripts/image_sample.py |
| 29 | sample = x.detach().cpu() |
| 30 | sample = ((sample + 1) * 127.5).clamp(0, 255).to(torch.uint8) |
| 31 | sample = sample.permute(0, 2, 3, 1) |
| 32 | sample = sample.contiguous() |
| 33 | return sample |
| 34 | |
| 35 | |
| 36 | def logs2pil(logs, keys=["sample"]): |