Author SHA1 Message Date
Jedrzej Kosinski 8fa8d4f16a Add code to test out ADE native context windows 2025-08-05 22:23:50 -07:00
35 changed files with 1087 additions and 251 deletions
+2 -1
View File
@@ -4,14 +4,15 @@ from .animatediff.utils_model import get_available_motion_models, Folders
from .animatediff.model_injection import prepare_dinklink_register_definitions
from .animatediff.motion_module_ad import prepare_dinklink_motion_module_ad
from .animatediff.nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
from .animatediff import documentation
from .animatediff.dinklink import init_dinklink
if len(get_available_motion_models()) == 0:
logger.error(f"No motion models found. Please download one and place in: {folder_paths.get_folder_paths(Folders.ANIMATEDIFF_MODELS)}")
WEB_DIRECTORY = "./web"
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]
documentation.format_descriptions(NODE_CLASS_MAPPINGS)
init_dinklink()
prepare_dinklink_register_definitions()
+1 -1
View File
@@ -70,9 +70,9 @@ def load_hmreferenceadapter(model_name: str):
else:
ops = comfy.ops.manual_cast
hmref = HMReferenceAdapter(ops=ops)
hmref.to(comfy.model_management.unet_dtype())
hmref.to(comfy.model_management.unet_offload_device())
load_result = hmref.load_state_dict(state_dict, strict=True)
hmref.to(comfy.model_management.unet_dtype())
hmref_model = create_HMModelPatcher(model=hmref, load_device=comfy.model_management.get_torch_device(),
offload_device=comfy.model_management.unet_offload_device())
return hmref_model
+75
View File
@@ -0,0 +1,75 @@
from typing import Union
from .logger import logger
def image(src):
return f'<img src={src} style="width: 0px; min-width: 100%">'
def video(src):
return f'<video src={src} autoplay muted loop controls controlslist="nodownload noremoteplayback noplaybackrate" style="width: 0px; min-width: 100%" class="VHS_loopedvideo">'
def short_desc(desc):
return f'<div id=VHS_shortdesc style="font-size: .8em">{desc}</div>'
def coll(text: str):
return f"{text}_collapsed"
descriptions = {
}
sizes = ['1.4','1.2','1']
def as_html(entry, depth=0):
if isinstance(entry, dict):
size = 0.8 if depth < 2 else 1
html = ''
for k in entry:
if k == "collapsed":
continue
collapse_single = k.endswith("_collapsed")
if collapse_single:
name = k[:-len("_collapsed")]
else:
name = k
collapse_flag = ' VHS_precollapse' if entry.get("collapsed", False) or collapse_single else ''
html += f'<div vhs_title=\"{name}\" style=\"display: flex; font-size: {size}em\" class=\"VHS_collapse{collapse_flag}\"><div style=\"color: #AAA; height: 1.5em;\">[<span style=\"font-family: monospace\">-</span>]</div><div style=\"width: 100%\">{name}: {as_html(entry[k], depth=depth+1)}</div></div>'
return html
if isinstance(entry, list):
html = ''
for i in entry:
html += f'<div>{as_html(i, depth=depth)}</div>'
return html
return str(entry)
def register_description(node_id: str, desc: Union[list, dict]):
descriptions[node_id] = desc
def format_descriptions(nodes):
for k in descriptions:
if k.endswith("_collapsed"):
k = k[:-len("_collapsed")]
nodes[k].DESCRIPTION = as_html(descriptions[k])
# undocumented_nodes = []
# for k in nodes:
# if not hasattr(nodes[k], "DESCRIPTION"):
# undocumented_nodes.append(k)
# if len(undocumented_nodes) > 0:
# logger.info(f"Undocumented nodes: {undocumented_nodes}")
class DocHelper:
def __init__(self):
self.actual_dict = {}
def add(self, add_dict):
self.actual_dict.update(add_dict)
return self
def get(self):
return self.actual_dict
@staticmethod
def combine(*args):
docs = DocHelper()
for doc in args:
docs.add(doc)
return docs.get()
+7 -7
View File
@@ -841,9 +841,9 @@ def load_motion_module_gen1(model_name: str, model: ModelPatcher, motion_lora: M
mm_state_dict = apply_mm_settings(model_dict=mm_state_dict, mm_settings=motion_model_settings)
# initialize AnimateDiffModelWrapper
ad_wrapper = AnimateDiffModel(mm_state_dict=mm_state_dict, mm_info=mm_info)
ad_wrapper.to(model.model_dtype())
ad_wrapper.to(model.offload_device)
load_result = ad_wrapper.load_state_dict(mm_state_dict, strict=False)
ad_wrapper.to(model.model_dtype())
verify_load_result(load_result=load_result, mm_info=mm_info)
# wrap motion_module into a ModelPatcher, to allow motion lora patches
motion_model = create_MotionModelPatcher(model=ad_wrapper, load_device=model.load_device, offload_device=model.offload_device)
@@ -865,9 +865,9 @@ def load_motion_module_gen2(model_name: str, motion_model_settings: AnimateDiffS
mm_state_dict = apply_mm_settings(model_dict=mm_state_dict, mm_settings=motion_model_settings)
# initialize AnimateDiffModelWrapper
ad_wrapper = AnimateDiffModel(mm_state_dict=mm_state_dict, mm_info=mm_info)
ad_wrapper.to(comfy.model_management.unet_dtype())
ad_wrapper.to(comfy.model_management.unet_offload_device())
load_result = ad_wrapper.load_state_dict(mm_state_dict, strict=False)
ad_wrapper.to(comfy.model_management.unet_dtype())
verify_load_result(load_result=load_result, mm_info=mm_info)
# wrap motion_module into a ModelPatcher, to allow motion lora patches
motion_model = create_MotionModelPatcher(model=ad_wrapper, load_device=comfy.model_management.get_torch_device(),
@@ -907,34 +907,34 @@ def verify_load_result(load_result: IncompatibleKeys, mm_info: AnimateDiffInfo):
def create_fresh_motion_module(motion_model: MotionModelPatcher) -> MotionModelPatcher:
ad_wrapper = AnimateDiffModel(mm_state_dict=motion_model.model.state_dict(), mm_info=motion_model.model.mm_info)
ad_wrapper.to(comfy.model_management.unet_dtype())
ad_wrapper.to(comfy.model_management.unet_offload_device())
ad_wrapper.load_state_dict(motion_model.model.state_dict())
ad_wrapper.to(comfy.model_management.unet_dtype())
return create_MotionModelPatcher(model=ad_wrapper, load_device=comfy.model_management.get_torch_device(),
offload_device=comfy.model_management.unet_offload_device())
def create_fresh_encoder_only_model(motion_model: MotionModelPatcher) -> MotionModelPatcher:
ad_wrapper = EncoderOnlyAnimateDiffModel(mm_state_dict=motion_model.model.state_dict(), mm_info=motion_model.model.mm_info)
ad_wrapper.to(comfy.model_management.unet_dtype())
ad_wrapper.to(comfy.model_management.unet_offload_device())
ad_wrapper.load_state_dict(motion_model.model.state_dict(), strict=False)
ad_wrapper.to(comfy.model_management.unet_dtype())
return create_MotionModelPatcher(model=ad_wrapper, load_device=comfy.model_management.get_torch_device(),
offload_device=comfy.model_management.unet_offload_device())
def inject_img_encoder_into_model(motion_model: MotionModelPatcher, w_encoder: MotionModelPatcher):
motion_model.model.init_img_encoder()
motion_model.model.img_encoder.to(comfy.model_management.unet_dtype())
motion_model.model.img_encoder.to(comfy.model_management.unet_offload_device())
motion_model.model.img_encoder.load_state_dict(w_encoder.model.img_encoder.state_dict())
motion_model.model.img_encoder.to(comfy.model_management.unet_dtype())
def inject_pia_conv_in_into_model(motion_model: MotionModelPatcher, w_pia: MotionModelPatcher):
motion_model.model.init_conv_in(w_pia.model.state_dict())
motion_model.model.conv_in.to(comfy.model_management.unet_dtype())
motion_model.model.conv_in.to(comfy.model_management.unet_offload_device())
motion_model.model.conv_in.load_state_dict(w_pia.model.conv_in.state_dict())
motion_model.model.conv_in.to(comfy.model_management.unet_dtype())
motion_model.model.mm_info.mm_format = AnimateDiffFormat.PIA
@@ -956,9 +956,9 @@ def inject_camera_encoder_into_model(motion_model: MotionModelPatcher, camera_ct
# initialize CameraPoseEncoder on motion model, and load keys
camera_encoder = CameraPoseEncoder(channels=motion_model.model.layer_channels, nums_rb=2, ops=motion_model.model.ops).to(
device=comfy.model_management.unet_offload_device(),
dtype=comfy.model_management.unet_dtype()
)
camera_encoder.load_state_dict(camera_state_dict)
camera_encoder.to(dtype=comfy.model_management.unet_dtype())
camera_encoder.temporal_pe_max_len = get_position_encoding_max_len(camera_state_dict, mm_name=camera_ctrl_name, mm_format=AnimateDiffFormat.ANIMATEDIFF)
motion_model.model.set_camera_encoder(camera_encoder=camera_encoder)
# initialize qkv_merge on specific attention blocks, and load keys
+30
View File
@@ -10,6 +10,9 @@ class AnimateDiffSettingsNode:
"pe_adjust": ("PE_ADJUST",),
"weight_adjust": ("WEIGHT_ADJUST",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("AD_SETTINGS",)
@@ -35,6 +38,9 @@ class ManualAdjustPENode:
"optional": {
"prev_pe_adjust": ("PE_ADJUST",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("PE_ADJUST",)
@@ -66,6 +72,9 @@ class SweetspotStretchPENode:
"optional": {
"prev_pe_adjust": ("PE_ADJUST",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("PE_ADJUST",)
@@ -93,6 +102,9 @@ class FullStretchPENode:
"optional": {
"prev_pe_adjust": ("PE_ADJUST",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("PE_ADJUST",)
@@ -120,6 +132,9 @@ class WeightAdjustAllAddNode:
"optional": {
"prev_weight_adjust": ("WEIGHT_ADJUST",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("WEIGHT_ADJUST",)
@@ -149,6 +164,9 @@ class WeightAdjustAllMultNode:
"optional": {
"prev_weight_adjust": ("WEIGHT_ADJUST",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("WEIGHT_ADJUST",)
@@ -180,6 +198,9 @@ class WeightAdjustIndivAddNode:
"optional": {
"prev_weight_adjust": ("WEIGHT_ADJUST",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("WEIGHT_ADJUST",)
@@ -213,6 +234,9 @@ class WeightAdjustIndivMultNode:
"optional": {
"prev_weight_adjust": ("WEIGHT_ADJUST",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("WEIGHT_ADJUST",)
@@ -251,6 +275,9 @@ class WeightAdjustIndivAttnAddNode:
"optional": {
"prev_weight_adjust": ("WEIGHT_ADJUST",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("WEIGHT_ADJUST",)
@@ -297,6 +324,9 @@ class WeightAdjustIndivAttnMultNode:
"optional": {
"prev_weight_adjust": ("WEIGHT_ADJUST",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("WEIGHT_ADJUST",)
+4 -1
View File
@@ -36,6 +36,9 @@ class ApplyAnimateLCMI2VModel:
"prev_m_models": ("M_MODELS",),
"per_block": ("PER_BLOCK",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("M_MODELS",)
@@ -93,7 +96,6 @@ class LoadAnimateLCMI2VModelNode:
class LoadAnimateDiffAndInjectI2VNode:
EXPERIMENTAL = True
@classmethod
def INPUT_TYPES(s):
return {
@@ -103,6 +105,7 @@ class LoadAnimateDiffAndInjectI2VNode:
},
"optional": {
"ad_settings": ("AD_SETTINGS",),
"deprecation_warning": ("ADEWARN", {"text": "Experimental. Don't expect to work.", "warn_type": "experimental", "color": "#CFC"}),
}
}
+6
View File
@@ -301,6 +301,9 @@ class CameraCtrlADKeyframeNode:
"inherit_missing": ("BOOLEAN", {"default": True}, ),
"guarantee_steps": ("INT", {"default": 1, "min": 0, "max": BIGMAX}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("AD_KEYFRAMES", )
@@ -400,6 +403,9 @@ class CameraCtrlPoseBasic:
"optional": {
"prev_poses": ("CAMERACTRL_POSES",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CAMERACTRL_POSES",)
+87
View File
@@ -45,7 +45,11 @@ class CreateLoraHookKeyframeInterpolationDEPR:
},
"optional": {
"prev_hook_kf": ("HOOK_KEYFRAMES",),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
DEPRECATED = True
@@ -94,7 +98,11 @@ class PairedConditioningSetMaskHookedDEPR:
"opt_mask": ("MASK", ),
"opt_lora_hook": ("HOOKS",),
"opt_timesteps": ("TIMESTEPS_RANGE",),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONDITIONING", "CONDITIONING")
@@ -125,7 +133,11 @@ class ConditioningSetMaskHookedDEPR:
"opt_mask": ("MASK", ),
"opt_lora_hook": ("HOOKS",),
"opt_timesteps": ("TIMESTEPS_RANGE",),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONDITIONING",)
@@ -158,7 +170,11 @@ class PairedConditioningSetMaskAndCombineHookedDEPR:
"opt_mask": ("MASK", ),
"opt_lora_hook": ("HOOKS",),
"opt_timesteps": ("TIMESTEPS_RANGE",),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONDITIONING", "CONDITIONING")
@@ -190,7 +206,11 @@ class ConditioningSetMaskAndCombineHookedDEPR:
"opt_mask": ("MASK", ),
"opt_lora_hook": ("HOOKS",),
"opt_timesteps": ("TIMESTEPS_RANGE",),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONDITIONING",)
@@ -219,7 +239,11 @@ class PairedConditioningSetUnmaskedAndCombineHookedDEPR:
},
"optional": {
"opt_lora_hook": ("HOOKS",),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONDITIONING", "CONDITIONING")
@@ -245,7 +269,11 @@ class ConditioningSetUnmaskedAndCombineHookedDEPR:
},
"optional": {
"opt_lora_hook": ("HOOKS",),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONDITIONING",)
@@ -270,6 +298,9 @@ class PairedConditioningCombineDEPR:
"positive_B": ("CONDITIONING",),
"negative_B": ("CONDITIONING",),
},
"optional": {
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
}
}
RETURN_TYPES = ("CONDITIONING", "CONDITIONING")
@@ -291,6 +322,9 @@ class ConditioningCombineDEPR:
"cond_A": ("CONDITIONING",),
"cond_B": ("CONDITIONING",),
},
"optional": {
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
}
}
RETURN_TYPES = ("CONDITIONING",)
@@ -318,6 +352,12 @@ class ConditioningTimestepsNodeDEPR:
"start_percent": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001}),
"end_percent": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.001})
},
"optional": {
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("TIMESTEPS_RANGE",)
@@ -337,6 +377,12 @@ class SetLoraHookKeyframesDEPR:
"lora_hook": ("HOOKS",),
"hook_kf": ("HOOK_KEYFRAMES",),
},
"optional": {
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("HOOKS",)
@@ -361,7 +407,11 @@ class CreateLoraHookKeyframeDEPR:
},
"optional": {
"prev_hook_kf": ("HOOK_KEYFRAMES",),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("HOOK_KEYFRAMES",)
@@ -393,6 +443,7 @@ class CreateLoraHookKeyframeFromStrengthListDEPR:
},
"optional": {
"prev_hook_kf": ("HOOK_KEYFRAMES",),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
}
}
@@ -450,6 +501,9 @@ class MaskableLoraLoaderDEPR:
"strength_model": ("FLOAT", {"default": 1.0, "min": -20.0, "max": 20.0, "step": 0.01}),
"strength_clip": ("FLOAT", {"default": 1.0, "min": -20.0, "max": 20.0, "step": 0.01}),
},
"optional": {
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
}
}
RETURN_TYPES = ("MODEL", "CLIP", "HOOKS")
@@ -489,6 +543,9 @@ class MaskableLoraLoaderModelOnlyDEPR(MaskableLoraLoaderDEPR):
"lora_name": (folder_paths.get_filename_list("loras"), ),
"strength_model": ("FLOAT", {"default": 1.0, "min": -20.0, "max": 20.0, "step": 0.01}),
},
"optional": {
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
}
}
RETURN_TYPES = ("MODEL", "HOOKS")
@@ -513,6 +570,9 @@ class MaskableSDModelLoaderDEPR(comfy_extras.nodes_hooks.CreateHookModelAsLora):
"strength_model": ("FLOAT", {"default": 1.0, "min": -20.0, "max": 20.0, "step": 0.01}),
"strength_clip": ("FLOAT", {"default": 1.0, "min": -20.0, "max": 20.0, "step": 0.01}),
},
"optional": {
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
}
}
RETURN_TYPES = ("MODEL", "CLIP", "HOOKS")
@@ -534,6 +594,9 @@ class MaskableSDModelLoaderModelOnlyDEPR(MaskableSDModelLoaderDEPR):
"ckpt_name": (folder_paths.get_filename_list("checkpoints"), ),
"strength_model": ("FLOAT", {"default": 1.0, "min": -20.0, "max": 20.0, "step": 0.01}),
},
"optional": {
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
}
}
RETURN_TYPES = ("MODEL", "HOOKS")
@@ -562,6 +625,12 @@ class SetModelLoraHookDEPR:
"conditioning": ("CONDITIONING",),
"lora_hook": ("HOOKS",),
},
"optional": {
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONDITIONING",)
@@ -581,6 +650,12 @@ class SetClipLoraHookDEPR:
"clip": ("CLIP",),
"lora_hook": ("HOOKS",),
},
"optional": {
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CLIP",)
@@ -602,7 +677,11 @@ class CombineLoraHooksDEPR:
"optional": {
"lora_hook_A": ("HOOKS",),
"lora_hook_B": ("HOOKS",),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("HOOKS",)
@@ -626,7 +705,11 @@ class CombineLoraHookFourOptionalDEPR:
"lora_hook_B": ("HOOKS",),
"lora_hook_C": ("HOOKS",),
"lora_hook_D": ("HOOKS",),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("HOOKS",)
@@ -656,7 +739,11 @@ class CombineLoraHookEightOptionalDEPR:
"lora_hook_F": ("HOOKS",),
"lora_hook_G": ("HOOKS",),
"lora_hook_H": ("HOOKS",),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated - use native ComfyUI nodes instead."}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("HOOKS",)
+4 -1
View File
@@ -66,7 +66,6 @@ class LoopedUniformContextOptionsNode:
# This Legacy version exists to maintain compatiblity with old workflows
class LegacyLoopedUniformContextOptionsNode:
DEPRECATED = True
@classmethod
def INPUT_TYPES(s):
return {
@@ -85,6 +84,7 @@ class LegacyLoopedUniformContextOptionsNode:
"guarantee_steps": ("INT", {"default": 1, "min": 0, "max": BIGMAX}),
"prev_context": ("CONTEXT_OPTIONS",),
"view_opts": ("VIEW_OPTS",),
"deprecation_warning": ("ADEWARN", {"text": ""}),
}
}
@@ -237,6 +237,9 @@ class ViewAsContextOptionsNode:
"guarantee_steps": ("INT", {"default": 1, "min": 0, "max": BIGMAX}),
"prev_context": ("CONTEXT_OPTIONS",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONTEXT_OPTIONS",)
+42
View File
@@ -21,6 +21,9 @@ class SetContextExtrasOnContextOptions:
"optional": {
"context_extras": ("CONTEXT_EXTRAS",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONTEXT_OPTIONS",)
@@ -51,6 +54,9 @@ class ContextExtras_NaiveReuse:
"end_percent": ("FLOAT", {"default": 0.15, "min": 0.0, "max": 1.0, "step": 0.001}),
"weighted_mean": ("FLOAT", {"default": 0.95, "min": 0.0, "max": 1.0, "step": 0.001}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONTEXT_EXTRAS",)
@@ -83,6 +89,9 @@ class NaiveReuse_KeyframeMultivalNode:
"guarantee_steps": ("INT", {"default": 1, "min": 0, "max": BIGMAX}),
"inherit_missing": ("BOOLEAN", {"default": True}, ),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("NAIVEREUSE_KEYFRAME",)
@@ -119,6 +128,9 @@ class NaiveReuse_KeyframeInterpolationNode:
"prev_kf": ("NAIVEREUSE_KEYFRAME",),
"mult_multival": ("MULTIVAL",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("NAIVEREUSE_KEYFRAME",)
@@ -166,6 +178,9 @@ class NaiveReuse_KeyframeFromListNode:
"prev_kf": ("NAIVEREUSE_KEYFRAME",),
"mult_multival": ("MULTIVAL",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("NAIVEREUSE_KEYFRAME",)
@@ -220,6 +235,9 @@ class ContextExtras_ContextRef:
"start_percent": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001}),
"end_percent": ("FLOAT", {"default": 0.25, "min": 0.0, "max": 1.0, "step": 0.001}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONTEXT_EXTRAS",)
@@ -261,6 +279,9 @@ class ContextRef_KeyframeMultivalNode:
"guarantee_steps": ("INT", {"default": 1, "min": 0, "max": BIGMAX}),
"inherit_missing": ("BOOLEAN", {"default": True}, ),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONTEXTREF_KEYFRAME",)
@@ -300,6 +321,9 @@ class ContextRef_KeyframeInterpolationNode:
"mode_replace": ("CONTEXTREF_MODE",),
"tune_replace": ("CONTEXTREF_TUNE",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONTEXTREF_KEYFRAME",)
@@ -348,6 +372,9 @@ class ContextRef_KeyframeFromListNode:
"mode_replace": ("CONTEXTREF_MODE",),
"tune_replace": ("CONTEXTREF_TUNE",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONTEXTREF_KEYFRAME",)
@@ -389,6 +416,9 @@ class ContextRef_ModeFirst:
return {
"required": {
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONTEXTREF_MODE",)
@@ -409,6 +439,9 @@ class ContextRef_ModeSliding:
"optional": {
"sliding_width": ("INT", {"default": 2, "min": 2, "max": BIGMAX, "step": 1}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONTEXTREF_MODE",)
@@ -430,6 +463,9 @@ class ContextRef_ModeIndexes:
"switch_on_idxs": ("STRING", {"default": ""}),
"always_include_0": ("BOOLEAN", {"default": True},),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONTEXTREF_MODE",)
@@ -458,6 +494,9 @@ class ContextRef_TuneAttnAdain:
"adain_ref_weight": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
"adain_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONTEXTREF_TUNE",)
@@ -483,6 +522,9 @@ class ContextRef_TuneAttn:
"attn_ref_weight": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
"attn_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CONTEXTREF_TUNE",)
+9 -1
View File
@@ -34,6 +34,7 @@ class AnimateDiffLoaderDEPR:
"unlimited_area_hack": ("BOOLEAN", {"default": False},),
"beta_schedule": (BetaSchedules.get_alias_list_with_first_element(BetaSchedules.SQRT_LINEAR),),
},
"optional": {"deprecation_warning": ("ADEWARN", {"text": "Deprecated"})},
}
RETURN_TYPES = ("MODEL", "LATENT")
@@ -94,6 +95,7 @@ class AnimateDiffLoaderAdvancedDEPR:
"closed_loop": ("BOOLEAN", {"default": False},),
"beta_schedule": (BetaSchedules.get_alias_list_with_first_element(BetaSchedules.SQRT_LINEAR),),
},
"optional": {"deprecation_warning": ("ADEWARN", {"text": "Deprecated"})},
}
RETURN_TYPES = ("MODEL", "LATENT")
@@ -169,6 +171,7 @@ class LegacyAnimateDiffLoaderWithContextDEPR:
"motion_scale": ("FLOAT", {"default": 1.0, "min": 0.0, "step": 0.001}),
"apply_v2_models_properly": ("BOOLEAN", {"default": True}),
"ad_keyframes": ("AD_KEYFRAMES",),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated; use AnimateDiff Loader instead."}),
}
}
@@ -266,6 +269,7 @@ class AnimateDiffCombineDEPR:
"pingpong": ("BOOLEAN", {"default": False}),
"save_image": ("BOOLEAN", {"default": True}),
},
"optional": {"deprecation_warning": ("ADEWARN", {"text": "Deprecated. Use VHS Video Combine"})},
"hidden": {
"prompt": "PROMPT",
"extra_pnginfo": "EXTRA_PNGINFO",
@@ -376,7 +380,7 @@ class AnimateDiffCombineDEPR:
"format": format,
}
]
return {"ui": {"images": previews, "animated": (True,)}}
return {"ui": {"gifs": previews}}
@@ -390,6 +394,7 @@ class AnimateDiffModelSettingsDEPR:
},
"optional": {
"mask_motion_scale": ("MASK",),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated"}),
}
}
@@ -419,6 +424,7 @@ class AnimateDiffModelSettingsSimpleDEPR:
"mask_motion_scale": ("MASK",),
"min_motion_scale": ("FLOAT", {"default": 1.0, "min": 0.0, "step": 0.001}),
"max_motion_scale": ("FLOAT", {"default": 1.0, "min": 0.0, "step": 0.001}),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated"}),
}
}
@@ -458,6 +464,7 @@ class AnimateDiffModelSettingsAdvancedDEPR:
"mask_motion_scale": ("MASK",),
"min_motion_scale": ("FLOAT", {"default": 1.0, "min": 0.0, "step": 0.001}),
"max_motion_scale": ("FLOAT", {"default": 1.0, "min": 0.0, "step": 0.001}),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated"}),
}
}
@@ -513,6 +520,7 @@ class AnimateDiffModelSettingsAdvancedAttnStrengthsDEPR:
"mask_motion_scale": ("MASK",),
"min_motion_scale": ("FLOAT", {"default": 1.0, "min": 0.0, "step": 0.001}),
"max_motion_scale": ("FLOAT", {"default": 1.0, "min": 0.0, "step": 0.001}),
"deprecation_warning": ("ADEWARN", {"text": "Deprecated"}),
}
}
+3
View File
@@ -36,6 +36,9 @@ class ApplyAnimateDiffFancyVideo:
"prev_m_models": ("M_MODELS",),
"per_block": ("PER_BLOCK",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("M_MODELS",)
+12
View File
@@ -101,6 +101,9 @@ class ApplyAnimateDiffModelNode:
"prev_m_models": ("M_MODELS",),
"per_block": ("PER_BLOCK",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("M_MODELS",)
@@ -153,6 +156,9 @@ class ApplyAnimateDiffModelBasicNode:
"ad_keyframes": ("AD_KEYFRAMES",),
"per_block": ("PER_BLOCK",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("M_MODELS",)
@@ -179,6 +185,9 @@ class LoadAnimateDiffModelNode:
"optional": {
"ad_settings": ("AD_SETTINGS",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 50}),
}
}
RETURN_TYPES = ("MOTION_MODEL_ADE",)
@@ -207,6 +216,9 @@ class ADKeyframeNode:
"inherit_missing": ("BOOLEAN", {"default": True}, ),
"guarantee_steps": ("INT", {"default": 1, "min": 0, "max": BIGMAX}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("AD_KEYFRAMES", )
+3
View File
@@ -20,6 +20,9 @@ class AnimateDiffLoraLoader:
"optional": {
"prev_motion_lora": ("MOTION_LORA",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 30}),
}
}
RETURN_TYPES = ("MOTION_LORA",)
+3
View File
@@ -114,6 +114,9 @@ class ApplyAnimateDiffMotionCtrlModel:
"prev_m_models": ("M_MODELS",),
"per_block": ("PER_BLOCK",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("M_MODELS",)
+18
View File
@@ -23,6 +23,9 @@ class MultivalDynamicNode:
"optional": {
"mask_optional": ("MASK",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("MULTIVAL",)
@@ -45,6 +48,9 @@ class MultivalScaledMaskNode:
"optional": {
"scaling": (ScaleType.LIST,),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("MULTIVAL",)
@@ -90,6 +96,9 @@ class MultivalDynamicFloatInputNode:
"optional": {
"mask_optional": ("MASK",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("MULTIVAL",)
@@ -110,6 +119,9 @@ class MultivalDynamicFloatsNode:
"optional": {
"mask_optional": ("MASK",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("MULTIVAL",)
@@ -127,6 +139,9 @@ class MultivalFloatNode:
"required": {
"float_val": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001},),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("MULTIVAL",)
@@ -144,6 +159,9 @@ class MultivalConvertToMaskNode:
"required": {
"multival": ("MULTIVAL",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("MASK",)
+34 -2
View File
@@ -1,6 +1,7 @@
from typing import Union
from torch import Tensor
from .documentation import short_desc, register_description, coll, DocHelper
from .motion_module_ad import BlockType
from .utils_model import ModelTypeSD
from .utils_motion import AllPerBlocks, PerBlock, PerBlockId, extend_list_to_batch_size
@@ -38,6 +39,9 @@ class ADBlockComboNode:
"effect": ("MULTIVAL",),
"scale": ("MULTIVAL",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("AD_BLOCK",)
@@ -64,6 +68,7 @@ class ADBlockIndivNode:
"effect": ("MULTIVAL",),
"scale_0": ("MULTIVAL",),
"scale_1": ("MULTIVAL",),
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
@@ -92,6 +97,7 @@ class PerBlockHighLevelNode:
"down": ("AD_BLOCK",),
"mid": ("AD_BLOCK",),
"up": ("AD_BLOCK",),
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
@@ -135,6 +141,7 @@ class PerBlock_SD15_MidLevelNode:
"up_1": ("AD_BLOCK",),
"up_2": ("AD_BLOCK",),
"up_3": ("AD_BLOCK",),
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
@@ -202,6 +209,7 @@ class PerBlock_SD15_LowLevelNode:
"up_3__0": ("AD_BLOCK",),
"up_3__1": ("AD_BLOCK",),
"up_3__2": ("AD_BLOCK",),
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
@@ -274,13 +282,24 @@ class PerBlock_SD15_FromFloatsNode:
"optional": {
"effect_21_floats": ("FLOATS",),
"scale_21_floats": ("FLOATS",),
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("PER_BLOCK",)
CATEGORY = "Animate Diff 🎭🅐🅓/per block"
FUNCTION = "create_per_block"
DESCRIPTION = 'Use Floats from Value Schedules to select SD1.5 effect/scale values for blocks.'
Desc = [
short_desc('Use Floats from Value Schedules to select SD1.5 effect/scale values for blocks.'),
'SD1.5 Motion Modules contain 21 blocks:',
'idx 0 - start of down blocks (down_0__0)',
'idx 7 - end of down blocks (down_3__1)',
'idx 8 - mid block (mid)',
'idx 9 - start of up blocks (up_0__0)',
'idx 20 - end of up blocks (up_3__2)',
]
register_description(NodeID, Desc)
def create_per_block(self,
effect_21_floats: Union[list[float], None]=None,
@@ -317,6 +336,7 @@ class PerBlock_SDXL_MidLevelNode:
"up_0": ("AD_BLOCK",),
"up_1": ("AD_BLOCK",),
"up_2": ("AD_BLOCK",),
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
@@ -375,6 +395,7 @@ class PerBlock_SDXL_LowLevelNode:
"up_2__0": ("AD_BLOCK",),
"up_2__1": ("AD_BLOCK",),
"up_2__2": ("AD_BLOCK",),
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
@@ -437,13 +458,24 @@ class PerBlock_SDXL_FromFloatsNode:
"optional": {
"effect_16_floats": ("FLOATS",),
"scale_16_floats": ("FLOATS",),
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("PER_BLOCK",)
CATEGORY = "Animate Diff 🎭🅐🅓/per block"
FUNCTION = "create_per_block"
DESCRIPTION = 'Use Floats from Value Schedules to select SDXL effect/scale values for blocks.'
Desc = [
short_desc('Use Floats from Value Schedules to select SDXL effect/scale values for blocks.'),
'SDXL Motion Modules contain 16 blocks:',
'idx 0 - start of down blocks (down_0__0)',
'idx 5 - end of down blocks (down_2__1)',
'idx 6 - mid block (mid)',
'idx 7 - start of up blocks (up_0__0)',
'idx 15 - end of up blocks (up_2__2)',
]
register_description(NodeID, Desc)
def create_per_block(self,
effect_16_floats: Union[list[float], None]=None,
+10 -1
View File
@@ -127,6 +127,9 @@ class ApplyAnimateDiffPIAModel:
"prev_m_models": ("M_MODELS",),
"per_block": ("PER_BLOCK",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("M_MODELS",)
@@ -158,7 +161,6 @@ class ApplyAnimateDiffPIAModel:
class LoadAnimateDiffAndInjectPIANode:
EXPERIMENTAL = True
@classmethod
def INPUT_TYPES(s):
return {
@@ -168,6 +170,7 @@ class LoadAnimateDiffAndInjectPIANode:
},
"optional": {
"ad_settings": ("AD_SETTINGS",),
"deprecation_warning": ("ADEWARN", {"text": "Experimental. Don't expect to work.", "warn_type": "experimental", "color": "#CFC"}),
}
}
@@ -202,6 +205,9 @@ class PIA_ADKeyframeNode:
"inherit_missing": ("BOOLEAN", {"default": True}, ),
"guarantee_steps": ("INT", {"default": 1, "min": 0, "max": BIGMAX}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("AD_KEYFRAMES", )
@@ -254,6 +260,9 @@ class InputPIA_PaperPresetsNode:
"print_values": ("BOOLEAN", {"default": False},),
#"effect_multival": ("MULTIVAL",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("PIA_INPUT",)
+54
View File
@@ -36,6 +36,9 @@ class SampleSettingsNode:
"ancestral_opts": ("ANCESTRAL_OPTS",),
#"noise_calib": ("NOISE_CALIBRATION",), # TODO: bring back once NoiseCalibration is working
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("SAMPLE_SETTINGS",)
@@ -68,6 +71,9 @@ class AncestralOptionsNode:
"optional": {
"seed_override": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "forceInput": True}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("ANCESTRAL_OPTS",)
@@ -95,6 +101,9 @@ class NoiseLayerReplaceNode:
"mask_optional": ("MASK",),
"seed_override": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "forceInput": True}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("NOISE_LAYERS",)
@@ -130,6 +139,9 @@ class NoiseLayerAddNode:
"mask_optional": ("MASK",),
"seed_override": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "forceInput": True}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("NOISE_LAYERS",)
@@ -168,6 +180,9 @@ class NoiseLayerAddWeightedNode:
"mask_optional": ("MASK",),
"seed_override": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "forceInput": True}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("NOISE_LAYERS",)
@@ -205,6 +220,9 @@ class NoiseLayerNormalizedSumNode:
"mask_optional": ("MASK",),
"seed_override": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "forceInput": True}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("NOISE_LAYERS",)
@@ -266,6 +284,9 @@ class FreeInitOptionsNode:
"iter_batch_offset": ("INT", {"default": 0, "min": 0, "max": BIGMAX}),
"iter_seed_offset": ("INT", {"default": 1, "min": BIGMIN, "max": BIGMAX}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("ITERATION_OPTS",)
@@ -290,6 +311,9 @@ class NoiseCalibrationNode:
"calib_iterations": ("INT", {"default": 1, "min": 1, "step": 1}),
"thresh_freq": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.001}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("NOISE_CALIBRATION",)
@@ -312,6 +336,9 @@ class CustomCFGNode:
"optional": {
"cfg_extras": ("CFG_EXTRAS",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CUSTOM_CFG",)
@@ -335,6 +362,9 @@ class CustomCFGSimpleNode:
"optional": {
"cfg_extras": ("CFG_EXTRAS",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CUSTOM_CFG",)
@@ -358,6 +388,9 @@ class CustomCFGKeyframeNode:
"prev_custom_cfg": ("CUSTOM_CFG",),
"cfg_extras": ("CFG_EXTRAS",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CUSTOM_CFG",)
@@ -387,6 +420,9 @@ class CustomCFGKeyframeSimpleNode:
"prev_custom_cfg": ("CUSTOM_CFG",),
"cfg_extras": ("CFG_EXTRAS",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 10}),
}
}
RETURN_TYPES = ("CUSTOM_CFG",)
@@ -416,6 +452,9 @@ class CustomCFGKeyframeInterpolationNode:
"prev_custom_cfg": ("CUSTOM_CFG",),
"cfg_extras": ("CFG_EXTRAS",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CUSTOM_CFG",)
@@ -502,6 +541,9 @@ class CFGExtrasPAGNode:
"optional": {
"prev_extras": ("CFG_EXTRAS",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CFG_EXTRAS",)
@@ -533,6 +575,9 @@ class CFGExtrasPAGSimpleNode:
"optional": {
"prev_extras": ("CFG_EXTRAS",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("CFG_EXTRAS",)
@@ -585,6 +630,9 @@ class CFGExtrasRescaleCFGSimpleNode:
"optional": {
"prev_extras": ("CFG_EXTRAS",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 10}),
}
}
RETURN_TYPES = ("CFG_EXTRAS",)
@@ -614,6 +662,9 @@ class NoisedImageInjectionNode:
"strength_multival": ("MULTIVAL", ),
"prev_image_inject": ("IMAGE_INJECT", ),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("IMAGE_INJECT",)
@@ -643,6 +694,9 @@ class NoisedImageInjectOptionsNode:
"composite_x": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION, "step": 1}),
"composite_y": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION, "step": 1}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("IMAGE_INJECT_OPTIONS",)
+111 -6
View File
@@ -1,10 +1,66 @@
from typing import Union
from .documentation import register_description, short_desc, coll, DocHelper
from .scheduling import (evaluate_prompt_schedule, evaluate_value_schedule, extract_cond_from_schedule, TensorInterp, PromptOptions,
verify_key_value)
from .utils_model import BIGMAX
from .logger import logger
desc_values = {coll('values'): 'Write your values here.'}
desc_prompts = {coll('prompts'): 'Write your prompts here.'}
desc_clip = {'clip': 'CLIP to use for encoding prompts.'}
desc_latent = {'latent': 'Used to get the amount of frames (max_length) to use for scheduling.'}
desc_prepend_text = {'prepend_text': 'OPTIONAL, adds text before all prompts.'}
desc_append_text = {'append_text': 'OPTIONAL, adds text after all prompts.'}
desc_values_replace = {'values_replace': 'OPTIONAL, replaces keys from value_replace keys with provided value schedules. Keys in the prompt are written as `some_key`, surrounded by the ` characters.'}
desc_tensor_interp = {'tensor_interp': 'Selects method of interpolating prompt conds - defaults to lerp.'}
desc_print_schedule = {'print_schedule': 'When True, prints output values for each frame.'}
desc_max_length = {'max_length': 'Used to select the intended length of schedule. If set to 0, will use the largest index in the schedule as max_length, but will disable relative indexes (negative and decimal).'}
desc_floats = {'floats': 'List of floats, likely outputted by a Value Scheduling node.'}
desc_FLOAT = {'FLOAT': 'Float (or list of floats) to convert to FLOATS type.'}
desc_value_key = {'value_key': 'Key to use for value schedule in Prompt Scheduling node. Can only contain a-z, A-Z, 0-9, and _ characters. In Prompt Scheduling, keys can be referred to as `some_key`, where the key is surrounded by ` characters.'}
desc_prev_replace = {'prev_replace': 'OPTIONAL, other values_replace can be chained.'}
desc_input_conditioning = {'conditioning': 'Encoded prompts. The output of a Prompt Scheduling node.'}
desc_index = {'index': 'The index to extract. Must be within the range [0,N] where N is the length of scheduled prompts.'}
desc_output_conditioning_single = {'CONDITIONING': 'The single step conditioning from the schedule.'}
desc_output_conditioning = {'CONDITIONING': 'Encoded prompts.'}
desc_output_latent = {'LATENT': 'Unmodified input latents; can be used as pipe, or can be ignored.'}
desc_format_allowed_idxs = {'allowed idxs':
{'single': 'A positive integer (e.g. 0, 2) schedules value for frame. A negative integer (e.g. -1, -5) schedules value for frame from the end (-1 would be the last frame). ' +
'A decimal (e.g. 0.5, 1.0) selects frame based relative location in whole schedule (0.5 would be halfway, 1.0 would be last frame).',
'range': 'Using rules above, single:single chooses uninterpolated prompts from start idx (included) to end idx (excluded). Examples -> 0:12, 0:-5, 2:0.5',
'hold': 'Putting a colon after a single idx stops interpolation until the next provided index. Examples -> 0:, 0.5:, 16: '}
}
desc_format_prompt = [
'Scheduling supports two formats: JSON and pythonic.',
{'JSON': ['"idx": "your prompt here", ...'],
'pythonic': ['idx = "your prompt here", ...']},
'The idx is the index of the frame - first frame is 0, last frame is max_frames-1. An idx may be the following:',
desc_format_allowed_idxs,
'The prompts themselves should be surrounded by double quotes ("your prompt here"). Portions of prompts can use value schedules provided values_replace.',
{'JSON': ['"0": "blue rock on mountain",', '"16": "green rock in lake"'],
'pythonic': ['0 = "blue rock on mountain",', '16 = "green rock in lake"']}
]
desc_format_values = [
'Scheduling supports two formats: JSON and pythonic.',
{'JSON': ['"idx": float/int_value, ...'],
'pythonic': ['idx = float/int_value, ...']},
'The idx is the index of the frame - first frame is 0, last frame is max_frames-1. An idx may be the following:',
desc_format_allowed_idxs,
'The values can be written without any special formatting.',
{'JSON': ['"0": 1.0,', '"16": 1.3'],
'pythonic': ['0 = 1.0,', '16 = 1.3']}
]
class PromptSchedulingLatentsNode:
NodeID = 'ADE_PromptSchedulingLatents'
NodeName = 'Prompt Scheduling [Latents] 🎭🅐🅓'
@@ -28,7 +84,14 @@ class PromptSchedulingLatentsNode:
RETURN_TYPES = ("CONDITIONING", "LATENT",)
CATEGORY = "Animate Diff 🎭🅐🅓/scheduling"
FUNCTION = "create_schedule"
DESCRIPTION = 'Encode a schedule of prompts with automatic interpolation, its length matching passed-in latent count.'
Desc = [
short_desc('Encode a schedule of prompts with automatic interpolation, its length matching passed-in latent count.'),
{'Format': desc_format_prompt},
{coll('Inputs'): DocHelper.combine(desc_prompts, desc_clip, desc_latent, desc_values_replace, desc_prepend_text, desc_append_text, desc_tensor_interp, desc_print_schedule)},
{coll('Outputs'): DocHelper.combine(desc_output_conditioning, desc_output_latent)}
]
register_description(NodeID, Desc)
def create_schedule(self, prompts: str, clip, latent: dict, print_schedule=False, tensor_interp=TensorInterp.LERP,
prepend_text='', append_text='', values_replace=None):
@@ -61,7 +124,14 @@ class PromptSchedulingNode:
RETURN_TYPES = ("CONDITIONING",)
CATEGORY = "Animate Diff 🎭🅐🅓/scheduling"
FUNCTION = "create_schedule"
DESCRIPTION = 'Encode a schedule of prompts with automatic interpolation.'
Desc = [
short_desc('Encode a schedule of prompts with automatic interpolation.'),
{'Format': desc_format_prompt},
{coll('Inputs'): DocHelper.combine(desc_prompts, desc_clip, desc_values_replace, desc_prepend_text, desc_append_text, desc_max_length, desc_tensor_interp, desc_print_schedule)},
{coll('Outputs'): DocHelper.combine(desc_output_conditioning)}
]
register_description(NodeID, Desc)
def create_schedule(self, prompts: str, clip, print_schedule=False, max_length: int=0, tensor_interp=TensorInterp.LERP,
prepend_text='', append_text='', values_replace=None):
@@ -84,12 +154,21 @@ class ValueSchedulingLatentsNode:
"optional": {
"print_schedule": ("BOOLEAN", {"default": False}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("FLOAT", "FLOATS", "INT", "INTS")
CATEGORY = "Animate Diff 🎭🅐🅓/scheduling"
FUNCTION = "create_schedule"
DESCRIPTION = 'Create a list of values with automatic interpolation, its length matching passed-in latent count.'
Desc = [
short_desc('Create a list of values with automatic interpolation, its length matching passed-in latent count.'),
{'Format': desc_format_values},
{coll('Inputs'): DocHelper.combine(desc_values, desc_latent, desc_print_schedule)},
]
register_description(NodeID, Desc)
def create_schedule(self, values: str, latent: dict, print_schedule=False):
float_vals = evaluate_value_schedule(values, latent["samples"].size(0))
@@ -114,12 +193,21 @@ class ValueSchedulingNode:
"print_schedule": ("BOOLEAN", {"default": False}),
"max_length": ("INT", {"default": 0, "min": 0, "max": BIGMAX, "step": 1}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("FLOAT", "FLOATS", "INT", "INTS")
CATEGORY = "Animate Diff 🎭🅐🅓/scheduling"
FUNCTION = "create_schedule"
DESCRIPTION = 'Create a list of values with automatic interpolation.'
Desc = [
short_desc('Create a list of values with automatic interpolation.'),
{'Format': desc_format_values},
{coll('Inputs'): DocHelper.combine(desc_values, desc_max_length, desc_print_schedule)},
]
register_description(NodeID, Desc)
def create_schedule(self, values: str, max_length: int, print_schedule=False):
float_vals = evaluate_value_schedule(values, max_length)
@@ -144,12 +232,20 @@ class AddValuesReplaceNode:
"optional": {
"prev_replace": ("VALUES_REPLACE",),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("VALUES_REPLACE",)
CATEGORY = "Animate Diff 🎭🅐🅓/scheduling"
FUNCTION = "add_values_replace"
DESCRIPTION = 'Add a values schedule bound to a key to be used in Prompt Scheduling node.'
Desc = [
short_desc('Add a values schedule bound to a key to be used in Prompt Scheduling node.'),
{'Inputs': DocHelper.combine(desc_value_key, desc_floats, desc_prev_replace)},
]
register_description(NodeID, Desc)
def add_values_replace(self, value_key: str, floats: Union[list[float]], prev_replace: dict=None):
# key can only have a-z, A-Z, 0-9, and _ characters
@@ -173,6 +269,9 @@ class FloatToFloatsNode:
"required": {
"FLOAT": ("FLOAT", {"default": 39, "forceInput": True}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("FLOATS",)
@@ -202,7 +301,13 @@ class ConditionExtractionNode:
RETURN_TYPES = ("CONDITIONING",)
CATEGORY = "Animate Diff 🎭🅐🅓/scheduling"
FUNCTION = "extract_conditioning"
DESCRIPTION = 'Extract a single conditioning step from a schedule of prompts.'
Desc = [
short_desc('Extract a single conditioning step from a schedule of prompts.'),
{coll('Inputs'): DocHelper.combine(desc_input_conditioning, desc_index)},
{coll('Outputs'): DocHelper.combine(desc_output_conditioning)}
]
register_description(NodeID, Desc)
def extract_conditioning(self, conditioning, index: int=0):
conditioning_step = extract_cond_from_schedule(conditioning, index)
+15
View File
@@ -46,6 +46,9 @@ class RawSigmaScheduleNode:
"lcm_original_timesteps": ("INT", {"default": 50, "min": 1, "max": 1000}),
"zsnr": ("BOOLEAN", {"default": False}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("SIGMA_SCHEDULE",)
@@ -80,6 +83,9 @@ class WeightedAverageSigmaScheduleNode:
"schedule_B": ("SIGMA_SCHEDULE",),
"weight_A": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.001}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("SIGMA_SCHEDULE",)
@@ -105,6 +111,9 @@ class InterpolatedWeightedAverageSigmaScheduleNode:
"weight_A_End": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.001}),
"interpolation": (InterpolationMethod._LIST,),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("SIGMA_SCHEDULE",)
@@ -133,6 +142,9 @@ class SplitAndCombineSigmaScheduleNode:
"schedule_End": ("SIGMA_SCHEDULE",),
"idx_split_percent": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.001})
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("SIGMA_SCHEDULE",)
@@ -159,6 +171,9 @@ class SigmaScheduleToSigmasNode:
"steps": ("INT", {"default": 20, "min": 1, "max": 10000}),
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
},
"hidden": {
"autosize": ("ADEAUTOSIZE", {"padding": 0}),
}
}
RETURN_TYPES = ("SIGMAS",)
+18 -4
View File
@@ -203,13 +203,10 @@ def groupnorm_mm_factory(params: InjectionParams, manual_cast=False):
input = rearrange(input, "(b f) c h w -> b c f h w", b=batched_conds)
if manual_cast:
weight, bias, offload_stream = comfy.ops.cast_bias_weight(self, input, offloadable=True)
weight, bias = comfy.ops.cast_bias_weight(self, input)
else:
weight, bias = self.weight, self.bias
offload_stream = None
input = group_norm(input, self.num_groups, weight, bias, self.eps)
if offload_stream is not None:
comfy.ops.uncast_bias_weight(self, weight, bias, offload_stream)
input = rearrange(input, "b c f h w -> (b f) c h w", b=batched_conds)
return input
return groupnorm_mm_forward
@@ -757,6 +754,23 @@ def get_resized_cond(cond_in, x_in: Tensor, full_idxs: list[int], context_length
def sliding_calc_cond_batch(executor: Callable, model, conds: list[list[dict]], x_in: Tensor, timestep, model_options):
ADGS: AnimateDiffGlobalState = model_options["transformer_options"]["ADGS"]
if not ADGS.is_using_sliding_context():
if model_options["transformer_options"].get("context_window", None) is not None:
window = model_options["transformer_options"]["context_window"]
model_options["transformer_options"]["ad_params"]["sub_idxs"] = window.index_list
model_options["transformer_options"]["ad_params"]["context_length"] = len(window.index_list)
device = None
if device is None:
motion_models_devices = ADGS.motion_models_devices.values()
else:
motion_models_devices = ADGS.motion_models_devices.get(device, None)
if motion_models_devices is None:
motion_models_devices = []
else:
motion_models_devices = [motion_models_devices]
model = ADGS.model_patcher_devices[device].model
for motion_models in motion_models_devices:
motion_models.set_sub_idxs(window.index_list)
motion_models.set_video_length(len(window.index_list), ADGS.params.full_length)
return executor(model, conds, x_in, timestep, model_options)
# get context windows
+1 -2
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui-animatediff-evolved"
description = "Improved AnimateDiff integration for ComfyUI."
version = "1.5.7"
version = "1.5.6"
license = { file = "LICENSE" }
dependencies = []
@@ -13,4 +13,3 @@ Repository = "https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved"
PublisherId = "kosinkadink"
DisplayName = "ComfyUI-AnimateDiff-Evolved"
Icon = ""
requires-comfyui = ">=0.3.68"
-12
View File
@@ -1,12 +0,0 @@
# Condition Step Extraction
Extract a single conditioning step from a schedule of prompts.
## Inputs
- `conditioning`: Encoded prompts from a Prompt Scheduling node.
- `index`: The step to extract. It must be within the scheduled prompt range.
## Outputs
- `CONDITIONING`: The single conditioning step from the schedule.
-24
View File
@@ -1,24 +0,0 @@
# AD Per Block Floats (SD1.5)
Use Floats from Value Schedules to select SD1.5 effect and scale values for blocks.
## Inputs
- `effect_21_floats`: Optional effect values. The list is extended to the required 21 values when needed.
- `scale_21_floats`: Optional scale values. The list is extended to the required 21 values when needed.
## Block index map
SD1.5 motion modules contain 21 blocks.
| Index | Block |
| ---: | --- |
| 0 | Start of down blocks (`down_0__0`) |
| 7 | End of down blocks (`down_3__1`) |
| 8 | Mid block (`mid`) |
| 9 | Start of up blocks (`up_0__0`) |
| 20 | End of up blocks (`up_3__2`) |
## Outputs
- `PER_BLOCK`: Per-block effect and scale configuration for an SD1.5 motion module.
-24
View File
@@ -1,24 +0,0 @@
# AD Per Block Floats (SDXL)
Use Floats from Value Schedules to select SDXL effect and scale values for blocks.
## Inputs
- `effect_16_floats`: Optional effect values. The list is extended to the required 16 values when needed.
- `scale_16_floats`: Optional scale values. The list is extended to the required 16 values when needed.
## Block index map
SDXL motion modules contain 16 blocks.
| Index | Block |
| ---: | --- |
| 0 | Start of down blocks (`down_0__0`) |
| 5 | End of down blocks (`down_2__1`) |
| 6 | Mid block (`mid`) |
| 7 | Start of up blocks (`up_0__0`) |
| 15 | End of up blocks (`up_2__2`) |
## Outputs
- `PER_BLOCK`: Per-block effect and scale configuration for an SDXL motion module.
-42
View File
@@ -1,42 +0,0 @@
# Prompt Scheduling
Encode a schedule of prompts with automatic interpolation.
## Schedule format
Schedules support JSON and Python-like formats. Frame 0 is the first frame and `max_frames - 1` is the last.
```text
"0": "blue rock on mountain",
"16": "green rock in lake"
```
```text
0 = "blue rock on mountain",
16 = "green rock in lake"
```
Prompts must be enclosed in double quotes. Prompt portions may use keys supplied through `values_replace`.
### Allowed indices
- **Single:** A positive integer such as `0` or `2` selects that frame. A negative integer such as `-1` or `-5` selects from the end (`-1` is the last frame). A decimal such as `0.5` or `1.0` selects a relative position (`0.5` is halfway and `1.0` is the last frame).
- **Range:** `start:end` uses an uninterpolated prompt from the included start index to the excluded end index. Examples: `0:12`, `0:-5`, `2:0.5`.
- **Hold:** A colon after one index stops interpolation until the next supplied index. Examples: `0:`, `0.5:`, `16:`.
## Inputs
| Input | Description |
| --- | --- |
| `prompts` | The prompt schedule. |
| `clip` | CLIP used to encode prompts. |
| `prepend_text` | Optional text added before every prompt. |
| `append_text` | Optional text added after every prompt. |
| `values_replace` | Optional value schedules substituted for keys written as `` `some_key` `` in prompts. |
| `print_schedule` | Print the resulting schedule when enabled. |
| `max_length` | Intended schedule length. At 0, the largest schedule index determines the length, but negative and decimal relative indices are disabled. |
| `tensor_interp` | Prompt-conditioning interpolation method; defaults to linear interpolation. |
## Outputs
- `CONDITIONING`: Encoded prompts.
-43
View File
@@ -1,43 +0,0 @@
# Prompt Scheduling [Latents]
Encode a schedule of prompts with automatic interpolation, its length matching the passed-in latent count.
## Schedule format
Schedules support JSON and Python-like formats. Frame 0 is the first frame and `max_frames - 1` is the last.
```text
"0": "blue rock on mountain",
"16": "green rock in lake"
```
```text
0 = "blue rock on mountain",
16 = "green rock in lake"
```
Prompts must be enclosed in double quotes. Prompt portions may use keys supplied through `values_replace`.
### Allowed indices
- **Single:** A positive integer such as `0` or `2` selects that frame. A negative integer such as `-1` or `-5` selects from the end (`-1` is the last frame). A decimal such as `0.5` or `1.0` selects a relative position (`0.5` is halfway and `1.0` is the last frame).
- **Range:** `start:end` uses an uninterpolated prompt from the included start index to the excluded end index. Examples: `0:12`, `0:-5`, `2:0.5`.
- **Hold:** A colon after one index stops interpolation until the next supplied index. Examples: `0:`, `0.5:`, `16:`.
## Inputs
| Input | Description |
| --- | --- |
| `prompts` | The prompt schedule. |
| `clip` | CLIP used to encode prompts. |
| `latent` | Supplies the frame count used as the schedule length. |
| `prepend_text` | Optional text added before every prompt. |
| `append_text` | Optional text added after every prompt. |
| `values_replace` | Optional value schedules substituted for keys written as `` `some_key` `` in prompts. |
| `tensor_interp` | Prompt-conditioning interpolation method; defaults to linear interpolation. |
| `print_schedule` | Print the resulting schedule when enabled. |
## Outputs
- `CONDITIONING`: Encoded prompts.
- `LATENT`: The unmodified input latents, usable as a pipe or safely ignored.
-33
View File
@@ -1,33 +0,0 @@
# Value Scheduling
Create a list of values with automatic interpolation.
## Schedule format
Schedules support JSON and Python-like formats. Values need no special formatting.
```text
"0": 1.0,
"16": 1.3
```
```text
0 = 1.0,
16 = 1.3
```
Frame 0 is the first frame and `max_frames - 1` is the last.
- **Single:** Positive integers select a frame, negative integers select from the end (`-1` is last), and decimals select a relative position (`0.5` is halfway and `1.0` is last).
- **Range:** `start:end` holds the start value without interpolation through the excluded end. Examples: `0:12`, `0:-5`, `2:0.5`.
- **Hold:** A trailing colon stops interpolation until the next index. Examples: `0:`, `0.5:`, `16:`.
## Inputs
- `values`: The value schedule.
- `max_length`: Intended schedule length. At 0, the largest schedule index determines the length, but negative and decimal relative indices are disabled.
- `print_schedule`: Print each output value when enabled.
## Outputs
The schedule is returned as `FLOAT`, `FLOATS`, rounded `INT`, and rounded `INTS` outputs.
-33
View File
@@ -1,33 +0,0 @@
# Value Scheduling [Latents]
Create a list of values with automatic interpolation, its length matching the passed-in latent count.
## Schedule format
Schedules support JSON and Python-like formats. Values need no special formatting.
```text
"0": 1.0,
"16": 1.3
```
```text
0 = 1.0,
16 = 1.3
```
Frame 0 is the first frame and `max_frames - 1` is the last.
- **Single:** Positive integers select a frame, negative integers select from the end (`-1` is last), and decimals select a relative position (`0.5` is halfway and `1.0` is last).
- **Range:** `start:end` holds the start value without interpolation through the excluded end. Examples: `0:12`, `0:-5`, `2:0.5`.
- **Hold:** A trailing colon stops interpolation until the next index. Examples: `0:`, `0.5:`, `16:`.
## Inputs
- `values`: The value schedule.
- `latent`: Supplies the frame count used as the schedule length.
- `print_schedule`: Print each output value when enabled.
## Outputs
The schedule is returned as `FLOAT`, `FLOATS`, rounded `INT`, and rounded `INTS` outputs.
-13
View File
@@ -1,13 +0,0 @@
# Add Values Replace
Add a value schedule bound to a key for use in a Prompt Scheduling node.
## Inputs
- `value_key`: The key for the value schedule. It may contain only `a-z`, `A-Z`, `0-9`, and `_`. Refer to it in a prompt by surrounding it with backticks, for example `` `some_key` ``.
- `floats`: A list of floats, typically produced by a Value Scheduling node.
- `prev_replace`: Optional existing replacements, allowing multiple Values Replace nodes to be chained.
## Outputs
- `VALUES_REPLACE`: The replacement mapping for a Prompt Scheduling node.
+53
View File
@@ -0,0 +1,53 @@
import { app } from '../../../scripts/app.js'
function addResizeHook(node, padding, useOldMin=false) {
let origOnCreated = node.onNodeCreated
node.onNodeCreated = function() {
let r = origOnCreated?.apply(this, arguments)
let size = this.computeSize();
size[0] += padding || 0;
if (useOldMin) {
//equal to LiteGraph.NODE_WIDTH*1.5*1.5
size[0] = Math.max(size[0], 315)
}
this.setSize(size);
return r
}
}
app.registerExtension({
name: "AnimateDiffEvolved.autosize",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
//since python_module is based off folder path,
//it could be changed by users and should only be used as fallback
if (nodeData?.name?.startsWith("ADE_")
|| nodeData.python_module == 'custom_nodes.ComfyUI-AnimateDiff-Evolved') {
if (nodeData?.input?.hidden?.autosize) {
addResizeHook(nodeType.prototype, nodeData.input.hidden.autosize[1]?.padding)
} else if (!nodeData?.input?.optional?.autosize) {
addResizeHook(nodeType.prototype, 0, true)
}
}
},
async getCustomWidgets() {
return {
ADEAUTOSIZE(node, inputName, inputData) {
let w = {
name : inputName,
type : "ADE.AUTOSIZE",
value : "",
options : {"serialize": false},
computeSize : function(width) {
return [0, -4];
}
}
if (!node.widgets) {
node.widgets = []
}
node.widgets.push(w)
addResizeHook(node, inputData[1].padding);
return w;
}
}
}
});
+51
View File
@@ -0,0 +1,51 @@
import { app } from '../../../scripts/app.js'
const deprecate_nodes = {
name: 'AnimateDiff.deprecate_nodes',
async getCustomWidgets() {
return {
ADEWARN(node, inputName, inputData) {
let w = {
name : inputName,
type : "ADE.WARN",
value : "",
draw : function(ctx, node, widget_width, y, H) {
var show_text = app.canvas.ds.scale > 0.5;
var margin = 15;
var text_color = inputData[1]['color'] || "#FCC"
ctx.textAlign = "center";
if (show_text) {
if(!this.disabled)
ctx.stroke();
ctx.save();
ctx.beginPath();
ctx.rect(margin, y, widget_width - margin * 2, H);
ctx.clip();
ctx.fillStyle = text_color;
let disp_text = inputData[1]['text']
ctx.fillText(disp_text, widget_width/2, y + H * 0.7);
ctx.restore();
}
},
options : {"serialize": false},
computeSize : function(width) {
if (inputData[1]['text']) {
return [width, 20]
}
return [0, -4]
}
}
if (!node.widgets) {
node.widgets = []
}
node.widgets.push(w)
return w
}
}
}
}
app.registerExtension(deprecate_nodes)
+292
View File
@@ -0,0 +1,292 @@
import { app } from '../../../scripts/app.js'
function chainCallback(object, property, callback) {
if (object == undefined) {
//This should not happen.
console.error("Tried to add callback to non-existant object")
return;
}
if (property in object && object[property]) {
const callback_orig = object[property]
object[property] = function () {
const r = callback_orig.apply(this, arguments);
callback.apply(this, arguments);
return r
};
} else {
object[property] = callback;
}
}
var helpDOM;
function initHelpDOM() {
let parentDOM = document.createElement("div");
document.body.appendChild(parentDOM)
parentDOM.appendChild(helpDOM)
helpDOM.className = "litegraph";
let scrollbarStyle = document.createElement('style');
parentDOM.className = "VHS_floatinghelp"
scrollbarStyle.innerHTML = `
.VHS_floatinghelp {
scrollbar-width: 6px;
scrollbar-color: #0003 #0000;
&::-webkit-scrollbar {
background: transparent;
width: 6px;
}
&::-webkit-scrollbar-thumb {
background: #0005;
border-radius: 20px
}
&::-webkit-scrollbar-button {
display: none;
}
}
.VHS_loopedvideo::-webkit-media-controls-mute-button {
display:none;
}
.VHS_loopedvideo::-webkit-media-controls-fullscreen-button {
display:none;
}
`
parentDOM.appendChild(scrollbarStyle)
chainCallback(app.canvas, "onDrawForeground", function (ctx, visible_rect){
let n = helpDOM.node
if (!n || !n?.graph) {
parentDOM.style['left'] = '-5000px'
return
}
//draw : function(ctx, node, widgetWidth, widgetY, height) {
//update widget position, even if off screen
const transform = ctx.getTransform();
const scale = app.canvas.ds.scale;//gets the litegraph zoom
//calculate coordinates with account for browser zoom
const bcr = app.canvas.canvas.getBoundingClientRect()
const x = transform.e*scale/transform.a + bcr.x;
const y = transform.f*scale/transform.a + bcr.y;
//TODO: text reflows at low zoom. investigate alternatives
Object.assign(parentDOM.style, {
left: (x+(n.pos[0] + n.size[0]+15)*scale) + "px",
top: (y+(n.pos[1]-LiteGraph.NODE_TITLE_HEIGHT)*scale) + "px",
width: "400px",
minHeight: "100px",
maxHeight: "600px",
overflowY: 'scroll',
transformOrigin: '0 0',
transform: 'scale(' + scale + ',' + scale +')',
fontSize: '18px',
backgroundColor: LiteGraph.NODE_DEFAULT_BGCOLOR,
boxShadow: '0 0 10px black',
borderRadius: '4px',
padding: '3px',
zIndex: 3,
position: "absolute",
display: 'inline',
});
});
function setCollapse(el, doCollapse) {
if (doCollapse) {
el.children[0].children[0].innerHTML = '+'
Object.assign(el.children[1].style, {
color: '#CCC',
overflowX: 'hidden',
width: '0px',
minWidth: 'calc(100% - 20px)',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
})
for (let child of el.children[1].children) {
if (child.style.display != 'none'){
child.origDisplay = child.style.display
}
child.style.display = 'none'
}
} else {
el.children[0].children[0].innerHTML = '-'
Object.assign(el.children[1].style, {
color: '',
overflowX: '',
width: '100%',
minWidth: '',
textOverflow: '',
whiteSpace: '',
})
for (let child of el.children[1].children) {
child.style.display = child.origDisplay
}
}
}
helpDOM.collapseOnClick = function() {
let doCollapse = this.children[0].innerHTML == '-'
setCollapse(this.parentElement, doCollapse)
}
helpDOM.selectHelp = function(name, value) {
//attempt to navigate to name in help
function collapseUnlessMatch(items,t) {
var match = items.querySelector('[vhs_title="' + t + '"]')
if (!match) {
for (let i of items.children) {
if (i.innerHTML.slice(0,t.length+5).includes(t)) {
match = i
break
}
}
}
if (!match) {
return null
}
//For longer documentation items with fewer collapsable elements,
//scroll to make sure the entirety of the selected item is visible
//This has the unfortunate side effect of trying to scroll the main
//window if the documentation windows is forcibly offscreen,
//but it's easy to simply scroll the main window back and seems to
//have no visual side effects
match.scrollIntoView(false)
window.scrollTo(0,0)
for (let i of items.querySelectorAll('.VHS_collapse')) {
if (i.contains(match)) {
setCollapse(i, false)
} else {
setCollapse(i, true)
}
}
return match
}
let target = collapseUnlessMatch(helpDOM, name)
if (target && value) {
collapseUnlessMatch(target, value)
}
}
helpDOM.addHelp = function(node, nodeType, description) {
if (!description) {
return
}
//Pad computed size for the clickable question mark
let originalComputeSize = node.computeSize
node.computeSize = function() {
let size = originalComputeSize.apply(this, arguments)
if (!this.title) {
return size
}
let title_width = this.title.length * 0.6 * LiteGraph.NODE_TEXT_SIZE
size[0] = Math.max(size[0], title_width + LiteGraph.NODE_TITLE_HEIGHT)
return size
}
node.description = description
chainCallback(node, "onDrawForeground", function (ctx) {
//draw question mark
ctx.save()
ctx.font = 'bold 20px Arial'
ctx.fillText("?", this.size[0]-17, -8)
ctx.restore()
})
chainCallback(node, "onMouseDown", function (e, pos, canvas) {
//On click would be preferred, but this'll be good enough
if (pos[1] < 0 && pos[0] + LiteGraph.NODE_TITLE_HEIGHT > this.size[0]) {
//corner question mark clicked
if (helpDOM.node == this) {
helpDOM.node = undefined
} else {
helpDOM.node = this;
helpDOM.innerHTML = this.description || "no help provided ".repeat(20)
for (let e of helpDOM.querySelectorAll('.VHS_collapse')) {
e.children[0].onclick = helpDOM.collapseOnClick
e.children[0].style.cursor = 'pointer'
}
for (let e of helpDOM.querySelectorAll('.VHS_precollapse')) {
setCollapse(e, true)
}
}
return true
}
})
let timeout = null
chainCallback(node, "onMouseMove", function (e, pos, canvas) {
if (timeout) {
clearTimeout(timeout)
timeout = null
}
if (helpDOM.node != this) {
return
}
timeout = setTimeout(() => {
let n = this
if (pos[0] > 0 && pos[0] < n.size[0]
&& pos[1] > 0 && pos[1] < n.size[1]) {
//TODO: provide help specific to element clicked
let inputRows = Math.max(n.inputs.length, n.outputs.length)
if (pos[1] < LiteGraph.NODE_SLOT_HEIGHT * inputRows) {
let row = Math.floor((pos[1] - 7) / LiteGraph.NODE_SLOT_HEIGHT)
if (pos[0] < n.size[0]/2) {
if (row < n.inputs.length) {
helpDOM.selectHelp(n.inputs[row].name)
}
} else {
if (row < n.outputs.length) {
helpDOM.selectHelp(n.outputs[row].name)
}
}
} else {
//probably widget, but widgets have variable height.
let basey = LiteGraph.NODE_SLOT_HEIGHT * inputRows + 6
for (let w of n.widgets) {
if (w.y) {
basey = w.y
}
let wheight = LiteGraph.NODE_WIDGET_HEIGHT+4
if (w.computeSize) {
wheight = w.computeSize(n.size[0])[1]
}
if (pos[1] < basey + wheight) {
helpDOM.selectHelp(w.name, w.value)
break
}
basey += wheight
}
}
}
}, 500)
})
chainCallback(node, "onMouseLeave", function (e, pos, canvas) {
if (timeout) {
clearTimeout(timeout)
timeout = null
}
});
}
}
app.registerExtension({
name: "AnimateDiffEvolved.documentation",
async init() {
if (app.VHSHelp) {
helpDOM = app.VHSHelp
} else {
helpDOM = document.createElement("div");
initHelpDOM()
app.VHSHelp = helpDOM
}
},
async beforeRegisterNodeDef(nodeType, nodeData, app) {
// NOTE: May need manual adjusting for the few non-namespaced nodes
if(nodeData?.name?.startsWith("ADE_") && nodeData.description) {
let description = nodeData.description
let el = document.createElement("div")
el.innerHTML = description
if (!el.children.length) {
//Is plaintext. Do minor convenience formatting
let chunks = description.split('\n')
nodeData.description = chunks[0]
description = chunks.join('<br>')
} else {
nodeData.description = el.querySelector('#VHS_shortdesc')?.innerHTML || el.children[1]?.firstChild?.innerHTML
}
chainCallback(nodeType.prototype, "onNodeCreated", function () {
helpDOM.addHelp(this, nodeType, description)
})
}
},
});
+142
View File
@@ -0,0 +1,142 @@
import { app } from '../../../scripts/app.js'
import { api } from '../../../scripts/api.js'
function offsetDOMWidget(
widget,
ctx,
node,
widgetWidth,
widgetY,
height
) {
const margin = 10
const elRect = ctx.canvas.getBoundingClientRect()
const transform = new DOMMatrix()
.scaleSelf(
elRect.width / ctx.canvas.width,
elRect.height / ctx.canvas.height
)
.multiplySelf(ctx.getTransform())
.translateSelf(0, widgetY + margin)
const scale = new DOMMatrix().scaleSelf(transform.a, transform.d)
Object.assign(widget.inputEl.style, {
transformOrigin: '0 0',
transform: scale,
left: `${transform.e}px`,
top: `${transform.d + transform.f}px`,
width: `${widgetWidth}px`,
height: `${(height || widget.parent?.inputHeight || 32) - margin}px`,
position: 'absolute',
background: !node.color ? '' : node.color,
color: !node.color ? '' : 'white',
zIndex: 5, //app.graph._nodes.indexOf(node),
})
}
export const hasWidgets = (node) => {
if (!node.widgets || !node.widgets?.[Symbol.iterator]) {
return false
}
return true
}
export const cleanupNode = (node) => {
if (!hasWidgets(node)) {
return
}
for (const w of node.widgets) {
if (w.canvas) {
w.canvas.remove()
}
if (w.inputEl) {
w.inputEl.remove()
}
// calls the widget remove callback
w.onRemoved?.()
}
}
const CreatePreviewElement = (name, val, format) => {
const [type] = format.split('/')
const w = {
name,
type,
value: val,
draw: function (ctx, node, widgetWidth, widgetY, height) {
const [cw, ch] = this.computeSize(widgetWidth)
offsetDOMWidget(this, ctx, node, widgetWidth, widgetY, ch)
},
computeSize: function (_) {
const ratio = this.inputRatio || 1
const width = Math.max(220, this.parent.size[0])
return [width, (width / ratio + 10)]
},
onRemoved: function () {
if (this.inputEl) {
this.inputEl.remove()
}
},
}
w.inputEl = document.createElement(type === 'video' ? 'video' : 'img')
w.inputEl.src = w.value
if (type === 'video') {
w.inputEl.setAttribute('type', 'video/webm');
w.inputEl.autoplay = true
w.inputEl.loop = true
w.inputEl.controls = false;
}
w.inputEl.onload = function () {
w.inputRatio = w.inputEl.naturalWidth / w.inputEl.naturalHeight
}
document.body.appendChild(w.inputEl)
return w
}
const gif_preview = {
name: 'AnimateDiff.gif_preview',
async beforeRegisterNodeDef(nodeType, nodeData, app) {
switch (nodeData.name) {
case 'ADE_AnimateDiffCombine':{
const onExecuted = nodeType.prototype.onExecuted
nodeType.prototype.onExecuted = function (message) {
const prefix = 'ad_gif_preview_'
const r = onExecuted ? onExecuted.apply(this, message) : undefined
if (this.widgets) {
const pos = this.widgets.findIndex((w) => w.name === `${prefix}_0`)
if (pos !== -1) {
for (let i = pos; i < this.widgets.length; i++) {
this.widgets[i].onRemoved?.()
}
this.widgets.length = pos
}
if (message?.gifs) {
message.gifs.forEach((params, i) => {
const previewUrl = api.apiURL(
'/view?' + new URLSearchParams(params).toString()
)
const w = this.addCustomWidget(
CreatePreviewElement(`${prefix}_${i}`, previewUrl, params.format || 'image/gif')
)
w.parent = this
})
}
const onRemoved = this.onRemoved
this.onRemoved = () => {
cleanupNode(this)
return onRemoved?.()
}
}
this.setSize([this.size[0], this.computeSize([this.size[0], this.size[1]])[1]])
return r
}
break
}
}
}
}
app.registerExtension(gif_preview)