sypyp
commited on
Commit
·
94ecc99
1
Parent(s):
39d9ad7
add readme
Browse files
readme.md
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Wan2.1 I2V model (480p)
|
2 |
+
|
3 |
+
example
|
4 |
+
|
5 |
+
```python
|
6 |
+
from diffusers.utils import load_image, export_to_video
|
7 |
+
from transformers import CLIPVisionModel, CLIPImageProcessor, UMT5EncoderModel, AutoTokenizer
|
8 |
+
from diffusers import WanI2VPipeline, WanTransformer3DModel, UniPCMultistepScheduler, AutoencoderKLWan
|
9 |
+
import torch
|
10 |
+
|
11 |
+
tokenizer = AutoTokenizer.from_pretrained("google/umt5-xxl")
|
12 |
+
text_encoder = UMT5EncoderModel.from_pretrained("google/umt5-xxl", torch_dtype=torch.bfloat16)
|
13 |
+
vae = AutoencoderKLWan.from_pretrained("StevenZhang/Wan2.1-VAE_Diff")
|
14 |
+
|
15 |
+
|
16 |
+
pipe = WanI2VPipeline.from_pretrained(
|
17 |
+
'ypyp/wan2.1_i2v_480p',
|
18 |
+
tokenizer=tokenizer,
|
19 |
+
text_encoder=text_encoder,
|
20 |
+
vae=vae,
|
21 |
+
)
|
22 |
+
|
23 |
+
image = load_image(
|
24 |
+
"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg"
|
25 |
+
)
|
26 |
+
device = "cuda"
|
27 |
+
seed = 0
|
28 |
+
prompt = ("An astronaut hatching from an egg, on the surface of the moon, the darkness and depth of space realised in "
|
29 |
+
"the background. High quality, ultrarealistic detail and breath-taking movie-like camera shot.")
|
30 |
+
generator = torch.Generator(device=device).manual_seed(seed)
|
31 |
+
|
32 |
+
pipe.to(device)
|
33 |
+
pipe.enable_model_cpu_offload()
|
34 |
+
|
35 |
+
inputs = {
|
36 |
+
'image': image,
|
37 |
+
"prompt": prompt,
|
38 |
+
'max_area': 480 * 832,
|
39 |
+
"generator": generator,
|
40 |
+
"num_inference_steps": 50,
|
41 |
+
"guidance_scale": 5.0,
|
42 |
+
"num_frames": 81,
|
43 |
+
"max_sequence_length": 512,
|
44 |
+
"output_type": "np",
|
45 |
+
'flow_shift': 3.0
|
46 |
+
}
|
47 |
+
|
48 |
+
output = pipe(**inputs).frames[0]
|
49 |
+
export_to_video(output, "output.mp4", fps=15)
|
50 |
+
|
51 |
+
```
|