RhymesAI commited on
Commit
22fddbb
verified
1 Parent(s): d4244db

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +127 -3
README.md CHANGED
@@ -1,3 +1,127 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+ <p align="center">
5
+ <img src="https://huggingface.co/rhymes-ai/Allegro/resolve/main/banner_white.gif">
6
+ </p>
7
+ <p align="center">
8
+ <a href="https://rhymes.ai/allegro_gallery" target="_blank"> Gallery</a> 路 <a href="https://github.com/rhymes-ai/Allegro" target="_blank">GitHub</a> 路 <a href="https://rhymes.ai/blog-details/allegro-advanced-video-generation-model" target="_blank">Blog</a> 路 <a href="https://arxiv.org/abs/2410.15458" target="_blank">Paper</a> 路 <a href="https://discord.com/invite/u8HxU23myj" target="_blank">Discord</a> 路 <a href="https://docs.google.com/forms/d/e/1FAIpQLSfq4Ez48jqZ7ncI7i4GuL7UyCrltfdtrOCDnm_duXxlvh5YmQ/viewform" target="_blank">Join Waitlist</a> (Try it on Discord!)
9
+
10
+ </p>
11
+
12
+ # Gallery
13
+ <img src="https://huggingface.co/rhymes-ai/Allegro/resolve/main/gallery.gif" width="1000" height="800"/>For more demos and corresponding prompts, see the [Allegro Gallery](https://rhymes.ai/allegro_gallery).
14
+
15
+
16
+ # Key Feature
17
+
18
+ - **Open Source**: Full [model weights](https://huggingface.co/rhymes-ai/Allegro) and [code](https://github.com/rhymes-ai/Allegro) available to the community, Apache 2.0!
19
+ - **Versatile Content Creation**: Capable of generating a wide range of content, from close-ups of humans and animals to diverse dynamic scenes.
20
+ - **High-Quality Output**: Generate detailed 6-second videos at 15 FPS with 720x1280 resolution, which can be interpolated to 30 FPS with [EMA-VFI](https://github.com/MCG-NJU/EMA-VFI).
21
+ - **Small and Efficient**: Features a 175M parameter VideoVAE and a 2.8B parameter VideoDiT model. Supports multiple precisions (FP32, BF16, FP16) and uses 9.3 GB of GPU memory in BF16 mode with CPU offloading. Context length is 79.2K, equivalent to 88 frames.
22
+
23
+ # Model info
24
+
25
+ <table>
26
+ <tr>
27
+ <th>Model</th>
28
+ <td>Allegro</td>
29
+ </tr>
30
+ <tr>
31
+ <th>Description</th>
32
+ <td>Text-to-Video Generation Model</td>
33
+ </tr>
34
+ <tr>
35
+ <th>Download</th>
36
+ <td><a href="https://huggingface.co/rhymes-ai/Allegro">Hugging Face</a></td>
37
+ </tr>
38
+ <tr>
39
+ <th rowspan="2">Parameter</th>
40
+ <td>VAE: 175M</td>
41
+ </tr>
42
+ <tr>
43
+ <td>DiT: 2.8B</td>
44
+ </tr>
45
+ <tr>
46
+ <th rowspan="2">Inference Precision</th>
47
+ <td>VAE: FP32/TF32/BF16/FP16 (best in FP32/TF32)</td>
48
+ </tr>
49
+ <tr>
50
+ <td>DiT/T5: BF16/FP32/TF32</td>
51
+ </tr>
52
+ <tr>
53
+ <th>Context Length</th>
54
+ <td>79.2K</td>
55
+ </tr>
56
+ <tr>
57
+ <th>Resolution</th>
58
+ <td>720 x 1280</td>
59
+ </tr>
60
+ <tr>
61
+ <th>Frames</th>
62
+ <td>88</td>
63
+ </tr>
64
+ <tr>
65
+ <th>Video Length</th>
66
+ <td>6 seconds @ 15 FPS</td>
67
+ </tr>
68
+ <tr>
69
+ <th>Single GPU Memory Usage</th>
70
+ <td>9.3G BF16 (with cpu_offload)</td>
71
+ </tr>
72
+ </table>
73
+
74
+
75
+ # Quick start
76
+
77
+ 1. Install the necessary requirements.
78
+
79
+ - Ensure Python >= 3.10, PyTorch >= 2.4, CUDA >= 12.4.
80
+
81
+ - It is recommended to use Anaconda to create a new environment (Python >= 3.10) `conda create -n rllegro python=3.10 -y` to run the following example.
82
+
83
+ - run `pip install git+https://github.com/huggingface/diffusers.git torch==2.4.1 transformers==4.40.1 accelerate sentencepiece imageio imageio-ffmpeg beautifulsoup4`
84
+
85
+ 2. Run inference.
86
+ ```python
87
+ import torch
88
+ from diffusers import AutoencoderKLAllegro, AllegroPipeline
89
+ from diffusers.utils import export_to_video
90
+ vae = AutoencoderKLAllegro.from_pretrained("rhymes-ai/Allegro", subfolder="vae", torch_dtype=torch.float32)
91
+ pipe = AllegroPipeline.from_pretrained(
92
+ "rhymes-ai/Allegro", vae=vae, torch_dtype=torch.bfloat16
93
+ )
94
+ pipe.to("cuda")
95
+ pipe.vae.enable_tiling()
96
+ prompt = "A seaside harbor with bright sunlight and sparkling seawater, with many boats in the water. From an aerial view, the boats vary in size and color, some moving and some stationary. Fishing boats in the water suggest that this location might be a popular spot for docking fishing boats."
97
+
98
+ positive_prompt = """
99
+ (masterpiece), (best quality), (ultra-detailed), (unwatermarked),
100
+ {}
101
+ emotional, harmonious, vignette, 4k epic detailed, shot on kodak, 35mm photo,
102
+ sharp focus, high budget, cinemascope, moody, epic, gorgeous
103
+ """
104
+
105
+ negative_prompt = """
106
+ nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality,
107
+ low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry.
108
+ """
109
+
110
+ prompt = prompt.format(prompt.lower().strip())
111
+
112
+ video = pipe(prompt, negative_prompt=negative_prompt, guidance_scale=7.5, max_sequence_length=512, num_inference_steps=100, generator = torch.Generator(device="cuda:0").manual_seed(42)).frames[0]
113
+ export_to_video(video, "output.mp4", fps=15)
114
+ ```
115
+
116
+ Use `pipe.enable_sequential_cpu_offload()` to offload the model into CPU for less GPU memory cost (about 9.3G, compared to 27.5G if CPU offload is not enabled), but the inference time will increase significantly.
117
+
118
+ 3. (Optional) Interpolate the video to 30 FPS.
119
+
120
+ It is recommended to use [EMA-VFI](https://github.com/MCG-NJU/EMA-VFI) to interpolate the video from 15 FPS to 30 FPS.
121
+
122
+ For better visual quality, please use imageio to save the video.
123
+
124
+ 4. For faster inference such Context Parallel, PAB, please refer to our [github repo](https://github.com/rhymes-ai/Allegro).
125
+
126
+ # License
127
+ This repo is released under the Apache 2.0 License.