FlexAM: Flexible Appearance-Motion Decomposition for Versatile Video Generation Control
2
16 commits
6 linked in READMEs
updated Aug 17, 2026
Mingzhi Sheng1*, Zekai Gu2*, Peng Li2, Cheng Lin3, Hao-Xiang Guo4, Ying-Cong Chen1,2β , Yuan Liu2β
1HKUST(GZ), 2HKUST, 3MUST, 4Tsinghua University
*Equal Contribution, β Corresponding Authors

π’ 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.
Before running any inference (Python or ComfyUI), please setup the environment and download the checkpoints.
Clone the repository and create conda environment:
git clone https://github.com/IGL-HKUST/FlexAM
conda create -n flexam python=3.10
conda activate flexam
Install pytorch, we recommend Pytorch 2.5.1 with CUDA 12.1:
pip install torch==2.5.1 torchvision==0.20.1 --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt
We rely on several external modules (MoGe, Pi3, etc.).
mkdir -p submodules
git submodule update --init --recursive
pip install -r requirements.txt
Download the FlexAM checkpoint and place it in thecheckpoints/ directory.
We provide two ways to use FlexAM: Python Script and ComfyUI.
We provide a native node for seamless integration into ComfyUI workflows.
β οΈ Note: Currently, the ComfyUI node supports Motion Transfer, Foreground Edit, and Background Edit. For Camera Control and Object Manipulation, please use the Python script.
Since we are not yet in the Manager, please install manually:
cd ComfyUI/custom_nodes/
git clone https://github.com/IGL-HKUST/FlexAM
cd FlexAM
pip install -r requirements.txt
ComfyUI/models/checkpoints.We provide a inference script for our tasks. Please refer to run_demo.sh to run the demo.py script.
Or you can run these tasks one by one as follows.

python demo.py \
--prompt <"prompt text"> \ # prompt text
--checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
--output_dir <output_dir> \ # output directory
--input_path <input_path> \ # the reference video path
--repaint <True/repaint_path > \ # the repaint first frame image path of input source video or use FLUX to repaint the first frame \
--video_length=97 \
--sample_size 512 896 \
--generate_type='full_edit' \
--density 10 \ # Control the sparsity of tracking points
--gpu <gpu_id> \ # the gpu id

python demo.py \
--prompt <"prompt text"> \ # prompt text
--checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
--output_dir <output_dir> \ # output directory
--input_path <input_path> \ # the reference video path
--repaint <True/repaint_path > \ # the repaint first frame image path of input source video or use FLUX to repaint the first frame \
--mask_path <mask_path> \ # White (255) represents the foreground to be edited, and black (0) remains unchanged
--video_length=97 \
--sample_size 512 896 \
--generate_type='foreground_edit' \
--dilation_pixels=30 \ # Dilation pixels for mask processing in foreground_edit mode
--density 10 \ # Control the sparsity of tracking points
--gpu <gpu_id> \ # the gpu id

python demo.py \
--prompt <"prompt text"> \ # prompt text
--checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
--output_dir <output_dir> \ # output directory
--input_path <input_path> \ # the reference video path
--repaint <True/repaint_path > \ # the repaint first frame image path of input source video or use FLUX to repaint the first frame \
--mask_path <mask_path> \ # White (255) represents the unchanged foreground, while the background indicates the area to be edited
--video_length=97 \
--sample_size 512 896 \
--generate_type='background_edit' \
--density 10 \ # Control the sparsity of tracking points
--gpu <gpu_id> \ # the gpu id

