Rayzl commited on
Commit
3371081
·
verified ·
1 Parent(s): 43df10c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +58 -3
README.md CHANGED
@@ -1,3 +1,58 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ base_model:
4
+ - Wan-AI/Wan2.2-I2V-A14B-Diffusers
5
+ - lightx2v/Wan2.2-Lightning
6
+ pipeline_tag: text-to-video
7
+ ---
8
+ This model is a merger of [Wan-AI/Wan2.2-I2V-A14B-Diffusers](https://huggingface.co/Wan-AI/Wan2.2-I2V-A14B-Diffusers) and [Wan2.2-Lightning v1 model](https://huggingface.co/lightx2v/Wan2.2-Lightning/tree/main/Wan2.2-I2V-A14B-4steps-lora-rank64-Seko-V1), it can be run with diffusers pipeline.
9
+
10
+ Running with diffusers:
11
+ ```python
12
+ import torch
13
+ import numpy as np
14
+ from diffusers import WanImageToVideoPipeline
15
+ from diffusers.utils import export_to_video, load_image
16
+
17
+ model_id = "FastDM/Wan2.2-I2V-A14B-Merge-Lightning-V1.0-Diffusers"
18
+ dtype = torch.bfloat16
19
+ device = "cuda"
20
+
21
+ pipe = WanImageToVideoPipeline.from_pretrained(model_id, torch_dtype=dtype)
22
+ pipe.to(device)
23
+
24
+
25
+ image = load_image(
26
+ "https://huggingface.co/datasets/YiYiXu/testing-images/resolve/main/wan_i2v_input.JPG"
27
+ )
28
+ max_area = 480 * 832
29
+ aspect_ratio = image.height / image.width
30
+ mod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[1]
31
+ height = round(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_value
32
+ width = round(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_value
33
+ image = image.resize((width, height))
34
+ prompt = "Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside."
35
+
36
+ negative_prompt = "色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走"
37
+ generator = torch.Generator(device=device).manual_seed(0)
38
+ output = pipe(
39
+ image=image,
40
+ prompt=prompt,
41
+ negative_prompt=negative_prompt,
42
+ height=height,
43
+ width=width,
44
+ num_frames=81,
45
+ guidance_scale=3.5,
46
+ num_inference_steps=40,
47
+ generator=generator,
48
+ ).frames[0]
49
+ export_to_video(output, "i2v_output.mp4", fps=16)
50
+
51
+ ```
52
+
53
+ **For speedup infer**, you can use [FastDM](https://github.com/KE-AI-ENG/FastDM), which generate a 720x1280 vedio with H20 only cost 120s.
54
+
55
+ test command:
56
+ ```
57
+ python gen.py --model-path FastDM/Wan2.2-I2V-A14B-Merge-Lightning-V1.0-Diffusers --architecture wan --guidance-scale 1.0 --height 480 --width 832 --steps 4 --use-fp8 --output-path ./wan-a14b-lightningv1.1-fp8-guid1.mp4 --num-frames 81 --fps 16 --task i2v --prompts [PROMPTS] --image-path [PATH/TO/IMAGE]
58
+ ```