14 lines
485 B
Python
14 lines
485 B
Python
import torch
|
|
from diffusers import DiffusionPipeline
|
|
from diffusers.utils import export_to_video
|
|
|
|
model_path = "/mnt/models/AI-ModelScope/text-to-video-ms-1.7b"
|
|
pipe = DiffusionPipeline.from_pretrained(
|
|
model_path, torch_dtype=torch.float16, variant="fp16"
|
|
)
|
|
pipe.enable_model_cpu_offload() # 省显存
|
|
pipe.enable_vae_slicing()
|
|
|
|
frames = pipe("Spiderman is surfing", num_frames=16).frames[0]
|
|
export_to_video(frames, "output.mp4") # 默认约2秒/8fps
|