3.2 進階:控制影片生成
學習如何用姿態估計與 Wan Animate 控制影片。
下載工作流程在 Cloud 中試用 API 文件
00:00
工作流程內部
來源範本的唯讀預覽。請在 Cloud 中開啟,以探索節點並進行變更。
從您的程式碼呼叫此模型
以下請求使用與 Playground 相同的已準備節點圖和設定。每次提交都可能啟動付費執行;若提交結果不明,請勿自動重試提交。
1 取得 API 金鑰 ↗
What you need
- Runs on
- Comfy Cloud
- 金鑰
- COMFY_API_KEY
- 您的檔案
- 由程式碼透過其 URL 上傳
需要付費 Cloud 方案與點數。
下載 API JSONAPI 文件 ↗
# 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({
"411": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"451:481",
0
],
"vae": [
"451:413",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"414": {
"class_type": "CreateVideo",
"inputs": {
"audio": [
"421",
1
],
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": [
"421",
2
],
"images": [
"411",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"415": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI",
"format": "auto",
"format.codec": "auto",
"video": [
"414",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"420": {
"class_type": "LoadVideo",
"inputs": {
"file": "UPLOADED_video_FILENAME"
},
"_meta": {
"title": "Load Video"
}
},
"421": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"420",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"422": {
"class_type": "DWPreprocessor",
"inputs": {
"bbox_detector": "yolox_l.onnx",
"detect_body": "enable",
"detect_face": "enable",
"detect_hand": "enable",
"image": [
"421",
0
],
"pose_estimator": "dw-ll_ucoco_384_bs5.torchscript.pt",
"resolution": 512,
"scale_stick_for_xinsr_cn": "disable"
},
"_meta": {
"title": "DWPose Estimator"
}
},
"470": {
"class_type": "CreateVideo",
"inputs": {
"audio": [
"421",
1
],
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": [
"421",
2
],
"images": [
"422",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"479": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Reference Image"
}
},
"451:399": {
"class_type": "WanAnimateToVideo",
"inputs": {
"batch_size": 1,
"clip_vision_output": [
"451:431",
0
],
"continue_motion_max_frames": 1,
"height": 720,
"length": 73,
"negative": [
"451:409",
0
],
"pose_video": [
"422",
0
],
"positive": [
"451:407",
0
],
"reference_image": [
"479",
0
],
"vae": [
"451:413",
0
],
"video_frame_offset": 0,
"width": 1280
},
"_meta": {
"title": "WanAnimateToVideo"
}
},
"451:400": {
"class_type": "KSampler",
"inputs": {
"cfg": 1,
"denoise": 1,
"latent_image": [
"451:399",
2
],
"model": [
"451:403",
0
],
"negative": [
"451:399",
1
],
"positive": [
"451:399",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 166084212342096,
"steps": 6
},
"_meta": {
"title": "KSampler"
}
},
"451:403": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "lightx2v_I2V_14B_480p_cfg_step_distill_rank128_bf16.safetensors",
"model": [
"451:444",
0
],
"strength_model": 1
},
"_meta": {
"title": "Load LoRA"
}
},
"451:407": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"451:412",
0
],
"text": "The porcelain-headed automaton in a charcoal wool vest, cream shirt, tailored trousers and black dress shoes dances alone in a vast brutalist concrete plaza at midnight. Its brass neck joints and bone-white head catch an amber rim light through drifting sea fog and light drizzle. It steps side to side, rolls its shoulders, spins and drops into a low crouch before springing up with its arms flung wide, its movements smooth yet slightly mechanical. Puddles on the wet slate-grey concrete mirror every move. Moody indigo and graphite tones, cinematic lighting, detailed fabric and porcelain textures, steady camera."
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"451:409": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"451:412",
0
],
"text": "static, blurry details, subtitles, style, artwork, painting, image, still, overall grayish tone, worst quality, low quality, JPEG compression artifacts, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn face, deformed, disfigured, malformed limbs, fused fingers, frozen frame, cluttered background, three legs, too many people in the background, walking backward."
},
"_meta": {
"title": "CLIP Text Encode (Prompt)"
}
},
"451:412": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "umt5_xxl_fp8_e4m3fn_scaled.safetensors",
"device": "default",
"type": "wan"
},
"_meta": {
"title": "Load CLIP"
}
},
"451:413": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "Wan2_1_VAE_fp32.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"451:431": {
"class_type": "CLIPVisionEncode",
"inputs": {
"clip_vision": [
"451:445",
0
],
"crop": "center",
"image": [
"421",
0
]
},
"_meta": {
"title": "CLIP Vision Encode"
}
},
"451:444": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "Wan2_2-Animate-14B_fp8_e4m3fn_scaled_KJ.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"451:445": {
"class_type": "CLIPVisionLoader",
"inputs": {
"clip_name": "clip_vision_h.safetensors"
},
"_meta": {
"title": "Load CLIP Vision"
}
},
"451:481": {
"class_type": "TrimVideoLatent",
"inputs": {
"samples": [
"451:400",
0
],
"trim_amount": [
"451:399",
3
]
},
"_meta": {
"title": "Trim Video Latent"
}
}
})
workflow.set_input("479", "image", client.assets.from_url("https://comfy.org/catalog-media/8a6af52a-f7ae-43fa-8811-b3aeb947cfaa/406a017b-96fc-4e71-a475-e04f9d953853"))
workflow.set_input("420", "file", client.assets.from_url("https://comfy.org/catalog-media/339f3f4a-c95c-41c1-afd6-b55cffed9192/a84db708-e387-4541-9aa6-56ea830532c3"))
# 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("415"):
output.to_file(output.name)試試範例
關於此工作流程
本進階 ComfyUI 工作流程讓使用者能以姿態估計技術與 Wan Animate 模型控制影片生成。流程核心利用 DWPose Estimator 從輸入影片提取姿態資訊,產生「控制影片」作為新影片生成的藍本。此控制影片結合 Wan Animate 模型,產生符合原始動作與姿態的新影片。流程包含多個關鍵節點,如 VAEDecode 解碼潛在表示、CreateVideo 組合畫格成影片、SaveVideo 輸出最終成果,並搭配 comfyui_controlnet_aux 自訂節點,強化影片生成的控制力,確保輸出貼合創作者需求。此流程特別適合動畫師與內容創作者,製作動作與風格一致的影片,並可依指定姿態參考進行創作。
問答
DWPose Estimator 從輸入影片提取姿態資訊,產生控制影片,引導後續動畫生成。
可以,建議選擇動作清楚、符合你想複製動作的影片以獲得最佳效果。
Wan Animate 利用姿態控制影片與參考圖像,生成符合指定姿態與風格的新影片。
請謹慎選擇參考圖像與姿態影片,並依需求調整流程參數,微調輸出風格與動作。