Bidirectional SAM2 Tracking for Video Inpainting in ComfyUI โ on a 16GB Laptop GPU
A local, open-source pipeline for replacing a subject’s head in a moving video shot, and the SAM2 patch that makes bidirectional mask tracking possible.

A few months ago I published an open-source project on GitHub: ComfyUI-Bidirectional-SAM2-Inpaint. It is an automated video inpainting pipeline built on ComfyUI, combining Wan 2.1 VACE, SAM2 and Qwen2.5-VL, designed to process long shots on limited hardware โ the reference machine is a laptop with a 16GB RTX 3080. This post documents how the pipeline works, why the SAM2 tracker had to be patched to propagate in both directions, and the workflow practices that determine the quality of the result.

