The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Fix cosmos VAE failing with videos longer than 121 frames.
comfyanonymouscca96a85ae75
diff --git a/comfy/ldm/cosmos/vae.py b/comfy/ldm/cosmos/vae.pyindex c8db68612..d64f292de 100644--- a/comfy/ldm/cosmos/vae.py+++ b/comfy/ldm/cosmos/vae.py@@ -18,6 +18,7 @@ import loggingimport torchfrom torch import nnfrom enum import Enum+import mathfrom .cosmos_tokenizer.layers3d import (EncoderFactorized,@@ -105,17 +106,23 @@ class CausalContinuousVideoTokenizer(nn.Module):z, posteriors = self.distribution(moments)latent_ch = z.shape[1]latent_t = z.shape[2]- dtype = z.dtype- mean = self.latent_mean.view(latent_ch, -1)[:, : latent_t].reshape([1, latent_ch, -1, 1, 1]).to(dtype=dtype, device=z.device)- std = self.latent_std.view(latent_ch, -1)[:, : latent_t].reshape([1, latent_ch, -1, 1, 1]).to(dtype=dtype, device=z.device)+ in_dtype = z.dtype+ mean = self.latent_mean.view(latent_ch, -1)+ std = self.latent_std.view(latent_ch, -1)++ mean = mean.repeat(1, math.ceil(latent_t / mean.shape[-1]))[:, : latent_t].reshape([1, latent_ch, -1, 1, 1]).to(dtype=in_dtype, device=z.device)+ std = std.repeat(1, math.ceil(latent_t / std.shape[-1]))[:, : latent_t].reshape([1, latent_ch, -1, 1, 1]).to(dtype=in_dtype, device=z.device)return ((z - mean) / std) * self.sigma_datadef decode(self, z):in_dtype = z.dtypelatent_ch = z.shape[1]latent_t = z.shape[2]- mean = self.latent_mean.view(latent_ch, -1)[:, : latent_t].reshape([1, latent_ch, -1, 1, 1]).to(dtype=in_dtype, device=z.device)- std = self.latent_std.view(latent_ch, -1)[:, : latent_t].reshape([1, latent_ch, -1, 1, 1]).to(dtype=in_dtype, device=z.device)+ mean = self.latent_mean.view(latent_ch, -1)+ std = self.latent_std.view(latent_ch, -1)++ mean = mean.repeat(1, math.ceil(latent_t / mean.shape[-1]))[:, : latent_t].reshape([1, latent_ch, -1, 1, 1]).to(dtype=in_dtype, device=z.device)+ std = std.repeat(1, math.ceil(latent_t / std.shape[-1]))[:, : latent_t].reshape([1, latent_ch, -1, 1, 1]).to(dtype=in_dtype, device=z.device)z = z / self.sigma_dataz = z * std + mean