Skip to content

Open-Sora: Democratizing Efficient Video Production for All

Python

debug

Shen-Chenhuid53245a98c96
diff --git a/configs/vae_magvit_v2/train/17x128x128.py b/configs/vae_magvit_v2/train/17x128x128.py
index 29cfb56..6367d12 100644
--- a/configs/vae_magvit_v2/train/17x128x128.py
+++ b/configs/vae_magvit_v2/train/17x128x128.py
@@ -19,7 +19,6 @@ sp_size = 1
model = dict(
type="VAE_MAGVIT_V2",
- num_frames = num_frames,
in_out_channels = 3,
latent_embed_dim = 256,
filters = 128,
@@ -28,10 +27,11 @@ model = dict(
temporal_downsample = (False, True, True),
num_groups = 32, # for nn.GroupNorm
kl_embed_dim = 64,
- custom_conv_padding = None,
activation_fn = 'swish',
- # image_size = image_size,
separate_first_frame_encoding = False,
+ custom_conv_padding = None,
+ # num_frames = num_frames,
+ # image_size = image_size,
# kl_loss_weight = 0.000001,
# perceptual_loss_weight = 0.1, # use vgg is not None and more than 0
# discriminator_factor = 1.0,
diff --git a/opensora/models/vae/vae_3d_v2.py b/opensora/models/vae/vae_3d_v2.py
index 1ff96f8..ff376a1 100644
--- a/opensora/models/vae/vae_3d_v2.py
+++ b/opensora/models/vae/vae_3d_v2.py
@@ -592,30 +592,30 @@ class VAE_3D_V2(nn.Module):
latent_embed_dim = 256,
filters = 128,
num_res_blocks = 2,
- image_size = (128, 128),
separate_first_frame_encoding = False,
+ channel_multipliers = (1, 2, 2, 4),
+ temporal_downsample = (True, True, False),
+ num_groups = 32, # for nn.GroupNorm
+ custom_conv_padding = None,
+ activation_fn = 'swish',
+ in_out_channels = 4,
+ kl_embed_dim = 64,
+ device="cpu",
+ dtype="bf16",
+ # image_size = (128, 128),
# kl_loss_weight = 0.000001,
# perceptual_loss_weight = 0.1,
# vgg = None,
# vgg_weights: VGG16_Weights = VGG16_Weights.DEFAULT,
- channel_multipliers = (1, 2, 2, 4),
- temporal_downsample = (True, True, False),
- num_frames = 17,
+ # num_frames = 17,
# discriminator_factor = 1.0,
# discriminator_in_channels = 3,
# discriminator_filters = 128,
- discriminator_channel_multipliers = (2,4,4,4,4),
+ # discriminator_channel_multipliers = (2,4,4,4,4),
# discriminator_loss="hinge",
# discriminator_start=50001,
- num_groups = 32, # for nn.GroupNorm
# conv_downsample = False,
# upsample = "nearest+conv", # options: "deconv", "nearest+conv"
- custom_conv_padding = None,
- activation_fn = 'swish',
- in_out_channels = 4,
- kl_embed_dim = 64,
- device="cpu",
- dtype="bf16",
# precision: Any = jax.lax.Precision.DEFAULT
):
super().__init__()
@@ -911,7 +911,7 @@ class VAE_3D_V2(nn.Module):
class VEALoss(nn.Module):
def __init__(
self,
- perceptual_loss_weight=0.1,
+ perceptual_loss_weight = 0.1,
kl_loss_weight = 0.000001,
vgg=None,
vgg_weights: VGG16_Weights = VGG16_Weights.DEFAULT,
@@ -924,7 +924,7 @@ class VEALoss(nn.Module):
self.perceptual_loss_weight = perceptual_loss_weight
self.vgg = None
self.perceptual_loss_weight = perceptual_loss_weight
- if perceptual_loss_weight is not None and perceptual_loss_weight > 0:
+ if perceptual_loss_weight is not None and perceptual_loss_weight > 0.0:
if not exists(vgg):
vgg = torchvision.models.vgg16(
weights = vgg_weights
diff --git a/scripts/train-vae-v2.py b/scripts/train-vae-v2.py
index 0f2a354..9297081 100644
--- a/scripts/train-vae-v2.py
+++ b/scripts/train-vae-v2.py
@@ -148,7 +148,6 @@ def main():
vae = vae.to(device, dtype)
discriminator = discriminator.to(device, dtype)
- breakpoint() # TODO: check vae parameters
# 4.5. setup optimizer
# vae optimizer