(latent, model, height, width, generator, batch_size)
| 85 | |
| 86 | |
| 87 | def init_latent(latent, model, height, width, generator, batch_size): |
| 88 | if latent is None: |
| 89 | latent = torch.randn( |
| 90 | (1, model.unet.in_channels, height // 8, width // 8), |
| 91 | generator=generator, |
| 92 | ) |
| 93 | latents = latent.expand(batch_size, model.unet.in_channels, height // 8, width // 8).to(model.device) |
| 94 | return latent, latents |
| 95 | |
| 96 | |
| 97 | @torch.no_grad() |
no outgoing calls
no test coverage detected