Wan2.1 VACE Inpainting
Edit specific regions in videos while preserving surrounding content. Great for object removal or replacement.
概要
The Wan2.1 VACE Inpainting workflow is designed to seamlessly edit specific regions in video content while preserving the integrity of the surrounding areas. This is particularly useful for tasks such as object removal or replacement in video sequences. Utilizing the Wan2.1 model, this workflow leverages a combination of nodes including KSampler for sampling, CLIPTextEncode for text encoding, and VAEDecode for decoding video frames. The workflow is structured into several steps, starting from loading models and video files, to creating masks and compositing the final video output.
Technically, the workflow employs the WanVaceToVideo node to convert inpainted frames back into video format, while the TrimVideoLatent and CreateVideo nodes manage the video length and format. The ImageCompositeMasked node is crucial for blending the inpainted regions with the original video, ensuring a natural look.
By using core nodes, the workflow avoids the need for additional custom installations, making it accessible and easy to implement. This workflow is particularly valuable for content creators and video editors who need to make precise edits without affecting the overall quality of the video.
入力するもの
- ワークフローを読み込み中
ComfyUI で実行できます。 このワークフローはこのページでは実行できません。すべてが読み込まれた状態でComfy Cloudで開くか、ご自身のComfyUI用にダウンロードしてください。
Cloudで試すワークフローの内部
ノードグラフの読み取り専用プレビューです。ノードを編集するには、Comfy Cloudで開くかダウンロードしてください。
Loading the graph
Open full-size workflow preview- 作成者
- ComfyUI
カスタムノードが必要です
- ワークフローを読み込み中
コードからこのワークフローを使用する
可能な場合はワークフローグラフと入力から生成されます。それ以外の場合は保存された例が表示されます。料金が発生する場合があるため、コードを実行する前に認証情報とエンドポイントを確認してください。
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({
"3": {
"class_type": "KSampler",
"inputs": {
"cfg": 1,
"denoise": 1,
"latent_image": [
"49",
2
],
"model": [
"48",
0
],
"negative": [
"49",
1
],
"positive": [
"49",
0
],
"sampler_name": "uni_pc",
"scheduler": "simple",
"seed": 584027519362099,
"steps": 4
},
"_meta": {
"title": "KSampler"
}
},
"6": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"38",
0
],
"text": "A little boy and a dog are hiking in the forest. The puppy runs around the boy cheerfully.\n"
},
"_meta": {
"title": "CLIP Text Encode (Positive Prompt)"
}
},
"7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"38",
0
],
"text": "过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走,过曝,"
},
"_meta": {
"title": "CLIP Text Encode (Negative Prompt)"
}
},
"8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"58",
0
],
"vae": [
"39",
0
]
},
"_meta": {
"title": "VAE Decode"
}
},
"38": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "umt5_xxl_fp8_e4m3fn_scaled.safetensors",
"device": "default",
"type": "wan"
},
"_meta": {
"title": "Load CLIP"
}
},
"39": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "wan_2.1_vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"48": {
"class_type": "ModelSamplingSD3",
"inputs": {
"model": [
"154",
0
],
"shift": 5
},
"_meta": {
"title": "ModelSamplingSD3"
}
},
"49": {
"class_type": "WanVaceToVideo",
"inputs": {
"batch_size": 1,
"control_masks": [
"130",
0
],
"control_video": [
"208",
0
],
"height": 720,
"length": 81,
"negative": [
"7",
0
],
"positive": [
"6",
0
],
"reference_image": [
"162",
0
],
"strength": 1,
"vae": [
"39",
0
],
"width": 720
},
"_meta": {
"title": "WanVaceToVideo"
}
},
"58": {
"class_type": "TrimVideoLatent",
"inputs": {
"samples": [
"3",
0
],
"trim_amount": [
"49",
3
]
},
"_meta": {
"title": "Trim Video Latent"
}
},
"68": {
"class_type": "CreateVideo",
"inputs": {
"bit_depth": "auto",
"codec": "none",
"color_space": "sRGB",
"fps": [
"210",
2
],
"images": [
"8",
0
]
},
"_meta": {
"title": "Create Video"
}
},
"69": {
"class_type": "SaveVideo",
"inputs": {
"filename_prefix": "video/ComfyUI",
"format": "auto",
"format.codec": "auto",
"video": [
"68",
0
]
},
"_meta": {
"title": "Save Video"
}
},
"111": {
"class_type": "MaskToImage",
"inputs": {
"mask": [
"215",
1
]
},
"_meta": {
"title": "Convert Mask to Image"
}
},
"129": {
"class_type": "RepeatImageBatch",
"inputs": {
"amount": [
"211",
2
],
"image": [
"111",
0
]
},
"_meta": {
"title": "Repeat Image Batch"
}
},
"130": {
"class_type": "ImageToMask",
"inputs": {
"channel": "red",
"image": [
"129",
0
]
},
"_meta": {
"title": "Convert Image to Mask"
}
},
"140": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "wan2.1_vace_14B_fp16.safetensors",
"weight_dtype": "fp8_e4m3fn_fast"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"154": {
"class_type": "LoraLoaderModelOnly",
"inputs": {
"lora_name": "Wan21_CausVid_14B_T2V_lora_rank32.safetensors",
"model": [
"140",
0
],
"strength_model": 0.30000000000000004
},
"_meta": {
"title": "Load LoRA"
}
},
"162": {
"class_type": "LoadImage",
"inputs": {
"image": "api_bfl_flux_1_kontext_multiple_images_input_dog.jpg"
},
"_meta": {
"title": "Load Image"
}
},
"208": {
"class_type": "ImageCompositeMasked",
"inputs": {
"destination": [
"213",
0
],
"mask": [
"215",
1
],
"resize_source": True,
"source": [
"216",
0
],
"x": 0,
"y": 0
},
"_meta": {
"title": "Image Composite Masked"
}
},
"209": {
"class_type": "LoadVideo",
"inputs": {
"file": "video_wan_vace_inpainting_input_video.mp4"
},
"_meta": {
"title": "Load Video"
}
},
"210": {
"class_type": "GetVideoComponents",
"inputs": {
"video": [
"209",
0
]
},
"_meta": {
"title": "Get Video Components"
}
},
"211": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"210",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"213": {
"class_type": "RebatchImages",
"inputs": {
"batch_size": [
"211",
2
],
"images": [
"210",
0
]
},
"_meta": {
"title": "Rebatch Images"
}
},
"214": {
"class_type": "PreviewImage",
"inputs": {
"images": [
"208",
0
]
},
"_meta": {
"title": "Preview Image"
}
},
"215": {
"class_type": "LoadImage",
"inputs": {
"image": "video_wan_vace_inpainting_1st_frame_and_mask.png"
},
"_meta": {
"title": "Load Image"
}
},
"216": {
"class_type": "MaskToImage",
"inputs": {
"mask": [
"219",
0
]
},
"_meta": {
"title": "Convert Mask to Image"
}
},
"219": {
"class_type": "InvertMask",
"inputs": {
"mask": [
"215",
1
]
},
"_meta": {
"title": "Invert Mask"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)よくある質問
The workflow uses the Wan2.1 model, specifically the VACE-1.3B and VACE-14B models, for video inpainting tasks.
Yes, the VACE-1.3B model supports 480P resolution, while the VACE-14B model supports up to 720P resolution.
No, the workflow is designed using core nodes, so no additional custom nodes are required.
You can use the ImageToMask node to define the region you want to inpaint in the video.