We provide three camera control methods: 1. Use predefined templates; 2. Use a pose text file (pose txt); 3. Input another video, where the "Pi3" automatically estimates the camera pose from it and applies it to the video to be generated.
We provide several template camera motion types, you can choose one of them. In practice, we find that providing a description of the camera motion in prompt will get better results.
python demo.py \
--prompt <"prompt text"> \ # prompt text
--checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
--output_dir <output_dir> \ # output directory
--input_path <input_path> \ # the reference image or video path
--camera_motion <camera_motion> \ # the camera motion type, see examples below
--tracking_method <tracking_method> \ # the tracking method (moge, DELTA). For image input, 'moge' is necessary.
--override_extrinsics <override/append> \ # how to apply camera motion: "override" to replace original camera, "append" to build upon it
--video_length=97 \
--sample_size 512 896 \
--density 5 \ # Control the sparsity of tracking points
--gpu <gpu_id> \ # the gpu id
Here are some tips for camera motion:
Multiple transformations can be combined using semicolon (;) as separator:
Notes:
python demo.py \
--prompt <"prompt text"> \ # prompt text
--checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
--output_dir <output_dir> \ # output directory
--input_path <input_path> \ # the reference image or video path
--camera_motion "path" \ # if camera motion type is "path", --pose_file is needed
--pose_file <pose_file_txt> \ # txt file of camera pose, Each line corresponds to one frame
--tracking_method <tracking_method> \ # the tracking method (moge, DELTA). For image input, 'moge' is necessary.
--override_extrinsics <override/append> \ # how to apply camera motion: "override" to replace original camera, "append" to build upon it
--video_length=97 \
--sample_size 512 896 \
--density 5 \ # Control the sparsity of tracking points
--gpu <gpu_id> \ # the gpu id
python demo.py \
--prompt <"prompt text"> \ # prompt text
--checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
--output_dir <output_dir> \ # output directory
--input_path <input_path> \ # the reference image or video path
--camera_motion "path" \ # if camera motion type is "path", --pose_file is needed
--pose_file <pose_file_mp4> \ # "Pi3" automatically estimates the camera pose from this video file
--tracking_method <tracking_method> \ # the tracking method (moge, DELTA). For image input, 'moge' is necessary.
--override_extrinsics <override/append> \ # how to apply camera motion: "override" to replace original camera, "append" to build upon it
--video_length=97 \
--sample_size 512 896 \
--density 5 \ # Control the sparsity of tracking points
--gpu <gpu_id> \ # the gpu id
We provide several template object manipulation types, you can choose one of them. In practice, we find that providing a description of the object motion in prompt will get better results.
python demo.py \
--prompt <"prompt text"> \ # prompt text
--checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
--input_path <input_path> \ # the reference image path
--object_motion <object_motion> \ # the object motion type (up, down, left, right)
--object_mask <object_mask_path> \ # the object mask path
--tracking_method <tracking_method> \ # the tracking method (moge, DELTA). For image input, 'moge' is nesserary.
--sample_size 512 896 \
--video_length=49 \
--density 30 \
--gpu <gpu_id> \ # the gpu id
It should be noted that depending on the tracker you choose, you may need to modify the scale of translation.
This project builds upon several excellent open source projects:
We thank the authors and contributors of these projects for their valuable contributions to the open source community!
If you find FlexAM useful for your research, please cite our paper:
@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},
}
This model checkpoint is based on FlexAM.
β οΈ Usage Note: By downloading or using these weights, you agree to comply with the Snap Inc. License regarding the DELTA modules. Please refer to the LICENSE file in this repository for the full text.
FlexAM: Flexible Appearance-Motion Decomposition for Versatile Video Generation Control
2
16 commits
6 linked in READMEs
updated Aug 17, 2026
Mingzhi Sheng1*, Zekai Gu2*, Peng Li2, Cheng Lin3, Hao-Xiang Guo4, Ying-Cong Chen1,2β , Yuan Liu2β
1HKUST(GZ), 2HKUST, 3MUST, 4Tsinghua University
*Equal Contribution, β Corresponding Authors

π’ 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.
Before running any inference (Python or ComfyUI), please setup the environment and download the checkpoints.
Clone the repository and create conda environment:
git clone https://github.com/IGL-HKUST/FlexAM
conda create -n flexam python=3.10
conda activate flexam
Install pytorch, we recommend Pytorch 2.5.1 with CUDA 12.1:
pip install torch==2.5.1 torchvision==0.20.1 --index-url https://download.pytorch.org/whl/cu121
pip install -r requirements.txt
We rely on several external modules (MoGe, Pi3, etc.).
mkdir -p submodules
git submodule update --init --recursive
pip install -r requirements.txt
Download the FlexAM checkpoint and place it in thecheckpoints/ directory.
We provide two ways to use FlexAM: Python Script and ComfyUI.
We provide a native node for seamless integration into ComfyUI workflows.
β οΈ Note: Currently, the ComfyUI node supports Motion Transfer, Foreground Edit, and Background Edit. For Camera Control and Object Manipulation, please use the Python script.
Since we are not yet in the Manager, please install manually:
cd ComfyUI/custom_nodes/
git clone https://github.com/IGL-HKUST/FlexAM
cd FlexAM
pip install -r requirements.txt
ComfyUI/models/checkpoints.We provide a inference script for our tasks. Please refer to run_demo.sh to run the demo.py script.
Or you can run these tasks one by one as follows.

python demo.py \
--prompt <"prompt text"> \ # prompt text
--checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
--output_dir <output_dir> \ # output directory
--input_path <input_path> \ # the reference video path
--repaint <True/repaint_path > \ # the repaint first frame image path of input source video or use FLUX to repaint the first frame \
--video_length=97 \
--sample_size 512 896 \
--generate_type='full_edit' \
--density 10 \ # Control the sparsity of tracking points
--gpu <gpu_id> \ # the gpu id

