ComfyUI Extension: AnimateDiff Evolved
A forked repository that actively maintains a/AnimateDiff, created by ArtVentureX.
Improved AnimateDiff integration for ComfyUI, adapts from sd-webui-animatediff. [w/Download one or more motion models from a/Original Models | a/Finetuned Models. See README for additional model links and usage. Put the model weights under %%ComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved/models%%. You are free to rename the models, but keeping original names will ease use when sharing your workflow.]
Custom Nodes (145)
- Canny
- ContextRef ModeβFirst ππ π
- AnimateDiff Unload ππ π
- Adjust PE [Full Stretch] ππ π
- Adjust Weight [AllβMult] ππ π
- RescaleCFG [Multival] ππ π
- AD Block ππ π
- PIA Input [Multival] ππ π β‘
- AD Per Block+ (SD1.5) ππ π
- AD Per Block+ (SDXL) ππ π
- Multival to Mask ππ π
- Visualize Context Options (S.Cus.) ππ π
- Custom CFG Keyframe [Multival] ππ π
- Load AnimateDiff Model ππ π β‘
- Context OptionsβBatched [Non-AD] ππ π
- Replace Camera Parameters ππ π β‘
- Set LoRA Hook Keyframes ππ π
- Set CLIP LoRA Hook ππ π
- Sample Settings ππ π
- AnimateDiff Keyframe ππ π
- Multival ππ π
- Multival [Float List] ππ π
- Multival [Floats] ππ π
- Context OptionsβStandard Static ππ π
- Context OptionsβStandard Uniform ππ π
- Context OptionsβLooped Uniform ππ π
- Context OptionsβViews Only [VRAMβ] ππ π
- Context OptionsβLooped Uniform ππ π
- Visualize Context Options (K.) ππ π
- Visualize Context Options (K.Adv.) ππ π
- View OptionsβStandard Static ππ π
- View OptionsβStandard Uniform ππ π
- View OptionsβLooped Uniform ππ π
- Set Context Extras ππ π
- Context ExtrasβContextRef ππ π
- ContextRef ModeβSliding ππ π
- ContextRef ModeβIndexes ππ π
- ContextRef TuneβAttn ππ π
- ContextRef TuneβAttn+Adain ππ π
- ContextRef Keyframe ππ π
- ContextRef Keyframes From List ππ π
- Context ExtrasβNaiveReuse ππ π
- NaiveReuse Keyframe ππ π
- NaiveReuse Keyframes Interp. ππ π
- NaiveReuse Keyframes From List ππ π
- Default Iteration Options ππ π
- FreeInit Iteration Options ππ π
- Register LoRA Hook ππ π
- Register LoRA Hook (Model Only) ππ π
- Register Model as LoRA Hook ππ π
- Register Model as LoRA Hook (MO) ππ π
- Combine LoRA Hooks [2] ππ π
- Combine LoRA Hooks [4] ππ π
- Combine LoRA Hooks [8] ππ π
- LoRA Hook Keyframes Interp. ππ π
- Set Props on Cond ππ π
- Manual Combine Conds ππ π
- Manual Combine Cond ππ π
- Noise Layer [Add] ππ π
- Noise Layer [Add Weighted] ππ π
- AnimateDiff Settings ππ π
- Adjust PE [Manual] ππ π
- Adjust Weight [AllβAdd] ππ π
- Adjust Weight [Indiv-AttnβAdd] ππ π
- Adjust Weight [Indiv-AttnβMult] ππ π
- Custom CFG Keyframe ππ π
- Custom CFG Keyframes Interp. ππ π
- CFG ExtrasβRescaleCFG ππ π
- Create Sigma Schedule ππ π
- Create Raw Sigma Schedule ππ π
- Prompt Scheduling ππ π
- Prompt Scheduling [Latents] ππ π
- Value Scheduling ππ π
- Add Values Replace ππ π
- Load AnimateDiff LoRA ππ π
- AD Block+ ππ π
- AD Per Block ππ π
- Multival Scaled Mask ππ π
- AD Per Block++ (SDXL) ππ π
- AD Per Block Floats (SDXL) ππ π
- PerturbedAttnGuide [Multival] ππ π
- AnimateDiff Loader ππ π β
- Use Evolved Sampling ππ π β‘
- Apply AnimateDiff Model (Adv.) ππ π β‘
- Apply AnimateLCM-I2V Model ππ π β‘
- ContextRef Keyframes Interp. ππ π
- Noise Layer [Normalized Sum] ππ π
- Noise Layer [Replace] ππ π
- Adjust PE [Sweetspot] ππ π
- Scale Ref Image and VAE Encode ππ π β‘
- π§ͺInject I2V into AnimateDiff Model ππ π β‘
- Apply AnimateDiff+CameraCtrl Model ππ π β‘
- Load AnimateDiff+CameraCtrl Model ππ π β‘
- Load CameraCtrl Poses (File) ππ π β‘
- LoRA Hook Keyframe ππ π
- LoRA Hook Keyframes From List ππ π
- Set Model LoRA Hook ππ π
- Set Props on Conds ππ π
- Set Props and Combine Conds ππ π
- Set Props and Combine Cond ππ π
- Set Unmasked Conds ππ π
- Set Unmasked Cond ππ π
- Timesteps Conditioning ππ π
- Empty Latent Image (Big Batch) ππ π
- Load Checkpoint w/ Noise Select ππ π
- Adjust Weight [IndivβAdd] ππ π
- Adjust Weight [IndivβMult] ππ π
- Custom CFG ππ π
- Custom CFG [Multival] ππ π
- Custom CFG Keyframes From List ππ π
- CFG ExtrasβPAG ππ π
- CFG ExtrasβPAG [Multival] ππ π
- CFG ExtrasβRescaleCFG [Multival] ππ π
- Sigma Schedule Weighted Mean ππ π
- Sigma Schedule Interp. Mean ππ π
- Sigma Schedule Split Combine ππ π
- Sigma Schedule To Sigmas ππ π
- Image Injection ππ π
- Image Injection Options ππ π
- Ancestral Options ππ π
- Value Scheduling [Latents] ππ π
- Float to Floats ππ π
- AD Per Block++ (SD1.5) ππ π
- AD Per Block Floats (SD1.5) ππ π
- Create CameraCtrl Poses (Combo) ππ π β‘
- Apply AnimateDiff Model ππ π β‘
- Load AnimateLCM-I2V Model ππ π β‘
- AnimateDiff+CameraCtrl Keyframe ππ π
- Load CameraCtrl Poses (Path) ππ π β‘
- Create CameraCtrl Poses (Adv.) ππ π β‘
- Create CameraCtrl Poses ππ π β‘
- Manual Append CameraCtrl Poses ππ π β‘
- Replace Orig. Pose Aspect Ratio ππ π β‘
- Apply AnimateDiff-PIA Model ππ π β‘
- PIA Input [Paper Presets] ππ π β‘
- AnimateDiff-PIA Keyframe ππ π
- π§ͺInject PIA into AnimateDiff Model ππ π β‘
- π«[DEPR] Motion Model Settings (Simple) ππ π β
- AnimateDiff Loader [Legacy] ππ π β
- π«AnimateDiff Loader [DEPRECATED] ππ π
- π«AnimateDiff Loader (Advanced) [DEPRECATED] ππ π
- π«AnimateDiff Combine [DEPRECATED, Use Video Combine (VHS) Instead!] ππ π
- π«[DEPR] Motion Model Settings ππ π β
- π«[DEPR] Motion Model Settings (Advanced) ππ π β
- π«[DEPR] Motion Model Settings (Adv. Attn) ππ π β
README
AnimateDiff for ComfyUI
Improved AnimateDiff integration for ComfyUI, as well as advanced sampling options dubbed Evolved Sampling usable outside of AnimateDiff. Please read the AnimateDiff repo README and Wiki for more information about how it works at its core.
AnimateDiff workflows will often make use of these helpful node packs:
- ComfyUI-Advanced-ControlNet for making ControlNets work with Context Options and controlling which latents should be affected by the ControlNet inputs. Includes SparseCtrl support. Maintained by me.
- ComfyUI-VideoHelperSuite for loading videos, combining images into videos, and doing various image/latent operations like appending, splitting, duplicating, selecting, or counting. Actively maintained by AustinMroz and I.
- comfyui_controlnet_aux for ControlNet preprocessors not present in vanilla ComfyUI. Maintained by Fannovel16.
- ComfyUI_IPAdapter_plus for IPAdapter support. Maintained by cubiq (matt3o).
- ComfyUI-KJNodes for miscellaneous nodes including selecting coordinates for animated GLIGEN. Maintained by kijai.
- ComfyUI_FizzNodes for an alternate way to do prompt-travel functionality with the BatchPromptSchedule node. Maintained by FizzleDorf.
Installation
If using ComfyUI Manager:
- Look for
AnimateDiff Evolved
, and be sure the author isKosinkadink
. Install it.
If installing manually:
- Clone this repo into
custom_nodes
folder.
Model Setup:
- Download motion modules. You will need at least 1. Different modules produce different results.
- Original models
mm_sd_v14
,mm_sd_v15
,mm_sd_v15_v2
,v3_sd15_mm
: HuggingFace | Google Drive | CivitAI - Stabilized finetunes of mm_sd_v14,
mm-Stabilized_mid
andmm-Stabilized_high
, by manshoety: HuggingFace - Finetunes of mm_sd_v15_v2,
mm-p_0.5.pth
andmm-p_0.75.pth
, by manshoety: HuggingFace - Higher resolution finetune,
temporaldiff-v1-animatediff
by CiaraRowles: HuggingFace - FP16/safetensor versions of vanilla motion models, hosted by continue-revolution (takes up less storage space, but uses up the same amount of VRAM as ComfyUI loads models in fp16 by default): HuffingFace
- Original models
- Place models in one of these locations (you can rename models if you wish):
ComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved/models
ComfyUI/models/animatediff_models
- Optionally, you can use Motion LoRAs to influence movement of v2-based motion models like mm_sd_v15_v2.
- Google Drive | HuggingFace | CivitAI
- Place Motion LoRAs in one of these locations (you can rename Motion LoRAs if you wish):
ComfyUI/custom_nodes/ComfyUI-AnimateDiff-Evolved/motion_lora
ComfyUI/models/animatediff_motion_lora
- Get creative! If it works for normal image generation, it (probably) will work for AnimateDiff generations. Latent upscales? Go for it. ControlNets, one or more stacked? You betcha. Masking the conditioning of ControlNets to only affect part of the animation? Sure. Try stuff and you will be surprised by what you can do. Samples with workflows are included below.
NOTE: you can also use custom locations for models/motion loras by making use of the ComfyUI extra_model_paths.yaml
file. The id for motion model folder is animatediff_models
and the id for motion lora folder is animatediff_motion_lora
.
Features
- Compatible with almost any vanilla or custom KSampler node.
- ControlNet, SparseCtrl, and IPAdapter support
- Infinite animation length support via sliding context windows across whole unet (Context Options) and/or within motion module (View Options)
- Scheduling Context Options to change across different points in the sampling process
- FreeInit and FreeNoise support (FreeInit is under iteration opts, FreeNoise is in SampleSettings' noise_type dropdown)
- Mixable Motion LoRAs from original AnimateDiff repository implemented. Caveat: the original loras really only work on v2-based motion models like
mm_sd_v15_v2
,mm-p_0.5.pth
, andmm-p_0.75.pth
.- UPDATE: New motion LoRAs without the v2 limitation can now be trained via the AnimateDiff-MotionDirector repo. Shoutout to ExponentialML for implementing MotionDirector for AnimateDiff purposes!
- Prompt travel using built-in Prompt Scheduling nodes, or BatchPromptSchedule node from ComfyUI_FizzNodes
- Scale and Effect multival inputs to control motion amount and motion model influence on generation.
- Can be float, list of floats, or masks
- Custom noise scheduling via Noise Types, Noise Layers, and seed_override/seed_offset/batch_offset in Sample Settings and related nodes
- AnimateDiff model v1/v2/v3 support
- Using multiple motion models at once via Gen2 nodes (each supporting
- HotshotXL support (an SDXL motion module arch),
hsxl_temporal_layers.safetensors
.- NOTE: You will need to use
autoselect
orlinear (HotshotXL/default)
beta_schedule, the sweetspot for context_length or total frames (when not using context) is 8 frames, and you will need to use an SDXL checkpoint.
- NOTE: You will need to use
- AnimateDiff-SDXL support, with corresponding model. Still in beta after several months.
- NOTE: You will need to use
autoselect
orlinear (AnimateDiff-SDXL)
beta_schedule. Other than that, same rules of thumb apply to AnimateDiff-SDXL as AnimateDiff.
- NOTE: You will need to use
- AnimateLCM support
- NOTE: You will need to use
autoselect
orlcm
orlcm[100_ots]
beta_schedule. To use fully with LCM, be sure to use appropriate LCM lora, use thelcm
sampler_name in KSampler nodes, and lower cfg to somewhere around 1.0 to 2.0. Don't forget to decrease steps (minimum = ~4 steps), since LCM converges faster (less steps). Increase step count to increase detail as desired.
- NOTE: You will need to use
- AnimateLCM-I2V support, big thanks to Fu-Yun Wang for providing me the original diffusers code he created during his work on the paper
- NOTE: Requires same settings as described for AnimateLCM above. Requires
Apply AnimateLCM-I2V Model
Gen2 node usage so thatref_latent
can be provided; useScale Ref Image and VAE Encode
node to preprocess input images. While this was intended as an img2video model, I found it works best for vid2vid purposes withref_drift=0.0
, and to use it for only at least 1 step before switching over to other models via chaining with toher Apply AnimateDiff Model (Adv.) nodes. Theapply_ref_when_disabled
can be set to True to allow the img_encoder to do its thing even when theend_percent
is reached. AnimateLCM-I2V is also extremely useful for maintaining coherence at higher resolutions (with ControlNet and SD LoRAs active, I could easily upscale from 512x512 source to 1024x1024 in a single pass). TODO: add examples
- NOTE: Requires same settings as described for AnimateLCM above. Requires
- CameraCtrl support, with the pruned model you must use here: CameraCtrl_pruned.safetensors
- NOTE: Requires AnimateDiff SD1.5 models, and was specifically trained for v3 model. Gen2 only, with helper nodes provided under Gen2/CameraCtrl submenu.
- PIA support, with the model pia.ckpt
- NOTE: You will need to use
autoselect
orsqrt_linear (AnimateDiff)
beta_schedule. RequiresApply AnimateDiff-PIA Model
Gen2 node usage if you want to actually provide input images. Thepia_input
can be provided via the paper's presets (PIA Input [Paper Presets]
) or by manually entering values (PIA Input [Multival]
).
- NOTE: You will need to use
- AnimateDiff Keyframes to change Scale and Effect at different points in the sampling process.
- fp8 support; requires newest ComfyUI and torch >= 2.1 (decreases VRAM usage, but changes outputs)
- Mac M1/M2/M3 support
- Usage of Context Options and Sample Settings outside of AnimateDiff via Gen2 Use Evolved Sampling node
- Maskable and Schedulable SD LoRA (and Models as LoRA) for both AnimateDiff and StableDiffusion usage via LoRA Hooks
- Per-frame GLIGEN coordinates control
- Currently requires GLIGENTextBoxApplyBatch from KJNodes to do so, but I will add native nodes to do this soon.
- Image Injection mid-sampling
- ContextRef and NaiveReuse (novel cross-context consistency techniques)
Upcoming Features
- Example workflows for every feature in AnimateDiff-Evolved repo, nodes will have usage descriptions (currently Value/Prompt Scheduling nodes have them), and YouTube tutorials/documentation
- UniCtrl support
- Unet-Ref support so that a bunch of papers can be ported over
- StoryDiffusion implementation
- Merging motion model weights/components, including per block customization
- Maskable Motion LoRA
- Timestep schedulable GLIGEN coordinates
- Dynamic memory management for motion models that load/unload at different start/end_percents
- Anything else AnimateDiff-related that comes out
Basic Usage and Nodes
Samples
Known Issues
Some motion models have visible watermark on resulting images (especially when using mm_sd_v15)
Training data used by the authors of the AnimateDiff paper contained Shutterstock watermarks. Since mm_sd_v15 was finetuned on finer, less drastic movement, the motion module attempts to replicate the transparency of that watermark and does not get blurred away like mm_sd_v14. Using other motion modules, or combinations of them using Advanced KSamplers should alleviate watermark issues.