(vae, latents)
| 76 | |
| 77 | |
| 78 | def latent2image(vae, latents): |
| 79 | latents = 1 / 0.18215 * latents |
| 80 | image = vae.decode(latents)['sample'] |
| 81 | image = (image / 2 + 0.5).clamp(0, 1) |
| 82 | image = image.cpu().permute(0, 2, 3, 1).numpy() |
| 83 | image = (image * 255).astype(np.uint8) |
| 84 | return image |
| 85 | |
| 86 | |
| 87 | def init_latent(latent, model, height, width, generator, batch_size): |
no test coverage detected