Update README.md
Browse files
README.md
CHANGED
@@ -2,61 +2,19 @@
|
|
2 |
library_name: diffusers
|
3 |
---
|
4 |
|
5 |
-
|
6 |
|
7 |
-
This project is a first step in integrating [HunyuanVideo](https://github.com/Tencent/HunyuanVideo) into [Diffusers](https://github.com/huggingface/diffusers).
|
8 |
-
|
9 |
-
**All credit go to [Tencent](https://github.com/Tencent) for the original [HunyuanVideo](https://github.com/Tencent/HunyuanVideo) project.**
|
10 |
-
|
11 |
-
**Thank you to Huggingface for the [Diffusers](https://github.com/huggingface/diffusers) library.** Special shout-out to [@a-r-r-o-w](https://github.com/a-r-r-o-w) for his work on integrating HunyuanVideo.
|
12 |
-
|
13 |
-
The License is inherted from [HunyuanVideo](https://github.com/Tencent/HunyuanVideo).
|
14 |
-
|
15 |
-
This library is provided as-is and will be superseded by the official release of HunyuanVideo via [Diffusers](https://github.com/huggingface/diffusers). Please help out if you can on the [PR](https://github.com/huggingface/diffusers/pull/10136).
|
16 |
-
|
17 |
-
|
18 |
-
## Installation
|
19 |
|
20 |
```bash
|
21 |
-
pip install git+https://github.com/
|
22 |
```
|
23 |
|
24 |
-
You will also need to install [flash-attn](https://github.com/Dao-AILab/flash-attention) for now.
|
25 |
-
|
26 |
-
## Usage
|
27 |
-
|
28 |
-
Please note that you need at least 80GB VRAM to run this pipeline. CPU offloading is having issues at the moment (PRs welcome!).
|
29 |
-
|
30 |
```python
|
31 |
import torch
|
32 |
-
from hyvideo.diffusion.pipelines.pipeline_hunyuan_video import HunyuanVideoPipeline
|
33 |
-
from hyvideo.modules.models import HYVideoDiffusionTransformer
|
34 |
-
from hyvideo.vae.autoencoder_kl_causal_3d import AutoencoderKLCausal3D
|
35 |
-
|
36 |
pipe = HunyuanVideoPipeline.from_pretrained(
|
37 |
-
|
38 |
-
transformer=HYVideoDiffusionTransformer.from_pretrained(
|
39 |
-
'magespace/hyvideo-diffusers',
|
40 |
-
torch_dtype=torch.bfloat16,
|
41 |
-
subfolder='transformer'
|
42 |
-
),
|
43 |
-
vae=AutoencoderKLCausal3D.from_pretrained(
|
44 |
-
'magespace/hyvideo-diffusers',
|
45 |
-
torch_dtype=torch.bfloat16,
|
46 |
-
subfolder='vae'
|
47 |
-
),
|
48 |
torch_dtype=torch.bfloat16,
|
49 |
)
|
50 |
-
pipe = pipe.to('cuda')
|
51 |
-
pipe.vae.enable_tiling()
|
52 |
-
```
|
53 |
-
|
54 |
-
Then running:
|
55 |
-
|
56 |
-
```python
|
57 |
-
prompt = "Close-up, A little girl wearing a red hoodie in winter strikes a match. The sky is dark, there is a layer of snow on the ground, and it is still snowing lightly. The flame of the match flickers, illuminating the girl's face intermittently."
|
58 |
-
|
59 |
-
result = pipe(prompt)
|
60 |
```
|
61 |
|
62 |
Post-processing:
|
@@ -65,11 +23,7 @@ Post-processing:
|
|
65 |
import PIL.Image
|
66 |
from diffusers.utils import export_to_video
|
67 |
|
68 |
-
|
69 |
-
output = (output * 255).clip(0, 255).astype("uint8")
|
70 |
-
output = [PIL.Image.fromarray(x) for x in output]
|
71 |
-
|
72 |
-
export_to_video(output, "output.mp4", fps=24)
|
73 |
```
|
74 |
|
75 |
For faster generation, you can optimize the `transformer` with `torch.compile`. Additionally, increasing `shift` in the scheduler can allow for lower step values as shown in the original paper.
|
|
|
2 |
library_name: diffusers
|
3 |
---
|
4 |
|
5 |
+
This is a development model meant to help test the HunyuanVideoPipeline integration to diffusers. Please help out if you can on the [PR](https://github.com/huggingface/diffusers/pull/10136).
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
```bash
|
9 |
+
pip install -qq git+https://github.com/huggingface/diffusers.git@hunyuan-video
|
10 |
```
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
```python
|
13 |
import torch
|
|
|
|
|
|
|
|
|
14 |
pipe = HunyuanVideoPipeline.from_pretrained(
|
15 |
+
"magespace/hyvideo-diffusers-dev",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
torch_dtype=torch.bfloat16,
|
17 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
```
|
19 |
|
20 |
Post-processing:
|
|
|
23 |
import PIL.Image
|
24 |
from diffusers.utils import export_to_video
|
25 |
|
26 |
+
export_to_video(result.frames[0], "output.mp4", fps=24)
|
|
|
|
|
|
|
|
|
27 |
```
|
28 |
|
29 |
For faster generation, you can optimize the `transformer` with `torch.compile`. Additionally, increasing `shift` in the scheduler can allow for lower step values as shown in the original paper.
|