Skip to content

Fix Gen1 Nodes scale/effect/per_block, deprecate LoRA Hook Keyframes Interp. node #505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions animatediff/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .nodes_pia import (ApplyAnimateDiffPIAModel, LoadAnimateDiffAndInjectPIANode, InputPIA_MultivalNode, InputPIA_PaperPresetsNode, PIA_ADKeyframeNode)
from .nodes_fancyvideo import (ApplyAnimateDiffFancyVideo,)
from .nodes_multival import MultivalDynamicNode, MultivalScaledMaskNode, MultivalDynamicFloatInputNode, MultivalDynamicFloatsNode, MultivalConvertToMaskNode
from .nodes_conditioning import (CreateLoraHookKeyframeInterpolation,
from .nodes_conditioning import (CreateLoraHookKeyframeInterpolationDEPR,
MaskableLoraLoaderDEPR, MaskableLoraLoaderModelOnlyDEPR, MaskableSDModelLoaderDEPR, MaskableSDModelLoaderModelOnlyDEPR,
SetModelLoraHookDEPR, SetClipLoraHookDEPR,
CombineLoraHooksDEPR, CombineLoraHookFourOptionalDEPR, CombineLoraHookEightOptionalDEPR,
Expand Down Expand Up @@ -98,7 +98,6 @@
"ADE_IterationOptsDefault": IterationOptionsNode,
"ADE_IterationOptsFreeInit": FreeInitOptionsNode,
# Conditioning
"ADE_LoraHookKeyframeInterpolation": CreateLoraHookKeyframeInterpolation,
# Conditioning (DEPRECATED)
"ADE_RegisterLoraHook": MaskableLoraLoaderDEPR,
"ADE_RegisterLoraHookModelOnly": MaskableLoraLoaderModelOnlyDEPR,
Expand All @@ -110,6 +109,7 @@
"ADE_SetLoraHookKeyframe": SetLoraHookKeyframesDEPR,
"ADE_AttachLoraHookToCLIP": SetClipLoraHookDEPR,
"ADE_LoraHookKeyframe": CreateLoraHookKeyframeDEPR,
"ADE_LoraHookKeyframeInterpolation": CreateLoraHookKeyframeInterpolationDEPR,
"ADE_LoraHookKeyframeFromStrengthList": CreateLoraHookKeyframeFromStrengthListDEPR,
"ADE_AttachLoraHookToConditioning": SetModelLoraHookDEPR,
"ADE_PairedConditioningSetMask": PairedConditioningSetMaskHookedDEPR,
Expand Down Expand Up @@ -269,7 +269,6 @@
"ADE_IterationOptsDefault": "Default Iteration Options 🎭🅐🅓",
"ADE_IterationOptsFreeInit": "FreeInit Iteration Options 🎭🅐🅓",
# Conditioning
"ADE_LoraHookKeyframeInterpolation": "LoRA Hook Keyframes Interp. 🎭🅐🅓",
# Conditioning (DEPRECATED)
"ADE_RegisterLoraHook": "Register LoRA Hook 🎭🅐🅓",
"ADE_RegisterLoraHookModelOnly": "Register LoRA Hook (Model Only) 🎭🅐🅓",
Expand All @@ -281,6 +280,7 @@
"ADE_SetLoraHookKeyframe": "Set LoRA Hook Keyframes 🎭🅐🅓",
"ADE_AttachLoraHookToCLIP": "Set CLIP LoRA Hook 🎭🅐🅓",
"ADE_LoraHookKeyframe": "LoRA Hook Keyframe 🎭🅐🅓",
"ADE_LoraHookKeyframeInterpolation": "LoRA Hook Keyframes Interp. 🎭🅐🅓",
"ADE_LoraHookKeyframeFromStrengthList": "LoRA Hook Keyframes From List 🎭🅐🅓",
"ADE_AttachLoraHookToConditioning": "Set Model LoRA Hook 🎭🅐🅓",
"ADE_PairedConditioningSetMask": "Set Props on Conds 🎭🅐🅓",
Expand Down
24 changes: 11 additions & 13 deletions animatediff/nodes_conditioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@
from .logger import logger


class CreateLoraHookKeyframeInterpolation:
###################################################################
# EVERYTHING BELOW HERE IS DEPRECATED;
# Can be replaced with vanilla ComfyUI nodes
#------------------------------------------------------------------
#------------------------------------------------------------------
#------------------------------------------------------------------
#------------------------------------------------------------------
#------------------------------------------------------------------
class CreateLoraHookKeyframeInterpolationDEPR:
@classmethod
def INPUT_TYPES(s):
return {
Expand All @@ -32,12 +40,14 @@ def INPUT_TYPES(s):
},
"optional": {
"prev_hook_kf": ("HOOK_KEYFRAMES",),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}

DEPRECATED = True
RETURN_TYPES = ("HOOK_KEYFRAMES",)
RETURN_NAMES = ("HOOK_KF",)
CATEGORY = "Animate Diff 🎭🅐🅓/conditioning/schedule lora hooks"
Expand Down Expand Up @@ -66,18 +76,6 @@ def create_hook_keyframes(self,
return (prev_hook_kf,)



###################################################################
# EVERYTHING BELOW HERE IS DEPRECATED;
# Can be replaced with vanilla ComfyUI nodes
#------------------------------------------------------------------
#------------------------------------------------------------------
#------------------------------------------------------------------
#------------------------------------------------------------------
#------------------------------------------------------------------



###############################################
### Mask, Combine, and Hook Conditioning
###############################################
Expand Down
21 changes: 12 additions & 9 deletions animatediff/nodes_gen1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .utils_motion import ADKeyframeGroup, get_combined_multival
from .motion_lora import MotionLoraInfo, MotionLoraList
from .motion_module_ad import AllPerBlocks
from .model_injection import (ModelPatcherHelper, InjectionParams, MotionModelGroup,
from .model_injection import (ModelPatcherHelper, InjectionParams, MotionModelGroup, get_mm_attachment,
load_motion_lora_as_patches, load_motion_module_gen1, load_motion_module_gen2, validate_model_compatibility_gen2,
validate_per_block_compatibility)
from .sample_settings import SampleSettings, SeedNoiseGeneration
Expand Down Expand Up @@ -59,12 +59,13 @@ def load_mm_and_inject_params(self,
if motion_lora is not None:
for lora in motion_lora.loras:
load_motion_lora_as_patches(motion_model, lora)
motion_model.scale_multival = scale_multival
motion_model.effect_multival = effect_multival
attachment = get_mm_attachment(motion_model)
attachment.scale_multival = scale_multival
attachment.effect_multival = effect_multival
if per_block is not None:
validate_per_block_compatibility(motion_model=motion_model, all_per_blocks=per_block)
motion_model.per_block_list = per_block.per_block_list
motion_model.keyframes = ad_keyframes.clone() if ad_keyframes else ADKeyframeGroup()
attachment.per_block_list = per_block.per_block_list
attachment.keyframes = ad_keyframes.clone() if ad_keyframes else ADKeyframeGroup()

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

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

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

DEPRECATED = True
RETURN_TYPES = ("MODEL",)
CATEGORY = "Animate Diff 🎭🅐🅓/① Gen1 nodes ①"
FUNCTION = "load_mm_and_inject_params"
Expand Down Expand Up @@ -161,12 +163,13 @@ def load_mm_and_inject_params(self,
motion_model_settings.attn_scale = motion_scale
params.set_motion_model_settings(motion_model_settings)

attachment = get_mm_attachment(motion_model)
if params.motion_model_settings.mask_attn_scale is not None:
motion_model.scale_multival = params.motion_model_settings.mask_attn_scale * params.motion_model_settings.attn_scale
attachment.scale_multival = params.motion_model_settings.mask_attn_scale * params.motion_model_settings.attn_scale
else:
motion_model.scale_multival = params.motion_model_settings.attn_scale
attachment.scale_multival = params.motion_model_settings.attn_scale

motion_model.keyframes = ad_keyframes.clone() if ad_keyframes else ADKeyframeGroup()
attachment.keyframes = ad_keyframes.clone() if ad_keyframes else ADKeyframeGroup()

# need to use a ModelPatcher that supports injection of motion modules into unet
model = model.clone()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "comfyui-animatediff-evolved"
description = "Improved AnimateDiff integration for ComfyUI."
version = "1.3.2"
version = "1.3.3"
license = { file = "LICENSE" }
dependencies = []

Expand Down