1+ import os
2+ import argparse
3+ from fastvideo import VideoGenerator , SamplingParam
4+
5+ def main (args ):
6+ os .makedirs (args .output_path , exist_ok = True )
7+ # Create a video generator with a pre-trained model
8+ generator = VideoGenerator .from_pretrained (
9+ "Wan-AI/Wan2.1-T2V-14B-Diffusers" ,
10+ num_gpus = args .num_gpus , # Adjust based on your hardware
11+ STA_mode = args .STA_mode ,
12+ skip_time_steps = args .skip_time_steps
13+ )
14+
15+ # Prompts for your video
16+ prompt = args .prompt
17+ prompt_path = args .prompt_path
18+ negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards"
19+
20+ if prompt_path is not None :
21+ with open (prompt_path , "r" ) as f :
22+ prompts = f .readlines ()
23+ else :
24+ prompts = [prompt ]
25+
26+ params = SamplingParam (
27+ height = args .height ,
28+ width = args .width ,
29+ num_frames = args .num_frames ,
30+ num_inference_steps = args .num_inference_steps ,
31+ fps = args .fps ,
32+ guidance_scale = args .guidance_scale ,
33+ seed = args .seed ,
34+ return_frames = True , # Also return frames from this call (defaults to False)
35+ output_path = args .output_path , # Controls where videos are saved
36+ save_video = True ,
37+ negative_prompt = negative_prompt
38+ )
39+
40+ # Generate the video
41+ for prompt in prompts :
42+ video = generator .generate_video (
43+ prompt ,
44+ sampling_param = params ,
45+ )
46+
47+ if __name__ == '__main__' :
48+ parser = argparse .ArgumentParser ()
49+ parser .add_argument ("--prompt" , type = str , default = "A man is dancing." )
50+ parser .add_argument ("--prompt_path" , type = str , default = None )
51+ parser .add_argument ("--height" , type = int , default = 768 )
52+ parser .add_argument ("--width" , type = int , default = 1280 )
53+ parser .add_argument ("--num_frames" , type = int , default = 69 )
54+ parser .add_argument ("--num_inference_steps" , type = int , default = 50 )
55+ parser .add_argument ("--fps" , type = int , default = 16 )
56+ parser .add_argument ("--guidance_scale" , type = float , default = 5.0 )
57+ parser .add_argument ("--seed" , type = int , default = 12345 )
58+ parser .add_argument ("--output_path" , type = str , default = "my_videos/" )
59+ parser .add_argument ("--num_gpus" , type = int , default = 1 )
60+ parser .add_argument ("--STA_mode" , type = str , default = "STA_searching" )
61+ parser .add_argument ("--skip_time_steps" , type = int , default = 12 )
62+ args = parser .parse_args ()
63+ main (args )
0 commit comments