Add sample usage and video-generation tag
#2
by
nielsr
HF Staff
- opened
README.md
CHANGED
@@ -1,11 +1,53 @@
|
|
1 |
---
|
2 |
-
license: mit
|
3 |
library_name: diffusers
|
|
|
4 |
pipeline_tag: text-to-video
|
|
|
|
|
5 |
---
|
6 |
|
7 |
# DCM: Dual-Expert Consistency Model for Efficient and High-Quality Video Generation
|
8 |
|
9 |
-
This repository hosts the Dual-Expert Consistency Model (DCM) as presented in the paper [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
|
|
|
|
|
|
|
|
|
|
1 |
---
|
|
|
2 |
library_name: diffusers
|
3 |
+
license: mit
|
4 |
pipeline_tag: text-to-video
|
5 |
+
tags:
|
6 |
+
- video-generation
|
7 |
---
|
8 |
|
9 |
# DCM: Dual-Expert Consistency Model for Efficient and High-Quality Video Generation
|
10 |
|
11 |
+
This repository hosts the Dual-Expert Consistency Model (DCM) as presented in the paper [Dual-Expert Consistency Model for Efficient and High-Quality Video Generation](https://huggingface.co/papers/2506.03123). DCM addresses the challenge of applying Consistency Models to video diffusion, which often leads to temporal inconsistency and loss of detail. By using a dual-expert approach, DCM achieves state-of-the-art visual quality with significantly reduced sampling steps.
|
12 |
+
|
13 |
+
For more information, please refer to the project's [Github repository](https://github.com/Vchitect/DCM).
|
14 |
+
|
15 |
+
## Usage
|
16 |
+
|
17 |
+
You can use this model with the `diffusers` library. Make sure you have `diffusers`, `transformers`, `torch`, `accelerate`, and `imageio` (with `imageio-ffmpeg` for MP4/GIF saving) installed.
|
18 |
+
|
19 |
+
```bash
|
20 |
+
pip install diffusers transformers torch accelerate imageio[ffmpeg]
|
21 |
+
```
|
22 |
+
|
23 |
+
Here is a quick example to generate a video:
|
24 |
+
|
25 |
+
```python
|
26 |
+
from diffusers import DiffusionPipeline
|
27 |
+
import torch
|
28 |
+
import imageio
|
29 |
+
|
30 |
+
# Load the pipeline
|
31 |
+
# The custom_pipeline argument is necessary because the pipeline class (WanPipeline)
|
32 |
+
# is defined within the repository and not part of the standard diffusers library.
|
33 |
+
pipe = DiffusionPipeline.from_pretrained("Vchitect/DCM", torch_dtype=torch.float16, custom_pipeline="Vchitect/DCM", trust_remote_code=True)
|
34 |
+
pipe.to("cuda")
|
35 |
+
|
36 |
+
# Define the prompt and generation parameters
|
37 |
+
prompt = "A futuristic car driving through a neon-lit city at night"
|
38 |
+
generator = torch.Generator(device="cuda").manual_seed(0) # for reproducibility
|
39 |
+
|
40 |
+
# Generate video frames
|
41 |
+
video_frames = pipe(
|
42 |
+
prompt=prompt,
|
43 |
+
num_frames=16, # number of frames to generate
|
44 |
+
num_inference_steps=4, # DCM excels at efficient generation in few steps
|
45 |
+
guidance_scale=7.5, # Classifier-free guidance scale
|
46 |
+
generator=generator,
|
47 |
+
).frames[0] # Assuming the output is a list containing one video (list of frames)
|
48 |
|
49 |
+
# Save the generated video
|
50 |
+
output_path = "generated_video.gif" # You can change this to .mp4 if imageio[ffmpeg] is properly set up
|
51 |
+
imageio.mimsave(output_path, video_frames, fps=8) # frames per second
|
52 |
+
print(f"Video saved to {output_path}")
|
53 |
+
```
|