Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import torch
|
| 3 |
-
from diffusers import DiffusionPipeline
|
| 4 |
from diffusers.utils import export_to_video
|
| 5 |
|
| 6 |
# Explicitly set the device to CPU
|
|
@@ -12,16 +12,13 @@ pipe = DiffusionPipeline.from_pretrained(
|
|
| 12 |
torch_dtype=torch.float32 # Use float32 for CPU
|
| 13 |
).to(device)
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
| 17 |
-
|
| 18 |
-
# Disable model offloading if running on CPU
|
| 19 |
-
# pipe.enable_model_cpu_offload() # This line should be removed or commented out
|
| 20 |
|
| 21 |
prompt = "Pop international experimental music"
|
| 22 |
|
| 23 |
# Generate the video frames on the CPU
|
| 24 |
-
video_frames = pipe(prompt, num_inference_steps=25
|
| 25 |
|
| 26 |
# Export the frames to a video file
|
| 27 |
video_path = export_to_video(video_frames)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import torch
|
| 3 |
+
from diffusers import DiffusionPipeline
|
| 4 |
from diffusers.utils import export_to_video
|
| 5 |
|
| 6 |
# Explicitly set the device to CPU
|
|
|
|
| 12 |
torch_dtype=torch.float32 # Use float32 for CPU
|
| 13 |
).to(device)
|
| 14 |
|
| 15 |
+
# Initialize the scheduler from the pipeline's configuration, no need to move it to the CPU
|
| 16 |
+
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
prompt = "Pop international experimental music"
|
| 19 |
|
| 20 |
# Generate the video frames on the CPU
|
| 21 |
+
video_frames = pipe(prompt, num_inference_steps=25).frames
|
| 22 |
|
| 23 |
# Export the frames to a video file
|
| 24 |
video_path = export_to_video(video_frames)
|