Fix controlnet bug for wan2.2 and add workflow examples

This commit is contained in:
denk
2025-08-09 13:38:19 +03:00
parent cf8e403f88
commit af0b4d9a29
3 changed files with 6 additions and 9 deletions
+3 -8
View File
@@ -15,13 +15,6 @@ from diffusers.models.transformers.transformer_wan import (
WanTransformerBlock
)
def zero_module(module):
for p in module.parameters():
nn.init.zeros_(p)
return module
logger = logging.get_logger(__name__) # pylint: disable=invalid-name
def zero_module(module):
@@ -189,7 +182,6 @@ class WanControlnet(ModelMixin, ConfigMixin, PeftAdapterMixin, FromOriginalModel
logger.warning(
"Passing `scale` via `attention_kwargs` when not using the PEFT backend is ineffective."
)
rotary_emb = self.rope(hidden_states)
# 0. Controlnet encoder
@@ -204,6 +196,9 @@ class WanControlnet(ModelMixin, ConfigMixin, PeftAdapterMixin, FromOriginalModel
# timestep shape: batch_size, or batch_size, seq_len (wan 2.2 ti2v)
if timestep.ndim == 2:
## for ComfyUI workflow
if hidden_states.shape[1] != timestep.shape[1]:
timestep = timestep.repeat_interleave(hidden_states.shape[1] // timestep.shape[1], dim=1)
ts_seq_len = timestep.shape[1]
timestep = timestep.flatten() # batch_size * seq_len
else:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long