From 4f0e43ec1b8dc7d5c7cbbed4ff5c6b6fdaf7b4e3 Mon Sep 17 00:00:00 2001 From: Kevin Turner <83819+keturn@users.noreply.github.com> Date: Fri, 18 Aug 2023 14:05:12 -0700 Subject: [PATCH] fix(TAESD): correct usage of singledispatchmethod so normal VAE still works --- invokeai/app/invocations/latent.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/invokeai/app/invocations/latent.py b/invokeai/app/invocations/latent.py index ee6ed63da8..2098581d53 100644 --- a/invokeai/app/invocations/latent.py +++ b/invokeai/app/invocations/latent.py @@ -736,11 +736,12 @@ class ImageToLatentsInvocation(BaseInvocation): context.services.latents.save(name, latents) return build_latents_output(latents_name=name, latents=latents, seed=None) + @singledispatchmethod def _encode_to_tensor(self, vae: AutoencoderKL, image_tensor: torch.FloatTensor) -> torch.FloatTensor: image_tensor_dist = vae.encode(image_tensor).latent_dist latents = image_tensor_dist.sample().to(dtype=vae.dtype) # FIXME: uses torch.randn. make reproducible! return latents - @singledispatchmethod - def _encode_to_tensor(self, vae: AutoencoderTiny, image_tensor: torch.FloatTensor) -> torch.FloatTensor: + @_encode_to_tensor.register + def _(self, vae: AutoencoderTiny, image_tensor: torch.FloatTensor) -> torch.FloatTensor: return vae.encode(image_tensor).latents