Remove unused grid_sizes assignment in CameraWanModel, WanModel_S2V, HumoWanModel, and AnimateWanModel; simplify patch size initialization in WanUni3CControlnet; refine sigmas check in WanUni3CCnetPatch.
This commit is contained in:
parent
9227315a52
commit
2c01c141b3
|
|
@ -908,7 +908,6 @@ class CameraWanModel(WanModel):
|
|||
if self.control_adapter is not None and camera_conditions is not None:
|
||||
x = x + self.control_adapter(camera_conditions).to(x.dtype)
|
||||
grid_sizes = x.shape[2:]
|
||||
transformer_options["grid_sizes"] = grid_sizes
|
||||
x = x.flatten(2).transpose(1, 2)
|
||||
|
||||
# time embeddings
|
||||
|
|
@ -1368,7 +1367,6 @@ class WanModel_S2V(WanModel):
|
|||
t = t.unsqueeze(1).repeat(1, x.shape[2])
|
||||
|
||||
grid_sizes = x.shape[2:]
|
||||
transformer_options["grid_sizes"] = grid_sizes
|
||||
x = x.flatten(2).transpose(1, 2)
|
||||
seq_len = x.size(1)
|
||||
|
||||
|
|
@ -1635,7 +1633,6 @@ class HumoWanModel(WanModel):
|
|||
x_input = x
|
||||
x = self.patch_embedding(x.float()).to(x.dtype)
|
||||
grid_sizes = x.shape[2:]
|
||||
transformer_options["grid_sizes"] = grid_sizes
|
||||
x = x.flatten(2).transpose(1, 2)
|
||||
|
||||
# time embeddings
|
||||
|
|
|
|||
|
|
@ -497,7 +497,6 @@ class AnimateWanModel(WanModel):
|
|||
x = self.patch_embedding(x.float()).to(x.dtype)
|
||||
x, motion_vec = self.after_patch_embedding(x, pose_latents, face_pixel_values)
|
||||
grid_sizes = x.shape[2:]
|
||||
transformer_options["grid_sizes"] = grid_sizes
|
||||
x = x.flatten(2).transpose(1, 2)
|
||||
|
||||
# time embeddings
|
||||
|
|
|
|||
|
|
@ -97,13 +97,11 @@ class WanUni3CControlnet(nn.Module):
|
|||
device=None, dtype=None, operations=None
|
||||
):
|
||||
super().__init__()
|
||||
self.dtype = dtype
|
||||
self.patch_size = (1, 2, 2)
|
||||
self.in_channels = in_channels
|
||||
patch_size = (1, 2, 2)
|
||||
self.num_layers = num_layers
|
||||
|
||||
self.controlnet_patch_embedding = operations.Conv3d(
|
||||
in_channels, conv_out_dim, kernel_size=self.patch_size, stride=self.patch_size, device=device, dtype=torch.float32)
|
||||
in_channels, conv_out_dim, kernel_size=patch_size, stride=patch_size, device=device, dtype=torch.float32)
|
||||
self.controlnet_mask_embedding = MaskCamEmbed(add_channels, mid_channels, conv_out_dim, device=device, dtype=dtype, operations=operations)
|
||||
|
||||
if conv_out_dim != dim:
|
||||
|
|
@ -152,11 +150,3 @@ class WanUni3CControlnet(nn.Module):
|
|||
hidden = self.controlnet_blocks[block_index](hidden, temb, freqs, transformer_options=transformer_options)
|
||||
residual = self.proj_out[block_index](hidden)
|
||||
return hidden, residual
|
||||
|
||||
def forward(self, control_input, temb, render_mask=None, camera_embedding=None, transformer_options={}):
|
||||
hidden, freqs = self.process_input(control_input, render_mask=render_mask, camera_embedding=camera_embedding)
|
||||
controlnet_states = []
|
||||
for i in range(self.num_layers):
|
||||
hidden, residual = self.forward_block(i, hidden, temb, freqs, transformer_options=transformer_options)
|
||||
controlnet_states.append(residual)
|
||||
return controlnet_states
|
||||
|
|
|
|||
|
|
@ -572,7 +572,7 @@ class WanUni3CCnetPatch:
|
|||
self.temp_data = None
|
||||
active = True
|
||||
sigmas = transformer_options.get("sigmas", None)
|
||||
if sigmas is not None and sigmas.numel() > 0:
|
||||
if sigmas is not None:
|
||||
sigma = sigmas[0].item()
|
||||
if sigma > self.sigma_start or sigma < self.sigma_end:
|
||||
active = False
|
||||
|
|
|
|||
Loading…
Reference in New Issue