Skip to content

Commit 3d6a0df

Browse files
authored
Add ComfyUI custom node for inference (hao-ai-lab#596)
1 parent c3c6f83 commit 3d6a0df

17 files changed

+2837
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,5 @@ docs/source/inference/examples/
5959

6060
# Static images
6161
!docs/source/_static/images/**/*.png
62+
!comfyui/assets/**/*.png
63+
!comfyui/assets/**/*.gif

comfyui/README.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# ComfyUI-FastVideo
2+
3+
A custom node suite for ComfyUI that provides accelerated video generation using [FastVideo](https://github.com/hao-ai-labs/FastVideo). See the [blog post](https://hao-ai-lab.github.io/blogs/fastvideo/) about FastVideo V1 to learn more.
4+
5+
## Multi-GPU Parallel Inference
6+
7+
One of the key features ComfyUI-FastVideo brings to ComfyUI is its ability to distribute the generation workload across multiple GPUs, resulting in significantly faster inference times.
8+
9+
![Wan2.1-I2V-14B-480P-Diffusers](./assets/wani2v.gif)
10+
11+
Example of Wan2.1-I2V-14B-480P-Diffusers model running on 4 GPUs.
12+
## Features
13+
14+
- Generate high-quality videos from text prompts and images
15+
- Configurable video parameters (prompt, resolution, frame count, FPS)
16+
- Support for multiple GPUs with tensor and sequence parallelism
17+
- Advanced configuration options for VAE, Text Encoder, and DIT components
18+
- Interruption/cancellation support for long-running generations
19+
20+
## Installation
21+
22+
### Requirements
23+
24+
- [ComfyUI](https://github.com/comfyanonymous/ComfyUI)
25+
- CUDA-capable GPU(s) with sufficient VRAM
26+
27+
### Install using ComfyUI Manager
28+
29+
Coming soon!
30+
31+
### Manual Installation
32+
33+
#### Copy the FastVideo `comfyui` directory into your ComfyUI custom_nodes directory:
34+
35+
```bash
36+
cp -r /path/to/FastVideo/comfyui /path/to/ComfyUI/custom_nodes/FastVideo
37+
```
38+
39+
#### Install dependencies:
40+
41+
Currently, the only dependency is `fastvideo`, which can be installed using pip.
42+
43+
```bash
44+
pip install fastvideo
45+
```
46+
47+
#### Install missing custom nodes:
48+
49+
`ComfyUI-VideoHelperSuite`:
50+
51+
```bash
52+
cd /path/to/ComfyUI/custom_nodes
53+
git clone https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite.git
54+
```
55+
56+
If you're seeing `ImportError: libGL.so.1: cannot open shared object file: No such file or directory`,
57+
you may need to install ffmpeg
58+
59+
```bash
60+
apt-get update && apt-get install ffmpeg
61+
```
62+
63+
## Usage
64+
65+
After installation, the following nodes will be available in the ComfyUI interface under the "fastvideo" category:
66+
67+
- **Video Generator**: The main node for generating videos from prompts
68+
- **Inference Args**: Configure video generation parameters
69+
- **VAE Config**
70+
- **Text Encoder Config**
71+
- **DIT Config**
72+
- **Load Image Path**: Load images for potential conditioning
73+
74+
You may have noticed many arguments on the nodes have 'auto' as the default value. This is because FastVideo will automatically detect the best values for these parameters based on the model and the hardware. However, you can also manually configure these parameters to get the best performance for your specific use case. We plan on releasing more optimized workflow files for different models and hardware configurations in the future.
75+
76+
You can see what some of the default configurations are by looking at the FastVideo repo:
77+
- [Wan2.1-I2V-14B-480P-Diffusers](https://github.com/hao-ai-lab/FastVideo/blob/main/fastvideo/v1/configs/wan_14B_i2v_480p_pipeline.json)
78+
- [FastHunyuan-diffusers](https://github.com/hao-ai-lab/FastVideo/blob/main/fastvideo/v1/configs/fasthunyuan_t2v.json)
79+
80+
### Node Configuration
81+
82+
#### Video Generator
83+
84+
- **prompt**: Text description of the video to generate
85+
- **output_path**: Directory where generated videos will be saved
86+
- **num_gpus**: Number of GPUs to use for generation
87+
- **model_path**: Path to the FastVideo model
88+
- **embedded_cfg_scale**: Classifier-free guidance scale
89+
- **sp_size**: Sequence parallelism size (usually should match num_gpus)
90+
- **tp_size**: Tensor parallelism size (usually should match num_gpus)
91+
- **precision**: Model precision (fp16 or bf16)
92+
93+
`model_path takes either a model id from huggingface or a local path to a model. Models by default will be downloaded to ~/.cache/huggingface/hub/ and cached for subsequent runs.`
94+
95+
#### Inference Args
96+
97+
- **height/width**: Resolution of the output video
98+
- **num_frames**: Number of frames to generate
99+
- **num_inference_steps**: Number of diffusion steps per frame
100+
- **guidance_scale**: Classifier-free guidance scale
101+
- **flow_shift**: Frame flow shift parameter
102+
- **seed**: Random seed for reproducible generation
103+
- **fps**: Frames per second of the output video
104+
- **image_path**: Optional path to input image for conditioning (for i2v models)
105+
106+
## Memory Management
107+
108+
Models will remain loaded in GPU memory between runs when you only change inference arguments (such as prompt, resolution, frame count, FPS, guidance scale, etc.) or the prompt text. This allows for faster subsequent generations since the model doesn't need to be reloaded.
109+
110+
However, if you need to change the following parameters, you will need to restart the ComfyUI server:
111+
- **Number of GPUs** (`num_gpus`)
112+
- **Model path** (`model_path`)
113+
- **Tensor parallelism size** (`tp_size`)
114+
- **Sequence parallelism size** (`sp_size`)
115+
116+
These parameters affect the model's distribution across GPUs and require a complete reinitialization of the model pipeline.
117+
118+
## Example workflows
119+
120+
### Text to Video
121+
122+
FastVideo-FastHunyuan-diffusers
123+
124+
![FastVideo-FastHunyuan-diffusers](./assets/fasthunyuan.png)
125+
126+
- [FastHunyuan-diffusers.json](./examples/FastHunyuan-diffusers.json)
127+
128+
### Image to Video
129+
130+
Wan2.1-I2V-14B-480P-Diffusers
131+
132+
![Wan2.1-I2V-14B-480P-Diffusers](./assets/wani2v.png)
133+
134+
- [Wan2.1-I2V-14B-480P-Diffusers.json](./examples/Wan2.1-I2V-14B-480P-Diffusers.json)
135+
136+
## License
137+
138+
This project is licensed under Apache 2.0.

comfyui/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .video_generator.nodes import (NODE_CLASS_MAPPINGS,
2+
NODE_DISPLAY_NAME_MAPPINGS)
3+
4+
WEB_DIRECTORY = "./web"
5+
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS', 'WEB_DIRECTORY']

comfyui/assets/fasthunyuan.png

1.25 MB
Loading

comfyui/assets/wani2v.gif

8.69 MB
Loading

comfyui/assets/wani2v.png

769 KB
Loading

0 commit comments

Comments
 (0)