Open-Sora: Democratizing Efficient Video Production for All
Python
debug
Shen-Chenhui3aa248d7cf3c
diff --git a/opensora/models/vae/model_utils.py b/opensora/models/vae/model_utils.pyindex 2737fec..95cb456 100644--- a/opensora/models/vae/model_utils.py+++ b/opensora/models/vae/model_utils.py@@ -91,10 +91,10 @@ class DiagonalGaussianDistribution(object):self.std = torch.exp(0.5 * self.logvar)self.var = torch.exp(self.logvar)if self.deterministic:- self.var = self.std = torch.zeros_like(self.mean).to(device=self.parameters.device, dtype=dtype)+ self.var = self.std = torch.zeros_like(self.mean).to(device=self.parameters.device, dtype=self.mean.dtype)def sample(self):- x = self.mean + self.std * torch.randn(self.mean.shape).to(device=self.parameters.device, dtype=self.dtype)+ x = self.mean + self.std * torch.randn(self.mean.shape).to(device=self.parameters.device, dtype=self.mean.dtype)return xdef kl(self, other=None):diff --git a/opensora/models/vae/vae_3d.py b/opensora/models/vae/vae_3d.pyindex cec4011..45e13ea 100644--- a/opensora/models/vae/vae_3d.py+++ b/opensora/models/vae/vae_3d.py@@ -413,8 +413,11 @@ class VAE_3D(nn.Module):# self.loss = model_utils.VEA3DLoss(kl_weight=kl_weight)- self.quant_conv = nn.Conv3d(latent_embed_dim, 2*kl_embed_dim, 1, dtype=dtype, device=device)- self.post_quant_conv = nn.Conv3d(kl_embed_dim, latent_embed_dim, 1, dtype=dtype, device=device)+ # self.quant_conv = nn.Conv3d(latent_embed_dim, 2*kl_embed_dim, 1, dtype=dtype, device=device)+ self.quant_conv = nn.Conv3d(latent_embed_dim, 2*kl_embed_dim, 1, device=device)++ # self.post_quant_conv = nn.Conv3d(kl_embed_dim, latent_embed_dim, 1, dtype=dtype, device=device)+ self.post_quant_conv = nn.Conv3d(kl_embed_dim, latent_embed_dim, 1, device=device)self.dtype = dtypedef encode(@@ -422,7 +425,7 @@ class VAE_3D(nn.Module):x,):encoded_feature = self.encoder(x)- moments = self.quant_conv(encoded_feature)+ moments = self.quant_conv(encoded_feature).to(x.dtype)posterior = model_utils.DiagonalGaussianDistribution(moments, dtype=self.dtype)return posterior@@ -430,7 +433,8 @@ class VAE_3D(nn.Module):self,z,):- z = self.post_quant_conv(z)+ dtype = z.dtype+ z = self.post_quant_conv(z).to(dtype)dec = self.decoder(z)return dec