File size: 795 Bytes
a6f4cc3
998bdae
b954d78
998bdae
 
a9e4715
 
 
 
 
 
 
 
 
92a9c4e
 
998bdae
 
a9e4715
 
92a9c4e
a9e4715
 
998bdae
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
import streamlit as st
import torch
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
from diffusers.utils import export_to_video

# Explicitly set the device to CPU
device = torch.device("cpu")

# Load the model onto the CPU
pipe = DiffusionPipeline.from_pretrained(
    "damo-vilab/text-to-video-ms-1.7b", 
    torch_dtype=torch.float32  # Use float32 for CPU
).to(device)

# Initialize the scheduler from the pipeline's configuration, no need to move it to the CPU
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)

prompt = "Pop international experimental music"

# Generate the video frames on the CPU
video_frames = pipe(prompt, num_inference_steps=25).frames

# Export the frames to a video file
video_path = export_to_video(video_frames)