From 94f59f09c88c2b53e07bb12ce44c630912379b7c Mon Sep 17 00:00:00 2001 From: kijai <40791699+kijai@users.noreply.github.com> Date: Thu, 10 Apr 2025 23:27:36 +0300 Subject: [PATCH] map camera types --- nodes.py | 28 ++++++++++++++++++++++++++-- wanvideo/modules/model.py | 2 ++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/nodes.py b/nodes.py index 3120c9e..49ff0e3 100644 --- a/nodes.py +++ b/nodes.py @@ -2046,7 +2046,18 @@ class WanVideoReCamMasterCameraEmbed: @classmethod def INPUT_TYPES(s): return {"required": { - "camera_type": ([str(i+1) for i in range(10)], {"default": "0", "tooltip": "Camera type to use"}), + "camera_type": ([ + "pan_right", + "pan_left", + "tilt_up", + "tilt_down", + "zoom_in", + "zoom_out", + "translate_up", + "translate_down", + "arc_left", + "arc_right", + ], {"default": "pan_right", "tooltip": "Camera type to use"}), "latents": ("LATENT", {"tooltip": "source video"}), }, } @@ -2070,9 +2081,22 @@ class WanVideoReCamMasterCameraEmbed: C, T, H, W = samples.shape num_frames = (T - 1) * 4 + 1 + camera_type_map = { + "pan_right": 1, + "pan_left": 2, + "tilt_up": 3, + "tilt_down": 4, + "zoom_in": 5, + "zoom_out": 6, + "translate_up": 7, + "translate_down": 8, + "arc_left": 9, + "arc_right": 10, + } + cam_idx = list(range(num_frames))[::4] print("cam_idx", cam_idx) - traj = [self.parse_matrix(cam_data[f"frame{idx}"][f"cam{int(camera_type):02d}"]) for idx in cam_idx] + traj = [self.parse_matrix(cam_data[f"frame{idx}"][f"cam{int(camera_type_map[camera_type]):02d}"]) for idx in cam_idx] traj = np.stack(traj).transpose(0, 2, 1) c2ws = [] for c2w in traj: diff --git a/wanvideo/modules/model.py b/wanvideo/modules/model.py index f16488c..8b010e4 100644 --- a/wanvideo/modules/model.py +++ b/wanvideo/modules/model.py @@ -493,8 +493,10 @@ class WanAttentionBlock(nn.Module): seq_lens, grid_sizes, freqs, rope_func=rope_func ) + #ReCamMaster if camera_embed is not None: y = self.projector(y) + x = x.to(torch.float32) + (y.to(torch.float32) * e[2].to(torch.float32)) # cross-attention & ffn function