| 133 | |
| 134 | @torch.no_grad() |
| 135 | def encode_condition_image(self, images): |
| 136 | dtype = next(self.pipeline.vae.parameters()).dtype |
| 137 | image_pil = [v2.functional.to_pil_image(images[i]) for i in range(images.shape[0])] |
| 138 | image_pt = self.pipeline.feature_extractor_vae(images=image_pil, return_tensors="pt").pixel_values |
| 139 | image_pt = image_pt.to(device=self.device, dtype=dtype) |
| 140 | latents = self.pipeline.vae.encode(image_pt).latent_dist.sample() |
| 141 | return latents |
| 142 | |
| 143 | @torch.no_grad() |
| 144 | def encode_target_images(self, images): |