| 587 | return self.text_encoders |
| 588 | |
| 589 | def vae_encode(self, img): |
| 590 | # move channel dim to end |
| 591 | # works for both images (b c h w) and video (b c f h w) |
| 592 | img = img.movedim(1, -1) |
| 593 | # Pixels are in range [-1, 1], Comfy code expects [0, 1] |
| 594 | img = (img + 1) / 2 |
| 595 | latents = self.vae.encode(img) |
| 596 | if self.latent_format is not None: |
| 597 | # some older models do this in prepare_inputs() so it can be None |
| 598 | latents = self.latent_format.process_in(latents) |
| 599 | return latents |
| 600 | |
| 601 | def vae_decode(self, latents): |
| 602 | if self.latent_format is not None: |