Views
No views yet

📢 System Requirements: Both the official Python inference code and the ComfyUI workflow were tested on Ubuntu 20.04 with Python 3.10, PyTorch 2.5.1, and CUDA 12.1 on an NVIDIA A800 GPU.
git clone https://github.com/IGL-HKUST/FlexAM
conda create -n flexam python=3.10
conda activate flexamPytorch 2.5.1 with CUDA 12.1:pip install torch==2.5.1 torchvision==0.20.1 --index-url https://download.pytorch.org/whl/cu121pip install -r requirements.txtmkdir -p submodules
git submodule update --init --recursive
pip install -r requirements.txtcheckpoints/ directory.⚠️ Note: Currently, the ComfyUI node supports Motion Transfer, Foreground Edit, and Background Edit. For Camera Control and Object Manipulation, please use the Python script.
cd ComfyUI/custom_nodes/
git clone https://github.com/IGL-HKUST/FlexAM
cd FlexAM
pip install -r requirements.txtComfyUI/models/checkpoints.run_demo.sh to run the demo.py script.
1python demo.py \
2 --prompt <"prompt text"> \ # prompt text
3 --checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
4 --output_dir <output_dir> \ # output directory
5 --input_path <input_path> \ # the reference video path
6 --repaint <True/repaint_path > \ # the repaint first frame image path of input source video or use FLUX to repaint the first frame \
7 --video_length=97 \
8 --sample_size 512 896 \
9 --generate_type='full_edit' \
10 --density 10 \ # Control the sparsity of tracking points
11 --gpu <gpu_id> \ # the gpu id
1python demo.py \
2 --prompt <"prompt text"> \ # prompt text
3 --checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
4 --output_dir <output_dir> \ # output directory
5 --input_path <input_path> \ # the reference video path
6 --repaint <True/repaint_path > \ # the repaint first frame image path of input source video or use FLUX to repaint the first frame \
7 --mask_path <mask_path> \ # White (255) represents the foreground to be edited, and black (0) remains unchanged
8 --video_length=97 \
9 --sample_size 512 896 \
10 --generate_type='foreground_edit' \
11 --dilation_pixels=30 \ # Dilation pixels for mask processing in foreground_edit mode
12 --density 10 \ # Control the sparsity of tracking points
13 --gpu <gpu_id> \ # the gpu id
1python demo.py \
2 --prompt <"prompt text"> \ # prompt text
3 --checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
4 --output_dir <output_dir> \ # output directory
5 --input_path <input_path> \ # the reference video path
6 --repaint <True/repaint_path > \ # the repaint first frame image path of input source video or use FLUX to repaint the first frame \
7 --mask_path <mask_path> \ # White (255) represents the unchanged foreground, while the background indicates the area to be edited
8 --video_length=97 \
9 --sample_size 512 896 \
10 --generate_type='background_edit' \
11 --density 10 \ # Control the sparsity of tracking points
12 --gpu <gpu_id> \ # the gpu id
1python demo.py \
2 --prompt <"prompt text"> \ # prompt text
3 --checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
4 --output_dir <output_dir> \ # output directory
5 --input_path <input_path> \ # the reference image or video path
6 --camera_motion <camera_motion> \ # the camera motion type, see examples below
7 --tracking_method <tracking_method> \ # the tracking method (moge, DELTA). For image input, 'moge' is necessary.
8 --override_extrinsics <override/append> \ # how to apply camera motion: "override" to replace original camera, "append" to build upon it
9 --video_length=97 \
10 --sample_size 512 896 \
11 --density 5 \ # Control the sparsity of tracking points
12 --gpu <gpu_id> \ # the gpu id1python demo.py \
2 --prompt <"prompt text"> \ # prompt text
3 --checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
4 --output_dir <output_dir> \ # output directory
5 --input_path <input_path> \ # the reference image or video path
6 --camera_motion "path" \ # if camera motion type is "path", --pose_file is needed
7 --pose_file <pose_file_txt> \ # txt file of camera pose, Each line corresponds to one frame
8 --tracking_method <tracking_method> \ # the tracking method (moge, DELTA). For image input, 'moge' is necessary.
9 --override_extrinsics <override/append> \ # how to apply camera motion: "override" to replace original camera, "append" to build upon it
10 --video_length=97 \
11 --sample_size 512 896 \
12 --density 5 \ # Control the sparsity of tracking points
13 --gpu <gpu_id> \ # the gpu id1python demo.py \
2 --prompt <"prompt text"> \ # prompt text
3 --checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
4 --output_dir <output_dir> \ # output directory
5 --input_path <input_path> \ # the reference image or video path
6 --camera_motion "path" \ # if camera motion type is "path", --pose_file is needed
7 --pose_file <pose_file_mp4> \ # "Pi3" automatically estimates the camera pose from this video file
8 --tracking_method <tracking_method> \ # the tracking method (moge, DELTA). For image input, 'moge' is necessary.
9 --override_extrinsics <override/append> \ # how to apply camera motion: "override" to replace original camera, "append" to build upon it
10 --video_length=97 \
11 --sample_size 512 896 \
12 --density 5 \ # Control the sparsity of tracking points
13 --gpu <gpu_id> \ # the gpu id
1python demo.py \
2 --prompt <"prompt text"> \ # prompt text
3 --checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
4 --input_path <input_path> \ # the reference image path
5 --object_motion <object_motion> \ # the object motion type (up, down, left, right)
6 --object_mask <object_mask_path> \ # the object mask path
7 --tracking_method <tracking_method> \ # the tracking method (moge, DELTA). For image input, 'moge' is nesserary.
8 --sample_size 512 896 \
9 --video_length=49 \
10 --density 30 \
11 --gpu <gpu_id> \ # the gpu id@misc{sheng2026FlexAM,
title={FlexAM: Flexible Appearance-Motion Decomposition for Versatile Video Generation Control},
author={Sheng, Mingzhi and Gu, Zekai and Li, Peng and Lin, Cheng and Guo, Hao-Xiang and Chen, Ying-Cong and Liu, Yuan},
year={2026},
eprint={2602.13185},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2602.13185},
}