diff --git a/docs/ADE_AnimateDiffModelSettings.md b/docs/ADE_AnimateDiffModelSettings.md new file mode 100644 index 0000000..14f209b --- /dev/null +++ b/docs/ADE_AnimateDiffModelSettings.md @@ -0,0 +1,117 @@ +# 🚫[DEPR] Motion Model Settings (Advanced) 🎭🅐🅓① +## Documentation +- Class name: ADE_AnimateDiffModelSettings +- Category: +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在配置AnimateDiff过程中的运动模型设置,允许用户微调运动比例参数以实现所需的动画效果。 + +## Input types +### Required +- pe_strength + - 决定位置编码调整的强度,影响动画的空间动态。 + - Comfy dtype: FLOAT + - Python dtype: float +- attn_strength + - 控制注意力调整的强度,影响动画元素的焦点和细节。 + - Comfy dtype: FLOAT + - Python dtype: float +- other_strength + - 调整其他模型参数的强度,提供动画效果的额外定制。 + - Comfy dtype: FLOAT + - Python dtype: float +- motion_pe_stretch + - 指定位置编码的拉伸程度,改变运动的时间尺度。 + - Comfy dtype: INT + - Python dtype: int +- cap_initial_pe_length + - 限制初始位置编码长度,设定运动的起始尺度。 + - Comfy dtype: INT + - Python dtype: int +- interpolate_pe_to_length + - 定义位置编码插值的目标长度,影响动画的平滑度和流畅性。 + - Comfy dtype: INT + - Python dtype: int +- initial_pe_idx_offset + - 设置初始位置编码索引偏移,调整动画的起始点。 + - Comfy dtype: INT + - Python dtype: int +- final_pe_idx_offset + - 决定最终位置编码索引偏移,影响动画的终点。 + - Comfy dtype: INT + - Python dtype: int + +### Optional +- mask_motion_scale + - 选择性地应用遮罩以缩放图像不同部分的运动,增强动画的真实性和复杂性。 + - Comfy dtype: MASK + - Python dtype: torch.Tensor +- min_motion_scale + - 设置运动的最小尺度,确保动画不会低于此阈值。 + - Comfy dtype: FLOAT + - Python dtype: float +- max_motion_scale + - 定义运动的最大尺度,限制动画效果的强度。 + - Comfy dtype: FLOAT + - Python dtype: float + +## Output types +- ad_settings + - Comfy dtype: AD_SETTINGS + - 输出配置好的运动模型设置,包含对运动比例参数的调整。 + - Python dtype: AnimateDiffSettings + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class AnimateDiffModelSettingsAdvanced: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "pe_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.0001}), + "attn_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.0001}), + "other_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.0001}), + "motion_pe_stretch": ("INT", {"default": 0, "min": 0, "step": 1}), + "cap_initial_pe_length": ("INT", {"default": 0, "min": 0, "step": 1}), + "interpolate_pe_to_length": ("INT", {"default": 0, "min": 0, "step": 1}), + "initial_pe_idx_offset": ("INT", {"default": 0, "min": 0, "step": 1}), + "final_pe_idx_offset": ("INT", {"default": 0, "min": 0, "step": 1}), + }, + "optional": { + "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}), + } + } + + RETURN_TYPES = ("AD_SETTINGS",) + CATEGORY = "" #"Animate Diff 🎭🅐🅓/① Gen1 nodes ①/motion settings/experimental" + FUNCTION = "get_motion_model_settings" + + def get_motion_model_settings(self, pe_strength: float, attn_strength: float, other_strength: float, + motion_pe_stretch: int, + cap_initial_pe_length: int, interpolate_pe_to_length: int, + initial_pe_idx_offset: int, final_pe_idx_offset: int, + mask_motion_scale: torch.Tensor=None, min_motion_scale: float=1.0, max_motion_scale: float=1.0): + adjust_pe = AdjustGroup(AdjustPE(motion_pe_stretch=motion_pe_stretch, + cap_initial_pe_length=cap_initial_pe_length, interpolate_pe_to_length=interpolate_pe_to_length, + initial_pe_idx_offset=initial_pe_idx_offset, final_pe_idx_offset=final_pe_idx_offset)) + adjust_weight = AdjustGroup(AdjustWeight( + pe_MULT=pe_strength, + attn_MULT=attn_strength, + other_MULT=other_strength, + )) + motion_model_settings = AnimateDiffSettings( + adjust_pe=adjust_pe, + adjust_weight=adjust_weight, + mask_attn_scale=mask_motion_scale, + mask_attn_scale_min=min_motion_scale, + mask_attn_scale_max=max_motion_scale, + ) + + return (motion_model_settings,) \ No newline at end of file diff --git a/docs/ADE_AnimateDiffModelSettingsAdvancedAttnStrengths.md b/docs/ADE_AnimateDiffModelSettingsAdvancedAttnStrengths.md new file mode 100644 index 0000000..9247be0 --- /dev/null +++ b/docs/ADE_AnimateDiffModelSettingsAdvancedAttnStrengths.md @@ -0,0 +1,153 @@ +# 🚫[DEPR] Motion Model Settings (Adv. Attn) 🎭🅐🅓① +## Documentation +- Class name: ADE_AnimateDiffModelSettingsAdvancedAttnStrengths +- Category: +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在配置AnimateDiff模型设置中的高级注意力强度。它允许通过调整各种注意力组件的强度来微调模型的注意力机制,从而更详细地控制动画生成过程。 + +## Input types +### Required +- pe_strength + - 指定位置编码调整的强度,影响模型的空间感知。 + - Comfy dtype: FLOAT + - Python dtype: float +- attn_strength + - 定义注意力机制的整体强度,影响模型如何专注于输入的不同部分。 + - Comfy dtype: FLOAT + - Python dtype: float +- attn_q_strength + - 调整注意力机制中查询组件的强度,微调模型的查询过程。 + - Comfy dtype: FLOAT + - Python dtype: float +- attn_k_strength + - 修改注意力机制中键组件的强度,影响模型如何匹配查询和键。 + - Comfy dtype: FLOAT + - Python dtype: float +- attn_v_strength + - 改变注意力机制中值组件的强度,影响基于匹配的查询和键的输出。 + - Comfy dtype: FLOAT + - Python dtype: float +- attn_out_weight_strength + - 控制注意力输出权重的强度,影响最终注意力输出的影响。 + - Comfy dtype: FLOAT + - Python dtype: float +- attn_out_bias_strength + - 调整注意力输出偏差的强度,微调应用于注意力输出的偏差。 + - Comfy dtype: FLOAT + - Python dtype: float +- other_strength + - 指定与注意力直接相关的其他模型调整的强度,提供对模型行为的更广泛控制。 + - Comfy dtype: FLOAT + - Python dtype: float +- motion_pe_stretch + - 定义运动中位置编码的拉伸因子,影响运动的空间表示。 + - Comfy dtype: INT + - Python dtype: int +- cap_initial_pe_length + - 限制初始位置编码的长度,限制动画开始时的空间范围。 + - Comfy dtype: INT + - Python dtype: int +- interpolate_pe_to_length + - 确定位置编码插值的长度,影响随时间的空间分辨率。 + - Comfy dtype: INT + - Python dtype: int +- initial_pe_idx_offset + - 设置位置编码索引的初始偏移,调整起始的空间参考点。 + - Comfy dtype: INT + - Python dtype: int +- final_pe_idx_offset + - 设置位置编码索引的最终偏移,调整结束的空间参考点。 + - Comfy dtype: INT + - Python dtype: int + +### Optional +- mask_motion_scale + - 可选张量用于选择性缩放运动,允许在动画中不同部分的运动缩放。 + - Comfy dtype: MASK + - Python dtype: torch.Tensor +- min_motion_scale + - 设置运动的最小缩放,确保运动强度的下限。 + - Comfy dtype: FLOAT + - Python dtype: float +- max_motion_scale + - 设置运动的最大缩放,确保运动强度的上限。 + - Comfy dtype: FLOAT + - Python dtype: float + +## Output types +- ad_settings + - Comfy dtype: AD_SETTINGS + - 返回AnimateDiff模型的高级注意力强度设置,允许对动画生成过程进行精确控制。 + - Python dtype: AnimateDiffSettings + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class AnimateDiffModelSettingsAdvancedAttnStrengths: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "pe_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.0001}), + "attn_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.0001}), + "attn_q_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.0001}), + "attn_k_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.0001}), + "attn_v_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.0001}), + "attn_out_weight_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.0001}), + "attn_out_bias_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.0001}), + "other_strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.0001}), + "motion_pe_stretch": ("INT", {"default": 0, "min": 0, "step": 1}), + "cap_initial_pe_length": ("INT", {"default": 0, "min": 0, "step": 1}), + "interpolate_pe_to_length": ("INT", {"default": 0, "min": 0, "step": 1}), + "initial_pe_idx_offset": ("INT", {"default": 0, "min": 0, "step": 1}), + "final_pe_idx_offset": ("INT", {"default": 0, "min": 0, "step": 1}), + }, + "optional": { + "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}), + } + } + + RETURN_TYPES = ("AD_SETTINGS",) + CATEGORY = "" #"Animate Diff 🎭🅐🅓/① Gen1 nodes ①/motion settings/experimental" + FUNCTION = "get_motion_model_settings" + + def get_motion_model_settings(self, pe_strength: float, attn_strength: float, + attn_q_strength: float, + attn_k_strength: float, + attn_v_strength: float, + attn_out_weight_strength: float, + attn_out_bias_strength: float, + other_strength: float, + motion_pe_stretch: int, + cap_initial_pe_length: int, interpolate_pe_to_length: int, + initial_pe_idx_offset: int, final_pe_idx_offset: int, + mask_motion_scale: torch.Tensor=None, min_motion_scale: float=1.0, max_motion_scale: float=1.0): + adjust_pe = AdjustGroup(AdjustPE(motion_pe_stretch=motion_pe_stretch, + cap_initial_pe_length=cap_initial_pe_length, interpolate_pe_to_length=interpolate_pe_to_length, + initial_pe_idx_offset=initial_pe_idx_offset, final_pe_idx_offset=final_pe_idx_offset)) + adjust_weight = AdjustGroup(AdjustWeight( + pe_MULT=pe_strength, + attn_MULT=attn_strength, + attn_q_MULT=attn_q_strength, + attn_k_MULT=attn_k_strength, + attn_v_MULT=attn_v_strength, + attn_out_weight_MULT=attn_out_weight_strength, + attn_out_bias_MULT=attn_out_bias_strength, + other_MULT=other_strength, + )) + motion_model_settings = AnimateDiffSettings( + adjust_pe=adjust_pe, + adjust_weight=adjust_weight, + mask_attn_scale=mask_motion_scale, + mask_attn_scale_min=min_motion_scale, + mask_attn_scale_max=max_motion_scale, + ) + + return (motion_model_settings,) \ No newline at end of file diff --git a/docs/ADE_AnimateDiffModelSettingsSimple.md b/docs/ADE_AnimateDiffModelSettingsSimple.md new file mode 100644 index 0000000..b8685df --- /dev/null +++ b/docs/ADE_AnimateDiffModelSettingsSimple.md @@ -0,0 +1,71 @@ +# 🚫[DEPR] Motion Model Settings (Simple) 🎭🅐🅓① +## Documentation +- Class name: ADE_AnimateDiffModelSettingsSimple +- Category: +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在为AnimateDiff框架中的简单场景配置运动模型设置。它允许调整运动比例参数并应用可选的遮罩,以微调动画过程。 + +## Input types +### Required +- motion_pe_stretch + - 定义运动模型中位置编码的拉伸因子,影响应用的运动的规模和强度。 + - Comfy dtype: INT + - Python dtype: int + +### Optional +- mask_motion_scale + - 可选的遮罩张量,用于选择性地缩放不同区域,增强对运动效果的控制。 + - Comfy dtype: MASK + - Python dtype: torch.Tensor +- min_motion_scale + - 设置运动的最小比例,提供运动强度的基线。 + - Comfy dtype: FLOAT + - Python dtype: float +- max_motion_scale + - 确定运动的最大比例,限制运动效果的强度。 + - Comfy dtype: FLOAT + - Python dtype: float + +## Output types +- ad_settings + - Comfy dtype: AD_SETTINGS + - 输出配置好的运动模型设置,包含对运动比例和可选遮罩的调整。 + - Python dtype: AnimateDiffSettings + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class AnimateDiffModelSettingsSimple: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "motion_pe_stretch": ("INT", {"default": 0, "min": 0, "step": 1}), + }, + "optional": { + "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}), + } + } + + RETURN_TYPES = ("AD_SETTINGS",) + CATEGORY = "" #"Animate Diff 🎭🅐🅓/① Gen1 nodes ①/motion settings/experimental" + FUNCTION = "get_motion_model_settings" + + def get_motion_model_settings(self, motion_pe_stretch: int, + mask_motion_scale: torch.Tensor=None, min_motion_scale: float=1.0, max_motion_scale: float=1.0): + adjust_pe = AdjustGroup(AdjustPE(motion_pe_stretch=motion_pe_stretch)) + motion_model_settings = AnimateDiffSettings( + adjust_pe=adjust_pe, + mask_attn_scale=mask_motion_scale, + mask_attn_scale_min=min_motion_scale, + mask_attn_scale_max=max_motion_scale, + ) + + return (motion_model_settings,) \ No newline at end of file diff --git a/docs/ADE_AnimateDiffModelSettings_Release.md b/docs/ADE_AnimateDiffModelSettings_Release.md new file mode 100644 index 0000000..43b218f --- /dev/null +++ b/docs/ADE_AnimateDiffModelSettings_Release.md @@ -0,0 +1,63 @@ +# 🚫[DEPR] Motion Model Settings 🎭🅐🅓① +## Documentation +- Class name: ADE_AnimateDiffModelSettings_Release +- Category: +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在配置AnimateDiff过程中的运动模型设置,重点是高级注意力强度调整。它旨在为用户提供微调通过AnimateDiff框架应用的动画效果的能力。 + +## Input types +### Required +- min_motion_scale + - 指定运动的最小尺度,影响动画效果的细微程度或强度。 + - Comfy dtype: FLOAT + - Python dtype: float +- max_motion_scale + - 定义运动的最大尺度,影响可以应用于动画的运动强度范围。 + - Comfy dtype: FLOAT + - Python dtype: float + +### Optional +- mask_motion_scale + - 一个遮罩张量,允许对输入的不同区域进行精细控制的运动缩放。 + - Comfy dtype: MASK + - Python dtype: torch.Tensor + +## Output types +- ad_settings + - Comfy dtype: AD_SETTINGS + - 输出是AnimateDiff模型的配置集,包含对运动尺度和潜在其他参数的调整。 + - Python dtype: AnimateDiffSettings + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class AnimateDiffModelSettings: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "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}), + }, + "optional": { + "mask_motion_scale": ("MASK",), + } + } + + RETURN_TYPES = ("AD_SETTINGS",) + CATEGORY = "" #"Animate Diff 🎭🅐🅓/① Gen1 nodes ①/motion settings" + FUNCTION = "get_motion_model_settings" + + def get_motion_model_settings(self, mask_motion_scale: torch.Tensor=None, min_motion_scale: float=1.0, max_motion_scale: float=1.0): + motion_model_settings = AnimateDiffSettings( + mask_attn_scale=mask_motion_scale, + mask_attn_scale_min=min_motion_scale, + mask_attn_scale_max=max_motion_scale, + ) + + return (motion_model_settings,) \ No newline at end of file diff --git a/docs/ADE_AnimateDiffUnload.md b/docs/ADE_AnimateDiffUnload.md new file mode 100644 index 0000000..aa80dad --- /dev/null +++ b/docs/ADE_AnimateDiffUnload.md @@ -0,0 +1,45 @@ +# AnimateDiff Unload 🎭🅐🅓 +## Documentation +- Class name: ADE_AnimateDiffUnload +- Category: Animate Diff 🎭🅐🅓/extras +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在从内存中卸载或释放与AnimateDiff模型相关的资源,确保有效的资源管理并为后续任务释放内存。 + +## Input types +### Required +- model + - 指定要卸载的AnimateDiff模型,允许释放其资源。 + - Comfy dtype: MODEL + - Python dtype: AnimateDiffModel + +## Output types +- model + - Comfy dtype: MODEL + - 确认指定的AnimateDiff模型已成功卸载,确保其资源已释放。 + - Python dtype: NoneType + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class AnimateDiffUnload: + def __init__(self) -> None: + pass + + @classmethod + def INPUT_TYPES(s): + return {"required": {"model": ("MODEL",)}} + + RETURN_TYPES = ("MODEL",) + CATEGORY = "Animate Diff 🎭🅐🅓/extras" + FUNCTION = "unload_motion_modules" + + def unload_motion_modules(self, model: ModelPatcher): + # return model clone with ejected params + #model = eject_params_from_model(model) + model = get_vanilla_model_patcher(model) + return (model.clone(),) \ No newline at end of file diff --git a/docs/ADE_ApplyAnimateDiffModel.md b/docs/ADE_ApplyAnimateDiffModel.md new file mode 100644 index 0000000..54aa15d --- /dev/null +++ b/docs/ADE_ApplyAnimateDiffModel.md @@ -0,0 +1,106 @@ +# Apply AnimateDiff Model (Adv.) 🎭🅐🅓② +## Documentation +- Class name: ADE_ApplyAnimateDiffModel +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ② +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +ADE_ApplyAnimateDiffModel节点旨在应用高级AnimateDiff模型配置以生成图像中的运动。它利用一套全面的参数来微调动画过程,适应各种运动效果和风格。 + +## Input types +### Required +- motion_model + - 指定用于动画的运动模型。它对于定义动画的行为和特性至关重要。 + - Comfy dtype: MOTION_MODEL_ADE + - Python dtype: MotionModelPatcher +- start_percent + - 定义动画效果的起始百分比,标记运动应用的开始。 + - Comfy dtype: FLOAT + - Python dtype: float +- end_percent + - 指定动画效果的结束百分比,确定运动停止的点。 + - Comfy dtype: FLOAT + - Python dtype: float + +### Optional +- motion_lora + - 可选参数,允许使用LoRA(低秩适应)技术调整运动,增强动画质量。 + - Comfy dtype: MOTION_LORA + - Python dtype: MotionLoraList +- scale_multival + - 可选参数,影响动画效果的规模,允许微调动画的强度。 + - Comfy dtype: MULTIVAL + - Python dtype: float +- effect_multival + - 可选参数,调整动画的整体效果,允许自定义视觉结果。 + - Comfy dtype: MULTIVAL + - Python dtype: float +- ad_keyframes + - 可选参数,指定动画的关键帧,允许精确控制运动的时间和序列。 + - Comfy dtype: AD_KEYFRAMES + - Python dtype: ADKeyframeGroup +- prev_m_models + - 可选参数,包括要在当前动画过程中考虑的先前运动模型,允许累积效果。 + - Comfy dtype: M_MODELS + - Python dtype: M_MODELS + +## Output types +- m_models + - Comfy dtype: M_MODELS + - 输出动画过程中使用的运动模型,包含所有调整和配置。 + - Python dtype: M_MODELS + +## Usage tips +- Infra type: GPU +- Common nodes: + - [ADE_UseEvolvedSampling](../../ComfyUI-AnimateDiff-Evolved/Nodes/ADE_UseEvolvedSampling.md) + +## Source code +```python +class ApplyAnimateDiffModelNode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "motion_model": ("MOTION_MODEL_ADE",), + "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": { + "motion_lora": ("MOTION_LORA",), + "scale_multival": ("MULTIVAL",), + "effect_multival": ("MULTIVAL",), + "ad_keyframes": ("AD_KEYFRAMES",), + "prev_m_models": ("M_MODELS",), + } + } + + RETURN_TYPES = ("M_MODELS",) + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②" + FUNCTION = "apply_motion_model" + + def apply_motion_model(self, motion_model: MotionModelPatcher, start_percent: float=0.0, end_percent: float=1.0, + motion_lora: MotionLoraList=None, ad_keyframes: ADKeyframeGroup=None, + scale_multival=None, effect_multival=None, + prev_m_models: MotionModelGroup=None,): + # set up motion models list + if prev_m_models is None: + prev_m_models = MotionModelGroup() + prev_m_models = prev_m_models.clone() + motion_model = motion_model.clone() + # check if internal motion model already present in previous model - create new if so + for prev_model in prev_m_models.models: + if motion_model.model is prev_model.model: + # need to create new internal model based on same state_dict + motion_model = create_fresh_motion_module(motion_model) + # apply motion model to loaded_mm + 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 + motion_model.keyframes = ad_keyframes.clone() if ad_keyframes else ADKeyframeGroup() + motion_model.timestep_percent_range = (start_percent, end_percent) + # add to beginning, so that after injection, it will be the earliest of prev_m_models to be run + prev_m_models.add_to_start(mm=motion_model) + return (prev_m_models,) \ No newline at end of file diff --git a/docs/ADE_ApplyAnimateDiffModelSimple.md b/docs/ADE_ApplyAnimateDiffModelSimple.md new file mode 100644 index 0000000..8c46036 --- /dev/null +++ b/docs/ADE_ApplyAnimateDiffModelSimple.md @@ -0,0 +1,72 @@ +# Apply AnimateDiff Model 🎭🅐🅓② +## Documentation +- Class name: ADE_ApplyAnimateDiffModelSimple +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ② +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在应用运动模型以动画化图像或序列,提供一个简化的界面以集成运动效果。它抽象了动画过程中的复杂性,使用户能够轻松地将预定义的运动模型应用于其内容。 + +## Input types +### Required +- motion_model + - 指定要应用的运动模型。它对于定义目标内容的动画行为和效果至关重要。 + - Comfy dtype: MOTION_MODEL_ADE + - Python dtype: MotionModelPatcher + +### Optional +- motion_lora + - 可选参数,用于整合运动Lora调整,增强动画效果。 + - Comfy dtype: MOTION_LORA + - Python dtype: MotionLoraList +- scale_multival + - 可选参数,用于缩放效果,提供应用运动强度的灵活性。 + - Comfy dtype: MULTIVAL + - Python dtype: Optional[MultiVal] +- effect_multival + - 可选参数,用于效果调整,使运动的视觉影响自定义。 + - Comfy dtype: MULTIVAL + - Python dtype: Optional[MultiVal] +- ad_keyframes + - 可选参数,用于指定关键帧,允许更受控和精确的动画效果。 + - Comfy dtype: AD_KEYFRAMES + - Python dtype: Optional[ADKeyframeGroup] + +## Output types +- m_models + - Comfy dtype: M_MODELS + - 输出应用了指定运动效果、关键帧和调整后的运动模型。 + - Python dtype: MotionModelGroup + +## Usage tips +- Infra type: GPU +- Common nodes: unknown + +## Source code +```python +class ApplyAnimateDiffModelBasicNode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "motion_model": ("MOTION_MODEL_ADE",), + }, + "optional": { + "motion_lora": ("MOTION_LORA",), + "scale_multival": ("MULTIVAL",), + "effect_multival": ("MULTIVAL",), + "ad_keyframes": ("AD_KEYFRAMES",), + } + } + + RETURN_TYPES = ("M_MODELS",) + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②" + FUNCTION = "apply_motion_model" + + def apply_motion_model(self, + motion_model: MotionModelPatcher, motion_lora: MotionLoraList=None, + scale_multival=None, effect_multival=None, ad_keyframes=None): + # just a subset of normal ApplyAnimateDiffModelNode inputs + return ApplyAnimateDiffModelNode.apply_motion_model(self, motion_model, motion_lora=motion_lora, + scale_multival=scale_multival, effect_multival=effect_multival, + ad_keyframes=ad_keyframes) \ No newline at end of file diff --git a/docs/ADE_ApplyAnimateDiffModelWithCameraCtrl.md b/docs/ADE_ApplyAnimateDiffModelWithCameraCtrl.md new file mode 100644 index 0000000..d6d38e2 --- /dev/null +++ b/docs/ADE_ApplyAnimateDiffModelWithCameraCtrl.md @@ -0,0 +1,106 @@ +# Apply AnimateDiff+CameraCtrl Model 🎭🅐🅓② +## Documentation +- Class name: ADE_ApplyAnimateDiffModelWithCameraCtrl +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点将AnimateDiff模型与摄像机控制相结合,集成运动模型调整和摄像机控制参数以生成动画序列。它利用摄像机控制姿势和其他动画参数来增强AnimateDiff模型的输出,提供更具动态性和可定制的动画体验。 + +## Input types +### Required +- motion_model + - 要进行动画处理的运动模型,结合AnimateDiff模型的功能和摄像机控制特性以增强动画。 + - Comfy dtype: MOTION_MODEL_ADE + - Python dtype: MotionModelPatcher +- cameractrl_poses + - 摄像机控制姿势列表,每个姿势定义动画过程中的特定摄像机位置和方向。 + - Comfy dtype: CAMERACTRL_POSES + - Python dtype: list[list[float]] +- start_percent + - 动画的起始百分比,作为总动画长度的一部分,允许实现部分动画。 + - Comfy dtype: FLOAT + - Python dtype: float +- end_percent + - 动画的结束百分比,作为总动画长度的一部分,允许自定义动画的持续时间。 + - Comfy dtype: FLOAT + - Python dtype: float + +### Optional +- motion_lora + - 可选参数,用于指定运动LoRA设置,以进一步自定义动画。 + - Comfy dtype: MOTION_LORA + - Python dtype: MotionLoraList +- scale_multival + - 可选参数,用于应用比例乘数,影响动画元素的整体大小。 + - Comfy dtype: MULTIVAL + - Python dtype: dict +- effect_multival + - 可选参数,用于应用效果乘数,允许在动画中添加其他视觉效果。 + - Comfy dtype: MULTIVAL + - Python dtype: dict +- cameractrl_multival + - 可选参数,用于应用多个摄像机控制值,增强动画中的动态摄像机运动。 + - Comfy dtype: MULTIVAL + - Python dtype: dict +- ad_keyframes + - 可选参数,用于定义动画中的关键帧,允许对动画序列进行精确控制。 + - Comfy dtype: AD_KEYFRAMES + - Python dtype: ADKeyframeGroup +- prev_m_models + - 可选参数,用于整合先前生成的运动模型,促进顺序或分层动画。 + - Comfy dtype: M_MODELS + - Python dtype: MotionModelGroup + +## Output types +- m_models + - Comfy dtype: M_MODELS + - 应用AnimateDiff模型和摄像机控制后生成的运动模型,包括任何指定的动画和效果。 + - Python dtype: MotionModelGroup + +## Usage tips +- Infra type: GPU +- Common nodes: unknown + +## Source code +```python +class ApplyAnimateDiffWithCameraCtrl: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "motion_model": ("MOTION_MODEL_ADE",), + "cameractrl_poses": ("CAMERACTRL_POSES",), + "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": { + "motion_lora": ("MOTION_LORA",), + "scale_multival": ("MULTIVAL",), + "effect_multival": ("MULTIVAL",), + "cameractrl_multival": ("MULTIVAL",), + "ad_keyframes": ("AD_KEYFRAMES",), + "prev_m_models": ("M_MODELS",), + } + } + + RETURN_TYPES = ("M_MODELS",) + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl" + FUNCTION = "apply_motion_model" + + def apply_motion_model(self, motion_model: MotionModelPatcher, cameractrl_poses: list[list[float]], start_percent: float=0.0, end_percent: float=1.0, + motion_lora: MotionLoraList=None, ad_keyframes: ADKeyframeGroup=None, + scale_multival=None, effect_multival=None, cameractrl_multival=None, + prev_m_models: MotionModelGroup=None,): + new_m_models = ApplyAnimateDiffModelNode.apply_motion_model(self, motion_model, start_percent=start_percent, end_percent=end_percent, + motion_lora=motion_lora, ad_keyframes=ad_keyframes, + scale_multival=scale_multival, effect_multival=effect_multival, prev_m_models=prev_m_models) + # most recent added model will always be first in list; + curr_model = new_m_models[0].models[0] + # confirm that model contains camera_encoder + if curr_model.model.camera_encoder is None: + raise Exception(f"Motion model '{curr_model.model.mm_info.mm_name}' does not contain a camera_encoder; cannot be used with Apply AnimateDiff-CameraCtrl Model node.") + camera_entries = [CameraEntry(entry) for entry in cameractrl_poses] + curr_model.orig_camera_entries = camera_entries + curr_model.cameractrl_multival = cameractrl_multival + return new_m_models \ No newline at end of file diff --git a/docs/ADE_ApplyAnimateLCMI2VModel.md b/docs/ADE_ApplyAnimateLCMI2VModel.md new file mode 100644 index 0000000..da7bbcd --- /dev/null +++ b/docs/ADE_ApplyAnimateLCMI2VModel.md @@ -0,0 +1,111 @@ +# Apply AnimateLCM-I2V Model 🎭🅐🅓② +## Documentation +- Class name: ADE_ApplyAnimateLCMI2VModel +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ②/AnimateLCM-I2V +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在应用AnimateLCM-I2V模型,通过I2V(图像到视频)功能使用潜在代码运动推理来动画化图像。它集成了运动模型和关键帧组,从静态图像生成动态动画视觉效果,并根据指定参数增强其运动和效果。 + +## Input types +### Required +- motion_model + - 运动模型参数对于定义将应用于静态图像的运动特性和动态至关重要。它影响节点的执行,通过确定将引入的动画和运动效果类型来发挥作用。 + - Comfy dtype: MOTION_MODEL_ADE + - Python dtype: MotionModelPatcher +- ref_latent + - 该参数保存要动画化的图像的参考潜在表示。它对于在应用运动效果时保持图像的原始特性至关重要。 + - Comfy dtype: LATENT + - Python dtype: dict +- ref_drift + - 指定在应用运动时偏离原始图像特性的程度,允许动画输出的微妙或显著变化。 + - Comfy dtype: FLOAT + - Python dtype: float +- apply_ref_when_disabled + - 确定即使在禁用运动模型时是否应用参考特性(如漂移),以确保动画过程的连续性。 + - Comfy dtype: BOOLEAN + - Python dtype: bool +- start_percent + - 定义动画在运动模型时间线中的起始点,允许精确控制动画效果的开始时间。 + - Comfy dtype: FLOAT + - Python dtype: float +- end_percent + - 设置动画在运动模型时间线中的结束点,允许自定义动画的持续时间和结尾。 + - Comfy dtype: FLOAT + - Python dtype: float + +### Optional +- motion_lora + - 一组运动特定的LoRA设置,可以应用于进一步自定义动画效果和动态。 + - Comfy dtype: MOTION_LORA + - Python dtype: MotionLoraList +- scale_multival + - 缩放效果的乘数,提供对动画元素大小和比例的额外控制。 + - Comfy dtype: MULTIVAL + - Python dtype: Optional[List[float]] +- effect_multival + - 各种效果的乘数,提供进一步自定义动画视觉外观和动态的能力。 + - Comfy dtype: MULTIVAL + - Python dtype: Optional[List[float]] +- ad_keyframes + - 指定一个关键帧组以进行高级动画控制,允许详细自定义随时间变化的运动和效果。 + - Comfy dtype: AD_KEYFRAMES + - Python dtype: ADKeyframeGroup +- prev_m_models + - 先前应用的运动模型组,使节点能够基于现有动画进行构建或修改,以增强或改变效果。 + - Comfy dtype: M_MODELS + - Python dtype: MotionModelGroup + +## Output types +- m_models + - Comfy dtype: M_MODELS + - 更新的运动模型列表,包括最新应用的带有其配置动画和效果的模型。 + - Python dtype: MotionModelGroup + +## Usage tips +- Infra type: GPU +- Common nodes: unknown + +## Source code +```python +class ApplyAnimateLCMI2VModel: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "motion_model": ("MOTION_MODEL_ADE",), + "ref_latent": ("LATENT",), + "ref_drift": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 10.0, "step": 0.001}), + "apply_ref_when_disabled": ("BOOLEAN", {"default": False}), + "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": { + "motion_lora": ("MOTION_LORA",), + "scale_multival": ("MULTIVAL",), + "effect_multival": ("MULTIVAL",), + "ad_keyframes": ("AD_KEYFRAMES",), + "prev_m_models": ("M_MODELS",), + } + } + + RETURN_TYPES = ("M_MODELS",) + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②/AnimateLCM-I2V" + FUNCTION = "apply_motion_model" + + def apply_motion_model(self, motion_model: MotionModelPatcher, ref_latent: dict, ref_drift: float=0.0, apply_ref_when_disabled=False, start_percent: float=0.0, end_percent: float=1.0, + motion_lora: MotionLoraList=None, ad_keyframes: ADKeyframeGroup=None, + scale_multival=None, effect_multival=None, + prev_m_models: MotionModelGroup=None,): + new_m_models = ApplyAnimateDiffModelNode.apply_motion_model(self, motion_model, start_percent=start_percent, end_percent=end_percent, + motion_lora=motion_lora, ad_keyframes=ad_keyframes, + scale_multival=scale_multival, effect_multival=effect_multival, prev_m_models=prev_m_models) + # most recent added model will always be first in list; + curr_model = new_m_models[0].models[0] + # confirm that model contains img_encoder + if curr_model.model.img_encoder is None: + raise Exception(f"Motion model '{curr_model.model.mm_info.mm_name}' does not contain an img_encoder; cannot be used with Apply AnimateLCM-I2V Model node.") + curr_model.orig_img_latents = ref_latent["samples"] + curr_model.orig_ref_drift = ref_drift + curr_model.orig_apply_ref_when_disabled = apply_ref_when_disabled + return new_m_models \ No newline at end of file diff --git a/docs/ADE_AttachLoraHookToCLIP.md b/docs/ADE_AttachLoraHookToCLIP.md new file mode 100644 index 0000000..e29a1af --- /dev/null +++ b/docs/ADE_AttachLoraHookToCLIP.md @@ -0,0 +1,51 @@ +# Set CLIP LoRA Hook 🎭🅐🅓 +## Documentation +- Class name: ADE_AttachLoraHookToCLIP +- Category: Animate Diff 🎭🅐🅓/conditioning +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在将LoRA挂钩附加到CLIP模型上,通过集成额外的计算层或修改来增强其功能。它作为CLIP模型的定制点,允许进行定制调整以影响模型的行为或输出。 + +## Input types +### Required +- clip + - 要附加LoRA挂钩的CLIP模型。此参数至关重要,因为它决定了将被修改的基础模型。 + - Comfy dtype: CLIP + - Python dtype: CLIP +- lora_hook + - 要附加到CLIP模型的LoRA挂钩。此挂钩代表要应用的修改或增强,在定制模型功能中起关键作用。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup + +## Output types +- hook_CLIP + - Comfy dtype: CLIP + - 附加了LoRA挂钩的修改后CLIP模型,代表原始模型的增强版本。 + - Python dtype: CLIPWithHooks + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class SetClipLoraHook: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "clip": ("CLIP",), + "lora_hook": ("LORA_HOOK",), + } + } + + RETURN_TYPES = ("CLIP",) + RETURN_NAMES = ("hook_CLIP",) + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning" + FUNCTION = "apply_lora_hook" + + def apply_lora_hook(self, clip: CLIP, lora_hook: LoraHookGroup): + new_clip = CLIPWithHooks(clip) + new_clip.set_desired_hooks(lora_hooks=lora_hook) + return (new_clip, ) \ No newline at end of file diff --git a/docs/ADE_AttachLoraHookToConditioning.md b/docs/ADE_AttachLoraHookToConditioning.md new file mode 100644 index 0000000..4d2ccbd --- /dev/null +++ b/docs/ADE_AttachLoraHookToConditioning.md @@ -0,0 +1,53 @@ +# Set Model LoRA Hook 🎭🅐🅓 +## Documentation +- Class name: ADE_AttachLoraHookToConditioning +- Category: Animate Diff 🎭🅐🅓/conditioning/single cond ops +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在将LoRA挂钩附加到条件数据上,从而根据指定的LoRA挂钩动态修改模型行为。它在生成模型的条件过程中,尤其是在动画和差分渲染的背景下,起着定制和控制的关键作用。 + +## Input types +### Required +- conditioning + - 要附加LoRA挂钩的条件数据。此数据决定了模型的行为和输出,附加LoRA挂钩可以进行动态调整。 + - Comfy dtype: CONDITIONING + - Python dtype: List[Tuple[Any, Dict[str, Any]]] +- lora_hook + - 要附加到条件数据的LoRA挂钩。此挂钩使得在运行时修改模型参数成为可能,从而增强了对生成过程的控制和定制。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup + +## Output types +- conditioning + - Comfy dtype: CONDITIONING + - 附加了LoRA挂钩的修改后条件数据,使得模型行为可以动态调整。 + - Python dtype: List[Tuple[Any, Dict[str, Any]]] + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class SetModelLoraHook: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "conditioning": ("CONDITIONING",), + "lora_hook": ("LORA_HOOK",), + } + } + + RETURN_TYPES = ("CONDITIONING",) + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning/single cond ops" + FUNCTION = "attach_lora_hook" + + def attach_lora_hook(self, conditioning, lora_hook: LoraHookGroup): + c = [] + for t in conditioning: + n = [t[0], t[1].copy()] + n[1]["lora_hook"] = lora_hook + c.append(n) + return (c, ) \ No newline at end of file diff --git a/docs/ADE_CameraCtrlAnimateDiffKeyframe.md b/docs/ADE_CameraCtrlAnimateDiffKeyframe.md new file mode 100644 index 0000000..8f103df --- /dev/null +++ b/docs/ADE_CameraCtrlAnimateDiffKeyframe.md @@ -0,0 +1,86 @@ +# AnimateDiff+CameraCtrl Keyframe 🎭🅐🅓 +## Documentation +- Class name: ADE_CameraCtrlAnimateDiffKeyframe +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在生成和管理包含摄像机控制的动画关键帧,从而在AnimateDiff框架内创建动态和复杂的摄像机运动。它允许指定动画的起始百分比,应用多值进行缩放、效果和摄像机控制,并继承缺失值以确保关键帧之间的连续性。 + +## Input types +### Required +- start_percent + - 指定动画的起始百分比,允许精确控制动画中摄像机运动和效果的时间。 + - Comfy dtype: FLOAT + - Python dtype: float + +### Optional +- prev_ad_keyframes + - 可选。允许包括先前定义的AnimateDiff关键帧,使动画可以进行更复杂的序列链和层叠。 + - Comfy dtype: AD_KEYFRAMES + - Python dtype: ADKeyframeGroup or None +- scale_multival + - 可选。应用缩放因子到动画,允许调整动画元素的大小。 + - Comfy dtype: MULTIVAL + - Python dtype: float or torch.Tensor +- effect_multival + - 可选。应用各种效果到动画,允许添加视觉增强或修改。 + - Comfy dtype: MULTIVAL + - Python dtype: float or torch.Tensor +- cameractrl_multival + - 可选。指定摄像机控制的多个值,允许在动画中创建复杂的摄像机运动。 + - Comfy dtype: MULTIVAL + - Python dtype: float or torch.Tensor +- inherit_missing + - 确定当前关键帧中的缺失值是否应继承自前面的关键帧,以确保动画的连续性。 + - Comfy dtype: BOOLEAN + - Python dtype: bool +- guarantee_steps + - 指定动画中保证的最小步数,确保一定程度的平滑和连续性。 + - Comfy dtype: INT + - Python dtype: int + +## Output types +- ad_keyframes + - Comfy dtype: AD_KEYFRAMES + - 生成一系列AnimateDiff关键帧,使动画具有复杂的摄像机运动。 + - Python dtype: ADKeyframeGroup + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class CameraCtrlADKeyframeNode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "start_percent": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001}, ), + }, + "optional": { + "prev_ad_keyframes": ("AD_KEYFRAMES", ), + "scale_multival": ("MULTIVAL",), + "effect_multival": ("MULTIVAL",), + "cameractrl_multival": ("MULTIVAL",), + "inherit_missing": ("BOOLEAN", {"default": True}, ), + "guarantee_steps": ("INT", {"default": 1, "min": 0, "max": BIGMAX}), + } + } + + RETURN_TYPES = ("AD_KEYFRAMES", ) + FUNCTION = "load_keyframe" + + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl" + + def load_keyframe(self, + start_percent: float, prev_ad_keyframes=None, + scale_multival: Union[float, torch.Tensor]=None, effect_multival: Union[float, torch.Tensor]=None, + cameractrl_multival: Union[float, torch.Tensor]=None, + inherit_missing: bool=True, guarantee_steps: int=1): + return ADKeyframeNode.load_keyframe(self, + start_percent=start_percent, prev_ad_keyframes=prev_ad_keyframes, + scale_multival=scale_multival, effect_multival=effect_multival, cameractrl_multival=cameractrl_multival, + inherit_missing=inherit_missing, guarantee_steps=guarantee_steps + ) \ No newline at end of file diff --git a/docs/ADE_CameraPoseAdvanced.md b/docs/ADE_CameraPoseAdvanced.md new file mode 100644 index 0000000..f6b128b --- /dev/null +++ b/docs/ADE_CameraPoseAdvanced.md @@ -0,0 +1,127 @@ +# Create CameraCtrl Poses (Adv.) 🎭🅐🅓② +## Documentation +- Class name: ADE_CameraPoseAdvanced +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl/poses +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +ADE_CameraPoseAdvanced节点旨在为动画创建高级摄像机控制姿势。它允许组合多种运动类型和强度,以生成复杂的摄像机运动,增强动画序列中的动态视觉叙事。 + +## Input types +### Required +- motion_type1 + - 指定要应用的第一种摄像机运动类型,影响整体摄像机运动及其对动画的视觉影响。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- strength1 + - 指定第一种运动类型的强度乘数,调整摄像机运动的强度。 + - Comfy dtype: FLOAT + - Python dtype: float +- motion_type2 + - 定义第二种摄像机运动类型,有助于增加摄像机路径的复杂性和深度。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- strength2 + - 定义第二种运动类型的强度乘数,修改摄像机路径的影响。 + - Comfy dtype: FLOAT + - Python dtype: float +- motion_type3 + - 指示第三种摄像机运动类型,为摄像机轨迹增加另一层运动。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- strength3 + - 指示第三种运动类型的强度乘数,改变摄像机运动的强度。 + - Comfy dtype: FLOAT + - Python dtype: float +- motion_type4 + - 指定第四种摄像机运动类型,进一步丰富摄像机的运动及其对场景的影响。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- strength4 + - 指定第四种运动类型的强度乘数,影响摄像机轨迹的深度。 + - Comfy dtype: FLOAT + - Python dtype: float +- motion_type5 + - 定义第五种摄像机运动类型,通过额外的运动细微差别增强动画。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- strength5 + - 定义第五种运动类型的强度乘数,影响摄像机运动的细微差别。 + - Comfy dtype: FLOAT + - Python dtype: float +- motion_type6 + - 指示第六种摄像机运动类型,完成复杂摄像机控制的运动集。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- strength6 + - 指示第六种运动类型的强度乘数,微调摄像机运动的复杂性。 + - Comfy dtype: FLOAT + - Python dtype: float +- speed + - 控制摄像机运动的速度,影响摄像机在姿势之间过渡的快慢。 + - Comfy dtype: FLOAT + - Python dtype: float +- frame_length + - 确定应用摄像机运动的帧数,定义运动的持续时间。 + - Comfy dtype: INT + - Python dtype: int + +### Optional +- prev_poses + - 可选。可以与新运动结合的先前摄像机姿势,以实现动画中的无缝过渡。 + - Comfy dtype: CAMERACTRL_POSES + - Python dtype: list[list[float]] + +## Output types +- cameractrl_poses + - Comfy dtype: CAMERACTRL_POSES + - 生成的摄像机控制姿势,代表指定运动和参数对摄像机在动画中路径的综合效果。 + - Python dtype: list[list[float]] + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class CameraCtrlPoseAdvanced: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "motion_type1": (CAM._LIST,), + "strength1": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}), + "motion_type2": (CAM._LIST,), + "strength2": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}), + "motion_type3": (CAM._LIST,), + "strength3": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}), + "motion_type4": (CAM._LIST,), + "strength4": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}), + "motion_type5": (CAM._LIST,), + "strength5": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}), + "motion_type6": (CAM._LIST,), + "strength6": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}), + "speed": ("FLOAT", {"default": 1.0, "min": -100.0, "max": 100.0, "step": 0.01}), + "frame_length": ("INT", {"default": 16}), + }, + "optional": { + "prev_poses": ("CAMERACTRL_POSES",), + } + } + + RETURN_TYPES = ("CAMERACTRL_POSES",) + FUNCTION = "camera_pose_combo" + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl/poses" + + def camera_pose_combo(self, + motion_type1: str, motion_type2: str, motion_type3: str, + motion_type4: str, motion_type5: str, motion_type6: str, + speed: float, frame_length: int, + prev_poses: list[list[float]]=None, + strength1=1.0, strength2=1.0, strength3=1.0, strength4=1.0, strength5=1.0, strength6=1.0): + return CameraCtrlPoseCombo.camera_pose_combo(self, + motion_type1=motion_type1, motion_type2=motion_type2, motion_type3=motion_type3, + motion_type4=motion_type4, motion_type5=motion_type5, motion_type6=motion_type6, + speed=speed, frame_length=frame_length, prev_poses=prev_poses, + strength1=strength1, strength2=strength2, strength3=strength3, + strength4=strength4, strength5=strength5, strength6=strength6) \ No newline at end of file diff --git a/docs/ADE_CameraPoseBasic.md b/docs/ADE_CameraPoseBasic.md new file mode 100644 index 0000000..6cb6380 --- /dev/null +++ b/docs/ADE_CameraPoseBasic.md @@ -0,0 +1,67 @@ +# Create CameraCtrl Poses 🎭🅐🅓② +## Documentation +- Class name: ADE_CameraPoseBasic +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl/poses +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在根据指定的运动类型、速度和帧长创建基本的摄像机控制姿势。它允许生成可用于控制摄像机在3D环境中的运动和方向的姿势,从而实现动态和可定制的动画。 + +## Input types +### Required +- motion_type + - 指定要应用于摄像机的运动类型,影响摄像机运动的方向和性质。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- speed + - 确定摄像机移动的速度,允许控制动画的节奏。 + - Comfy dtype: FLOAT + - Python dtype: float +- frame_length + - 定义应用摄像机运动的帧数,设置摄像机运动的持续时间。 + - Comfy dtype: INT + - Python dtype: int + +### Optional +- prev_poses + - 可选。提供先前的摄像机姿势,以与新生成的姿势结合,实现动画之间的无缝过渡。 + - Comfy dtype: CAMERACTRL_POSES + - Python dtype: list[list[float]] + +## Output types +- cameractrl_poses + - Comfy dtype: CAMERACTRL_POSES + - 输出生成的摄像机控制姿势,准备用于动画。 + - Python dtype: list[list[float]] + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class CameraCtrlPoseBasic: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "motion_type": (CAM._LIST,), + "speed": ("FLOAT", {"default": 1.0, "min": -100.0, "max": 100.0, "step": 0.01}), + "frame_length": ("INT", {"default": 16}), + }, + "optional": { + "prev_poses": ("CAMERACTRL_POSES",), + } + } + + RETURN_TYPES = ("CAMERACTRL_POSES",) + FUNCTION = "camera_pose_basic" + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl/poses" + + def camera_pose_basic(self, motion_type: str, speed: float, frame_length: int, prev_poses: list[list[float]]=None): + motion = CAM.get(motion_type) + RT = get_camera_motion(motion.rotate, motion.translate, speed, frame_length) + new_motion = ndarray_to_poses(RT=RT) + if prev_poses is not None: + new_motion = combine_poses(prev_poses, new_motion) + return (new_motion,) \ No newline at end of file diff --git a/docs/ADE_CameraPoseCombo.md b/docs/ADE_CameraPoseCombo.md new file mode 100644 index 0000000..6dffa65 --- /dev/null +++ b/docs/ADE_CameraPoseCombo.md @@ -0,0 +1,100 @@ +# Create CameraCtrl Poses (Combo) 🎭🅐🅓② +## Documentation +- Class name: ADE_CameraPoseCombo +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl/poses +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +ADE_CameraPoseCombo节点旨在通过组合多种运动类型及其相应的强度来创建复杂的摄像机控制姿势。它允许在动画序列中自定义摄像机运动,从而生成动态且细致的摄像机行为。 + +## Input types +### Required +- motion_type1 + - 指定要包含在组合中的第一种摄像机运动类型。每种运动类型都对整体摄像机运动模式有所贡献。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- motion_type2 + - 指定要包含在组合中的第二种摄像机运动类型,增加摄像机运动的复杂性。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- motion_type3 + - 指定第三种摄像机运动类型,进一步丰富摄像机的运动模式。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- motion_type4 + - 指定第四种摄像机运动类型,对摄像机运动的多样性有所贡献。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- motion_type5 + - 指定第五种摄像机运动类型,为摄像机运动的复杂性增加另一层。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- motion_type6 + - 指定第六种摄像机运动类型,完成综合摄像机控制的运动集。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- speed + - 控制摄像机运动的速度,影响摄像机在姿势之间过渡的快慢。 + - Comfy dtype: FLOAT + - Python dtype: float +- frame_length + - 确定摄像机运动发生的帧数,定义动画的持续时间。 + - Comfy dtype: INT + - Python dtype: int + +### Optional +- prev_poses + - 可选。可以与新运动结合的先前摄像机姿势,以实现动画中的无缝过渡。此输入对于创建流畅且连续的摄像机运动至关重要,尤其是在需要保持叙述或视觉连续性的场景中。 + - Comfy dtype: CAMERACTRL_POSES + - Python dtype: list[list[float]] + +## Output types +- cameractrl_poses + - Comfy dtype: CAMERACTRL_POSES + - 组合指定的运动和强度后生成的摄像机控制姿势,准备用于动画。 + - Python dtype: list[list[float]] + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class CameraCtrlPoseCombo: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "motion_type1": (CAM._LIST,), + "motion_type2": (CAM._LIST,), + "motion_type3": (CAM._LIST,), + "motion_type4": (CAM._LIST,), + "motion_type5": (CAM._LIST,), + "motion_type6": (CAM._LIST,), + "speed": ("FLOAT", {"default": 1.0, "min": -100.0, "max": 100.0, "step": 0.01}), + "frame_length": ("INT", {"default": 16}), + }, + "optional": { + "prev_poses": ("CAMERACTRL_POSES",), + } + } + + RETURN_TYPES = ("CAMERACTRL_POSES",) + FUNCTION = "camera_pose_combo" + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl/poses" + + def camera_pose_combo(self, + motion_type1: str, motion_type2: str, motion_type3: str, + motion_type4: str, motion_type5: str, motion_type6: str, + speed: float, frame_length: int, + prev_poses: list[list[float]]=None, + strength1=1.0, strength2=1.0, strength3=1.0, strength4=1.0, strength5=1.0, strength6=1.0): + combined_motion = CameraMotion.combine([ + CAM.get(motion_type1).multiply(strength1), CAM.get(motion_type2).multiply(strength2), CAM.get(motion_type3).multiply(strength3), + CAM.get(motion_type4).multiply(strength4), CAM.get(motion_type5).multiply(strength5), CAM.get(motion_type6).multiply(strength6) + ]) + RT = get_camera_motion(combined_motion.rotate, combined_motion.translate, speed, frame_length) + new_motion = ndarray_to_poses(RT=RT) + if prev_poses is not None: + new_motion = combine_poses(prev_poses, new_motion) + return (new_motion,) \ No newline at end of file diff --git a/docs/ADE_CombineLoraHooks.md b/docs/ADE_CombineLoraHooks.md new file mode 100644 index 0000000..9d5723b --- /dev/null +++ b/docs/ADE_CombineLoraHooks.md @@ -0,0 +1,52 @@ +# Combine LoRA Hooks [2] 🎭🅐🅓 +## Documentation +- Class name: ADE_CombineLoraHooks +- Category: Animate Diff 🎭🅐🅓/conditioning/combine lora hooks +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在将多个LoRA挂钩组聚合成一个统一的LoRA挂钩组。它有助于组合各种LoRA挂钩,通过整合每个单独挂钩提供的不同修改或增强,实现更复杂和细致的模型条件。 + +## Input types +### Required +### Optional +- lora_hook_A + - 表示要组合的第一个LoRA挂钩组。在聚合过程中起关键作用,贡献其修改或增强到最终的统一LoRA挂钩组。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- lora_hook_B + - 表示要组合的第二个LoRA挂钩组。贡献其独特的修改或增强到统一LoRA挂钩组,丰富整体的条件效果。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup + +## Output types +- lora_hook + - Comfy dtype: LORA_HOOK + - 输出是一个统一的LoRA挂钩组,结合了输入LoRA挂钩组的修改或增强。此聚合挂钩有助于更复杂的模型条件。 + - Python dtype: LoraHookGroup + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class CombineLoraHooks: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + }, + "optional": { + "lora_hook_A": ("LORA_HOOK",), + "lora_hook_B": ("LORA_HOOK",), + } + } + + RETURN_TYPES = ("LORA_HOOK",) + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning/combine lora hooks" + FUNCTION = "combine_lora_hooks" + + def combine_lora_hooks(self, lora_hook_A: LoraHookGroup=None, lora_hook_B: LoraHookGroup=None): + candidates = [lora_hook_A, lora_hook_B] + return (LoraHookGroup.combine_all_lora_hooks(candidates),) \ No newline at end of file diff --git a/docs/ADE_CombineLoraHooksEight.md b/docs/ADE_CombineLoraHooksEight.md new file mode 100644 index 0000000..8c7a9ab --- /dev/null +++ b/docs/ADE_CombineLoraHooksEight.md @@ -0,0 +1,87 @@ +# Combine LoRA Hooks [8] 🎭🅐🅓 +## Documentation +- Class name: ADE_CombineLoraHooksEight +- Category: Animate Diff 🎭🅐🅓/conditioning/combine lora hooks +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在将多达八个LoRA挂钩组合成一个统一的LoRA挂钩组。它有助于整合多个LoRA挂钩的修改,允许在生成任务中对模型行为进行更复杂和细致的调整。 + +## Input types +### Required +### Optional +- lora_hook_A + - 表示要组合的第一个LoRA挂钩组。在聚合过程中起基础性作用,为组合后的LoRA挂钩组设定初始条件。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- lora_hook_B + - 表示要组合的第二个LoRA挂钩组。其包含的修改扩大了组合后LoRA挂钩组的能力和修改范围。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- lora_hook_C + - 作为组合过程中的第三个LoRA挂钩组,贡献了额外的修改,进一步丰富了组合后LoRA挂钩组的功能。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- lora_hook_D + - 表示要组合的第四个LoRA挂钩组,增加了组合后LoRA挂钩组中的修改多样性。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- lora_hook_E + - 作为组合过程中的第五个LoRA挂钩组,通过引入更多细微调整增强了组合后LoRA挂钩组。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- lora_hook_F + - 表示要组合的第六个LoRA挂钩组,其包含的修改拓宽了组合后LoRA挂钩组的范围。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- lora_hook_G + - 作为组合过程中的第七个LoRA挂钩组,增加了组合后LoRA挂钩组中的复杂性和深度。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- lora_hook_H + - 作为第八个也是最后一个要组合的LoRA挂钩组,完成了聚合,最大化了组合后LoRA挂钩组中的修改和调整。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup + +## Output types +- lora_hook + - Comfy dtype: LORA_HOOK + - 组合多达八个LoRA挂钩后的统一LoRA挂钩组。此组合组能够对模型行为应用一整套全面的修改。 + - Python dtype: LoraHookGroup + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class CombineLoraHookEightOptional: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + }, + "optional": { + "lora_hook_A": ("LORA_HOOK",), + "lora_hook_B": ("LORA_HOOK",), + "lora_hook_C": ("LORA_HOOK",), + "lora_hook_D": ("LORA_HOOK",), + "lora_hook_E": ("LORA_HOOK",), + "lora_hook_F": ("LORA_HOOK",), + "lora_hook_G": ("LORA_HOOK",), + "lora_hook_H": ("LORA_HOOK",), + } + } + + RETURN_TYPES = ("LORA_HOOK",) + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning/combine lora hooks" + FUNCTION = "combine_lora_hooks" + + def combine_lora_hooks(self, + lora_hook_A: LoraHookGroup=None, lora_hook_B: LoraHookGroup=None, + lora_hook_C: LoraHookGroup=None, lora_hook_D: LoraHookGroup=None, + lora_hook_E: LoraHookGroup=None, lora_hook_F: LoraHookGroup=None, + lora_hook_G: LoraHookGroup=None, lora_hook_H: LoraHookGroup=None): + candidates = [lora_hook_A, lora_hook_B, lora_hook_C, lora_hook_D, + lora_hook_E, lora_hook_F, lora_hook_G, lora_hook_H] + return (LoraHookGroup.combine_all_lora_hooks(candidates),) \ No newline at end of file diff --git a/docs/ADE_CombineLoraHooksFour.md b/docs/ADE_CombineLoraHooksFour.md new file mode 100644 index 0000000..228e36f --- /dev/null +++ b/docs/ADE_CombineLoraHooksFour.md @@ -0,0 +1,63 @@ +# Combine LoRA Hooks [4] 🎭🅐🅓 +## Documentation +- Class name: ADE_CombineLoraHooksFour +- Category: Animate Diff 🎭🅐🅓/conditioning/combine lora hooks +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在聚合和组合多达四个LoRA挂钩成一个统一的LoRA挂钩组。它有助于整合多个LoRA挂钩的修改,允许在Animate Diff框架中对模型行为进行更复杂和细致的调整。 + +## Input types +### Required +### Optional +- lora_hook_A + - 表示要组合的第一个LoRA挂钩组。在聚合过程中起关键作用,贡献整体修改。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- lora_hook_B + - 作为组合的第二个LoRA挂钩组。其包含的修改允许进行层叠,增强模型的适应性。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- lora_hook_C + - 第三个LoRA挂钩组,增加了另一层定制,进一步优化了模型行为。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- lora_hook_D + - 表示第四个也是最后一个要组合的LoRA挂钩组,完成了修改集,使模型能够进行全面调整。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup + +## Output types +- lora_hook + - Comfy dtype: LORA_HOOK + - 组合多达四个LoRA挂钩后的统一组。此组合挂钩组允许增强和更复杂的模型条件。 + - Python dtype: LoraHookGroup + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class CombineLoraHookFourOptional: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + }, + "optional": { + "lora_hook_A": ("LORA_HOOK",), + "lora_hook_B": ("LORA_HOOK",), + "lora_hook_C": ("LORA_HOOK",), + "lora_hook_D": ("LORA_HOOK",), + } + } + + RETURN_TYPES = ("LORA_HOOK",) + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning/combine lora hooks" + FUNCTION = "combine_lora_hooks" + + def combine_lora_hooks(self, + lora_hook_A: LoraHookGroup=None, lora_hook_B: LoraHookGroup=None, + lora_hook_C: LoraHookGroup=None, lora_hook_D: LoraHookGroup=None,): + candidates = [lora_hook_A, lora_hook_B, lora_hook_C, lora_hook_D] \ No newline at end of file diff --git a/docs/ADE_ConditioningSetMask.md b/docs/ADE_ConditioningSetMask.md new file mode 100644 index 0000000..fcb8d47 --- /dev/null +++ b/docs/ADE_ConditioningSetMask.md @@ -0,0 +1,77 @@ +# Set Props on Cond 🎭🅐🅓 +## Documentation +- Class name: ADE_ConditioningSetMask +- Category: Animate Diff 🎭🅐🅓/conditioning/single cond ops +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在将掩码应用于条件数据,根据指定参数调整条件的区域和强度。它使得条件输入的动态修改成为可能,以更好地符合预期结果,如关注或排除数据中的特定区域。 + +## Input types +### Required +- cond_ADD + - 要添加或修改的条件数据。此参数对于在现有条件框架中引入新的上下文或内容至关重要。 + - Comfy dtype: CONDITIONING + - Python dtype: Tensor +- strength + - 定义掩码对条件数据影响的强度,允许对修改影响进行精细控制。 + - Comfy dtype: FLOAT + - Python dtype: float +- set_cond_area + - 确定掩码效果是应用于默认区域还是掩码的边界,提供在特定区域进行定位的灵活性。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str + +### Optional +- opt_mask + - 一个可选掩码,指定要修改的条件数据区域,提供对条件影响的额外控制。 + - Comfy dtype: MASK + - Python dtype: Tensor +- opt_lora_hook + - 一个可选参数,允许将Lora挂钩应用于条件,进一步定制条件过程。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- opt_timesteps + - 可选的时间步条件,允许对条件数据进行时间调整。 + - Comfy dtype: TIMESTEPS_COND + - Python dtype: TimestepsCond + +## Output types +- conditioning + - Comfy dtype: CONDITIONING + - 修改后的条件数据,反映了应用的掩码和调整,包括添加的任何额外条件数据。 + - Python dtype: Tensor + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class ConditioningSetMaskHooked: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "cond_ADD": ("CONDITIONING",), + "strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}), + "set_cond_area": (COND_CONST._LIST_COND_AREA,), + }, + "optional": { + "opt_mask": ("MASK", ), + "opt_lora_hook": ("LORA_HOOK",), + "opt_timesteps": ("TIMESTEPS_COND",) + } + } + + RETURN_TYPES = ("CONDITIONING",) + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning/single cond ops" + FUNCTION = "append_and_hook" + + def append_and_hook(self, cond_ADD, + strength: float, set_cond_area: str, + opt_mask: Tensor=None, opt_lora_hook: LoraHookGroup=None, opt_timesteps: TimestepsCond=None): + (final_conditioning,) = set_mask_conds(conds=[cond_ADD], + strength=strength, set_cond_area=set_cond_area, + opt_mask=opt_mask, opt_lora_hook=opt_lora_hook, opt_timesteps=opt_timesteps) + return (final_conditioning,) \ No newline at end of file diff --git a/docs/ADE_ConditioningSetMaskAndCombine.md b/docs/ADE_ConditioningSetMaskAndCombine.md new file mode 100644 index 0000000..7cdd864 --- /dev/null +++ b/docs/ADE_ConditioningSetMaskAndCombine.md @@ -0,0 +1,82 @@ +# Set Props and Combine Cond 🎭🅐🅓 +## Documentation +- Class name: ADE_ConditioningSetMaskAndCombine +- Category: Animate Diff 🎭🅐🅓/conditioning/single cond ops +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点专门用于生成模型的高级条件数据操作,特别关注掩码和附加条件层的应用和组合。它通过应用掩码、强度调整和整合新的条件数据来增强或修改现有条件,从而允许对生成过程进行更精确的控制。 + +## Input types +### Required +- cond + - 要增强或修改的原始条件数据。它作为应用附加条件层和掩码的基础,直接影响最终输出。 + - Comfy dtype: CONDITIONING + - Python dtype: CustomType[CONDITIONING] +- cond_ADD + - 要与原始条件结合的附加条件数据。此层应用于现有条件之上,允许引入新特性或修改。 + - Comfy dtype: CONDITIONING + - Python dtype: CustomType[CONDITIONING] +- strength + - 一个标量值,确定掩码应用于条件的强度。它控制附加条件和掩码对原始数据的影响程度。 + - Comfy dtype: FLOAT + - Python dtype: float +- set_cond_area + - 指定在条件数据中进行修改的区域,而不提及特定类型。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str + +### Optional +- opt_mask + - 一个可选掩码,可以应用于条件数据。它允许选择性地增强或修改条件中的特定区域。 + - Comfy dtype: MASK + - Python dtype: torch.Tensor +- opt_lora_hook + - 一个可选的LoraHookGroup,可以应用于进一步操作条件数据。它提供了修改条件的额外灵活性。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- opt_timesteps + - 用于条件操作的可选时间步。此参数允许在生成过程中的特定点应用修改。 + - Comfy dtype: TIMESTEPS_COND + - Python dtype: TimestepsCond + +## Output types +- conditioning + - Comfy dtype: CONDITIONING + - 应用附加条件层、掩码和调整后的增强或修改的条件数据。 + - Python dtype: CustomType[CONDITIONING] + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class ConditioningSetMaskAndCombineHooked: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "cond": ("CONDITIONING",), + "cond_ADD": ("CONDITIONING",), + "strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}), + "set_cond_area": (COND_CONST._LIST_COND_AREA,), + }, + "optional": { + "opt_mask": ("MASK", ), + "opt_lora_hook": ("LORA_HOOK",), + "opt_timesteps": ("TIMESTEPS_COND",) + } + } + + RETURN_TYPES = ("CONDITIONING",) + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning/single cond ops" + FUNCTION = "append_and_combine" + + def append_and_combine(self, conditioning, conditioning_ADD, + strength: float, set_cond_area: str, + opt_mask: Tensor=None, opt_lora_hook: LoraHookGroup=None, opt_timesteps: TimestepsCond=None): + (final_conditioning,) = set_mask_and_combine_conds(conds=[conditioning], new_conds=[conditioning_ADD], + strength=strength, set_cond_area=set_cond_area, + opt_mask=opt_mask, opt_lora_hook=opt_lora_hook, opt_timesteps=opt_timesteps) + return (final_conditioning,) \ No newline at end of file diff --git a/docs/ADE_ConditioningSetUnmaskedAndCombine.md b/docs/ADE_ConditioningSetUnmaskedAndCombine.md new file mode 100644 index 0000000..a53ef9c --- /dev/null +++ b/docs/ADE_ConditioningSetUnmaskedAndCombine.md @@ -0,0 +1,60 @@ +# Set Unmasked Cond 🎭🅐🅓 +## Documentation +- Class name: ADE_ConditioningSetUnmaskedAndCombine +- Category: Animate Diff 🎭🅐🅓/conditioning/single cond ops +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点专门用于生成模型的高级条件数据操作,特别关注取消掩码和组合不同的条件输入集。它通过应用复杂的条件转换来增强或修改生成过程。 + +## Input types +### Required +- cond + - 作为转换基础的主要条件输入。它在决定生成过程的初始状态或上下文方面起着关键作用。 + - Comfy dtype: CONDITIONING + - Python dtype: list +- cond_DEFAULT + - 旨在与主要条件输入结合的附加条件输入。此输入通常代表修改或增强基础条件的默认或补充信息。 + - Comfy dtype: CONDITIONING + - Python dtype: list + +### Optional +- opt_lora_hook + - 一个可选参数,允许将Lora挂钩应用于条件输入,为条件过程提供进一步的定制和控制机制。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup + +## Output types +- conditioning + - Comfy dtype: CONDITIONING + - 结合并取消掩码提供的条件输入的结果,代表用于生成模型的修改或增强的条件状态。 + - Python dtype: list + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class ConditioningSetUnmaskedAndCombineHooked: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "cond": ("CONDITIONING",), + "cond_DEFAULT": ("CONDITIONING",), + }, + "optional": { + "opt_lora_hook": ("LORA_HOOK",), + } + } + + RETURN_TYPES = ("CONDITIONING",) + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning/single cond ops" + FUNCTION = "append_and_combine" + + def append_and_combine(self, cond, cond_DEFAULT, + opt_lora_hook: LoraHookGroup=None): + (final_conditioning,) = set_unmasked_and_combine_conds(conds=[cond], new_conds=[cond_DEFAULT], + opt_lora_hook=opt_lora_hook) + return (final_conditioning,) \ No newline at end of file diff --git a/docs/ADE_CustomCFGKeyframe.md b/docs/ADE_CustomCFGKeyframe.md new file mode 100644 index 0000000..54cbd35 --- /dev/null +++ b/docs/ADE_CustomCFGKeyframe.md @@ -0,0 +1,69 @@ + +# Custom CFG Keyframe 🎭🅐🅓 +## Documentation +- Class name: ADE_CustomCFGKeyframe +- Category: Animate Diff 🎭🅐🅓/sample settings +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +ADE_CustomCFGKeyframe节点旨在创建和管理Animate Diff框架内的自定义配置关键帧。它允许在动画时间线上指定各种动画参数,从而精确控制动画的行为和外观。 + +## Input types +### Required +- cfg_multival + - 定义关键帧的配置值,可以影响动画过程的各个方面。对于在特定时间段定制动画特性至关重要。 + - Comfy dtype: MULTIVAL + - Python dtype: Union[float, torch.Tensor] +- start_percent + - 指定关键帧在动画时间线中的起始点,以百分比表示,允许精确的时间控制。 + - Comfy dtype: FLOAT + - Python dtype: float +- guarantee_steps + - 确定应用关键帧配置的最小步数,确保一定的效果持续时间。 + - Comfy dtype: INT + - Python dtype: int + +### Optional +- prev_custom_cfg + - 通过指定先前的自定义配置组,允许自定义配置关键帧的链式连接,从而实现复杂的动画序列。 + - Comfy dtype: CUSTOM_CFG + - Python dtype: CustomCFGKeyframeGroup or None + +## Output types +- custom_cfg + - Comfy dtype: CUSTOM_CFG + - 输出一个封装了定义关键帧的自定义配置对象,准备集成到动画管道中。 + - Python dtype: CustomCFGKeyframeGroup + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class CustomCFGKeyframeNode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "cfg_multival": ("MULTIVAL",), + "start_percent": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001}), + "guarantee_steps": ("INT", {"default": 1, "min": 0, "max": BIGMAX}), + }, + "optional": { + "prev_custom_cfg": ("CUSTOM_CFG",), + } + } + + RETURN_TYPES = ("CUSTOM_CFG",) + CATEGORY = "Animate Diff 🎭🅐🅓/sample settings" + FUNCTION = "create_custom_cfg" + + def create_custom_cfg(self, cfg_multival: Union[float, Tensor], start_percent: float=0.0, guarantee_steps: int=1, + prev_custom_cfg: CustomCFGKeyframeGroup=None): + if not prev_custom_cfg: + prev_custom_cfg = CustomCFGKeyframeGroup() + prev_custom_cfg = prev_custom_cfg.clone() + keyframe = CustomCFGKeyframe(cfg_multival=cfg_multival, start_percent=start_percent, guarantee_steps=guarantee_steps) + prev_custom_cfg.add(keyframe) + return (prev_custom_cfg,) \ No newline at end of file diff --git a/docs/ADE_EmptyLatentImageLarge.md b/docs/ADE_EmptyLatentImageLarge.md new file mode 100644 index 0000000..d8923ac --- /dev/null +++ b/docs/ADE_EmptyLatentImageLarge.md @@ -0,0 +1,55 @@ +# Empty Latent Image (Big Batch) 🎭🅐🅓 +## Documentation +- Class name: ADE_EmptyLatentImageLarge +- Category: Animate Diff 🎭🅐🅓/extras +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +ADE_EmptyLatentImageLarge节点旨在初始化一个用零填充的大型潜在图像张量。此张量作为进一步生成过程的空白画布,允许在潜在层面上创建和操作图像。 + +## Input types +### Required +- width + - 指定要生成的潜在图像的宽度。它决定了生成张量的水平维度。 + - Comfy dtype: INT + - Python dtype: int +- height + - 确定潜在图像的高度。它影响生成张量的垂直维度。 + - Comfy dtype: INT + - Python dtype: int +- batch_size + - 控制一次生成的潜在图像的数量。它影响生成张量的第一个维度,允许批处理多个图像。 + - Comfy dtype: INT + - Python dtype: int + +## Output types +- latent + - Comfy dtype: LATENT + - 输出是一个表示一批空白潜在图像的张量。每个图像都用零初始化,准备进行后续生成修改。 + - Python dtype: torch.Tensor + +## Usage tips +- Infra type: GPU +- Common nodes: + - [BatchPromptScheduleLatentInput](../../ComfyUI_FizzNodes/Nodes/BatchPromptScheduleLatentInput.md) + - [KSampler](../../Comfy/Nodes/KSampler.md) + +## Source code +```python +class EmptyLatentImageLarge: + def __init__(self, device="cpu"): + self.device = device + + @classmethod + def INPUT_TYPES(s): + return {"required": { "width": ("INT", {"default": 512, "min": 64, "max": comfy_nodes.MAX_RESOLUTION, "step": 8}), + "height": ("INT", {"default": 512, "min": 64, "max": comfy_nodes.MAX_RESOLUTION, "step": 8}), + "batch_size": ("INT", {"default": 1, "min": 1, "max": 262144})}} + RETURN_TYPES = ("LATENT",) + FUNCTION = "generate" + + CATEGORY = "Animate Diff 🎭🅐🅓/extras" + + def generate(self, width, height, batch_size=1): + latent = torch.zeros([batch_size, 4, height // 8, width // 8]) + return ({"samples":latent}, ) \ No newline at end of file diff --git a/docs/ADE_InjectI2VIntoAnimateDiffModel.md b/docs/ADE_InjectI2VIntoAnimateDiffModel.md new file mode 100644 index 0000000..f155012 --- /dev/null +++ b/docs/ADE_InjectI2VIntoAnimateDiffModel.md @@ -0,0 +1,65 @@ +# 🧪Inject I2V into AnimateDiff Model 🎭🅐🅓② +## Documentation +- Class name: ADE_InjectI2VIntoAnimateDiffModel +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ②/AnimateLCM-I2V/🧪experimental +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在将I2V(Image to Video)模型集成到AnimateDiff框架中,通过引入运动模型增强其功能。它作为桥梁,丰富AnimateDiff的动画过程,增加更多的运动动态,从而实现更复杂和细致的动画输出。 + +## Input types +### Required +- model_name + - 指定要加载的运动模型的名称,在确定动画的运动动态方面起着至关重要的作用。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- motion_model + - 表示要注入到AnimateDiff模型中的运动模型对象,对于在动画过程中应用特定的运动动态至关重要。 + - Comfy dtype: MOTION_MODEL_ADE + - Python dtype: MotionModelPatcher + +### Optional +- ad_settings + - AnimateDiff过程的可选设置,允许自定义动画的外观和行为。 + - Comfy dtype: AD_SETTINGS + - Python dtype: AnimateDiffSettings + +## Output types +- MOTION_MODEL + - Comfy dtype: MOTION_MODEL_ADE + - 注入了I2V功能的增强版AnimateDiff模型,准备好用于动画任务。 + - Python dtype: MotionModelPatcher + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class LoadAnimateDiffAndInjectI2VNode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "model_name": (get_available_motion_models(),), + "motion_model": ("MOTION_MODEL_ADE",), + }, + "optional": { + "ad_settings": ("AD_SETTINGS",), + } + } + + RETURN_TYPES = ("MOTION_MODEL_ADE",) + RETURN_NAMES = ("MOTION_MODEL",) + + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②/AnimateLCM-I2V/🧪experimental" + FUNCTION = "load_motion_model" + + def load_motion_model(self, model_name: str, motion_model: MotionModelPatcher, ad_settings: AnimateDiffSettings=None): + # make sure model w/ encoder actually has encoder + if motion_model.model.img_encoder is None: + raise Exception("Passed-in motion model was expected to have an img_encoder, but did not.") + # load motion module and motion settings, if included + loaded_motion_model = load_motion_module_gen2(model_name=model_name, motion_model_settings=ad_settings) + inject_img_encoder_into_model(motion_model=loaded_motion_model, w_encoder=motion_model) + return (loaded_motion_model,) \ No newline at end of file diff --git a/docs/ADE_LoadAnimateDiffModel.md b/docs/ADE_LoadAnimateDiffModel.md new file mode 100644 index 0000000..3ee0206 --- /dev/null +++ b/docs/ADE_LoadAnimateDiffModel.md @@ -0,0 +1,56 @@ +# Load AnimateDiff Model 🎭🅐🅓② +## Documentation +- Class name: ADE_LoadAnimateDiffModel +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ② +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在加载AnimateDiff模型,便于在AnimateDiff框架内集成和应用运动模型以实现动画目的。它作为动画管道中的基础组件,使用户能够利用高级动画技术。 + +## Input types +### Required +- model_name + - 指定要加载的运动模型的名称。这是一个关键输入,因为它决定了在AnimateDiff框架内将使用哪个运动模型进行动画。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str + +### Optional +- ad_settings + - 可选参数,允许包括特定的动画设置,提供对动画过程的额外定制和控制。 + - Comfy dtype: AD_SETTINGS + - Python dtype: AnimateDiffSettings + +## Output types +- MOTION_MODEL + - Comfy dtype: MOTION_MODEL_ADE + - 输出已加载的运动模型,准备在动画管道中进一步处理和应用。 + - Python dtype: MotionModelPatcher + +## Usage tips +- Infra type: GPU +- Common nodes: + - [ADE_ApplyAnimateDiffModel](../../ComfyUI-AnimateDiff-Evolved/Nodes/ADE_ApplyAnimateDiffModel.md) + +## Source code +```python +class LoadAnimateDiffModelNode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "model_name": (get_available_motion_models(),), + }, + "optional": { + "ad_settings": ("AD_SETTINGS",), + } + } + + RETURN_TYPES = ("MOTION_MODEL_ADE",) + RETURN_NAMES = ("MOTION_MODEL",) + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②" + FUNCTION = "load_motion_model" + + def load_motion_model(self, model_name: str, ad_settings: AnimateDiffSettings=None): + # load motion module and motion settings, if included + motion_model = load_motion_module_gen2(model_name=model_name, motion_model_settings=ad_settings) + return (motion_model,) \ No newline at end of file diff --git a/docs/ADE_LoadAnimateDiffModelWithCameraCtrl.md b/docs/ADE_LoadAnimateDiffModelWithCameraCtrl.md new file mode 100644 index 0000000..145bb1f --- /dev/null +++ b/docs/ADE_LoadAnimateDiffModelWithCameraCtrl.md @@ -0,0 +1,60 @@ +# Load AnimateDiff+CameraCtrl Model 🎭🅐🅓② +## Documentation +- Class name: ADE_LoadAnimateDiffModelWithCameraCtrl +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在加载具有集成摄像机控制功能的AnimateDiff模型,使得可以直接在AnimateDiff框架内应用摄像机运动和调整。它有助于将动态摄像机控制参数整合到AnimateDiff模型中,从而增强动画过程并实现更复杂的视觉效果。 + +## Input types +### Required +- model_name + - 指定要加载的运动模型的名称。它对于识别将添加摄像机控制功能的特定AnimateDiff模型至关重要。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- camera_ctrl + - 定义要注入到AnimateDiff模型中的摄像机控制参数。此输入对于定制动画中的摄像机运动和效果至关重要。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str + +### Optional +- ad_settings + - AnimateDiff模型的可选设置,允许进一步定制动画过程。 + - Comfy dtype: AD_SETTINGS + - Python dtype: dict + +## Output types +- MOTION_MODEL + - Comfy dtype: MOTION_MODEL_ADE + - 集成了摄像机控制功能的修改后的AnimateDiff模型,准备用于动画任务。 + - Python dtype: MotionModel + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class LoadAnimateDiffModelWithCameraCtrl: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "model_name": (get_available_motion_models(),), + "camera_ctrl": (get_available_motion_models(),), + }, + "optional": { + "ad_settings": ("AD_SETTINGS",), + } + } + + RETURN_TYPES = ("MOTION_MODEL_ADE",) + RETURN_NAMES = ("MOTION_MODEL",) + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl" + FUNCTION = "load_camera_ctrl" + + def load_camera_ctrl(self, model_name: str, camera_ctrl: str, ad_settings: AnimateDiffSettings=None): + loaded_motion_model = load_motion_module_gen2(model_name=model_name, motion_model_settings=ad_settings) + inject_camera_encoder_into_model(motion_model=loaded_motion_model, camera_ctrl_name=camera_ctrl) + return (loaded_motion_model,) \ No newline at end of file diff --git a/docs/ADE_LoadAnimateLCMI2VModel.md b/docs/ADE_LoadAnimateLCMI2VModel.md new file mode 100644 index 0000000..553e048 --- /dev/null +++ b/docs/ADE_LoadAnimateLCMI2VModel.md @@ -0,0 +1,66 @@ +# Load AnimateLCM-I2V Model 🎭🅐🅓② +## Documentation +- Class name: ADE_LoadAnimateLCMI2VModel +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ②/AnimateLCM-I2V +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +ADE_LoadAnimateLCMI2VModel节点旨在加载和准备用于动画过程的AnimateLCM-I2V运动模型。它确保所选的运动模型与AnimateLCM-I2V格式兼容并具有图像编码器,从而促进将运动模型集成到动画工作流程中。 + +## Input types +### Required +- model_name + - 指定要加载的运动模型的名称,确保该模型可用且与AnimateLCM-I2V格式兼容。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str + +### Optional +- ad_settings + - Animate Diff过程的可选设置,可以应用于运动模型,允许自定义动画。 + - Comfy dtype: AD_SETTINGS + - Python dtype: AnimateDiffSettings or None + +## Output types +- MOTION_MODEL + - Comfy dtype: MOTION_MODEL_ADE + - 已加载的运动模型,准备用于动画过程。 + - Python dtype: MotionModelPatcher +- encoder_only + - Comfy dtype: MOTION_MODEL_ADE + - 仅包含编码器的运动模型版本,适用于特定的动画任务。 + - Python dtype: MotionModelPatcher + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class LoadAnimateLCMI2VModelNode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "model_name": (get_available_motion_models(),), + }, + "optional": { + "ad_settings": ("AD_SETTINGS",), + } + } + + RETURN_TYPES = ("MOTION_MODEL_ADE", "MOTION_MODEL_ADE") + RETURN_NAMES = ("MOTION_MODEL", "encoder_only") + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②/AnimateLCM-I2V" + FUNCTION = "load_motion_model" + + def load_motion_model(self, model_name: str, ad_settings: AnimateDiffSettings=None): + # load motion module and motion settings, if included + motion_model = load_motion_module_gen2(model_name=model_name, motion_model_settings=ad_settings) + # make sure model is an AnimateLCM-I2V model + if motion_model.model.mm_info.mm_format != AnimateDiffFormat.ANIMATELCM: + raise Exception(f"Motion model '{motion_model.model.mm_info.mm_name}' is not an AnimateLCM-I2V model; selected model is not AnimateLCM, and does not contain an img_encoder.") + if motion_model.model.img_encoder is None: + raise Exception(f"Motion model '{motion_model.model.mm_info.mm_name}' is not an AnimateLCM-I2V model; selected model IS AnimateLCM, but does NOT contain an img_encoder.") + # create encoder-only motion model + encoder_only_motion_model = create_fresh_encoder_only_model(motion_model=motion_model) + return (motion_model, encoder_only_motion_model) \ No newline at end of file diff --git a/docs/ADE_LoadCameraPoses.md b/docs/ADE_LoadCameraPoses.md new file mode 100644 index 0000000..4b78e48 --- /dev/null +++ b/docs/ADE_LoadCameraPoses.md @@ -0,0 +1,54 @@ +# Load CameraCtrl Poses (File) 🎭🅐🅓② +## Documentation +- Class name: ADE_LoadCameraPoses +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl/poses +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +`ADE_LoadCameraPoses`节点旨在从指定的文件加载摄像机控制姿势,便于在Animate Diff框架内操纵和动画化摄像机位置。它作为创建动态和复杂摄像机运动的基础元素,用于动画序列。 + +## Input types +### Required +- pose_filename + - 指定要从中加载摄像机控制姿势的文件名。此文件名应对应包含所需摄像机姿势的文件,使节点能够检索和利用这些姿势进行动画化。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str + +## Output types +- cameractrl_poses + - Comfy dtype: CAMERACTRL_POSES + - 输出一系列摄像机控制姿势,这些姿势结构为浮点数列表,表示摄像机在动画上下文中的位置、方向和其他相关参数。 + - Python dtype: list[list[float]] + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class LoadCameraPoses: + @classmethod + def INPUT_TYPES(s): + input_dir = folder_paths.get_input_directory() + files = [f for f in os.listdir(input_dir) if os.path.isfile(os.path.join(input_dir, f))] + files = [f for f in files if f.endswith(".txt")] + return { + "required": { + "pose_filename": (sorted(files),), + } + } + + RETURN_TYPES = ("CAMERACTRL_POSES",) + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl/poses" + FUNCTION = "load_camera_poses" + + def load_camera_poses(self, pose_filename: str): + file_path = folder_paths.get_annotated_filepath(pose_filename) + with open(file_path, 'r') as f: + poses = f.readlines() + # first line of file is the link to source, so can be skipped, + # and the rest is a header-less CSV file separated by single spaces + poses = [pose.strip().split(' ') for pose in poses[1:]] + poses = [[float(x) for x in pose] for pose in poses] + poses = set_original_pose_dims(poses, pose_width=CAM.DEFAULT_POSE_WIDTH, pose_height=CAM.DEFAULT_POSE_HEIGHT) + return (poses,) \ No newline at end of file diff --git a/docs/ADE_LoraHookKeyframe.md b/docs/ADE_LoraHookKeyframe.md new file mode 100644 index 0000000..0d9832d --- /dev/null +++ b/docs/ADE_LoraHookKeyframe.md @@ -0,0 +1,70 @@ +# LoRA Hook Keyframe 🎭🅐🅓 +## Documentation +- Class name: ADE_LoraHookKeyframe +- Category: Animate Diff 🎭🅐🅓/conditioning/schedule lora hooks +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点用于创建LoRA挂钩关键帧,这是在动画序列中特定点调整LoRA(低秩适应)挂钩影响的机制。它允许动态调度LoRA挂钩的强度,从而在动画过程中精确控制其效果。 + +## Input types +### Required +- strength_model + - 指定关键帧处LoRA挂钩的强度,影响挂钩在动画中此点对模型行为的影响。 + - Comfy dtype: FLOAT + - Python dtype: float +- start_percent + - 确定关键帧效果的起始点,占总动画长度的百分比,允许精确控制LoRA挂钩影响的时间。 + - Comfy dtype: FLOAT + - Python dtype: float +- guarantee_steps + - 保证关键帧效果将应用的最小步数,确保LoRA挂钩的影响至少维持此持续时间。 + - Comfy dtype: INT + - Python dtype: int + +### Optional +- prev_hook_kf + - 可选的前一个LoRA挂钩关键帧组,新的关键帧将添加到其中,允许链式连接多个关键帧以实现复杂的动画效果。 + - Comfy dtype: LORA_HOOK_KEYFRAMES + - Python dtype: LoraHookKeyframeGroup + +## Output types +- HOOK_KF + - Comfy dtype: LORA_HOOK_KEYFRAMES + - 返回一组LoRA挂钩关键帧,包括新创建的关键帧,便于在动画中管理和应用多个关键帧。 + - Python dtype: LoraHookKeyframeGroup + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class CreateLoraHookKeyframe: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "strength_model": ("FLOAT", {"default": 1.0, "min": -20.0, "max": 20.0, "step": 0.01}), + "start_percent": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001}), + "guarantee_steps": ("INT", {"default": 1, "min": 0, "max": BIGMAX}), + }, + "optional": { + "prev_hook_kf": ("LORA_HOOK_KEYFRAMES",), + } + } + + RETURN_TYPES = ("LORA_HOOK_KEYFRAMES",) + RETURN_NAMES = ("HOOK_KF",) + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning/schedule lora hooks" + FUNCTION = "create_hook_keyframe" + + def create_hook_keyframe(self, strength_model: float, start_percent: float, guarantee_steps: float, + prev_hook_kf: LoraHookKeyframeGroup=None): + if prev_hook_kf: + prev_hook_kf = prev_hook_kf.clone() + else: + prev_hook_kf = LoraHookKeyframeGroup() + keyframe = LoraHookKeyframe(strength=strength_model, start_percent=start_percent, guarantee_steps=guarantee_steps) + prev_hook_kf.add(keyframe) + return (prev_hook_kf,) \ No newline at end of file diff --git a/docs/ADE_LoraHookKeyframeFromStrengthList.md b/docs/ADE_LoraHookKeyframeFromStrengthList.md new file mode 100644 index 0000000..e2fa264 --- /dev/null +++ b/docs/ADE_LoraHookKeyframeFromStrengthList.md @@ -0,0 +1,91 @@ +# LoRA Hook Keyframes From List 🎭🅐🅓 +## Documentation +- Class name: ADE_LoraHookKeyframeFromStrengthList +- Category: Animate Diff 🎭🅐🅓/conditioning/schedule lora hooks +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点用于根据强度列表创建一系列LoRA挂钩关键帧,从而动态调整模型行为的多个步骤。它允许自定义关键帧属性,如强度和起始百分比,从而精确控制动画或转换过程。 + +## Input types +### Required +- strengths_float + - 指定序列中每个关键帧的强度。此参数可以接受单个浮点值或浮点值列表,允许灵活定义每个关键帧的强度。 + - Comfy dtype: FLOAT + - Python dtype: Union[float, List[float]] +- start_percent + - 定义关键帧序列的起始百分比,设置动画或转换的起始点。 + - Comfy dtype: FLOAT + - Python dtype: float +- end_percent + - 设置关键帧序列的结束百分比,标记动画或转换的终点。 + - Comfy dtype: FLOAT + - Python dtype: float +- print_keyframes + - 一个布尔标志,启用时会将每个关键帧的详细信息打印到日志中,有助于调试和可视化关键帧序列。 + - Comfy dtype: BOOLEAN + - Python dtype: bool + +### Optional +- prev_hook_kf + - 一个可选参数,允许从前一个LoRA挂钩关键帧序列继续,启用序列之间的无缝过渡。 + - Comfy dtype: LORA_HOOK_KEYFRAMES + - Python dtype: LoraHookKeyframeGroup + +## Output types +- HOOK_KF + - Comfy dtype: LORA_HOOK_KEYFRAMES + - 返回一组LoRA挂钩关键帧,表示将应用于模型的一系列调整。 + - Python dtype: LoraHookKeyframeGroup + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class CreateLoraHookKeyframeFromStrengthList: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "strengths_float": ("FLOAT", {"default": -1, "min": -1, "step": 0.001, "forceInput": True}), + "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}), + "print_keyframes": ("BOOLEAN", {"default": False}), + }, + "optional": { + "prev_hook_kf": ("LORA_HOOK_KEYFRAMES",), + } + } + + RETURN_TYPES = ("LORA_HOOK_KEYFRAMES",) + RETURN_NAMES = ("HOOK_KF",) + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning/schedule lora hooks" + FUNCTION = "create_hook_keyframes" + + def create_hook_keyframes(self, strengths_float: Union[float, list[float]], + start_percent: float, end_percent: float, + prev_hook_kf: LoraHookKeyframeGroup=None, print_keyframes=False): + if prev_hook_kf: + prev_hook_kf = prev_hook_kf.clone() + else: + prev_hook_kf = LoraHookKeyframeGroup() + if type(strengths_float) in (float, int): + strengths_float = [float(strengths_float)] + elif isinstance(strengths_float, Iterable): + pass + else: + raise Exception(f"strengths_floast must be either an interable input or a float, but was {type(strengths_float).__repr__}.") + percents = InterpolationMethod.get_weights(num_from=start_percent, num_to=end_percent, length=len(strengths_float), method=InterpolationMethod.LINEAR) + + is_first = True + for percent, strength in zip(percents, strengths_float): + guarantee_steps = 0 + if is_first: + guarantee_steps = 1 + is_first = False + prev_hook_kf.add(LoraHookKeyframe(strength=strength, start_percent=percent, guarantee_steps=guarantee_steps)) + if print_keyframes: + logger.info(f"LoraHookKeyframe - start_percent:{percent} = {strength}") + return (prev_hook_kf,) \ No newline at end of file diff --git a/docs/ADE_LoraHookKeyframeInterpolation.md b/docs/ADE_LoraHookKeyframeInterpolation.md new file mode 100644 index 0000000..e35c7df --- /dev/null +++ b/docs/ADE_LoraHookKeyframeInterpolation.md @@ -0,0 +1,102 @@ +# LoRA Hook Keyframes Interpolation 🎭🅐🅓 +## Documentation +- Class name: ADE_LoraHookKeyframeInterpolation +- Category: Animate Diff 🎭🅐🅓/conditioning/schedule lora hooks +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点用于创建插值的LoRA挂钩关键帧,从而动态调整模型行为随时间的变化。它基于指定的起始和结束百分比、强度和插值方法生成一系列关键帧,从而实现对模型参数的细粒度控制。 + +## Input types +### Required +- start_percent + - 定义插值的起始百分比,设置生成关键帧序列的起始点。 + - Comfy dtype: FLOAT + - Python dtype: float +- end_percent + - 指定插值的结束百分比,确定生成关键帧序列的终点。 + - Comfy dtype: FLOAT + - Python dtype: float +- strength_start + - 设置插值的初始强度值,标记强度调整范围的开始。 + - Comfy dtype: FLOAT + - Python dtype: float +- strength_end + - 确定插值的结束强度值,结束强度调整范围。 + - Comfy dtype: FLOAT + - Python dtype: float +- interpolation + - 选择用于生成关键帧序列的插值方法,影响起始和结束值之间的过渡。 + - Comfy dtype: COMBO[STRING] + - Python dtype: InterpolationMethod +- intervals + - 指定起始和结束点之间生成的间隔(或关键帧)数,影响插值的粒度。 + - Comfy dtype: INT + - Python dtype: int +- print_keyframes + - 可选。控制是否记录生成的关键帧,有助于调试和可视化插值过程。 + - Comfy dtype: BOOLEAN + - Python dtype: bool + +### Optional +- prev_hook_kf + - 可选。允许包括先前定义的一组LoRA挂钩关键帧,新的插值关键帧将添加到其中。 + - Comfy dtype: LORA_HOOK_KEYFRAMES + - Python dtype: LoraHookKeyframeGroup + +## Output types +- HOOK_KF + - Comfy dtype: LORA_HOOK_KEYFRAMES + - 返回一组LoRA挂钩关键帧,包括先前存在的和新插值的关键帧,准备在模型条件中应用。 + - Python dtype: LoraHookKeyframeGroup + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class CreateLoraHookKeyframeInterpolation: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "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}), + "strength_start": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ), + "strength_end": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.001}, ), + "interpolation": (InterpolationMethod._LIST, ), + "intervals": ("INT", {"default": 5, "min": 2, "max": 100, "step": 1}), + "print_keyframes": ("BOOLEAN", {"default": False}), + }, + "optional": { + "prev_hook_kf": ("LORA_HOOK_KEYFRAMES",), + } + } + + RETURN_TYPES = ("LORA_HOOK_KEYFRAMES",) + RETURN_NAMES = ("HOOK_KF",) + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning/schedule lora hooks" + FUNCTION = "create_hook_keyframes" + + def create_hook_keyframes(self, + start_percent: float, end_percent: float, + strength_start: float, strength_end: float, interpolation: str, intervals: int, + prev_hook_kf: LoraHookKeyframeGroup=None, print_keyframes=False): + if prev_hook_kf: + prev_hook_kf = prev_hook_kf.clone() + else: + prev_hook_kf = LoraHookKeyframeGroup() + percents = InterpolationMethod.get_weights(num_from=start_percent, num_to=end_percent, length=intervals, method=interpolation) + strengths = InterpolationMethod.get_weights(num_from=strength_start, num_to=strength_end, length=intervals, method=interpolation) + + is_first = True + for percent, strength in zip(percents, strengths): + guarantee_steps = 0 + if is_first: + guarantee_steps = 1 + is_first = False + prev_hook_kf.add(LoraHookKeyframe(strength=strength, start_percent=percent, guarantee_steps=guarantee_steps)) + if print_keyframes: + logger.info(f"LoraHookKeyframe - start_percent:{percent} = {strength}") + return (prev_hook_kf,) \ No newline at end of file diff --git a/docs/ADE_PairedConditioningSetMask.md b/docs/ADE_PairedConditioningSetMask.md new file mode 100644 index 0000000..8498d3e --- /dev/null +++ b/docs/ADE_PairedConditioningSetMask.md @@ -0,0 +1,87 @@ +# Set Props on Conds 🎭🅐🅓 +## Documentation +- Class name: ADE_PairedConditioningSetMask +- Category: Animate Diff 🎭🅐🅓/conditioning +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +ADE_PairedConditioningSetMask节点旨在对一对条件输入应用掩码和条件调整。它利用强度、设置条件区域以及可选元素如掩码、Lora挂钩和时间步条件等附加参数来微调条件过程,旨在根据指定的调整增强或修改生成内容的属性。 + +## Input types +### Required +- positive_ADD + - 指定要调整的正向条件输入。它在定义要在生成内容中增强或修改的属性或特性方面起着关键作用。 + - Comfy dtype: CONDITIONING + - Python dtype: CONDITIONING +- negative_ADD + - 指定要调整的负向条件输入。它对于定义要以与正向条件相反的方式减弱或改变的属性或特性至关重要。 + - Comfy dtype: CONDITIONING + - Python dtype: CONDITIONING +- strength + - 决定条件调整的强度。较高的值表示对条件输入的影响更强。 + - Comfy dtype: FLOAT + - Python dtype: float +- set_cond_area + - 定义要受调整影响的条件输入区域。它允许对条件输入进行有针对性的修改。 + - Comfy dtype: COMBO[STRING] + - Python dtype: COND_CONST._LIST_COND_AREA + +### Optional +- opt_mask + - 一个可选掩码,可以应用于条件输入以进行更精确的调整。 + - Comfy dtype: MASK + - Python dtype: Tensor +- opt_lora_hook + - 一个可选的Lora挂钩,可以应用于附加条件转换。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- opt_timesteps + - 可选的时间步条件,允许对条件输入进行时间调整。 + - Comfy dtype: TIMESTEPS_COND + - Python dtype: TimestepsCond + +## Output types +- positive + - Comfy dtype: CONDITIONING + - 应用指定调整后的正向条件输出。 + - Python dtype: CONDITIONING +- negative + - Comfy dtype: CONDITIONING + - 应用指定调整后的负向条件输出。 + - Python dtype: CONDITIONING + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class PairedConditioningSetMaskHooked: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "positive_ADD": ("CONDITIONING", ), + "negative_ADD": ("CONDITIONING", ), + "strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}), + "set_cond_area": (COND_CONST._LIST_COND_AREA,), + }, + "optional": { + "opt_mask": ("MASK", ), + "opt_lora_hook": ("LORA_HOOK",), + "opt_timesteps": ("TIMESTEPS_COND",) + } + } + + RETURN_TYPES = ("CONDITIONING", "CONDITIONING") + RETURN_NAMES = ("positive", "negative") + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning" + FUNCTION = "append_and_hook" + + def append_and_hook(self, positive_ADD, negative_ADD, + strength: float, set_cond_area: str, + opt_mask: Tensor=None, opt_lora_hook: LoraHookGroup=None, opt_timesteps: TimestepsCond=None): + final_positive, final_negative = set_mask_conds(conds=[positive_ADD, negative_ADD], + strength=strength, set_cond_area=set_cond_area, + opt_mask=opt_mask, opt_lora_hook=opt_lora_hook, opt_timesteps=opt_timesteps) + return (final_positive, final_negative) \ No newline at end of file diff --git a/docs/ADE_PairedConditioningSetMaskAndCombine.md b/docs/ADE_PairedConditioningSetMaskAndCombine.md new file mode 100644 index 0000000..6af2f92 --- /dev/null +++ b/docs/ADE_PairedConditioningSetMaskAndCombine.md @@ -0,0 +1,97 @@ +# Set Props and Combine Conds 🎭🅐🅓 +## Documentation +- Class name: ADE_PairedConditioningSetMaskAndCombine +- Category: Animate Diff 🎭🅐🅓/conditioning +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点专门用于生成模型的成对条件数据的高级操作,特别关注掩码和附加条件层的应用和组合。它通过应用掩码、强度调整和整合新的条件元素来增强或修改现有条件,从而更精确地控制生成过程。 + +## Input types +### Required +- positive + - 要增强或修改的原始正向条件数据。 + - Comfy dtype: CONDITIONING + - Python dtype: torch.Tensor +- negative + - 要增强或修改的原始负向条件数据。 + - Comfy dtype: CONDITIONING + - Python dtype: torch.Tensor +- positive_ADD + - 要与原始条件结合的附加正向条件数据。 + - Comfy dtype: CONDITIONING + - Python dtype: torch.Tensor +- negative_ADD + - 要与原始条件结合的附加负向条件数据。 + - Comfy dtype: CONDITIONING + - Python dtype: torch.Tensor +- strength + - 定义掩码或条件修改强度的参数。 + - Comfy dtype: FLOAT + - Python dtype: float +- set_cond_area + - 指定掩码或修改应用于条件的区域。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str + +### Optional +- opt_mask + - 一个可选掩码,可以应用于条件数据以进行选择性修改。 + - Comfy dtype: MASK + - Python dtype: torch.Tensor +- opt_lora_hook + - 一个可选参数,允许将Lora挂钩应用于条件数据,提供额外的转换或控制层。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- opt_timesteps + - 可选的时间步条件,允许进行时间调整。 + - Comfy dtype: TIMESTEPS_COND + - Python dtype: TimestepsCond + +## Output types +- positive + - Comfy dtype: CONDITIONING + - 应用掩码、强度调整并与附加条件结合后的增强或修改后的正向条件数据。 + - Python dtype: torch.Tensor +- negative + - Comfy dtype: CONDITIONING + - 应用掩码、强度调整并与附加条件结合后的增强或修改后的负向条件数据。 + - Python dtype: torch.Tensor + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class PairedConditioningSetMaskAndCombineHooked: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "positive": ("CONDITIONING",), + "negative": ("CONDITIONING",), + "positive_ADD": ("CONDITIONING",), + "negative_ADD": ("CONDITIONING",), + "strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}), + "set_cond_area": (COND_CONST._LIST_COND_AREA,), + }, + "optional": { + "opt_mask": ("MASK", ), + "opt_lora_hook": ("LORA_HOOK",), + "opt_timesteps": ("TIMESTEPS_COND",) + } + } + + RETURN_TYPES = ("CONDITIONING", "CONDITIONING") + RETURN_NAMES = ("positive", "negative") + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning" + FUNCTION = "append_and_combine" + + def append_and_combine(self, positive, negative, positive_ADD, negative_ADD, + strength: float, set_cond_area: str, + opt_mask: Tensor=None, opt_lora_hook: LoraHookGroup=None, opt_timesteps: TimestepsCond=None): + final_positive, final_negative = set_mask_and_combine_conds(conds=[positive, negative], new_conds=[positive_ADD, negative_ADD], + strength=strength, set_cond_area=set_cond_area, + opt_mask=opt_mask, opt_lora_hook=opt_lora_hook, opt_timesteps=opt_timesteps) + return (final_positive, final_negative,) \ No newline at end of file diff --git a/docs/ADE_PairedConditioningSetUnmaskedAndCombine.md b/docs/ADE_PairedConditioningSetUnmaskedAndCombine.md new file mode 100644 index 0000000..ab66c01 --- /dev/null +++ b/docs/ADE_PairedConditioningSetUnmaskedAndCombine.md @@ -0,0 +1,75 @@ +# Set Unmasked Conds 🎭🅐🅓 +## Documentation +- Class name: ADE_PairedConditioningSetUnmaskedAndCombine +- Category: Animate Diff 🎭🅐🅓/conditioning +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在处理和组合成对的条件输入,应用取消掩码和可选的LoRA挂钩转换。它专注于将默认或基线条件与当前条件整合,准备进一步处理或生成任务,从而增强对条件过程的灵活性和控制。 + +## Input types +### Required +- positive + - 要与其默认对应项结合的当前正向条件输入。 + - Comfy dtype: CONDITIONING + - Python dtype: Dict[str, Any] +- negative + - 要与其默认对应项结合的当前负向条件输入。 + - Comfy dtype: CONDITIONING + - Python dtype: Dict[str, Any] +- positive_DEFAULT + - 要与当前正向条件结合的默认正向条件输入。 + - Comfy dtype: CONDITIONING + - Python dtype: Dict[str, Any] +- negative_DEFAULT + - 要与当前负向条件结合的默认负向条件输入。 + - Comfy dtype: CONDITIONING + - Python dtype: Dict[str, Any] + +### Optional +- opt_lora_hook + - 一个可选的LoRA挂钩,用于在结合条件输入之前对其进行转换。 + - Comfy dtype: LORA_HOOK + - Python dtype: Optional[LoraHookGroup] + +## Output types +- positive + - Comfy dtype: CONDITIONING + - 将当前和默认输入整合后的组合正向条件输出。 + - Python dtype: Dict[str, Any] +- negative + - Comfy dtype: CONDITIONING + - 将当前和默认输入整合后的组合负向条件输出。 + - Python dtype: Dict[str, Any] + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class PairedConditioningSetUnmaskedAndCombineHooked: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "positive": ("CONDITIONING",), + "negative": ("CONDITIONING",), + "positive_DEFAULT": ("CONDITIONING",), + "negative_DEFAULT": ("CONDITIONING",), + }, + "optional": { + "opt_lora_hook": ("LORA_HOOK",), + } + } + + RETURN_TYPES = ("CONDITIONING", "CONDITIONING") + RETURN_NAMES = ("positive", "negative") + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning" + FUNCTION = "append_and_combine" + + def append_and_combine(self, positive, negative, positive_DEFAULT, negative_DEFAULT, + opt_lora_hook: LoraHookGroup=None): + final_positive, final_negative = set_unmasked_and_combine_conds(conds=[positive, negative], new_conds=[positive_DEFAULT, negative_DEFAULT], + opt_lora_hook=opt_lora_hook) + return (final_positive, final_negative,) \ No newline at end of file diff --git a/docs/ADE_RawSigmaSchedule.md b/docs/ADE_RawSigmaSchedule.md new file mode 100644 index 0000000..4b395cd --- /dev/null +++ b/docs/ADE_RawSigmaSchedule.md @@ -0,0 +1,78 @@ +# Create Raw Sigma Schedule 🎭🅐🅓 +## Documentation +- Class name: ADE_RawSigmaSchedule +- Category: Animate Diff 🎭🅐🅓/sample settings/sigma schedule +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在根据给定的beta计划生成一个sigma计划。它将beta计划转换为sigma计划,这对于控制扩散模型中的噪声水平至关重要,特别是在动画和图像合成的背景下。 + +## Input types +### Required +- raw_beta_schedule + - 指定要转换为sigma计划的beta计划。此参数对于确定整个扩散过程中的噪声水平的进展和强度至关重要。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- linear_start + - 定义用于sigma计划生成的线性插值的起点。它影响扩散过程中的初始噪声水平。 + - Comfy dtype: FLOAT + - Python dtype: float +- linear_end + - 设置sigma计划中线性插值的终点,影响扩散过程中的最终噪声水平。 + - Comfy dtype: FLOAT + - Python dtype: float +- sampling + - 确定sigma计划中使用的采样方法,影响噪声水平的插值和应用方式。类型“ModelSamplingType”应理解为实际选择的采样方法的占位符。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- lcm_original_timesteps + - 指定使用LCM采样时要考虑的原始时间步数,影响sigma计划的粒度。 + - Comfy dtype: INT + - Python dtype: int +- lcm_zsnr + - 一个布尔标志,指示是否对sigma计划应用零信噪比(zSNR)调整,增强计划与某些扩散过程的兼容性。 + - Comfy dtype: BOOLEAN + - Python dtype: bool + +## Output types +- sigma_schedule + - Comfy dtype: SIGMA_SCHEDULE + - 生成的sigma计划,概述了扩散过程每一步要应用的具体噪声水平。 + - Python dtype: SigmaSchedule + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class RawSigmaScheduleNode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "raw_beta_schedule": (BetaSchedules.RAW_BETA_SCHEDULE_LIST,), + "linear_start": ("FLOAT", {"default": 0.00085, "min": 0.0, "max": 1.0, "step": 0.000001}), + "linear_end": ("FLOAT", {"default": 0.012, "min": 0.0, "max": 1.0, "step": 0.000001}), + #"cosine_s": ("FLOAT", {"default": 8e-3, "min": 0.0, "max": 1.0, "step": 0.000001}), + "sampling": (ModelSamplingType._FULL_LIST,), + "lcm_original_timesteps": ("INT", {"default": 50, "min": 1, "max": 1000}), + "lcm_zsnr": ("BOOLEAN", {"default": False}), + } + } + + RETURN_TYPES = ("SIGMA_SCHEDULE",) + CATEGORY = "Animate Diff 🎭🅐🅓/sample settings/sigma schedule" + FUNCTION = "get_sigma_schedule" + + def get_sigma_schedule(self, raw_beta_schedule: str, linear_start: float, linear_end: float,# cosine_s: float, + sampling: str, lcm_original_timesteps: int, lcm_zsnr: bool): + new_config = ModelSamplingConfig(beta_schedule=raw_beta_schedule, linear_start=linear_start, linear_end=linear_end) + if sampling != ModelSamplingType.LCM: + lcm_original_timesteps=None + lcm_zsnr=False + model_type = ModelSamplingType.from_alias(sampling) + new_model_sampling = BetaSchedules._to_model_sampling(alias=BetaSchedules.AUTOSELECT, model_type=model_type, config_override=new_config, original_timesteps=lcm_original_timesteps) + if lcm_zsnr: + SigmaSchedule.apply_zsnr(new_model_sampling=new_model_sampling) + return (SigmaSchedule(model_sampling=new_model_sampling, model_type=model_type),) \ No newline at end of file diff --git a/docs/ADE_RegisterLoraHook.md b/docs/ADE_RegisterLoraHook.md new file mode 100644 index 0000000..e745bab --- /dev/null +++ b/docs/ADE_RegisterLoraHook.md @@ -0,0 +1,96 @@ +# Register LoRA Hook 🎭🅐🅓 +## Documentation +- Class name: ADE_RegisterLoraHook +- Category: Animate Diff 🎭🅐🅓/conditioning/register lora hooks +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在AnimateDiff框架内注册LoRA挂钩,从而实现模型行为的动态修改,以增强动画和图像处理能力。 + +## Input types +### Required +- model + - 要应用LoRA挂钩的模型,作为动态行为修改的基础。 + - Comfy dtype: MODEL + - Python dtype: ModelPatcher or ModelPatcherAndInjector +- clip + - 可能与主模型一起可选修改的CLIP模型,允许同步调整。 + - Comfy dtype: CLIP + - Python dtype: CLIP +- lora_name + - 要应用的特定LoRA挂钩的标识符,决定行为修改的性质。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- strength_model + - 定义LoRA挂钩对模型影响的强度,允许对行为修改进行精细控制。 + - Comfy dtype: FLOAT + - Python dtype: float +- strength_clip + - 指定LoRA挂钩对CLIP模型影响的强度,使其行为精确调整。 + - Comfy dtype: FLOAT + - Python dtype: float + +## Output types +- model + - Comfy dtype: MODEL + - 应用LoRA挂钩后的模型,准备进行增强的动画和图像处理任务。 + - Python dtype: ModelPatcher or ModelPatcherAndInjector +- clip + - Comfy dtype: CLIP + - 可选修改后的CLIP模型,与主模型同步调整以实现增强。 + - Python dtype: CLIP +- lora_hook + - Comfy dtype: LORA_HOOK + - 已注册的LoRA挂钩,封装了指定的修改,准备应用于模型。 + - Python dtype: LoraHookGroup + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class MaskableLoraLoader: + def __init__(self): + self.loaded_lora = None + + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "model": ("MODEL",), + "clip": ("CLIP",), + "lora_name": (folder_paths.get_filename_list("loras"), ), + "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}), + } + } + + RETURN_TYPES = ("MODEL", "CLIP", "LORA_HOOK") + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning/register lora hooks" + FUNCTION = "load_lora" + + def load_lora(self, model: Union[ModelPatcher, ModelPatcherAndInjector], clip: CLIP, lora_name: str, strength_model: float, strength_clip: float): + if strength_model == 0 and strength_clip == 0: + return (model, clip) + + lora_path = folder_paths.get_full_path("loras", lora_name) + lora = None + if self.loaded_lora is not None: + if self.loaded_lora[0] == lora_path: + lora = self.loaded_lora[1] + else: + temp = self.loaded_lora + self.loaded_lora = None + del temp + + if lora is None: + lora = comfy.utils.load_torch_file(lora_path, safe_load=True) + self.loaded_lora = (lora_path, lora) + + lora_hook = LoraHook(lora_name=lora_name) + lora_hook_group = LoraHookGroup() + lora_hook_group.add(lora_hook) + model_lora, clip_lora = load_hooked_lora_for_models(model=model, clip=clip, lora=lora, lora_hook=lora_hook, + strength_model=strength_model, strength_clip=strength_clip) + return (model_lora, clip_lora, lora_hook_group) \ No newline at end of file diff --git a/docs/ADE_RegisterLoraHookModelOnly.md b/docs/ADE_RegisterLoraHookModelOnly.md new file mode 100644 index 0000000..e0b21f1 --- /dev/null +++ b/docs/ADE_RegisterLoraHookModelOnly.md @@ -0,0 +1,57 @@ +# Register LoRA Hook (Model Only) 🎭🅐🅓 +## Documentation +- Class name: ADE_RegisterLoraHookModelOnly +- Category: Animate Diff 🎭🅐🅓/conditioning/register lora hooks +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在将模型注册为LoRA(低秩适应)挂钩,专注于模型而不涉及任何CLIP模型。它通过LoRA技术实现模型行为的修改和增强,为将LoRA挂钩集成到模型中提供了一种简化的方法,以实现高级定制和性能调优。 + +## Input types +### Required +- model + - 要注册LoRA挂钩的模型。它是LoRA适应的主要目标,决定了应用修改的范围和影响。 + - Comfy dtype: MODEL + - Python dtype: Union[ModelPatcher, ModelPatcherAndInjector] +- lora_name + - 要应用的LoRA配置的名称。指定要使用的特定LoRA适应设置和参数,指导定制过程。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- strength_model + - 一个浮点值,表示LoRA适应对模型的强度。此参数控制应用的LoRA修改的强度,允许对模型行为进行精细调整。 + - Comfy dtype: FLOAT + - Python dtype: float + +## Output types +- model + - Comfy dtype: MODEL + - 注册了LoRA挂钩后的模型。此输出反映了模型的修改状态,展示了LoRA适应的效果。 + - Python dtype: ModelPatcher +- lora_hook + - Comfy dtype: LORA_HOOK + - 已与模型注册的LoRA挂钩。此输出表示应用的LoRA适应机制,便于进一步定制和性能调优。 + - Python dtype: LoraHook + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class MaskableLoraLoaderModelOnly(MaskableLoraLoader): + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "model": ("MODEL",), + "lora_name": (folder_paths.get_filename_list("loras"), ), + "strength_model": ("FLOAT", {"default": 1.0, "min": -20.0, "max": 20.0, "step": 0.01}), + } + } + + RETURN_TYPES = ("MODEL", "LORA_HOOK") + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning/register lora hooks" + FUNCTION = "load_lora_model_only" + + def load_lora_model_only(self, model: ModelPatcher, lora_name: str, strength_model: float): + model_lora, clip_lora, lora_hook = self.load_lora(mod \ No newline at end of file diff --git a/docs/ADE_RegisterModelAsLoraHook.md b/docs/ADE_RegisterModelAsLoraHook.md new file mode 100644 index 0000000..fdcef86 --- /dev/null +++ b/docs/ADE_RegisterModelAsLoraHook.md @@ -0,0 +1,83 @@ +# Register Model as LoRA Hook 🎭🅐🅓 +## Documentation +- Class name: ADE_RegisterModelAsLoraHook +- Category: Animate Diff 🎭🅐🅓/conditioning/register lora hooks +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在将模型注册为AnimateDiff框架中的LoRA挂钩,从而在生成过程中实现模型行为的动态修改和控制。它通过LoRA(低秩适应)技术与模型集成,允许根据特定条件或输入对模型输出进行增强定制和微调。 + +## Input types +### Required +- model + - 表示LoRA挂钩将应用到的目标模型参数。它对于定义LoRA适应的范围和上下文至关重要,影响模型行为在生成过程中的修改方式。 + - Comfy dtype: MODEL + - Python dtype: Union[ModelPatcher, ModelPatcherAndInjector] +- clip + - 指定过程中涉及的CLIP模型(如果有),提供LoRA适应可能与主模型一起应用的上下文。 + - Comfy dtype: CLIP + - Python dtype: CLIP +- ckpt_name + - 指示加载模型状态的检查点名称,对于使用特定预训练权重或配置初始化模型至关重要。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- strength_model + - 控制应用于模型的LoRA修改的强度参数。它允许对LoRA对模型行为的影响进行微调,从而实现生成过程的精确调整。 + - Comfy dtype: FLOAT + - Python dtype: float +- strength_clip + - 类似于strength_model,此参数调整LoRA修改的强度,但特别针对过程中涉及的CLIP模型。它允许分别控制不同生成框架组件的适应强度。 + - Comfy dtype: FLOAT + - Python dtype: float + +## Output types +- model + - Comfy dtype: MODEL + - 应用LoRA挂钩后的模型,反映通过输入参数指定的动态适应。 + - Python dtype: ModelPatcher +- clip + - Comfy dtype: CLIP + - 如果过程中涉及CLIP模型,则应用LoRA挂钩的CLIP模型。它指示LoRA修改应用于CLIP组件。 + - Python dtype: CLIP +- lora_hook + - Comfy dtype: LORA_HOOK + - 已注册并应用于模型和/或CLIP的LoRA挂钩,封装了所做的具体适应。 + - Python dtype: LoraHook + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class MaskableSDModelLoader: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "model": ("MODEL",), + "clip": ("CLIP",), + "ckpt_name": (folder_paths.get_filename_list("checkpoints"), ), + "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}), + } + } + + RETURN_TYPES = ("MODEL", "CLIP", "LORA_HOOK") + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning/register lora hooks" + FUNCTION = "load_model_as_lora" + + def load_model_as_lora(self, model: ModelPatcher, clip: CLIP, ckpt_name: str, strength_model: float, strength_clip: float): + ckpt_path = folder_paths.get_full_path("checkpoints", ckpt_name) + out = comfy.sd.load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, embedding_directory=folder_paths.get_folder_paths("embeddings")) + model_loaded = out[0] + clip_loaded = out[1] + + lora_hook = LoraHook(lora_name=ckpt_name) + lora_hook_group = LoraHookGroup() + lora_hook_group.add(lora_hook) + model_lora, clip_lora = load_model_as_hooked_lora_for_models(model=model, clip=clip, + model_loaded=model_loaded, clip_loaded=clip_loaded, + lora_hook=lora_hook, + strength_model=strength_model, strength_clip=strength_clip) + return (model_lora, clip_lora, lora_hook_group) \ No newline at end of file diff --git a/docs/ADE_RegisterModelAsLoraHookModelOnly.md b/docs/ADE_RegisterModelAsLoraHookModelOnly.md new file mode 100644 index 0000000..3d1e3e9 --- /dev/null +++ b/docs/ADE_RegisterModelAsLoraHookModelOnly.md @@ -0,0 +1,59 @@ +# Register Model as LoRA Hook (MO) 🎭🅐🅓 +## Documentation +- Class name: ADE_RegisterModelAsLoraHookModelOnly +- Category: Animate Diff 🎭🅐🅓/conditioning/register lora hooks +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点专门用于将模型注册为LoRA挂钩,重点是仅对模型进行修改。它允许将LoRA(低秩适应)技术集成到特定模型中,增强其适应性和性能,以便执行特定任务,而不影响其他组件。 + +## Input types +### Required +- model + - 要使用LoRA技术进行适应的模型。它作为应用低秩适应的主要目标,旨在增强其性能或适应性,以执行特定任务。 + - Comfy dtype: MODEL + - Python dtype: ModelPatcher +- ckpt_name + - 要从中应用LoRA配置的检查点名称。此参数指定要使用的LoRA适应集,指导模型行为的定制。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- strength_model + - 一个浮点值,决定LoRA适应对模型的强度。它调节LoRA参数对模型行为的影响程度。 + - Comfy dtype: FLOAT + - Python dtype: float + +## Output types +- model + - Comfy dtype: MODEL + - 应用指定LoRA适应后的模型。此输出反映了通过LoRA技术定制后的增强版模型。 + - Python dtype: ModelPatcher +- lora_hook + - Comfy dtype: LORA_HOOK + - 已集成到模型中的LoRA挂钩的引用。此输出提供了对应用的LoRA适应的访问,便于进一步操作或分析。 + - Python dtype: LoraHook + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class MaskableSDModelLoaderModelOnly(MaskableSDModelLoader): + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "model": ("MODEL",), + "ckpt_name": (folder_paths.get_filename_list("checkpoints"), ), + "strength_model": ("FLOAT", {"default": 1.0, "min": -20.0, "max": 20.0, "step": 0.01}), + } + } + + RETURN_TYPES = ("MODEL", "LORA_HOOK") + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning/register lora hooks" + FUNCTION = "load_model_as_lora_model_only" + + def load_model_as_lora_model_only(self, model: ModelPatcher, ckpt_name: str, strength_model: float): + model_lora, clip_lora, lora_hook = self.load_model_as_lora(model=model, clip=None, ckpt_name=ckpt_name, + strength_model=strength_model, strength_clip=0) + return (model_lora, lora_hook) \ No newline at end of file diff --git a/docs/ADE_ReplaceCameraParameters.md b/docs/ADE_ReplaceCameraParameters.md new file mode 100644 index 0000000..eb86e29 --- /dev/null +++ b/docs/ADE_ReplaceCameraParameters.md @@ -0,0 +1,70 @@ +# Replace Camera Parameters 🎭🅐🅓② +## Documentation +- Class name: ADE_ReplaceCameraParameters +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl/poses +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在修改动画或图像处理管道中的摄像机控制参数,允许根据预定义或动态生成的标准调整摄像机姿势。此功能对于实现特定的视觉效果、视角或需要特定摄像机方向或运动的动画至关重要。 + +## Input types +### Required +- poses + - 表示要修改的摄像机姿势的参数。它在确定最终输出中起着关键作用,通过指定初始摄像机位置和方向来进行调整。 + - Comfy dtype: CAMERACTRL_POSES + - Python dtype: list[list[float]] +- fx + - 摄像机在x轴上的焦距。调整此参数会影响摄像机沿x轴的视野,从而影响渲染场景的视角和比例。 + - Comfy dtype: FLOAT + - Python dtype: float +- fy + - 摄像机在y轴上的焦距。与“fx”类似,此参数修改沿y轴的视野,影响场景的深度和高度感知。 + - Comfy dtype: FLOAT + - Python dtype: float +- cx + - 摄像机光学中心的x坐标。改变此值会水平移动场景的中心点,可用于校正或实现某些视觉效果。 + - Comfy dtype: FLOAT + - Python dtype: float +- cy + - 摄像机光学中心的y坐标。此参数垂直移动场景的中心点,允许调整垂直对齐或模拟摄像机倾斜效果。 + - Comfy dtype: FLOAT + - Python dtype: float + +## Output types +- cameractrl_poses + - Comfy dtype: CAMERACTRL_POSES + - 应用新的摄像机参数后的修改摄像机姿势。此输出对于依赖更新摄像机方向的渲染或进一步处理的下游过程至关重要。 + - Python dtype: list[list[float]] + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class CameraCtrlReplaceCameraParameters: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "poses":("CAMERACTRL_POSES",), + "fx": ("FLOAT", {"default": CAM.DEFAULT_FX, "min": 0, "max": 1, "step": 0.000000001}), + "fy": ("FLOAT", {"default": CAM.DEFAULT_FY, "min": 0, "max": 1, "step": 0.000000001}), + "cx": ("FLOAT", {"default": CAM.DEFAULT_CX, "min": 0, "max": 1, "step": 0.01}), + "cy": ("FLOAT", {"default": CAM.DEFAULT_CY, "min": 0, "max": 1, "step": 0.01}), + }, + } + + RETURN_TYPES = ("CAMERACTRL_POSES",) + FUNCTION = "set_camera_parameters" + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl/poses" + + def set_camera_parameters(self, poses: list[list[float]], fx: float, fy: float, cx: float, cy: float): + new_poses = copy.deepcopy(poses) + for pose in new_poses: + # fx,fy,cx,fy are in indexes 1-4 of the 19-long pose list + pose[1] = fx + pose[2] = fy + pose[3] = cx + pose[4] = cy + return (new_poses,) \ No newline at end of file diff --git a/docs/ADE_ReplaceOriginalPoseAspectRatio.md b/docs/ADE_ReplaceOriginalPoseAspectRatio.md new file mode 100644 index 0000000..7c735ce --- /dev/null +++ b/docs/ADE_ReplaceOriginalPoseAspectRatio.md @@ -0,0 +1,61 @@ +--- + +tags: +- Animation +- CameraControl + +--- + +# Replace Orig. Pose Aspect Ratio 🎭🅐🅓② +## Documentation +- Class name: ADE_ReplaceOriginalPoseAspectRatio +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl/poses +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在调整AnimateDiff框架内原始姿势的纵横比,特别用于摄像机控制应用。它修改姿势的尺寸以匹配新的纵横比,确保动画和视觉效果根据所需的空间维度准确渲染。 + +## Input types +### Required +- poses + - 要调整的姿势列表。每个姿势是一个浮点数列表,表示摄像机控制点的空间和旋转参数。 + - Comfy dtype: CAMERACTRL_POSES + - Python dtype: list[list[float]] +- orig_pose_width + - 姿势的原始宽度,将用于计算新的纵横比。 + - Comfy dtype: INT + - Python dtype: int +- orig_pose_height + - 姿势的原始高度,将用于计算新的纵横比。 + - Comfy dtype: INT + - Python dtype: int + +## Output types +- cameractrl_poses + - Comfy dtype: CAMERACTRL_POSES + - 应用新纵横比后的调整姿势,准备在AnimateDiff框架内进行进一步处理或动画。 + - Python dtype: list[list[float]] + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class CameraCtrlSetOriginalAspectRatio: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "poses":("CAMERACTRL_POSES",), + "orig_pose_width": ("INT", {"default": 1280, "min": 1, "max": BIGMAX}), + "orig_pose_height": ("INT", {"default": 720, "min": 1, "max": BIGMAX}), + } + } + + RETURN_TYPES = ("CAMERACTRL_POSES",) + FUNCTION = "set_aspect_ratio" + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②/CameraCtrl/poses" + + def set_aspect_ratio(self, poses: list[list[float]], orig_pose_width: int, orig_pose_height: int): + return (set_original_pose_dims(poses, pose_width=orig_pose_width, pose_height=orig_pose_height),) \ No newline at end of file diff --git a/docs/ADE_SetLoraHookKeyframe.md b/docs/ADE_SetLoraHookKeyframe.md new file mode 100644 index 0000000..88e80dc --- /dev/null +++ b/docs/ADE_SetLoraHookKeyframe.md @@ -0,0 +1,50 @@ +# Set LoRA Hook Keyframes 🎭🅐🅓 +## Documentation +- Class name: ADE_SetLoraHookKeyframe +- Category: Animate Diff 🎭🅐🅓/conditioning +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点用于将一组LoRA挂钩关键帧分配给特定的LoRA挂钩组。它允许在动画时间线上定制和动态调整LoRA挂钩行为,从而在动画过程的不同阶段精确控制模型的响应。 + +## Input types +### Required +- lora_hook + - 将应用关键帧的LoRA挂钩组。此参数对于识别将接收新关键帧设置的目标挂钩组至关重要。 + - Comfy dtype: LORA_HOOK + - Python dtype: LoraHookGroup +- hook_kf + - 将分配给指定LoRA挂钩组的LoRA挂钩关键帧集。此参数定义了动画时间线上LoRA挂钩的时间、强度和其他特性。 + - Comfy dtype: LORA_HOOK_KEYFRAMES + - Python dtype: LoraHookKeyframeGroup + +## Output types +- lora_hook + - Comfy dtype: LORA_HOOK + - 应用了新关键帧集的更新LoRA挂钩组。此输出反映了对LoRA挂钩所做的更改,包含了指定的关键帧设置。 + - Python dtype: LoraHookGroup + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class SetLoraHookKeyframes: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "lora_hook": ("LORA_HOOK",), + "hook_kf": ("LORA_HOOK_KEYFRAMES",), + } + } + + RETURN_TYPES = ("LORA_HOOK",) + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning" + FUNCTION = "set_hook_keyframes" + + def set_hook_keyframes(self, lora_hook: LoraHookGroup, hook_kf: LoraHookKeyframeGroup): + new_lora_hook = lora_hook.clone() + new_lora_hook.set_keyframes_on_hooks(hook_kf=hook_kf) + return (new_lora_hook,) \ No newline at end of file diff --git a/docs/ADE_SigmaSchedule.md b/docs/ADE_SigmaSchedule.md new file mode 100644 index 0000000..4987ac2 --- /dev/null +++ b/docs/ADE_SigmaSchedule.md @@ -0,0 +1,46 @@ +# Create Sigma Schedule 🎭🅐🅓 +## Documentation +- Class name: ADE_SigmaSchedule +- Category: Animate Diff 🎭🅐🅓/sample settings/sigma schedule +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +ADE_SigmaSchedule节点旨在根据给定的beta计划生成一个sigma计划。它抽象了sigma计划创建的复杂性,提供了一种简便的方法来获得符合特定模型采样类型和配置的sigma计划。 + +## Input types +### Required +- beta_schedule + - 指定用于生成sigma计划的beta计划。此参数至关重要,因为它决定了将派生sigma计划的基本配置。 + - Comfy dtype: COMBO[STRING] + - Python dtype: BetaSchedules.ALIAS_ACTIVE_LIST + +## Output types +- sigma_schedule + - Comfy dtype: SIGMA_SCHEDULE + - 输出一个sigma计划对象,它对于定义基于扩散的生成模型中的噪声级别进程至关重要。 + - Python dtype: SigmaSchedule (custom type from the animatediff package) + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class SigmaScheduleNode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "beta_schedule": (BetaSchedules.ALIAS_ACTIVE_LIST,), + } + } + + RETURN_TYPES = ("SIGMA_SCHEDULE",) + CATEGORY = "Animate Diff 🎭🅐🅓/sample settings/sigma schedule" + FUNCTION = "get_sigma_schedule" + + def get_sigma_schedule(self, beta_schedule: str): + model_type = ModelSamplingType.from_alias(ModelSamplingType.EPS) + new_model_sampling = BetaSchedules._to_model_sampling(alias=beta_schedule, + model_type=model_type) + return (SigmaSchedule(model_sampling=new_model_sampling, model_type=model_type),) \ No newline at end of file diff --git a/docs/ADE_SigmaScheduleSplitAndCombine.md b/docs/ADE_SigmaScheduleSplitAndCombine.md new file mode 100644 index 0000000..c3dd89c --- /dev/null +++ b/docs/ADE_SigmaScheduleSplitAndCombine.md @@ -0,0 +1,59 @@ +# Sigma Schedule Split Combine 🎭🅐🅓 +## Documentation +- Class name: ADE_SigmaScheduleSplitAndCombine +- Category: Animate Diff 🎭🅐🅓/sample settings/sigma schedule +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在通过基于指定的权重和插值方法拆分和组合sigma计划来操作它们。它允许创建两个输入计划的混合新sigma计划,从而实现sigma值随时间的自定义进程。 + +## Input types +### Required +- schedule_Start + - 用于拆分和组合过程的起始sigma计划,决定新sigma计划的初始部分。 + - Comfy dtype: SIGMA_SCHEDULE + - Python dtype: SigmaSchedule +- schedule_End + - 用于拆分和组合过程的结束sigma计划,影响新sigma计划的后段。 + - Comfy dtype: SIGMA_SCHEDULE + - Python dtype: SigmaSchedule +- idx_split_percent + - 初始sigma计划拆分的百分比,决定两个计划之间的过渡点。 + - Comfy dtype: FLOAT + - Python dtype: float + +## Output types +- sigma_schedule + - Comfy dtype: SIGMA_SCHEDULE + - 结果sigma计划,是根据指定的拆分百分比修改的起始和结束输入计划的混合体。 + - Python dtype: SigmaSchedule + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class SplitAndCombineSigmaScheduleNode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "schedule_Start": ("SIGMA_SCHEDULE",), + "schedule_End": ("SIGMA_SCHEDULE",), + "idx_split_percent": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.001}) + } + } + + RETURN_TYPES = ("SIGMA_SCHEDULE",) + CATEGORY = "Animate Diff 🎭🅐🅓/sample settings/sigma schedule" + FUNCTION = "get_sigma_schedule" + + def get_sigma_schedule(self, schedule_Start: SigmaSchedule, schedule_End: SigmaSchedule, idx_split_percent: float): + validate_sigma_schedule_compatibility(schedule_Start, schedule_End) + # first, calculate index to act as split; get diff from 1.0 since sigmas are flipped at this stage + idx = int((1.0-idx_split_percent) * schedule_Start.total_sigmas()) + new_sigmas = torch.cat([schedule_End.model_sampling.sigmas[:idx], schedule_Start.model_sampling.sigmas[idx:]], dim=0) + new_schedule = schedule_Start.clone() + new_schedule.model_sampling.set_sigmas(new_sigmas) + return (new_schedule,) \ No newline at end of file diff --git a/docs/ADE_SigmaScheduleWeightedAverage.md b/docs/ADE_SigmaScheduleWeightedAverage.md new file mode 100644 index 0000000..95e9492 --- /dev/null +++ b/docs/ADE_SigmaScheduleWeightedAverage.md @@ -0,0 +1,57 @@ +# Sigma Schedule Weighted Mean 🎭🅐🅓 +## Documentation +- Class name: ADE_SigmaScheduleWeightedAverage +- Category: Animate Diff 🎭🅐🅓/sample settings/sigma schedule +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在通过计算两个提供的sigma计划的加权平均值来创建一个新的sigma计划。它允许根据指定的加权因子将两个计划的特性混合成一个新的计划。 + +## Input types +### Required +- schedule_A + - 第一个要混合的sigma计划。它是加权平均计算的基础之一。 + - Comfy dtype: SIGMA_SCHEDULE + - Python dtype: SigmaSchedule +- schedule_B + - 第二个与第一个混合的sigma计划。它为加权平均计算做出贡献,补充第一个计划。 + - Comfy dtype: SIGMA_SCHEDULE + - Python dtype: SigmaSchedule +- weight_A + - 第一个sigma计划的加权因子。它决定了第一个计划在最终混合计划中的特性比例。 + - Comfy dtype: FLOAT + - Python dtype: float + +## Output types +- sigma_schedule + - Comfy dtype: SIGMA_SCHEDULE + - 根据指定的加权因子混合两个输入计划后的结果sigma计划。 + - Python dtype: SigmaSchedule + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class WeightedAverageSigmaScheduleNode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "schedule_A": ("SIGMA_SCHEDULE",), + "schedule_B": ("SIGMA_SCHEDULE",), + "weight_A": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.001}), + } + } + + RETURN_TYPES = ("SIGMA_SCHEDULE",) + CATEGORY = "Animate Diff 🎭🅐🅓/sample settings/sigma schedule" + FUNCTION = "get_sigma_schedule" + + def get_sigma_schedule(self, schedule_A: SigmaSchedule, schedule_B: SigmaSchedule, weight_A: float): + validate_sigma_schedule_compatibility(schedule_A, schedule_B) + new_sigmas = schedule_A.model_sampling.sigmas * weight_A + schedule_B.model_sampling.sigmas * (1-weight_A) + combo_schedule = schedule_A.clone() + combo_schedule.model_sampling.set_sigmas(new_sigmas) + return (combo_schedule,) \ No newline at end of file diff --git a/docs/ADE_SigmaScheduleWeightedAverageInterp.md b/docs/ADE_SigmaScheduleWeightedAverageInterp.md new file mode 100644 index 0000000..c9c2e31 --- /dev/null +++ b/docs/ADE_SigmaScheduleWeightedAverageInterp.md @@ -0,0 +1,72 @@ +# Sigma Schedule Interpolated Mean 🎭🅐🅓 +## Documentation +- Class name: ADE_SigmaScheduleWeightedAverageInterp +- Category: Animate Diff 🎭🅐🅓/sample settings/sigma schedule +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点旨在通过基于指定的权重范围和插值方法在两个给定的sigma计划之间进行插值来创建一个新的sigma计划。它有效地将两个输入计划的特性融合成一个新的计划,从而在扩散过程中实现动态调整。 + +## Input types +### Required +- schedule_A + - 第一个要插值的sigma计划。 + - Comfy dtype: SIGMA_SCHEDULE + - Python dtype: SigmaSchedule +- schedule_B + - 第二个要插值的sigma计划。 + - Comfy dtype: SIGMA_SCHEDULE + - Python dtype: SigmaSchedule +- weight_A_Start + - 插值中第一个sigma计划的起始权重。 + - Comfy dtype: FLOAT + - Python dtype: float +- weight_A_End + - 插值中第一个sigma计划的结束权重。 + - Comfy dtype: FLOAT + - Python dtype: float +- interpolation + - 用于混合sigma计划的插值方法。 + - Comfy dtype: COMBO[STRING] + - Python dtype: InterpolationMethod + +## Output types +- sigma_schedule + - Comfy dtype: SIGMA_SCHEDULE + - 插值后的结果sigma计划。 + - Python dtype: SigmaSchedule + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class InterpolatedWeightedAverageSigmaScheduleNode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "schedule_A": ("SIGMA_SCHEDULE",), + "schedule_B": ("SIGMA_SCHEDULE",), + "weight_A_Start": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.001}), + "weight_A_End": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.001}), + "interpolation": (InterpolationMethod._LIST,), + } + } + + RETURN_TYPES = ("SIGMA_SCHEDULE",) + CATEGORY = "Animate Diff 🎭🅐🅓/sample settings/sigma schedule" + FUNCTION = "get_sigma_schedule" + + def get_sigma_schedule(self, schedule_A: SigmaSchedule, schedule_B: SigmaSchedule, + weight_A_Start: float, weight_A_End: float, interpolation: str): + validate_sigma_schedule_compatibility(schedule_A, schedule_B) + # get reverse weights, since sigmas are currently reversed + weights = InterpolationMethod.get_weights(num_from=weight_A_Start, num_to=weight_A_End, + length=schedule_A.total_sigmas(), method=interpolation, reverse=True) + weights = weights.to(schedule_A.model_sampling.sigmas.dtype).to(schedule_A.model_sampling.sigmas.device) + new_sigmas = schedule_A.model_sampling.sigmas * weights + schedule_B.model_sampling.sigmas * (1.0-weights) + combo_schedule = schedule_A.clone() + combo_schedule.model_sampling.set_sigmas(new_sigmas) + return (combo_schedule,) \ No newline at end of file diff --git a/docs/ADE_TimestepsConditioning.md b/docs/ADE_TimestepsConditioning.md new file mode 100644 index 0000000..ef33ebf --- /dev/null +++ b/docs/ADE_TimestepsConditioning.md @@ -0,0 +1,48 @@ +# Timesteps Conditioning 🎭🅐🅓 +## Documentation +- Class name: ADE_TimestepsConditioning +- Category: Animate Diff 🎭🅐🅓/conditioning +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点专注于调整在动画或扩散过程中特定条件的应用时间,允许精确控制在动画进程中引入某些效果或修改的时间。这使得条件的应用更加动态和细致,从而提高生成内容的整体质量和灵活性。 + +## Input types +### Required +- start_percent + - 指定应用给定条件的起始点(占总动画长度的百分比),允许精确的时间控制。 + - Comfy dtype: FLOAT + - Python dtype: float +- end_percent + - 定义条件应用的结束点(占总动画长度的百分比),使效果能够定制到动画的特定阶段。 + - Comfy dtype: FLOAT + - Python dtype: float + +## Output types +- timesteps_cond + - Comfy dtype: TIMESTEPS_COND + - 条件的时间调整,封装为一种特定类型,表示在整个动画或扩散过程中的条件调度。 + - Python dtype: TimestepsCond + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class ConditioningTimestepsNode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "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}) + } + } + + RETURN_TYPES = ("TIMESTEPS_COND",) + CATEGORY = "Animate Diff 🎭🅐🅓/conditioning" + FUNCTION = "create_schedule" + + def create_schedule(self, start_percent: float, end_percent: float): + return (TimestepsCond(start_percent=start_percent, end_percent=end_percent),) \ No newline at end of file diff --git a/docs/ADE_UpscaleAndVAEEncode.md b/docs/ADE_UpscaleAndVAEEncode.md new file mode 100644 index 0000000..12af467 --- /dev/null +++ b/docs/ADE_UpscaleAndVAEEncode.md @@ -0,0 +1,74 @@ +# Scale Ref Image and VAE Encode 🎭🅐🅓② +## Documentation +- Class name: ADE_UpscaleAndVAEEncode +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ②/AnimateLCM-I2V +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +ADE_UpscaleAndVAEEncode节点旨在通过首先将图像放大到更高分辨率,然后使用变分自编码器(VAE)将其编码为潜在表示来处理图像。此节点是AnimateDiff套件的一部分,专门用于在应用进一步的生成或转换过程之前增强图像质量。 + +## Input types +### Required +- image + - 表示要放大和编码的输入图像的参数。它在确定最终潜在表示的质量和分辨率方面起着关键作用。 + - Comfy dtype: IMAGE + - Python dtype: torch.Tensor +- vae + - 指定用于将放大的图像编码为其潜在表示的变分自编码器模型。它影响编码效率和生成的潜在空间的质量。 + - Comfy dtype: VAE + - Python dtype: torch.nn.Module +- latent_size + - 表示要生成的潜在表示的大小。它决定输出潜在空间的维度。 + - Comfy dtype: LATENT + - Python dtype: torch.Tensor +- scale_method + - 定义用于放大图像的方法。它影响放大图像的质量。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- crop + - 指定放大后应用的裁剪方法,影响最终图像的构图。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str + +## Output types +- latent + - Comfy dtype: LATENT + - 输出是输入图像的潜在表示,由VAE在放大后编码。它以压缩形式捕捉图像的基本特征,适合进一步的生成任务。 + - Python dtype: Dict[str, torch.Tensor] + +## Usage tips +- Infra type: GPU +- Common nodes: unknown + +## Source code +```python +class UpscaleAndVaeEncode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "image": ("IMAGE",), + "vae": ("VAE",), + "latent_size": ("LATENT",), + "scale_method": (ScaleMethods._LIST_IMAGE,), + "crop": (CropMethods._LIST, {"default": CropMethods.CENTER},), + } + } + + RETURN_TYPES = ("LATENT",) + FUNCTION = "preprocess_images" + + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②/AnimateLCM-I2V" + + def preprocess_images(self, image: torch.Tensor, vae: VAE, latent_size: torch.Tensor, scale_method: str, crop: str): + b, c, h, w = latent_size["samples"].size() + image = image.movedim(-1,1) + image = comfy.utils.common_upscale(samples=image, width=w*8, height=h*8, upscale_method=scale_method, crop=crop) + image = image.movedim(1,-1) + # now that images are the expected size, VAEEncode them + try: # account for old ComfyUI versions (TODO: remove this when other changes require ComfyUI update) + if not hasattr(vae, "vae_encode_crop_pixels"): + image = VAEEncode.vae_encode_crop_pixels(image) + except Exception: + pass + return ({"samples": vae.encode(image[:,:,:,:3])},) \ No newline at end of file diff --git a/docs/ADE_UseEvolvedSampling.md b/docs/ADE_UseEvolvedSampling.md new file mode 100644 index 0000000..3c18947 --- /dev/null +++ b/docs/ADE_UseEvolvedSampling.md @@ -0,0 +1,113 @@ +# Use Evolved Sampling 🎭🅐🅓② +## Documentation +- Class name: ADE_UseEvolvedSampling +- Category: Animate Diff 🎭🅐🅓/② Gen2 nodes ② +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +ADE_UseEvolvedSampling节点将先进的采样技术集成到动画扩散过程中,利用进化模型采样配置来增强生成动画的质量和效率。它根据模型配置和动态条件调整采样过程,旨在优化动画输出的视觉保真度和计算性能。 + +## Input types +### Required +- model + - 指定用于动画扩散过程的模型,影响生成动画的整体质量和特性。 + - Comfy dtype: MODEL + - Python dtype: Model +- beta_schedule + - 决定在采样过程中应用的beta计划,影响动画过渡的平滑度和质量。 + - Comfy dtype: COMBO[STRING] + - Python dtype: BetaSchedules.ALIAS_LIST + +### Optional +- m_models + - 可选。为动画过程提供额外的模型,可能增强输出的多样性和丰富性。 + - Comfy dtype: M_MODELS + - Python dtype: list +- context_options + - 可选。定义可以修改采样过程行为的上下文特定选项,定制其以满足特定需求或偏好。 + - Comfy dtype: CONTEXT_OPTIONS + - Python dtype: dict +- sample_settings + - 可选。指定与采样过程相关的设置,如分辨率和时间调整,直接影响动画的视觉质量。 + - Comfy dtype: SAMPLE_SETTINGS + - Python dtype: dict + +## Output types +- model + - Comfy dtype: MODEL + - 增强的模型实例,配备进化的采样配置以改进动画扩散。 + - Python dtype: Model + +## Usage tips +- Infra type: CPU +- Common nodes: + - [KSampler](../../Comfy/Nodes/KSampler.md) + - [ToBasicPipe](../../ComfyUI-Impact-Pack/Nodes/ToBasicPipe.md) + - [SamplerCustom](../../Comfy/Nodes/SamplerCustom.md) + - [LCMScheduler](../../ComfyUI-sampler-lcm-alternative/Nodes/LCMScheduler.md) + +## Source code +```python +class UseEvolvedSamplingNode: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "model": ("MODEL",), + "beta_schedule": (BetaSchedules.ALIAS_LIST, {"default": BetaSchedules.AUTOSELECT}), + }, + "optional": { + "m_models": ("M_MODELS",), + "context_options": ("CONTEXT_OPTIONS",), + "sample_settings": ("SAMPLE_SETTINGS",), + #"beta_schedule_override": ("BETA_SCHEDULE",), + } + } + + RETURN_TYPES = ("MODEL",) + CATEGORY = "Animate Diff 🎭🅐🅓/② Gen2 nodes ②" + FUNCTION = "use_evolved_sampling" + + def use_evolved_sampling(self, model: ModelPatcher, beta_schedule: str, m_models: MotionModelGroup=None, context_options: ContextOptionsGroup=None, + sample_settings: SampleSettings=None, beta_schedule_override=None): + if m_models is not None: + m_models = m_models.clone() + # for each motion model, confirm that it is compatible with SD model + for motion_model in m_models.models: + validate_model_compatibility_gen2(model=model, motion_model=motion_model) + # create injection params + model_name_list = [motion_model.model.mm_info.mm_name for motion_model in m_models.models] + model_names = ",".join(model_name_list) + # TODO: check if any apply_v2_properly is set to False + params = InjectionParams(unlimited_area_hack=False, model_name=model_names) + else: + params = InjectionParams() + # apply context options + if context_options: + params.set_context(context_options) + # need to use a ModelPatcher that supports injection of motion modules into unet + model = ModelPatcherAndInjector.create_from(model, hooks_only=True) + model.motion_models = m_models + model.sample_settings = sample_settings if sample_settings is not None else SampleSettings() + model.motion_injection_params = params + + if model.sample_settings.custom_cfg is not None: + logger.info("[Sample Settings] custom_cfg is set; will override any KSampler cfg values or patches.") + + if model.sample_settings.sigma_schedule is not None: + logger.info("[Sample Settings] sigma_schedule is set; will override beta_schedule.") + model.add_object_patch("model_sampling", model.sample_settings.sigma_schedule.clone().model_sampling) + else: + # save model_sampling from BetaSchedule as object patch + # if autoselect, get suggested beta_schedule from motion model + if beta_schedule == BetaSchedules.AUTOSELECT: + if model.motion_models is None or model.motion_models.is_empty(): + beta_schedule = BetaSchedules.USE_EXISTING + else: + beta_schedule = model.motion_models[0].model.get_best_beta_schedule(log=True) + new_model_sampling = BetaSchedules.to_model_sampling(beta_schedule, model) + if new_model_sampling is not None: + model.add_object_patch("model_sampling", new_model_sampling) + + del m_models + return (model,) \ No newline at end of file diff --git a/docs/AnimateDiffLoaderV1.md b/docs/AnimateDiffLoaderV1.md new file mode 100644 index 0000000..c3db36c --- /dev/null +++ b/docs/AnimateDiffLoaderV1.md @@ -0,0 +1,97 @@ +# 🚫AnimateDiff Loader [DEPRECATED] 🎭🅐🅓 +## Documentation +- Class name: AnimateDiffLoaderV1 +- Category: +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点用于初始化和准备AnimateDiff模型,便于其进行动画生成任务。它抽象了加载模型的复杂性,确保其正确设置以供后续使用。 + +## Input types +### Required +- model + - 该参数用于指定要加载的AnimateDiff模型,使节点能够正确初始化和准备模型以进行动画任务。 + - Comfy dtype: MODEL + - Python dtype: str +- latents + - 该参数允许指定初始化模型可能需要的潜在向量,提供一种自定义模型初始状态的方法。 + - Comfy dtype: LATENT + - Python dtype: str +- model_name + - 用于从可用选项中选择特定运动模型,该参数确保根据提供的名称加载正确版本的AnimateDiff模型。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- unlimited_area_hack + - 一个布尔参数,启用时应用特定的黑客技术以绕过可动画区域的限制,为动画任务提供更多灵活性。 + - Comfy dtype: BOOLEAN + - Python dtype: bool +- beta_schedule + - 指定在模型操作期间使用的beta计划,影响AnimateDiff模型的行为和性能。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str + +## Output types +- model + - Comfy dtype: MODEL + - 表示已加载的AnimateDiff模型,准备进行动画生成任务。 + - Python dtype: str +- latent + - Comfy dtype: LATENT + - 输出与已加载模型相关的潜在向量,可用于进一步的自定义或动画过程。 + - Python dtype: str + +## Usage tips +- Infra type: CPU +- Common nodes: unknown + +## Source code +```python +class AnimateDiffLoader_Deprecated: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "model": ("MODEL",), + "latents": ("LATENT",), + "model_name": (get_available_motion_models(),), + "unlimited_area_hack": ("BOOLEAN", {"default": False},), + "beta_schedule": (BetaSchedules.get_alias_list_with_first_element(BetaSchedules.SQRT_LINEAR),), + }, + } + + RETURN_TYPES = ("MODEL", "LATENT") + CATEGORY = "" + FUNCTION = "load_mm_and_inject_params" + + def load_mm_and_inject_params( + self, + model: ModelPatcher, + latents: Dict[str, torch.Tensor], + model_name: str, unlimited_area_hack: bool, beta_schedule: str, + ): + # load motion module + motion_model = load_motion_module_gen1(model_name, model) + # get total frames + init_frames_len = len(latents["samples"]) # deprecated - no longer used for anything lol + # set injection params + params = InjectionParams( + unlimited_area_hack=unlimited_area_hack, + apply_mm_groupnorm_hack=True, + model_name=model_name, + apply_v2_properly=False, + ) + # inject for use in sampling code + model = ModelPatcherAndInjector.create_from(model, hooks_only=True) + model.motion_models = MotionModelGroup(motion_model) + model.motion_injection_params = params + + # save model sampling from BetaSchedule as object patch + # if autoselect, get suggested beta_schedule from motion model + if beta_schedule == BetaSchedules.AUTOSELECT and not model.motion_models.is_empty(): + beta_schedule = model.motion_models[0].model.get_best_beta_schedule(log=True) + new_model_sampling = BetaSchedules.to_model_sampling(beta_schedule, model) + if new_model_sampling is not None: + model.add_object_patch("model_sampling", new_model_sampling) + + del motion_model + return (model, latents) \ No newline at end of file diff --git a/docs/CheckpointLoaderSimpleWithNoiseSelect.md b/docs/CheckpointLoaderSimpleWithNoiseSelect.md new file mode 100644 index 0000000..71152c2 --- /dev/null +++ b/docs/CheckpointLoaderSimpleWithNoiseSelect.md @@ -0,0 +1,86 @@ +# Load Checkpoint w/ Noise Select 🎭🅐🅓 +## Documentation +- Class name: CheckpointLoaderSimpleWithNoiseSelect +- Category: Animate Diff 🎭🅐🅓/extras +- Output node: False +- Repo Ref: https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved.git + +此节点专门用于加载模型检查点,重点是噪声选择,允许在生成任务中更细致地控制模型的初始化和行为。它通过结合beta计划调整和可选的噪声缩放因子扩展了标准检查点加载功能,以满足高级自定义需求。 + +## Input types +### Required +- ckpt_name + - 指定要加载的检查点名称。此参数对于从预定义的可用检查点列表中识别特定模型检查点文件至关重要。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str +- beta_schedule + - 决定应用于模型的beta计划。此参数允许调整模型的采样行为,增强模型性能的灵活性。 + - Comfy dtype: COMBO[STRING] + - Python dtype: str + +### Optional +- use_custom_scale_factor + - 一个布尔标志,指示是否应用自定义噪声缩放因子。设置为true时,它可以微调噪声对模型输出的影响。 + - Comfy dtype: BOOLEAN + - Python dtype: bool +- scale_factor + - 定义噪声缩放因子的大小,前提是'use_custom_scale_factor'为true。它允许对应用于模型的噪声水平进行精确控制。 + - Comfy dtype: FLOAT + - Python dtype: float + +## Output types +- model + - Comfy dtype: MODEL + - 加载的模型,按照指定的beta计划和噪声缩放选项进行配置。 + - Python dtype: torch.nn.Module +- clip + - Comfy dtype: CLIP + - 如果适用,加载检查点相关的CLIP模型。 + - Python dtype: torch.nn.Module +- vae + - Comfy dtype: VAE + - 如果适用,加载检查点相关的VAE模型。 + - Python dtype: torch.nn.Module + +## Usage tips +- Infra type: GPU +- Common nodes: + - [LoraLoader](../../Comfy/Nodes/LoraLoader.md) + - [CLIPTextEncode](../../Comfy/Nodes/CLIPTextEncode.md) + - [ADE_AnimateDiffLoaderWithContext](../../ComfyUI-AnimateDiff-Evolved/Nodes/ADE_AnimateDiffLoaderWithContext.md) + - [BatchPromptSchedule](../../ComfyUI_FizzNodes/Nodes/BatchPromptSchedule.md) + - [CLIPSetLastLayer](../../Comfy/Nodes/CLIPSetLastLayer.md) + - [Lora Loader Stack (rgthree)](../../rgthree-comfy/Nodes/Lora Loader Stack (rgthree).md) + - IPAdapterApply + - [ToBasicPipe](../../ComfyUI-Impact-Pack/Nodes/ToBasicPipe.md) + +## Source code +```python +class CheckpointLoaderSimpleWithNoiseSelect: + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "ckpt_name": (folder_paths.get_filename_list("checkpoints"), ), + "beta_schedule": (BetaSchedules.ALIAS_LIST, {"default": BetaSchedules.USE_EXISTING}, ) + }, + "optional": { + "use_custom_scale_factor": ("BOOLEAN", {"default": False}), + "scale_factor": ("FLOAT", {"default": 0.18215, "min": 0.0, "max": 1.0, "step": 0.00001}) + } + } + RETURN_TYPES = ("MODEL", "CLIP", "VAE") + FUNCTION = "load_checkpoint" + + CATEGORY = "Animate Diff 🎭🅐🅓/extras" + + def load_checkpoint(self, ckpt_name, beta_schedule, output_vae=True, output_clip=True, use_custom_scale_factor=False, scale_factor=0.18215): + ckpt_path = folder_paths.get_full_path("checkpoints", ckpt_name) + out = load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, embedding_directory=folder_paths.get_folder_paths("embeddings")) + # register chosen beta schedule on model - convert to beta_schedule name recognized by ComfyUI + new_model_sampling = BetaSchedules.to_model_sampling(beta_schedule, out[0]) + if new_model_sampling is not None: + out[0].model.model_sampling = new_model_sampling + if use_custom_scale_factor: + out[0].model.latent_format.scale_factor = scale_factor + return out \ No newline at end of file