One-to-all pose cfg
This commit is contained in:
@@ -2211,7 +2211,7 @@ class WanModel(torch.nn.Module):
|
||||
num_cond_latents=None,
|
||||
add_text_emb=None,
|
||||
sdancer_input=None, # SteadyDancer
|
||||
one_to_all_input=None, # One-to-All
|
||||
one_to_all_input=None, one_to_all_controlnet_strength=0.0 # One-to-All
|
||||
):
|
||||
r"""
|
||||
Forward pass through the diffusion model
|
||||
@@ -2340,9 +2340,8 @@ class WanModel(torch.nn.Module):
|
||||
self.refextractor.to(self.offload_device)
|
||||
# pose controlnet
|
||||
controlnet_tokens = one_to_all_input.get("controlnet_tokens", None)
|
||||
if not is_uncond and controlnet_tokens is not None and one_to_all_input['controlnet_start_percent'] <= current_step_percentage <= one_to_all_input['controlnet_end_percent']:
|
||||
onetoall_control_enabled = True
|
||||
onetoall_control_strength = one_to_all_input.get("controlnet_strength", 1.0)
|
||||
if controlnet_tokens is not None and one_to_all_input['controlnet_start_percent'] <= current_step_percentage <= one_to_all_input['controlnet_end_percent']:
|
||||
onetoall_control_enabled = one_to_all_controlnet_strength != 0.0
|
||||
# token replace
|
||||
if one_to_all_input.get("token_replace", False):
|
||||
use_token_replace = True
|
||||
@@ -3042,7 +3041,7 @@ class WanModel(torch.nn.Module):
|
||||
# One-to-All-Animation controlnet
|
||||
if onetoall_control_enabled:
|
||||
if prev_x is not None and (b - 1) < len(self.controlnet.blocks):
|
||||
tqdm.write(f"Applying One-to-All ControlNet at block {b}")
|
||||
#tqdm.write(f"Applying One-to-All ControlNet at block {b}")
|
||||
if b == 1:
|
||||
ctrl_in = prev_x + controlnet_tokens
|
||||
elif prev_control is not None:
|
||||
@@ -3054,7 +3053,7 @@ class WanModel(torch.nn.Module):
|
||||
prev_control = control_out
|
||||
|
||||
control_out_proj = self.controlnet_zero[b - 1](control_out)
|
||||
x = x + control_out_proj * onetoall_control_strength
|
||||
x = x + control_out_proj * one_to_all_controlnet_strength
|
||||
if b < len(self.controlnet.blocks): # Store prev_x only while controlnet is active
|
||||
prev_x = x
|
||||
elif b == len(self.controlnet.blocks): # Controlnet done, free memory
|
||||
|
||||
Reference in New Issue
Block a user