Skip to content

Commit fe3afca

Browse files
committed
Fix Gen1 nodes not applying scale/effect/per_block after refactor
1 parent 2dc8b31 commit fe3afca

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

animatediff/nodes_gen1.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .utils_motion import ADKeyframeGroup, get_combined_multival
1212
from .motion_lora import MotionLoraInfo, MotionLoraList
1313
from .motion_module_ad import AllPerBlocks
14-
from .model_injection import (ModelPatcherHelper, InjectionParams, MotionModelGroup,
14+
from .model_injection import (ModelPatcherHelper, InjectionParams, MotionModelGroup, get_mm_attachment,
1515
load_motion_lora_as_patches, load_motion_module_gen1, load_motion_module_gen2, validate_model_compatibility_gen2,
1616
validate_per_block_compatibility)
1717
from .sample_settings import SampleSettings, SeedNoiseGeneration
@@ -59,12 +59,13 @@ def load_mm_and_inject_params(self,
5959
if motion_lora is not None:
6060
for lora in motion_lora.loras:
6161
load_motion_lora_as_patches(motion_model, lora)
62-
motion_model.scale_multival = scale_multival
63-
motion_model.effect_multival = effect_multival
62+
attachment = get_mm_attachment(motion_model)
63+
attachment.scale_multival = scale_multival
64+
attachment.effect_multival = effect_multival
6465
if per_block is not None:
6566
validate_per_block_compatibility(motion_model=motion_model, all_per_blocks=per_block)
66-
motion_model.per_block_list = per_block.per_block_list
67-
motion_model.keyframes = ad_keyframes.clone() if ad_keyframes else ADKeyframeGroup()
67+
attachment.per_block_list = per_block.per_block_list
68+
attachment.keyframes = ad_keyframes.clone() if ad_keyframes else ADKeyframeGroup()
6869

6970
# create injection params
7071
params = InjectionParams(unlimited_area_hack=False)
@@ -80,7 +81,7 @@ def load_mm_and_inject_params(self,
8081

8182
# backwards compatibility to support old way of masking scale
8283
if params.motion_model_settings.mask_attn_scale is not None:
83-
motion_model.scale_multival = get_combined_multival(scale_multival, (params.motion_model_settings.mask_attn_scale * params.motion_model_settings.attn_scale))
84+
attachment.scale_multival = get_combined_multival(scale_multival, (params.motion_model_settings.mask_attn_scale * params.motion_model_settings.attn_scale))
8485

8586
# need to use a ModelPatcher that supports injection of motion modules into unet
8687
model = model.clone()
@@ -134,6 +135,7 @@ def INPUT_TYPES(s):
134135
}
135136
}
136137

138+
DEPRECATED = True
137139
RETURN_TYPES = ("MODEL",)
138140
CATEGORY = "Animate Diff 🎭🅐🅓/① Gen1 nodes ①"
139141
FUNCTION = "load_mm_and_inject_params"
@@ -161,12 +163,13 @@ def load_mm_and_inject_params(self,
161163
motion_model_settings.attn_scale = motion_scale
162164
params.set_motion_model_settings(motion_model_settings)
163165

166+
attachment = get_mm_attachment(motion_model)
164167
if params.motion_model_settings.mask_attn_scale is not None:
165-
motion_model.scale_multival = params.motion_model_settings.mask_attn_scale * params.motion_model_settings.attn_scale
168+
attachment.scale_multival = params.motion_model_settings.mask_attn_scale * params.motion_model_settings.attn_scale
166169
else:
167-
motion_model.scale_multival = params.motion_model_settings.attn_scale
170+
attachment.scale_multival = params.motion_model_settings.attn_scale
168171

169-
motion_model.keyframes = ad_keyframes.clone() if ad_keyframes else ADKeyframeGroup()
172+
attachment.keyframes = ad_keyframes.clone() if ad_keyframes else ADKeyframeGroup()
170173

171174
# need to use a ModelPatcher that supports injection of motion modules into unet
172175
model = model.clone()

0 commit comments

Comments
 (0)