-
Notifications
You must be signed in to change notification settings - Fork 126
/
sample.py
46 lines (35 loc) · 1.26 KB
/
sample.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from videosys import OpenSoraConfig, VideoSysEngine
def run_base():
# change num_gpus for multi-gpu inference
# sampling parameters are defined in the config
config = OpenSoraConfig(num_sampling_steps=30, cfg_scale=7.0, num_gpus=1)
engine = VideoSysEngine(config)
prompt = "Sunset over the sea."
# num frames: 2s, 4s, 8s, 16s
# resolution: 144p, 240p, 360p, 480p, 720p
# aspect ratio: 9:16, 16:9, 3:4, 4:3, 1:1
# seed=-1 means random seed. >0 means fixed seed.
video = engine.generate(
prompt=prompt,
resolution="480p",
aspect_ratio="9:16",
num_frames="2s",
seed=-1,
).video[0]
engine.save_video(video, f"./outputs/{prompt}.mp4")
def run_low_mem():
config = OpenSoraConfig(cpu_offload=True, tiling_size=1)
engine = VideoSysEngine(config)
prompt = "Sunset over the sea."
video = engine.generate(prompt).video[0]
engine.save_video(video, f"./outputs/{prompt}.mp4")
def run_pab():
config = OpenSoraConfig(enable_pab=True)
engine = VideoSysEngine(config)
prompt = "Sunset over the sea."
video = engine.generate(prompt).video[0]
engine.save_video(video, f"./outputs/{prompt}.mp4")
if __name__ == "__main__":
run_base()
# run_low_mem()
# run_pab()