python demo.py \
--prompt <"prompt text"> \ # prompt text
--checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
--output_dir <output_dir> \ # output directory
--input_path <input_path> \ # the reference video path
--repaint <True/repaint_path > \ # the repaint first frame image path of input source video or use FLUX to repaint the first frame \
--mask_path <mask_path> \ # White (255) represents the foreground to be edited, and black (0) remains unchanged
--video_length=97 \
--sample_size 512 896 \
--generate_type='foreground_edit' \
--dilation_pixels=30 \ # Dilation pixels for mask processing in foreground_edit mode
--density 10 \ # Control the sparsity of tracking points
--gpu <gpu_id> \ # the gpu id

python demo.py \
--prompt <"prompt text"> \ # prompt text
--checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
--output_dir <output_dir> \ # output directory
--input_path <input_path> \ # the reference video path
--repaint <True/repaint_path > \ # the repaint first frame image path of input source video or use FLUX to repaint the first frame \
--mask_path <mask_path> \ # White (255) represents the unchanged foreground, while the background indicates the area to be edited
--video_length=97 \
--sample_size 512 896 \
--generate_type='background_edit' \
--density 10 \ # Control the sparsity of tracking points
--gpu <gpu_id> \ # the gpu id

We provide three camera control methods: 1. Use predefined templates; 2. Use a pose text file (pose txt); 3. Input another video, where the "Pi3" automatically estimates the camera pose from it and applies it to the video to be generated.
We provide several template camera motion types, you can choose one of them. In practice, we find that providing a description of the camera motion in prompt will get better results.
python demo.py \
--prompt <"prompt text"> \ # prompt text
--checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
--output_dir <output_dir> \ # output directory
--input_path <input_path> \ # the reference image or video path
--camera_motion <camera_motion> \ # the camera motion type, see examples below
--tracking_method <tracking_method> \ # the tracking method (moge, DELTA). For image input, 'moge' is necessary.
--override_extrinsics <override/append> \ # how to apply camera motion: "override" to replace original camera, "append" to build upon it
--video_length=97 \
--sample_size 512 896 \
--density 5 \ # Control the sparsity of tracking points
--gpu <gpu_id> \ # the gpu id
Here are some tips for camera motion:
Multiple transformations can be combined using semicolon (;) as separator:
Notes:
python demo.py \
--prompt <"prompt text"> \ # prompt text
--checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
--output_dir <output_dir> \ # output directory
--input_path <input_path> \ # the reference image or video path
--camera_motion "path" \ # if camera motion type is "path", --pose_file is needed
--pose_file <pose_file_txt> \ # txt file of camera pose, Each line corresponds to one frame
--tracking_method <tracking_method> \ # the tracking method (moge, DELTA). For image input, 'moge' is necessary.
--override_extrinsics <override/append> \ # how to apply camera motion: "override" to replace original camera, "append" to build upon it
--video_length=97 \
--sample_size 512 896 \
--density 5 \ # Control the sparsity of tracking points
--gpu <gpu_id> \ # the gpu id
python demo.py \
--prompt <"prompt text"> \ # prompt text
--checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
--output_dir <output_dir> \ # output directory
--input_path <input_path> \ # the reference image or video path
--camera_motion "path" \ # if camera motion type is "path", --pose_file is needed
--pose_file <pose_file_mp4> \ # "Pi3" automatically estimates the camera pose from this video file
--tracking_method <tracking_method> \ # the tracking method (moge, DELTA). For image input, 'moge' is necessary.
--override_extrinsics <override/append> \ # how to apply camera motion: "override" to replace original camera, "append" to build upon it
--video_length=97 \
--sample_size 512 896 \
--density 5 \ # Control the sparsity of tracking points
--gpu <gpu_id> \ # the gpu id
We provide several template object manipulation types, you can choose one of them. In practice, we find that providing a description of the object motion in prompt will get better results.
python demo.py \
--prompt <"prompt text"> \ # prompt text
--checkpoint_path <model_path> \ # FlexAM checkpoint path (e.g checkpoints/Diffusion_Transformer/Wan2.2-Fun-5B-FLEXAM)
--input_path <input_path> \ # the reference image path
--object_motion <object_motion> \ # the object motion type (up, down, left, right)
--object_mask <object_mask_path> \ # the object mask path
--tracking_method <tracking_method> \ # the tracking method (moge, DELTA). For image input, 'moge' is nesserary.
--sample_size 512 896 \
--video_length=49 \
--density 30 \
--gpu <gpu_id> \ # the gpu id
It should be noted that depending on the tracker you choose, you may need to modify the scale of translation.
This project builds upon several excellent open source projects:
We thank the authors and contributors of these projects for their valuable contributions to the open source community!
If you find FlexAM useful for your research, please cite our paper:
@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},
}
This model checkpoint is based on FlexAM.
β οΈ Usage Note: By downloading or using these weights, you agree to comply with the Snap Inc. License regarding the DELTA modules. Please refer to the LICENSE file in this repository for the full text.