Views
No views yet

1from fastvideo import VideoGenerator, SamplingParam
2import json
3# from fastvideo.configs.sample import SamplingParam
4
5OUTPUT_PATH = "video_samples_self_forcing_causal_wan2_2_14B_i2v"
6def main():
7 # FastVideo will automatically use the optimal default arguments for the
8 # model.
9 # If a local path is provided, FastVideo will make a best effort
10 # attempt to identify the optimal arguments.
11 generator = VideoGenerator.from_pretrained(
12 "FastVideo/SFWan2.2-I2V-A14B-Preview-Diffusers",
13 # FastVideo will automatically handle distributed setup
14 num_gpus=1,
15 use_fsdp_inference=True,
16 dit_cpu_offload=True, # DiT need to be offloaded for MoE
17 dit_precision="fp32",
18 vae_cpu_offload=False,
19 text_encoder_cpu_offload=True,
20 dmd_denoising_steps=[1000, 850, 700, 550, 350, 275, 200, 125],
21 # Set pin_cpu_memory to false if CPU RAM is limited and there're no frequent CPU-GPU transfer
22 pin_cpu_memory=True,
23 # image_encoder_cpu_offload=False,
24 )
25
26 sampling_param = SamplingParam.from_pretrained("FastVideo/SFWan2.2-I2V-A14B-Preview-Diffusers")
27 sampling_param.num_frames = 81
28 sampling_param.width = 832
29 sampling_param.height = 480
30 sampling_param.seed = 1000
31
32 with open("prompts/mixkit_i2v.jsonl", "r") as f:
33 prompt_image_pairs = json.load(f)
34
35 for prompt_image_pair in prompt_image_pairs:
36 prompt = prompt_image_pair["prompt"]
37 image_path = prompt_image_pair["image_path"]
38 _ = generator.generate_video(prompt, image_path=image_path, output_path=OUTPUT_PATH, save_video=True, sampling_param=sampling_param)
39
40
41if __name__ == "__main__":
42 main()