1+ #!/usr/bin/env python3
2+ """
3+ Simple script to generate a video using the FastVideo generator.
4+ """
5+
6+ import os
7+ import sys
8+
9+ # Add FastVideo to path
10+ sys .path .insert (0 , "/workspace/FastVideo" )
11+
12+ from fastvideo .entrypoints .video_generator import VideoGenerator
13+
14+
15+ def generate_video ():
16+ """Generate a video using the FastVideo generator."""
17+
18+ # Configuration
19+ input_image_path = "/workspace/FastVideo/tennis.jpg"
20+ prompt = "A tennis ball bouncing on a racquet, the ball moves in a smooth arc as it hits the strings and rebounds with natural physics. The racquet strings vibrate slightly from the impact, and the ball continues its trajectory with realistic motion."
21+ num_inference_steps = 10
22+ output_path = "/workspace/FastVideo/cosmos2_fastvideo_output.mp4"
23+
24+ # Check if input image exists
25+ if not os .path .exists (input_image_path ):
26+ print (f"Error: Input image not found: { input_image_path } " )
27+ return False
28+
29+ try :
30+ # Create video generator
31+ print ("Creating FastVideo generator..." )
32+ generator = VideoGenerator .from_pretrained (
33+ model_path = "nvidia/Cosmos-Predict2-2B-Video2World" ,
34+ num_gpus = 1 ,
35+ )
36+
37+ print ("Generator created successfully" )
38+
39+ # Run inference
40+ print ("Generating video..." )
41+ result = generator .generate_video (
42+ prompt = prompt ,
43+ input_path = input_image_path ,
44+ num_inference_steps = num_inference_steps ,
45+ guidance_scale = 7.0 ,
46+ seed = 42 ,
47+ save_video = True ,
48+ output_path = output_path
49+ )
50+
51+ if result :
52+ print ("Video generation completed successfully!" )
53+ return True
54+ else :
55+ print ("Video generation failed - no result returned" )
56+ return False
57+
58+ except Exception as e :
59+ print (f"Error during video generation: { e } " )
60+ import traceback
61+ traceback .print_exc ()
62+ return False
63+
64+
65+ if __name__ == "__main__" :
66+ success = generate_video ()
67+ if success :
68+ print ("✅ Video generation completed successfully" )
69+ sys .exit (0 )
70+ else :
71+ print ("❌ Video generation failed" )
72+ sys .exit (1 )
0 commit comments