@@ -495,7 +495,54 @@ def create_hook_keyframe(self, strength_mult: float, start_percent: float, prev_
495495 keyframe = comfy .hooks .HookKeyframe (strength = strength_mult , start_percent = start_percent )
496496 prev_hook_kf .add (keyframe )
497497 return (prev_hook_kf ,)
498+
499+ class CreateHookKeyframesInterpolated :
500+ NodeId = 'CreateHookKeyframesInterpolated'
501+ NodeName = 'Create Hook Keyframes Interp.'
502+ @classmethod
503+ def INPUT_TYPES (s ):
504+ return {
505+ "required" : {
506+ "strength_start" : ("FLOAT" , {"default" : 1.0 , "min" : 0.0 , "max" : 10.0 , "step" : 0.001 }, ),
507+ "strength_end" : ("FLOAT" , {"default" : 1.0 , "min" : 0.0 , "max" : 10.0 , "step" : 0.001 }, ),
508+ "interpolation" : (comfy .hooks .InterpolationMethod ._LIST , ),
509+ "start_percent" : ("FLOAT" , {"default" : 0.0 , "min" : 0.0 , "max" : 1.0 , "step" : 0.001 }),
510+ "end_percent" : ("FLOAT" , {"default" : 1.0 , "min" : 0.0 , "max" : 1.0 , "step" : 0.001 }),
511+ "keyframes_count" : ("INT" , {"default" : 5 , "min" : 2 , "max" : 100 , "step" : 1 }),
512+ "print_keyframes" : ("BOOLEAN" , {"default" : False }),
513+ },
514+ "optional" : {
515+ "prev_hook_kf" : ("HOOK_KEYFRAMES" ,),
516+ },
517+ }
498518
519+ EXPERIMENTAL = True
520+ RETURN_TYPES = ("HOOK_KEYFRAMES" ,)
521+ RETURN_NAMES = ("HOOK_KF" ,)
522+ CATEGORY = "advanced/hooks/scheduling"
523+ FUNCTION = "create_hook_keyframes"
524+
525+ def create_hook_keyframes (self , strength_start : float , strength_end : float , interpolation : str ,
526+ start_percent : float , end_percent : float , keyframes_count : int ,
527+ print_keyframes = False , prev_hook_kf : comfy .hooks .HookKeyframeGroup = None ):
528+ if prev_hook_kf is None :
529+ prev_hook_kf = comfy .hooks .HookKeyframeGroup ()
530+ prev_hook_kf = prev_hook_kf .clone ()
531+ percents = comfy .hooks .InterpolationMethod .get_weights (num_from = start_percent , num_to = end_percent , length = keyframes_count ,
532+ method = comfy .hooks .InterpolationMethod .LINEAR )
533+ strengths = comfy .hooks .InterpolationMethod .get_weights (num_from = strength_start , num_to = strength_end , length = keyframes_count , method = interpolation )
534+
535+ is_first = True
536+ for percent , strength in zip (percents , strengths ):
537+ guarantee_steps = 0
538+ if is_first :
539+ guarantee_steps = 1
540+ is_first = False
541+ prev_hook_kf .add (comfy .hooks .HookKeyframe (strength = strength , start_percent = percent , guarantee_steps = guarantee_steps ))
542+ if print_keyframes :
543+ print (f"Hook Keyframe - start_percent:{ percent } = { strength } " )
544+ return (prev_hook_kf ,)
545+
499546class CreateHookKeyframesFromFloats :
500547 NodeId = 'CreateHookKeyframesFromFloats'
501548 NodeName = 'Create Hook Keyframes From Floats'
@@ -672,6 +719,7 @@ def combine_hooks(self,
672719 # Scheduling
673720 SetHookKeyframes ,
674721 CreateHookKeyframe ,
722+ CreateHookKeyframesInterpolated ,
675723 CreateHookKeyframesFromFloats ,
676724 # Combine
677725 CombineHooks ,
0 commit comments