This commit is contained in:
Eugene Fairley 2025-06-27 11:33:44 -07:00
parent a30704e0c0
commit ee8a636cb7
3 changed files with 7 additions and 4 deletions

View File

@ -440,7 +440,7 @@ class WanModel(torch.nn.Module):
# embeddings
self.patch_embedding = operations.Conv3d(
in_dim, dim, kernel_size=patch_size, stride=patch_size, device=operation_settings.get("device"), dtype=torch.float32)
20, dim, kernel_size=patch_size, stride=patch_size, device=operation_settings.get("device"), dtype=torch.float32)
self.text_embedding = nn.Sequential(
operations.Linear(text_dim, dim, device=operation_settings.get("device"), dtype=operation_settings.get("dtype")), nn.GELU(approximate='tanh'),
operations.Linear(dim, dim, device=operation_settings.get("device"), dtype=operation_settings.get("dtype")))

View File

@ -1064,6 +1064,7 @@ class WAN21(BaseModel):
def concat_cond(self, **kwargs):
noise = kwargs.get("noise", None)
extra_channels = self.diffusion_model.patch_embedding.weight.shape[1] - noise.shape[1]
print(f"extra channels: {extra_channels}, noise shape: {noise.shape}, patch embedding weight shape: {self.diffusion_model.patch_embedding.weight.shape}")
if extra_channels == 0:
return None
@ -1080,6 +1081,7 @@ class WAN21(BaseModel):
image[:, i: i + 16] = self.process_latent_in(image[:, i: i + 16])
image = utils.resize_to_batch_size(image, noise.shape[0])
print(f"image shape: {image.shape}")
if not self.image_to_video or extra_channels == image.shape[1]:
return image
@ -1098,8 +1100,10 @@ class WAN21(BaseModel):
mask = torch.nn.functional.pad(mask, (0, 0, 0, 0, 0, noise.shape[-3] - mask.shape[-3]), mode='constant', value=0)
if mask.shape[1] == 1:
mask = mask.repeat(1, 4, 1, 1, 1)
print(f"Mask shape: {mask.shape}, noise shape: {noise.shape}")
mask = utils.resize_to_batch_size(mask, noise.shape[0])
print(f"image shape: {image.shape}, mask shape: {mask.shape}")
return torch.cat((mask, image), dim=1)
def extra_conds(self, **kwargs):

View File

@ -657,7 +657,6 @@ class WanTrackToVideo:
zero_frames = torch.zeros(3, 81 - 1, height, width)
start_image = start_image.permute(3,0,1,2) # C, T, H, W
start_image = start_image * 2 - 1
res = torch.concat([
start_image.to(start_image.device),
zero_frames
@ -668,7 +667,7 @@ class WanTrackToVideo:
res.permute(1,2,3,0)[:, :, :, :3] # T, H, W, C
)[0]
y = torch.concat([msk, y])
print('?')
motion_patched = patch_motion(processed_tracks, y, temperature, (4, 16), topk)[None]
mask, video = motion_patched[:, 0:4], motion_patched[:, 4:]
# Add motion features to conditioning