Nodes/AnimateDiff Evolved/Image Injection πŸŽ­πŸ…πŸ…“
ComfyUI Node Runs on cloud

Image Injection πŸŽ­πŸ…πŸ…“

Anchoring your animation to a real frame mid-sampling

By KosinkadinkΒ·Created 3 years agoΒ·Updated 8 days agoΒ· 3,519
Image Injection πŸŽ­πŸ…πŸ…“
  • image
  • vae
  • mask_opt
  • img_inject_opts
  • strength_multival
  • prev_image_inject
  • IMAGE_INJECT
β—„invert_maskfalseβ–Ί
β—„resize_imagetrueβ–Ί
β—„start_percent0.000β–Ί
β—„guarantee_steps1β–Ί

Long AnimateDiff runs drift. The motion module keeps generating plausible frames, but nothing's actually anchoring the sequence to anything concrete, so subjects morph, backgrounds shift, and a clip that started coherent slowly stops looking like it. Image Injection - listed plainly as a feature in the README - is the fix: partway through sampling, inject a real image (noised to the right level for that point in the process) into the generation, pulling the clip back toward something you actually chose rather than whatever the model's drifted into.

How it works

You give it an image and a vae to encode it with. At start_percent of the way through sampling, that image gets noised to match the current step and blended into the latent, holding for at least guarantee_steps steps. resize_image (default true) auto-fits your image to the latent's resolution so you don't have to pre-match dimensions by hand. mask_opt restricts the injection to part of the frame instead of the whole thing - useful if you only want to re-anchor, say, a character's face and let the rest of the frame keep drifting freely - and invert_mask flips which side of that mask the injection actually applies to.

strength_multival controls how strongly the injection pulls, and because it's a Multival, that strength itself can vary spatially or be built from a masked value rather than staying one flat number. img_inject_opts (built by the sibling Image Injection Options node) lets you control exactly where in the frame the image gets composited if it isn't filling the whole canvas. And prev_image_inject chains multiple injections together - different reference images anchoring different points across a long clip, rather than a single one-time correction.

The inputs and outputs that matter

Required: image and vae.

Optional: mask_opt (MASK), invert_mask (default false), resize_image (default true), start_percent (default 0), guarantee_steps (default 1), img_inject_opts (IMAGE_INJECT_OPTIONS), strength_multival (MULTIVAL), prev_image_inject (IMAGE_INJECT, chains multiple injections).

Output is a single IMAGE_INJECT, which plugs into your Sample Settings' image-injection slot.

How to install it

ComfyUI Manager: search AnimateDiff Evolved, confirm the author is Kosinkadink, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Kosinkadink/ComfyUI-AnimateDiff-Evolved

then restart. No dedicated model download for this node - it works with whatever checkpoint and VAE your workflow already has loaded.

Common issues & troubleshooting

Injection doesn't seem to change anything. Confirm the IMAGE_INJECT output actually reaches Sample Settings, and that Sample Settings feeds your loader or Use Evolved Sampling. Also check strength_multival isn't left at a value that effectively zeroes the injection out.

Injected image looks like a hard cut instead of a natural anchor. Push start_percent earlier in the process and give the injection more room, or lower strength_multival so the model has more freedom to blend the injected content into its own generation rather than overwriting it wholesale.

Only part of the frame should be re-anchored, but the whole thing's affected. Wire in mask_opt - without one, injection applies to the full frame. Check invert_mask too if the affected region looks like the opposite of what you painted.

Multiple reference images aren't all showing up. Confirm each additional injection is properly chained through prev_image_inject rather than left as a separate, disconnected node - a broken chain silently drops everything before it.

CategoryAnimate Diff πŸŽ­πŸ…πŸ…“/sample settings/image inject

Inputs (10)

NameTypeDefaultDescription
imageIMAGEβ€”
vaeVAEβ€”
mask_optoptMASKβ€”
invert_maskoptBOOLEANfalseβ€”
resize_imageoptBOOLEANtrueβ€”
start_percentoptFLOAT0.0000–1β€”
guarantee_stepsoptINT11–9007199254740991β€”
img_inject_optsoptIMAGE_INJECT_OPTIONSβ€”
strength_multivaloptMULTIVALβ€”
prev_image_injectoptIMAGE_INJECTβ€”

Outputs (1)

NameTypeDescription
IMAGE_INJECTIMAGE_INJECTβ€”