AnimateDiff - IPAdapters Looping Animation
Drag and drop then dream through a stack of images
查看工作流内部
源模板的只读预览。在 Cloud 中打开,即可查看节点并进行修改。
Loading the graph
Open full-size workflow preview- 输出
- 视频
- 作者
- Purz
从代码中调用该模型
以下请求使用与体验区相同的预设图和设置。每次提交都可能开始一次付费运行;如果提交结果未知,请勿自动重试。
What you need
- Runs on
- Comfy Cloud
- 密钥
- COMFY_API_KEY
- 你的文件
- 由代码根据链接上传
需要付费的 Cloud 方案和额度。
# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"14": {
"class_type": "VHS_VideoCombine",
"inputs": {
"crf": 12,
"filename_prefix": "AnimateDiff",
"format": "video/h264-mp4",
"frame_rate": 24,
"images": [
"38:13",
0
],
"loop_count": 0,
"pingpong": False,
"pix_fmt": "yuv420p",
"save_metadata": True,
"save_output": True,
"trim_to_audio": False
},
"_meta": {
"title": "Video Combine 🎥🅥🅗🅢"
}
},
"61": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_1_FILENAME"
},
"_meta": {
"title": "Image 1"
}
},
"62": {
"class_type": "ImageScaleToTotalPixels",
"inputs": {
"image": [
"61",
0
],
"megapixels": 1,
"resolution_steps": 1,
"upscale_method": "lanczos"
},
"_meta": {
"title": "Rescale Image 1"
}
},
"63": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_2_FILENAME"
},
"_meta": {
"title": "Image 2"
}
},
"64": {
"class_type": "ImageScaleToTotalPixels",
"inputs": {
"image": [
"63",
0
],
"megapixels": 1,
"resolution_steps": 1,
"upscale_method": "lanczos"
},
"_meta": {
"title": "Rescale Image 2"
}
},
"65": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_3_FILENAME"
},
"_meta": {
"title": "Image 3"
}
},
"66": {
"class_type": "ImageScaleToTotalPixels",
"inputs": {
"image": [
"65",
0
],
"megapixels": 1,
"resolution_steps": 1,
"upscale_method": "lanczos"
},
"_meta": {
"title": "Rescale Image 3"
}
},
"67": {
"class_type": "ImageBatchMulti",
"inputs": {
"image_1": [
"62",
0
],
"image_2": [
"64",
0
],
"image_3": [
"66",
0
],
"image_4": [
"62",
0
],
"inputcount": 4
},
"_meta": {
"title": "Image Batch Multi"
}
},
"76": {
"class_type": "VHS_VideoCombine",
"inputs": {
"crf": 12,
"filename_prefix": "AnimateDiff",
"format": "video/h264-mp4",
"frame_rate": 24,
"images": [
"77:75",
0
],
"loop_count": 0,
"pingpong": False,
"pix_fmt": "yuv420p",
"save_metadata": True,
"save_output": True,
"trim_to_audio": False
},
"_meta": {
"title": "Video Combine 🎥🅥🅗🅢"
}
},
"38:1": {
"class_type": "ADE_UseEvolvedSampling",
"inputs": {
"beta_schedule": "lcm >> sqrt_linear",
"context_options": [
"38:7",
0
],
"m_models": [
"38:2",
0
],
"model": [
"38:8",
0
],
"sample_settings": [
"38:6",
0
]
},
"_meta": {
"title": "Use Evolved Sampling 🎭🅐🅓②"
}
},
"38:10": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"38:8",
1
],
"text": "nsfw, nude"
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"38:11": {
"class_type": "KSampler",
"inputs": {
"cfg": 2,
"denoise": 1,
"latent_image": [
"38:12",
0
],
"model": [
"38:36",
0
],
"negative": [
"38:10",
0
],
"positive": [
"38:9",
0
],
"sampler_name": "lcm",
"scheduler": "beta",
"seed": 484814760137008,
"steps": 13
},
"_meta": {
"title": "KSampler"
}
},
"38:12": {
"class_type": "EmptyLatentImage",
"inputs": {
"batch_size": [
"38:27",
2
],
"height": 576,
"width": 1024
},
"_meta": {
"title": "Empty Latent Image"
}
},
"38:13": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"38:11",
0
],
"vae": [
"38:8",
2
]
},
"_meta": {
"title": "VAE Decode"
}
},
"38:2": {
"class_type": "ADE_ApplyAnimateDiffModelSimple",
"inputs": {
"effect_multival": [
"38:5",
0
],
"motion_model": [
"38:3",
0
],
"scale_multival": [
"38:4",
0
]
},
"_meta": {
"title": "Apply AnimateDiff Model 🎭🅐🅓②"
}
},
"38:21": {
"class_type": "IPAdapterUnifiedLoader",
"inputs": {
"model": [
"38:1",
0
],
"preset": "PLUS (high strength)"
},
"_meta": {
"title": "IPAdapter Unified Loader"
}
},
"38:27": {
"class_type": "IPAdapterWeights",
"inputs": {
"add_ending_frames": 16,
"add_starting_frames": 16,
"end_frame": 9999,
"frames": 48,
"image": [
"67",
0
],
"method": "alternate batches",
"start_frame": 0,
"timing": "ease_in",
"weights": "1.0, 0.0"
},
"_meta": {
"title": "IPAdapter Weights"
}
},
"38:3": {
"class_type": "ADE_LoadAnimateDiffModel",
"inputs": {
"model_name": "AnimateLCM_sd15_t2v.ckpt"
},
"_meta": {
"title": "Load AnimateDiff Model 🎭🅐🅓②"
}
},
"38:32": {
"class_type": "IPAdapterBatch",
"inputs": {
"embeds_scaling": "V only",
"encode_batch_size": 0,
"end_at": 1,
"image": [
"38:27",
3
],
"ipadapter": [
"38:21",
1
],
"model": [
"38:21",
0
],
"start_at": 0,
"weight": [
"38:27",
0
],
"weight_type": "ease in"
},
"_meta": {
"title": "IPAdapter Batch (Adv.)"
}
},
"38:33": {
"class_type": "IPAdapterBatch",
"inputs": {
"embeds_scaling": "V only",
"encode_batch_size": 0,
"end_at": 1,
"image": [
"38:27",
4
],
"ipadapter": [
"38:21",
1
],
"model": [
"38:32",
0
],
"start_at": 0,
"weight": [
"38:27",
1
],
"weight_type": "ease out"
},
"_meta": {
"title": "IPAdapter Batch (Adv.)"
}
},
"38:36": {
"class_type": "PatchModelAddDownscale",
"inputs": {
"block_number": 3,
"downscale_after_skip": True,
"downscale_factor": 2,
"downscale_method": "bicubic",
"end_percent": 0.35,
"model": [
"38:33",
0
],
"start_percent": 0,
"upscale_method": "bicubic"
},
"_meta": {
"title": "PatchModelAddDownscale (Kohya Deep Shrink)"
}
},
"38:4": {
"class_type": "ADE_MultivalDynamic",
"inputs": {
"float_val": 1
},
"_meta": {
"title": "Multival 🎭🅐🅓"
}
},
"38:5": {
"class_type": "ADE_MultivalDynamic",
"inputs": {
"float_val": 1
},
"_meta": {
"title": "Multival 🎭🅐🅓"
}
},
"38:6": {
"class_type": "ADE_AnimateDiffSamplingSettings",
"inputs": {
"adapt_denoise_steps": False,
"batch_offset": 0,
"noise_type": "repeated_context",
"seed_gen": "comfy",
"seed_offset": 0,
"seed_override": 0
},
"_meta": {
"title": "Sample Settings 🎭🅐🅓"
}
},
"38:7": {
"class_type": "ADE_LoopedUniformContextOptions",
"inputs": {
"closed_loop": False,
"context_length": 16,
"context_overlap": 4,
"context_stride": 1,
"fuse_method": "pyramid",
"guarantee_steps": 1,
"start_percent": 0,
"use_on_equal_length": False
},
"_meta": {
"title": "Context Options◆Looped Uniform 🎭🅐🅓"
}
},
"38:8": {
"class_type": "CheckpointLoaderSimple",
"inputs": {
"ckpt_name": "realismByStableYogi_v4LCM.safetensors"
},
"_meta": {
"title": "Load Checkpoint"
}
},
"38:9": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"38:8",
1
],
"text": "A slow, hypnotic dream in which a giant hourglass and its tiny cloaked wanderer drift through changing worlds: molten golden sand pours and glows, then freezes into shimmering blue ice under falling snow, then softens into moss, vines and blooming flowers in warm sunset light. Gentle continuous morphing, swirling particles of light and drifting mist, rippling reflections on the water, subtle camera breathing, painterly brushwork, rich saturated colour, smooth seamless loop with no cuts, ethereal and calm atmosphere, like a half-remembered dream."
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"77:69": {
"class_type": "RepeatImageBatch",
"inputs": {
"amount": [
"77:70",
3
],
"image": [
"62",
0
]
},
"_meta": {
"title": "Repeat Image Batch"
}
},
"77:70": {
"class_type": "GetImageSizeAndCount",
"inputs": {
"image": [
"38:13",
0
]
},
"_meta": {
"title": "Get Image Size & Count"
}
},
"77:71": {
"class_type": "RepeatImageBatch",
"inputs": {
"amount": [
"77:70",
3
],
"image": [
"64",
0
]
},
"_meta": {
"title": "Repeat Image Batch"
}
},
"77:72": {
"class_type": "RepeatImageBatch",
"inputs": {
"amount": [
"77:70",
3
],
"image": [
"66",
0
]
},
"_meta": {
"title": "Repeat Image Batch"
}
},
"77:73": {
"class_type": "ImageStitch",
"inputs": {
"direction": "right",
"image1": [
"77:69",
0
],
"image2": [
"77:71",
0
],
"match_image_size": True,
"spacing_color": "black",
"spacing_width": 10
},
"_meta": {
"title": "Stitch Images"
}
},
"77:74": {
"class_type": "ImageStitch",
"inputs": {
"direction": "right",
"image1": [
"77:73",
0
],
"image2": [
"77:72",
0
],
"match_image_size": True,
"spacing_color": "black",
"spacing_width": 10
},
"_meta": {
"title": "Stitch Images"
}
},
"77:75": {
"class_type": "ImageStitch",
"inputs": {
"direction": "down",
"image1": [
"77:74",
0
],
"image2": [
"38:13",
0
],
"match_image_size": True,
"spacing_color": "black",
"spacing_width": 10
},
"_meta": {
"title": "Stitch Images"
}
}
})
workflow.set_input("61", "image", client.assets.from_url("https://comfy.org/catalog-media/44f132a2-b86b-423a-9dea-cd45e8dc8a45/137fbc6b-7de9-4656-a813-7b6666d8b3da"))
workflow.set_input("63", "image", client.assets.from_url("https://comfy.org/catalog-media/0672b137-0632-4be0-80be-38150ed1f9d8/b3faec0a-3433-4529-9937-75cd0029a35b"))
workflow.set_input("65", "image", client.assets.from_url("https://comfy.org/catalog-media/746bafc1-ced6-4d5c-8460-302f786532b2/1d5e894e-b82a-439c-98c4-021685a5852c"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)
for output in job.get_outputs("14"):
output.to_file(output.name)
for output in job.get_outputs("76"):
output.to_file(output.name)试试一个示例
关于此工作流
This ComfyUI workflow, titled 'AnimateDiff - IPAdapters Looping Animation,' is designed to create seamless animated transitions between a series of images. It leverages the power of Stable Diffusion 1.5 (SD1.5) along with custom nodes such as 'comfyui-animatediff-evolved' and 'comfyui_ipadapter_plus' to achieve fluid animations.
The workflow uses a combination of nodes like 'VHS_VideoCombine' and 'ImageBatchMulti' to process multiple images in sequence, creating a looping animation effect. By utilizing Weighted IPAdapters, the workflow ensures that each image transition maintains a consistent style and theme, enhancing the overall visual coherence of the animation.
Technically, the workflow begins with loading images into the 'LoadImage' node, which are then scaled appropriately using the 'ImageScaleToTotalPixels' node. The 'ImageBatchMulti' node is crucial for handling multiple images, allowing them to be processed as a batch. The 'VHS_VideoCombine' node plays a pivotal role in merging these images into a continuous video loop. This setup is particularly useful for artists and content creators looking to produce engaging visual content that smoothly transitions between different scenes or concepts.
The integration of the 'comfyui-videohelpersuite' further aids in refining the video output, ensuring high-quality animations.
常见问答
The 'Weighted IPAdapters' help maintain a consistent visual style across all images, ensuring smooth transitions in the animation.
This workflow is specifically designed for SD1.5. While it may work with other versions, results can vary and are not guaranteed.
Ensure that images are similar in style and theme. Adjust the 'Weighted IPAdapters' settings to fine-tune the transitions.
The workflow focuses on visual animation. You can add audio using video editing software after exporting the animation.